diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 895165b..9071e97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,14 +10,14 @@ on: jobs: testsuite: - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - php-version: ['7.2', '7.4', '8.1'] + php-version: ['7.3', '8.2'] prefer-lowest: [''] include: - - php-version: '7.2' + - php-version: '7.3' prefer-lowest: 'prefer-lowest' steps: @@ -48,31 +48,31 @@ jobs: run: | if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then composer update --prefer-lowest --prefer-stable - elif ${{ matrix.php-version == '8.1' }}; then + elif ${{ matrix.php-version == '8.2' }}; then composer update --ignore-platform-reqs else composer update fi - name: Configure PHPUnit matcher - if: matrix.php-version == '7.4' + if: matrix.php-version == '7.3' uses: mheap/phpunit-matcher-action@main - name: Run PHPUnit run: | - if [[ ${{ matrix.php-version }} == '7.4' ]]; then + if [[ ${{ matrix.php-version }} == '7.3' ]]; then export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml else vendor/bin/phpunit fi - name: Submit code coverage - if: success() && matrix.php-version == '7.4' + if: success() && matrix.php-version == '7.3' uses: codecov/codecov-action@v3 cs-stan: name: Coding Standard & Static Analysis - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 @@ -80,7 +80,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '7.3' extensions: mbstring, intl tools: cs2pr coverage: none diff --git a/README.md b/README.md index ea5d315..2449715 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,9 @@ into their expected location: `resources/locales//cake.po` ## Contributing to Localized -If you find that your country is not part of the Localized plugin, please fork the project on Github. +If you find that your country is not part of the Localized plugin, please fork the project on GitHub. Once you have forked the project you can commit your validator class (and any test cases). -As soon as you have pushed your changes back to Github you can send a pull request and your changes will be reviewed and merged in, or feedback will be given. +As soon as you have pushed your changes back to GitHub you can send a pull request and your changes will be reviewed and merged in, or feedback will be given. ### Validation methods diff --git a/composer.json b/composer.json index 9377ce9..21c4268 100644 --- a/composer.json +++ b/composer.json @@ -17,12 +17,12 @@ "source": "https://github.com/cakephp/localized" }, "require": { - "php": ">=7.2", - "cakephp/cakephp": "^4.1.0" + "php": ">=7.3", + "cakephp/cakephp": "^4.2.0" }, "require-dev": { "cakephp/cakephp-codesniffer": "^4.0", - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^9.5" }, "autoload": { "psr-4": { @@ -50,11 +50,16 @@ "test": "phpunit --stderr", "stan": "phpstan analyse src/", "psalm": "php vendor/psalm/phar/psalm.phar --show-info=false src/", - "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12.0 psalm/phar:^3.7 && mv composer.backup composer.json", + "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^1.0.0 psalm/phar:^5.0 && mv composer.backup composer.json", "stan-rebuild-baseline": "phpstan analyse --configuration phpstan.neon --error-format baselineNeon src/ > phpstan-baseline.neon", "psalm-rebuild-baseline": "php vendor/psalm/phar/psalm.phar --show-info=false --set-baseline=psalm-baseline.xml src/", "rector": "rector process src/", "rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:^0.7 && mv composer.backup composer.json", "coverage-test": "phpunit --stderr --coverage-clover=clover.xml" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/src/Validation/LocalizedValidation.php b/src/Validation/LocalizedValidation.php index 6d2194d..e0cbf5a 100644 --- a/src/Validation/LocalizedValidation.php +++ b/src/Validation/LocalizedValidation.php @@ -14,7 +14,7 @@ */ namespace Cake\Localized\Validation; -use Cake\I18n\Date; +use Cake\I18n\FrozenDate; use Cake\I18n\I18n; use Cake\I18n\Number; @@ -45,19 +45,19 @@ public static function date(string $string): bool I18n::setLocale(static::$validationLocale); } - $currentLenient = Date::lenientParsingEnabled(); + $currentLenient = FrozenDate::lenientParsingEnabled(); if ($currentLenient) { - Date::disableLenientParsing(); + FrozenDate::disableLenientParsing(); } - $isValid = Date::parseDate($string) !== null; + $isValid = FrozenDate::parseDate($string) !== null; if ($needChange) { I18n::setLocale($currentLocale); } if ($currentLenient) { - Date::enableLenientParsing(); + FrozenDate::enableLenientParsing(); } return $isValid; @@ -77,19 +77,19 @@ public static function dateTime(string $string): bool I18n::setLocale(static::$validationLocale); } - $currentLenient = Date::lenientParsingEnabled(); + $currentLenient = FrozenDate::lenientParsingEnabled(); if ($currentLenient) { - Date::disableLenientParsing(); + FrozenDate::disableLenientParsing(); } - $isValid = Date::parseDateTime($string) !== null; + $isValid = FrozenDate::parseDateTime($string) !== null; if ($needChange) { I18n::setLocale($currentLocale); } if ($currentLenient) { - Date::enableLenientParsing(); + FrozenDate::enableLenientParsing(); } return $isValid;