From 5b4cba41c52b20a6644aec4d786b45b3528788e0 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 25 Jul 2024 14:11:14 +0200 Subject: [PATCH] Fix --- .../PhpVisitor/Reflector/FunctionLikeNodeScanner.php | 3 +-- .../Plugin/EventHandler/Event/AddRemoveTaintsEvent.php | 9 +++++++-- tests/fixtures/SuicidalAutoloader/autoloader.php | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index d9f534ab1c0..7444d7d7db4 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -126,8 +126,7 @@ public function start( PhpParser\Node\FunctionLike $stmt, bool $fake_method = false, PhpParser\Comment\Doc $doc_comment = null - ) - { + ) { if ($stmt instanceof PhpParser\Node\Expr\Closure || $stmt instanceof PhpParser\Node\Expr\ArrowFunction ) { diff --git a/src/Psalm/Plugin/EventHandler/Event/AddRemoveTaintsEvent.php b/src/Psalm/Plugin/EventHandler/Event/AddRemoveTaintsEvent.php index 97934728826..d5c42e9e370 100644 --- a/src/Psalm/Plugin/EventHandler/Event/AddRemoveTaintsEvent.php +++ b/src/Psalm/Plugin/EventHandler/Event/AddRemoveTaintsEvent.php @@ -2,6 +2,7 @@ namespace Psalm\Plugin\EventHandler\Event; +use PhpParser\Node\ArrayItem; use PhpParser\Node\Expr; use Psalm\Codebase; use Psalm\Context; @@ -17,10 +18,11 @@ final class AddRemoveTaintsEvent /** * Called after an expression has been checked * + * @param ArrayItem|Expr $expr * @internal */ public function __construct( - Expr $expr, + $expr, Context $context, StatementsSource $statements_source, Codebase $codebase @@ -31,7 +33,10 @@ public function __construct( $this->codebase = $codebase; } - public function getExpr(): Expr + /** + * @return ArrayItem|Expr + */ + public function getExpr() { return $this->expr; } diff --git a/tests/fixtures/SuicidalAutoloader/autoloader.php b/tests/fixtures/SuicidalAutoloader/autoloader.php index ac6e8d54a47..d31e8da0747 100644 --- a/tests/fixtures/SuicidalAutoloader/autoloader.php +++ b/tests/fixtures/SuicidalAutoloader/autoloader.php @@ -18,6 +18,7 @@ 'PHPUnit\Framework\DOMElement', 'Stringable', 'AllowDynamicProperties', + '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))`