Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf158d5b

Browse files
committed
Do not report nonexistent variable passed to by-ref parameter with checkImplicitMixed
1 parent3447391 commitf158d5b

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

‎src/Rules/FunctionCallParametersCheck.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,11 @@ public function check(
313313

314314
if (
315315
!$parameter->passedByReference()->createsNewVariable()
316-
|| (!$isBuiltin &&$this->checkUnresolvableParameterTypes)// bleeding edge only
316+
|| (
317+
!$isBuiltin
318+
&&$this->checkUnresolvableParameterTypes// bleeding edge only
319+
&& !$argumentValueTypeinstanceof ErrorType
320+
)
317321
) {
318322
$accepts =$this->ruleLevelHelper->acceptsWithReason($parameterType,$argumentValueType,$scope->isDeclareStrictTypes());
319323

‎tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,4 +849,12 @@ public function testBug10872(): void
849849
$this->analyse([__DIR__ .'/data/bug-10872.php'], []);
850850
}
851851

852+
publicfunctiontestBug12015():void
853+
{
854+
$this->checkThisOnly =false;
855+
$this->checkExplicitMixed =true;
856+
$this->checkImplicitMixed =true;
857+
$this->analyse([__DIR__ .'/data/bug-12015.php'], []);
858+
}
859+
852860
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespaceBug12015;
4+
5+
class HelloWorld
6+
{
7+
8+
/**
9+
* @param-out int $ref
10+
*/
11+
publicstaticfunctionpassRef(?int &$ref):void
12+
{
13+
$ref =1;
14+
}
15+
}
16+
17+
functiontest():void
18+
{
19+
HelloWorld::passRef($storeHere);
20+
echo$storeHere;
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp