Skip to content

Commit

Permalink
Fix and add lowest run
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Aug 10, 2024
1 parent e129b98 commit e7c21a4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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) }}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/BCHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 34 additions & 2 deletions src/Psalm/Internal/PhpTraverser/CustomTraverser.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,54 @@
<?php

/**
* phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
*/

declare(strict_types=1);

namespace Psalm\Internal\PhpTraverser;

use LogicException;
use PhpParser\Node;
use PhpParser\NodeTraverser;
use Psalm\Internal\BCHelper;

use function array_pop;
use function array_splice;
use function gettype;
use function is_array;

if (BCHelper::usePHPParserV4()) {
/**
* @internal
*/
final class CustomTraverser extends InternalCustomTraverser
{
protected function traverseNode(Node $node): Node
{
$this->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()
{
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/SuicidalAutoloader/autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))`
Expand Down

0 comments on commit e7c21a4

Please sign in to comment.