Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -3181,7 +3181,7 @@ private function enterArrowFunctionWithoutReflection(Expr\ArrowFunction $arrowFu
$arrowFunctionScope->nativeExpressionTypes,
$arrowFunctionScope->conditionalExpressions,
$arrowFunctionScope->inClosureBindScopeClasses,
null,
new TrivialParametersAcceptor(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enterAnonymousFunctionWithoutReflection uses the same thing.

true,
[],
[],
Expand Down
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ public function dataFileAsserts(): iterable

if (PHP_VERSION_ID >= 70400) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/arrow-function-argument-type.php');
yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/Functions/data/bug-anonymous-function-method-constant.php');
}

yield from $this->gatherAssertTypes(__DIR__ . '/data/closure-argument-type.php');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,13 @@ public function testBugSpaceship(): void
$this->analyse([__DIR__ . '/data/bug-spaceship.php'], []);
}

public function testBugFunctionMethodConstants(): void
{
if (PHP_VERSION_ID < 70400) {
$this->markTestSkipped('Test requires PHP 7.4.');
}

$this->analyse([__DIR__ . '/data/bug-anonymous-function-method-constant.php'], []);
}

}
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Functions/ClosureReturnTypeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleLevelHelper;
use PHPStan\Testing\RuleTestCase;
use const PHP_VERSION_ID;

/**
* @extends RuleTestCase<ClosureReturnTypeRule>
Expand Down Expand Up @@ -128,4 +129,13 @@ public function testBug7220(): void
$this->analyse([__DIR__ . '/data/bug-7220.php'], []);
}

public function testBugFunctionMethodConstants(): void
{
if (PHP_VERSION_ID < 70400) {
$this->markTestSkipped('Test requires PHP 7.4.');
}

$this->analyse([__DIR__ . '/data/bug-anonymous-function-method-constant.php'], []);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types = 1); // lint >= 7.4

namespace BugAnonymousFunctionMethodConstant;

$a = fn() => __FUNCTION__;
$b = fn() => __METHOD__;

$c = function() { return __FUNCTION__; };
$d = function() { return __METHOD__; };

\PHPStan\Testing\assertType("'{closure}'", $a());
\PHPStan\Testing\assertType("'{closure}'", $b());
\PHPStan\Testing\assertType("'{closure}'", $c());
\PHPStan\Testing\assertType("'{closure}'", $d());