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 f57d5ec
Show file tree
Hide file tree
Showing 4 changed files with 46 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
32 changes: 30 additions & 2 deletions src/Psalm/Internal/PhpTraverser/CustomTraverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,44 @@
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 +56,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
2 changes: 1 addition & 1 deletion tests/fixtures/SuicidalAutoloader/autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'PHPUnit\Framework\DOMElement',
'Stringable',
'AllowDynamicProperties',
'PhpParser\Node\Stmt\Throw', // 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 f57d5ec

Please sign in to comment.