Skip to content

Commit

Permalink
Merge pull request #226 from cakephp/fixes
Browse files Browse the repository at this point in the history
Fix up deprecations.
  • Loading branch information
dereuromark authored Jan 17, 2023
2 parents 6dd46b4 + 2887666 commit 1cdfb43
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -48,39 +48,39 @@ 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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '7.3'
extensions: mbstring, intl
tools: cs2pr
coverage: none
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ into their expected location: `resources/locales/<locale>/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

Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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
}
}
}
18 changes: 9 additions & 9 deletions src/Validation/LocalizedValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
namespace Cake\Localized\Validation;

use Cake\I18n\Date;
use Cake\I18n\FrozenDate;
use Cake\I18n\I18n;
use Cake\I18n\Number;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 1cdfb43

Please sign in to comment.