From ed2270b0b358e95e310d9392e1c35123dd8beed0 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Sun, 22 Jun 2025 12:05:10 +0200 Subject: [PATCH 1/2] update stan --- .phive/phars.xml | 3 +-- composer.json | 7 +------ psalm.xml | 25 ------------------------- src/Command/CompileCommand.php | 2 +- 4 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 psalm.xml diff --git a/.phive/phars.xml b/.phive/phars.xml index a655ee4..f5aa330 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,4 @@ - - + diff --git a/composer.json b/composer.json index 274e32e..3e15dc2 100644 --- a/composer.json +++ b/composer.json @@ -53,13 +53,8 @@ "cs-check": "phpcs --colors --parallel=16 -p src/ tests/", "cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/", "phpstan": "tools/phpstan analyse", - "psalm": "tools/psalm --show-info=false", - "stan": [ - "@phpstan", - "@psalm" - ], + "stan": "@phpstan", "phpstan-baseline": "tools/phpstan --generate-baseline", - "psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml", "stan-setup": "phive install", "test": "phpunit" }, diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index 3b80c9b..0000000 --- a/psalm.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/Command/CompileCommand.php b/src/Command/CompileCommand.php index 78949c0..6fad77a 100644 --- a/src/Command/CompileCommand.php +++ b/src/Command/CompileCommand.php @@ -49,7 +49,7 @@ public function execute(Arguments $args, ConsoleIo $io) { $type = $args->getArgumentAt(0); - /** @psalm-var class-string<\Cake\TwigView\View\TwigView> $viewClass */ + /** @phpstan-var class-string<\Cake\TwigView\View\TwigView> $viewClass */ $viewClass = $args->getOption('view-class'); // Setup cached TwigView to avoid creating for every file From 49a0d9cf93a55fe25e61ccf28a5cf6b27e6d0c89 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 22 Jun 2025 23:07:32 -0400 Subject: [PATCH 2/2] Fix phpcs --- src/Filesystem/Scanner.php | 4 ++-- src/Twig/Extension/TimeExtension.php | 2 +- src/Twig/Extension/ViewExtension.php | 8 ++++---- src/Twig/Node/Cell.php | 4 ++-- src/Twig/Node/Element.php | 4 ++-- src/View/TwigView.php | 2 +- tests/TestCase/Twig/FileLoaderTest.php | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Filesystem/Scanner.php b/src/Filesystem/Scanner.php index 4433e54..8cf5b9a 100644 --- a/src/Filesystem/Scanner.php +++ b/src/Filesystem/Scanner.php @@ -140,10 +140,10 @@ protected static function setupIterator(string $path, array $extensions): Iterat $path, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | - FilesystemIterator::SKIP_DOTS + FilesystemIterator::SKIP_DOTS, ), RecursiveIteratorIterator::CHILD_FIRST, - RecursiveIteratorIterator::CATCH_GET_CHILD + RecursiveIteratorIterator::CATCH_GET_CHILD, ), '/.+' . $extPattern . '$/', RegexIterator::GET_MATCH); } diff --git a/src/Twig/Extension/TimeExtension.php b/src/Twig/Extension/TimeExtension.php index f92553a..0d08fdf 100644 --- a/src/Twig/Extension/TimeExtension.php +++ b/src/Twig/Extension/TimeExtension.php @@ -76,7 +76,7 @@ public function getFunctions(): array public function formatDate( mixed $date, ?string $format = null, - DateTimeZone|string|false|null $timezone = null + DateTimeZone|string|false|null $timezone = null, ): string { if (!isset($this->coreExt)) { $this->coreExt = new CoreExtension(); diff --git a/src/Twig/Extension/ViewExtension.php b/src/Twig/Extension/ViewExtension.php index 54442ba..778ad27 100644 --- a/src/Twig/Extension/ViewExtension.php +++ b/src/Twig/Extension/ViewExtension.php @@ -38,28 +38,28 @@ public function getFunctions(): array function ($context, string $name, array $data = [], array $options = []) { return $context['_view']->cell($name, $data, $options); }, - ['needs_context' => true, 'is_safe' => ['all']] + ['needs_context' => true, 'is_safe' => ['all']], ), new TwigFunction( 'element', function ($context, string $name, array $data = [], array $options = []) { return $context['_view']->element($name, $data, $options); }, - ['needs_context' => true, 'is_safe' => ['all']] + ['needs_context' => true, 'is_safe' => ['all']], ), new TwigFunction( 'fetch', function ($context, string $name, string $default = '') { return $context['_view']->fetch($name, $default); }, - ['needs_context' => true, 'is_safe' => ['all']] + ['needs_context' => true, 'is_safe' => ['all']], ), new TwigFunction( 'helper_*_*', function ($context, $helper, $method, array $args = []) { return $context['_view']->{$helper}->{$method}(...$args); }, - ['needs_context' => true, 'is_variadic' => true, 'is_safe' => ['all']] + ['needs_context' => true, 'is_variadic' => true, 'is_safe' => ['all']], ), ]; } diff --git a/src/Twig/Node/Cell.php b/src/Twig/Node/Cell.php index 7089365..e548120 100644 --- a/src/Twig/Node/Cell.php +++ b/src/Twig/Node/Cell.php @@ -56,7 +56,7 @@ public function __construct( ?AbstractExpression $data = null, ?AbstractExpression $options = null, int $lineno = 0, - ?string $tag = null + ?string $tag = null, ) { if ($data === null) { $data = new ArrayExpression([], $lineno); @@ -76,7 +76,7 @@ public function __construct( 'variable' => $variable, ], $lineno, - $tag + $tag, ); $this->assign = $assign; diff --git a/src/Twig/Node/Element.php b/src/Twig/Node/Element.php index 3213c3f..f2b82e8 100644 --- a/src/Twig/Node/Element.php +++ b/src/Twig/Node/Element.php @@ -44,7 +44,7 @@ public function __construct( ?AbstractExpression $data = null, ?AbstractExpression $options = null, int $lineno = 0, - ?string $tag = null + ?string $tag = null, ) { if ($data === null) { $data = new ArrayExpression([], $lineno); @@ -62,7 +62,7 @@ public function __construct( ], [], $lineno, - $tag + $tag, ); } diff --git a/src/View/TwigView.php b/src/View/TwigView.php index c5e8a0b..fadfe88 100644 --- a/src/View/TwigView.php +++ b/src/View/TwigView.php @@ -293,7 +293,7 @@ protected function _evaluate(string $templateFile, array $dataForView): string $dataForView = array_merge( $dataForView, - iterator_to_array($this->helpers()->getIterator()) + iterator_to_array($this->helpers()->getIterator()), ); return $this->getTwig()->load($templateFile)->render($dataForView); diff --git a/tests/TestCase/Twig/FileLoaderTest.php b/tests/TestCase/Twig/FileLoaderTest.php index dcfdff2..a0e16d5 100644 --- a/tests/TestCase/Twig/FileLoaderTest.php +++ b/tests/TestCase/Twig/FileLoaderTest.php @@ -68,7 +68,7 @@ public function testGetCacheKey() { $this->assertSame( TEST_APP . 'templates/simple.twig', - $this->loader->getCacheKey(TEST_APP . 'templates/simple.twig') + $this->loader->getCacheKey(TEST_APP . 'templates/simple.twig'), ); }