114
114
use PHPStan \Node \MethodReturnStatementsNode ;
115
115
use PHPStan \Node \NoopExpressionNode ;
116
116
use PHPStan \Node \PropertyAssignNode ;
117
+ use PHPStan \Node \PropertyHookStatementNode ;
117
118
use PHPStan \Node \ReturnStatement ;
118
119
use PHPStan \Node \StaticMethodCallableNode ;
119
120
use PHPStan \Node \UnreachableStatementNode ;
@@ -343,6 +344,7 @@ public function processStmtNodes(
343
344
$ stmtCount = count ($ stmts );
344
345
$ shouldCheckLastStatement = $ parentNode instanceof Node \Stmt \Function_
345
346
|| $ parentNode instanceof Node \Stmt \ClassMethod
347
+ || $ parentNode instanceof PropertyHookStatementNode
346
348
|| $ parentNode instanceof Expr \Closure;
347
349
foreach ($ stmts as $ i => $ stmt ) {
348
350
if ($ alreadyTerminated && !($ stmt instanceof Node \Stmt \Function_ || $ stmt instanceof Node \Stmt \ClassLike)) {
@@ -360,7 +362,7 @@ public function processStmtNodes(
360
362
$ hasYield = $ hasYield || $ statementResult ->hasYield ();
361
363
362
364
if ($ shouldCheckLastStatement && $ isLast ) {
363
- /** @var Node\Stmt\Function_|Node\Stmt\ClassMethod|Expr\Closure $parentNode */
365
+ /** @var Node\Stmt\Function_|Node\Stmt\ClassMethod|PropertyHookStatementNode| Expr\Closure $parentNode */
364
366
$ parentNode = $ parentNode ;
365
367
366
368
$ endStatements = $ statementResult ->getEndStatements ();
@@ -377,7 +379,7 @@ public function processStmtNodes(
377
379
$ endStatementResult ->getThrowPoints (),
378
380
$ endStatementResult ->getImpurePoints (),
379
381
),
380
- $ parentNode ->returnType !== null ,
382
+ $ parentNode ->getReturnType () !== null ,
381
383
), $ endStatementResult ->getScope ());
382
384
}
383
385
} else {
@@ -391,7 +393,7 @@ public function processStmtNodes(
391
393
$ statementResult ->getThrowPoints (),
392
394
$ statementResult ->getImpurePoints (),
393
395
),
394
- $ parentNode ->returnType !== null ,
396
+ $ parentNode ->getReturnType () !== null ,
395
397
), $ scope );
396
398
}
397
399
}
@@ -414,9 +416,9 @@ public function processStmtNodes(
414
416
415
417
$ statementResult = new StatementResult ($ scope , $ hasYield , $ alreadyTerminated , $ exitPoints , $ throwPoints , $ impurePoints );
416
418
if ($ stmtCount === 0 && $ shouldCheckLastStatement ) {
417
- /** @var Node\Stmt\Function_|Node\Stmt\ClassMethod|Expr\Closure $parentNode */
419
+ /** @var Node\Stmt\Function_|Node\Stmt\ClassMethod|PropertyHookStatementNode| Expr\Closure $parentNode */
418
420
$ parentNode = $ parentNode ;
419
- $ returnTypeNode = $ parentNode ->returnType ;
421
+ $ returnTypeNode = $ parentNode ->getReturnType () ;
420
422
if ($ parentNode instanceof Expr \Closure) {
421
423
$ parentNode = new Node \Stmt \Expression ($ parentNode , $ parentNode ->getAttributes ());
422
424
}
@@ -4700,7 +4702,7 @@ private function processPropertyHooks(
4700
4702
$ this ->processExprNode ($ stmt , $ hook ->body , $ hookScope , $ nodeCallback , ExpressionContext::createTopLevel ());
4701
4703
$ nodeCallback (new PropertyAssignNode (new PropertyFetch (new Variable ('this ' ), $ propertyName , $ hook ->body ->getAttributes ()), $ hook ->body , false ), $ hookScope );
4702
4704
} elseif (is_array ($ hook ->body )) {
4703
- $ this ->processStmtNodes ($ stmt , $ hook ->body , $ hookScope , $ nodeCallback , StatementContext::createTopLevel ());
4705
+ $ this ->processStmtNodes (new PropertyHookStatementNode ( $ hook ) , $ hook ->body , $ hookScope , $ nodeCallback , StatementContext::createTopLevel ());
4704
4706
}
4705
4707
4706
4708
}
0 commit comments