diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d1103373cb..e94a3740cb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,7 +115,7 @@ jobs: echo "chunks=$(php -r 'echo json_encode(range(1, ${{ env.CHUNK_COUNT }} ));')" >> $GITHUB_OUTPUT tests: - name: "Unit Tests - PHP ${{ matrix.php-version }} ${{ matrix.chunk }}/${{ matrix.count }}" + name: "Unit Tests - PHP ${{ matrix.php-version }} ${{ matrix.dependencies }} ${{ matrix.chunk }}/${{ matrix.count }}" runs-on: ubuntu-latest needs: @@ -129,6 +129,9 @@ jobs: - "8.1" - "8.2" - "8.3" + dependencies: + - highest + - lowest count: ${{ fromJson(needs.chunk-matrix.outputs.count) }} chunk: ${{ fromJson(needs.chunk-matrix.outputs.chunks) }} @@ -158,8 +161,17 @@ jobs: echo "files_cache=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT echo "vcs_cache=$(composer config cache-vcs-dir)" >> $GITHUB_OUTPUT - - name: Generate composer.lock + - name: Generate highest composer.lock + if: ${{ matrix.dependencies == 'highest' }} + run: | + composer update --no-install + env: + COMPOSER_ROOT_VERSION: dev-master + + - name: Generate lowest composer.lock + if: ${{ matrix.dependencies == 'lowest' }} run: | + composer require nikic/php-parser ^4.16 composer update --no-install env: COMPOSER_ROOT_VERSION: dev-master diff --git a/src/Psalm/Internal/BCHelper.php b/src/Psalm/Internal/BCHelper.php index 51332ef8408..316148d96e4 100644 --- a/src/Psalm/Internal/BCHelper.php +++ b/src/Psalm/Internal/BCHelper.php @@ -38,7 +38,7 @@ public static function getPHPParserClassName(string $className): string public static function usePHPParserV4(): bool { - return class_exists('\PhpParser\Node\Stmt\Throw'); + return class_exists('\PhpParser\Node\Stmt\Throw_'); } public static function isThrow(Node $stmt): bool diff --git a/src/Psalm/Internal/PhpTraverser/CustomTraverser.php b/src/Psalm/Internal/PhpTraverser/CustomTraverser.php index fbe4429db9d..085302993dd 100644 --- a/src/Psalm/Internal/PhpTraverser/CustomTraverser.php +++ b/src/Psalm/Internal/PhpTraverser/CustomTraverser.php @@ -1,5 +1,9 @@ customTraverseNode($node); + + return $node; + } + } +} else { + /** + * @internal + */ + final class CustomTraverser extends InternalCustomTraverser + { + protected function traverseNode(Node $node): void + { + $this->customTraverseNode($node); + } + } +} + + /** * @internal */ -final class CustomTraverser extends NodeTraverser +abstract class InternalCustomTraverser extends NodeTraverser { public function __construct() { @@ -28,7 +60,7 @@ public function __construct() * * @param Node $node node to traverse */ - protected function traverseNode(Node $node): void + protected function customTraverseNode(Node $node): void { foreach ($node->getSubNodeNames() as $name) { $subNode = &$node->$name; diff --git a/tests/fixtures/SuicidalAutoloader/autoloader.php b/tests/fixtures/SuicidalAutoloader/autoloader.php index d31e8da0747..6e28b6c1b78 100644 --- a/tests/fixtures/SuicidalAutoloader/autoloader.php +++ b/tests/fixtures/SuicidalAutoloader/autoloader.php @@ -18,7 +18,8 @@ 'PHPUnit\Framework\DOMElement', 'Stringable', 'AllowDynamicProperties', - 'PhpParser\Node\Stmt\Throw', // BCHelper for nikic/php-parser v4/5 + 'PhpParser\PhpVersion', // BCHelper for nikic/php-parser v4/5 + 'PhpParser\Node\Stmt\Throw_', // BCHelper for nikic/php-parser v4/5 // https://github.com/symfony/symfony/pull/40203 // these are actually functions, referenced as `if (!function_exists(u::class))`