From 3f1c6f6f60aab5d52eca65870e11d7eb79cc4bfd Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Sun, 22 Jun 2025 11:22:40 +0200 Subject: [PATCH 1/3] update stan --- .github/workflows/ci.yml | 52 +----------- .phive/phars.xml | 3 +- .stickler.yml | 3 - composer.json | 7 +- psalm-baseline.xml | 152 ------------------------------------ psalm.xml | 19 ----- src/Chronos.php | 4 +- src/ChronosDate.php | 4 +- src/ChronosTime.php | 2 +- tests/TestCase/TestCase.php | 1 - 10 files changed, 9 insertions(+), 238 deletions(-) delete mode 100644 .stickler.yml delete mode 100644 psalm-baseline.xml delete mode 100644 psalm.xml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3372484..a872edd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,56 +15,8 @@ permissions: jobs: testsuite: - runs-on: ubuntu-22.04 - continue-on-error: ${{ matrix.unstable }} - strategy: - fail-fast: false - matrix: - php-version: ['8.1'] - dependencies: [highest] - unstable: [false] - include: - - php-version: '8.1' - dependencies: lowest - unstable: false - - php-version: '8.2' - dependencies: highest - unstable: false - - php-version: '8.3' - dependencies: highest - unstable: false - - php-version: '8.4' - dependencies: highest - unstable: true - - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - extensions: mbstring, intl - ini-values: zend.assertions=1 - coverage: pcov - - - name: Composer install - uses: ramsey/composer-install@v3 - with: - dependency-versions: ${{ matrix.dependencies }} - composer-options: ${{ matrix.composer-options }} - - - name: Run PHPUnit - run: | - if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.dependencies }} == 'highest' ]]; then - export CODECOVERAGE=1 && vendor/bin/phpunit --display-deprecations --display-warnings --display-incomplete --display-skipped --coverage-clover=coverage.xml - else - vendor/bin/phpunit --display-deprecations --display-warnings - fi - - - name: Code Coverage Report - if: success() && matrix.php-version == '8.1' && matrix.dependencies == 'highest' - uses: codecov/codecov-action@v5 + uses: cakephp/.github/.github/workflows/testsuite-with-db.yml@5.x + secrets: inherit cs-stan: uses: cakephp/.github/.github/workflows/cs-stan.yml@5.x diff --git a/.phive/phars.xml b/.phive/phars.xml index a655ee46..f5aa3300 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,4 @@ - - + diff --git a/.stickler.yml b/.stickler.yml deleted file mode 100644 index 30472b32..00000000 --- a/.stickler.yml +++ /dev/null @@ -1,3 +0,0 @@ -linters: - phpcs: - standard: CakePHP diff --git a/composer.json b/composer.json index b8f2301d..25d4ee34 100644 --- a/composer.json +++ b/composer.json @@ -59,12 +59,7 @@ "cs-check": "phpcs --colors --parallel=16 -p", "cs-fix": "phpcbf --colors --parallel=16 -p", "phpstan": "tools/phpstan analyse", - "psalm": "tools/psalm --show-info=false", - "psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml", - "stan": [ - "@phpstan", - "@psalm" - ], + "stan": "@phpstan", "stan-baseline": "tools/phpstan --generate-baseline", "stan-setup": "phive install", "test": "phpunit" diff --git a/psalm-baseline.xml b/psalm-baseline.xml deleted file mode 100644 index 0de0d542..00000000 --- a/psalm-baseline.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - - - array_filter - date_default_timezone_get - date_default_timezone_get - iterator_to_array - - - diffForHumans - diffFormatter - format - format - format - format - format - format - getTimestamp - getTimezone - getWeekendDays - hasTestNow - now - now - now - now - now - now - now - now - now - now - now - now - now - now - now - now - now - now - now - now - now - now - safeCreateDateTimeZone - toDateString - toDateString - toDateString - toDateString - toDateString - toDateString - toDateString - tomorrow - yesterday - - - static::$days - static::$days - static::$days - static::$days - static::$days - static::$days - static::$days - static::$days - static::$days - static::$weekEndsAt - static::$weekEndsAt - static::$weekStartsAt - static::$weekStartsAt - - - 'Y', - 'yearIso' => 'o', - 'month' => 'n', - 'day' => 'j', - 'hour' => 'G', - 'minute' => 'i', - 'second' => 's', - 'micro' => 'u', - 'microsecond' => 'u', - 'dayOfWeek' => 'N', - 'dayOfYear' => 'z', - 'weekOfYear' => 'W', - 'daysInMonth' => 't', - 'timestamp' => 'U', - ];]]> - - - f]]> - - - public static function createFromFormat( - - - - - array_filter - date_default_timezone_get - iterator_to_array - - - diffForHumans - diffFormatter - format - getTestNow - getWeekEndsAt - getWeekEndsAt - getWeekStartsAt - getWeekStartsAt - getWeekendDays - hasTestNow - now - now - now - now - now - now - now - now - now - now - now - now - tomorrow - yesterday - - - static::$days - static::$days - static::$days - static::$days - static::$days - static::$days - static::$days - static::$days - static::$days - - - 'Y', - 'yearIso' => 'o', - 'month' => 'n', - 'day' => 'j', - 'dayOfWeek' => 'N', - 'dayOfYear' => 'z', - 'weekOfYear' => 'W', - 'daysInMonth' => 't', - ];]]> - - - diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index 19b4ca20..00000000 --- a/psalm.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - diff --git a/src/Chronos.php b/src/Chronos.php index 9c28ec0c..a46f1d39 100644 --- a/src/Chronos.php +++ b/src/Chronos.php @@ -56,8 +56,8 @@ * @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise * @property-read string $timezoneName * @property-read string $tzName - * @psalm-immutable - * @psalm-consistent-constructor + * @immutable + * @phpstan-consistent-constructor */ class Chronos extends DateTimeImmutable implements Stringable { diff --git a/src/ChronosDate.php b/src/ChronosDate.php index 8fb9e99a..9a8b3052 100644 --- a/src/ChronosDate.php +++ b/src/ChronosDate.php @@ -41,8 +41,8 @@ * @property-read int $age does a diffInYears() with default parameters * @property-read int<1, 4> $quarter the quarter of this instance, 1 - 4 * @property-read int<1, 2> $half the half of the year, with 1 for months Jan...Jun and 2 for Jul...Dec. - * @psalm-immutable - * @psalm-consistent-constructor + * @immutable + * @phpstan-consistent-constructor */ class ChronosDate implements Stringable { diff --git a/src/ChronosTime.php b/src/ChronosTime.php index aa7b8c80..7d65dd2a 100644 --- a/src/ChronosTime.php +++ b/src/ChronosTime.php @@ -21,7 +21,7 @@ use Stringable; /** - * @psalm-consistent-constructor + * @phpstan-consistent-constructor */ class ChronosTime implements Stringable { diff --git a/tests/TestCase/TestCase.php b/tests/TestCase/TestCase.php index 8029b822..688115f6 100644 --- a/tests/TestCase/TestCase.php +++ b/tests/TestCase/TestCase.php @@ -138,7 +138,6 @@ protected function withTimezone(string $tz, Closure $cb) */ public function deprecated(Closure $callable): void { - /** @var bool $deprecation Expand type for psalm */ $deprecation = false; $previousHandler = set_error_handler( From ea8cf5027f47b4efaff75848b6149f806a95d4ce Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 22 Jun 2025 23:12:59 -0400 Subject: [PATCH 2/3] Fix potential type error Replace the vague type error on failure with a more explicit error message. --- src/ChronosDate.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ChronosDate.php b/src/ChronosDate.php index 9a8b3052..85bad798 100644 --- a/src/ChronosDate.php +++ b/src/ChronosDate.php @@ -354,10 +354,11 @@ public function modify(string $modifier): static } $new = clone $this; - $new->native = $new->native->modify($modifier); - if ($new->native === false) { + $native = $new->native->modify($modifier); + if ($native === false) { throw new InvalidArgumentException(sprintf('Unable to modify date using `%s`', $modifier)); } + $new->native = $native; if ($new->format('H:i:s') !== '00:00:00') { $new->native = $new->native->setTime(0, 0, 0); From 451fa4bad24c2e8db7da69c45d638fcea444ec81 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Mon, 23 Jun 2025 06:34:34 +0200 Subject: [PATCH 3/3] adjust CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a872edd2..b93c1e48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ permissions: jobs: testsuite: - uses: cakephp/.github/.github/workflows/testsuite-with-db.yml@5.x + uses: cakephp/.github/.github/workflows/testsuite-without-db.yml@5.x secrets: inherit cs-stan: