From 5d0872ec2ad925c0b0cc128f0300139300c6f98d Mon Sep 17 00:00:00 2001 From: "ondrej@mirtes.cz" Date: Mon, 30 Nov 2026 10:11:25 +0000 Subject: [PATCH] Count a property bound by reference as read when the other side can read it A private property bound by reference - a by-ref promoted parameter, $this->prop = &$var, $this->prop['k'] = &$var, self::$prop = &$var - was only written, so it was reported as never read although whatever is written to it can be read through the variable it is bound to. PropertyWrite::isByReference() marks these writes, and UnusedPrivatePropertyRule counts them as reads. No PropertyRead is recorded, so the uninitialized-property checks see no read before the assignment. A binding to a local variable of a method waits for the method's VariableWritesNode and counts only when the method also reads the variable or lets it escape apart from the binding, or the variable is a by-ref or promoted parameter: a binding to a throwaway local is still reported. VariableWritesNode::getObservingAccessCount() gives the number of read and escape sites per variable for that. Closes https://github.com/phpstan/phpstan/issues/15886 Closes https://github.com/phpstan/phpstan/issues/10068 Amp-Thread-ID: https://ampcode.com/threads/T-01a22bbf-fbea-7343-93fe-fd2c23d22096 --- src/Analyser/VariableLivenessResolver.php | 12 +- src/Node/ClassStatementsGatherer.php | 80 ++++++++ src/Node/Property/PropertyWrite.php | 21 ++ src/Node/VariableWritesNode.php | 12 ++ .../DeadCode/UnusedPrivatePropertyRule.php | 4 + .../UnusedPrivatePropertyRuleTest.php | 109 ++++++++++ .../PHPStan/Rules/DeadCode/data/bug-10068.php | 38 ++++ .../DeadCode/data/bug-15886-array-offset.php | 68 +++++++ .../Rules/DeadCode/data/bug-15886-local.php | 186 ++++++++++++++++++ .../DeadCode/data/bug-15886-promoted.php | 42 ++++ .../Rules/DeadCode/data/bug-15886-review.php | 110 +++++++++++ .../Rules/DeadCode/data/bug-15886-static.php | 49 +++++ .../PHPStan/Rules/DeadCode/data/bug-15886.php | 61 ++++++ ...ReadOnlyByPhpDocPropertyAssignRuleTest.php | 5 + .../UninitializedPropertyRuleTest.php | 6 + .../data/bug-15886-readonly-phpdoc.php | 26 +++ .../data/bug-15886-uninitialized.php | 42 ++++ turbo-ext/src/ClassStatementsGatherer.cpp | 167 +++++++++++++++- turbo-ext/src/VariableLivenessResolver.cpp | 25 ++- .../src/generated/ClassStatementsGatherer.h | 36 ++-- 20 files changed, 1080 insertions(+), 19 deletions(-) create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-10068.php create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-15886-array-offset.php create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-15886-local.php create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-15886-promoted.php create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-15886-review.php create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-15886-static.php create mode 100644 tests/PHPStan/Rules/DeadCode/data/bug-15886.php create mode 100644 tests/PHPStan/Rules/Properties/data/bug-15886-readonly-phpdoc.php create mode 100644 tests/PHPStan/Rules/Properties/data/bug-15886-uninitialized.php diff --git a/src/Analyser/VariableLivenessResolver.php b/src/Analyser/VariableLivenessResolver.php index 18c5006b116..e0f06b40865 100644 --- a/src/Analyser/VariableLivenessResolver.php +++ b/src/Analyser/VariableLivenessResolver.php @@ -161,7 +161,17 @@ public static function resolve(Node\FunctionLike $function, ?VariableFlow $flow) $self->resolveCoverage(); } - return new VariableWritesNode($function, array_values($self->writes), $self->observedIds + $self->readIds, $self->readIds, $self->coveredIds, $self->overwrittenIds, $self->readNames, $self->redundantTypes, $self->mentionedNames, $self->escapedNames, $self->variableOverwritingLoops, $self->opaque, $self->allNamesMentioned); + $observingAccessCounts = []; + foreach ($self->accesses as $name => $accesses) { + foreach ($accesses as $access) { + if (!in_array($access->kind, [VariableFlow::READ, VariableFlow::ESCAPE], true)) { + continue; + } + $observingAccessCounts[$name] = ($observingAccessCounts[$name] ?? 0) + 1; + } + } + + return new VariableWritesNode($function, array_values($self->writes), $self->observedIds + $self->readIds, $self->readIds, $self->coveredIds, $self->overwrittenIds, $self->readNames, $self->redundantTypes, $self->mentionedNames, $self->escapedNames, $self->variableOverwritingLoops, $self->opaque, $self->allNamesMentioned, $observingAccessCounts); } private function collect(?VariableFlow $flow): void diff --git a/src/Node/ClassStatementsGatherer.php b/src/Node/ClassStatementsGatherer.php index 71a56858423..f16e9d298ef 100644 --- a/src/Node/ClassStatementsGatherer.php +++ b/src/Node/ClassStatementsGatherer.php @@ -25,9 +25,11 @@ use PHPStan\Turbo\ShadowedByTurboExtension; use PHPStan\Type\TypeUtils; use ReflectionProperty; +use function array_key_exists; use function count; use function in_array; use function is_string; +use function spl_object_id; use function strtolower; #[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ClassStatementsGatherer.cpp')] @@ -66,6 +68,9 @@ final class ClassStatementsGatherer /** @var list */ private array $propertyAssigns = []; + /** @var array> lowercase method name => AssignRef object id => bound variable name and by-reference write */ + private array $referenceBindings = []; + /** * @param callable(Node $node, Scope $scope): void $nodeCallback */ @@ -220,6 +225,10 @@ private function gatherNodes(Node $node, Scope $scope): void $this->propertyAssigns[] = new PropertyAssign($node, $scope); return; } + if ($node instanceof VariableWritesNode) { + $this->resolveReferenceBindings($node, $scope); + return; + } if (!$node instanceof Expr) { return; } @@ -228,6 +237,25 @@ private function gatherNodes(Node $node, Scope $scope): void return; } if ($node instanceof Expr\AssignRef) { + $boundVar = $node->var; + while ($boundVar instanceof ArrayDimFetch) { + $boundVar = $boundVar->var; + } + if ($boundVar instanceof PropertyFetch || $boundVar instanceof StaticPropertyFetch) { + $write = new PropertyWrite($boundVar, $scope, false, $node); + $function = $scope->getFunction(); + if ( + $node->expr instanceof Expr\Variable + && is_string($node->expr->name) + && $function !== null + && !$scope->isInAnonymousFunction() + ) { + // whether the local is read through elsewhere is known once the method's VariableWritesNode arrives + $this->referenceBindings[strtolower($function->getName())][spl_object_id($node)] = [$node->expr->name, $write]; + } else { + $this->propertyUsages[] = $write; + } + } if (!$node->expr instanceof PropertyFetch && !$node->expr instanceof StaticPropertyFetch) { $this->gatherNodes($node->expr, $scope); return; @@ -262,6 +290,58 @@ private function gatherNodes(Node $node, Scope $scope): void $this->propertyUsages[] = new PropertyRead($node, $scope); } + /** + * A property bound by reference to a local variable ($this->prop = &$local) is read + * through that variable only when the method uses the variable apart from the binding: + * reads it, passes it on, or shares it as a by-ref parameter, global or static. + */ + private function resolveReferenceBindings(VariableWritesNode $node, Scope $scope): void + { + if ($this->referenceBindings === [] || $scope->isInAnonymousFunction()) { + return; + } + $function = $scope->getFunction(); + if ($function === null) { + return; + } + $methodKey = strtolower($function->getName()); + if (!array_key_exists($methodKey, $this->referenceBindings)) { + return; + } + $bindings = $this->referenceBindings[$methodKey]; + unset($this->referenceBindings[$methodKey]); + + $sharedVariableNames = []; + foreach ($node->getFunctionLike()->getParams() as $param) { + if (!$param->byRef && $param->flags === 0) { + continue; + } + if (!$param->var instanceof Expr\Variable || !is_string($param->var->name)) { + continue; + } + $sharedVariableNames[$param->var->name] = true; + } + + $bindingCounts = []; + foreach ($bindings as [$variableName]) { + $bindingCounts[$variableName] = ($bindingCounts[$variableName] ?? 0) + 1; + } + + foreach ($bindings as [$variableName, $write]) { + if ( + !array_key_exists($variableName, $sharedVariableNames) + && !$node->areAllVariableNamesReferenced() + && !$node->isOpaque() + // each binding itself reads the variable and lets it escape once + && $node->getObservingAccessCount($variableName) <= 2 * $bindingCounts[$variableName] + ) { + continue; + } + + $this->propertyUsages[] = $write; + } + } + private function tryToApplyPropertyReads(Expr\FuncCall $node, Scope $scope): void { $args = $node->getArgs(); diff --git a/src/Node/Property/PropertyWrite.php b/src/Node/Property/PropertyWrite.php index 02d845272ca..0cfb2667805 100644 --- a/src/Node/Property/PropertyWrite.php +++ b/src/Node/Property/PropertyWrite.php @@ -5,6 +5,7 @@ use PhpParser\Node\Expr\AssignRef; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\StaticPropertyFetch; +use PhpParser\Node\Param; use PHPStan\Analyser\Scope; use PHPStan\Node\ClassPropertyNode; use PHPStan\Node\PropertyAssignNode; @@ -44,6 +45,26 @@ public function isPromotedPropertyWrite(): bool return $this->promotedPropertyWrite; } + /** + * Whether the write binds the property to a reference ($this->prop = &$var, + * $var = &$this->prop, a by-ref promoted parameter), so what is later + * written to the property can be read through the other side. + */ + public function isByReference(): bool + { + if ($this->originalNode instanceof AssignRef) { + return true; + } + + if (!$this->originalNode instanceof ClassPropertyNode) { + return false; + } + + $propertyNode = $this->originalNode->getOriginalNode(); + + return $propertyNode instanceof Param && $propertyNode->byRef; + } + /** * Whether the write happens through offset access ($this->prop[...] = ...) * on an ArrayAccess object, which goes through offsetSet() rather than diff --git a/src/Node/VariableWritesNode.php b/src/Node/VariableWritesNode.php index e5137c2b412..3bb220a1320 100644 --- a/src/Node/VariableWritesNode.php +++ b/src/Node/VariableWritesNode.php @@ -37,6 +37,7 @@ final class VariableWritesNode extends NodeAbstract implements VirtualNode * @param array $referencedVariableNames * @param array $untrackedVariableNames * @param array $variableOverwritingLoops + * @param array $observingAccessCounts */ public function __construct( private Node\FunctionLike $functionLike, @@ -52,6 +53,7 @@ public function __construct( private array $variableOverwritingLoops, private bool $opaque, private bool $allVariableNamesReferenced, + private array $observingAccessCounts = [], ) { parent::__construct($functionLike->getAttributes()); @@ -134,6 +136,16 @@ public function isVariableEverRead(string $variableName): bool return isset($this->readVariableNames[$variableName]); } + /** + * How many sites in the body read the variable or let it escape (pass it + * by reference, bind a reference to it, capture it by reference, declare + * it global or static). + */ + public function getObservingAccessCount(string $variableName): int + { + return $this->observingAccessCounts[$variableName] ?? 0; + } + /** * The type of the assigned value when the write assigns the value the * variable provably already has, null otherwise. diff --git a/src/Rules/DeadCode/UnusedPrivatePropertyRule.php b/src/Rules/DeadCode/UnusedPrivatePropertyRule.php index f1176e89887..980600c4e0d 100644 --- a/src/Rules/DeadCode/UnusedPrivatePropertyRule.php +++ b/src/Rules/DeadCode/UnusedPrivatePropertyRule.php @@ -247,6 +247,10 @@ public function processNode(Node $node, Scope $scope): array } } else { $properties[$propertyName]['written'] = true; + if ($usage->isByReference()) { + $properties[$propertyName]['read'] = true; + $properties[$propertyName]['hasTrueRead'] = true; + } } } } diff --git a/tests/PHPStan/Rules/DeadCode/UnusedPrivatePropertyRuleTest.php b/tests/PHPStan/Rules/DeadCode/UnusedPrivatePropertyRuleTest.php index b49feb428af..a78bf01779a 100644 --- a/tests/PHPStan/Rules/DeadCode/UnusedPrivatePropertyRuleTest.php +++ b/tests/PHPStan/Rules/DeadCode/UnusedPrivatePropertyRuleTest.php @@ -516,4 +516,113 @@ public function testBug12201(): void ]); } + public function testBug15886(): void + { + $this->alwaysWrittenTags = []; + $this->alwaysReadTags = []; + + $this->analyse([__DIR__ . '/data/bug-15886.php'], [ + [ + 'Property Bug15886\OnlyWritten::$log is never read, only written.', + 54, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + ]); + } + + #[RequiresPhp('>= 8.0.0')] + public function testBug15886Promoted(): void + { + $this->alwaysWrittenTags = []; + $this->alwaysReadTags = []; + + $this->analyse([__DIR__ . '/data/bug-15886-promoted.php'], []); + } + + public function testBug15886Static(): void + { + $this->alwaysWrittenTags = []; + $this->alwaysReadTags = []; + + $this->analyse([__DIR__ . '/data/bug-15886-static.php'], []); + } + + public function testBug15886Local(): void + { + $this->alwaysWrittenTags = []; + $this->alwaysReadTags = []; + + $this->analyse([__DIR__ . '/data/bug-15886-local.php'], [ + [ + 'Property Bug15886Local\ThrowawayLocal::$cache is never read, only written.', + 9, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + [ + 'Property Bug15886Local\ByValueParameter::$cache is never read, only written.', + 28, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + [ + 'Static property Bug15886Local\StaticPropertyThrowawayLocal::$cache is never read, only written.', + 173, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + ]); + } + + public function testBug15886ArrayOffset(): void + { + $this->alwaysWrittenTags = []; + $this->alwaysReadTags = []; + + $this->analyse([__DIR__ . '/data/bug-15886-array-offset.php'], [ + [ + 'Property Bug15886ArrayOffset\ArrayOffsetThrowawayLocal::$counters is never read, only written.', + 56, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + ]); + } + + #[RequiresPhp('>= 8.0.0')] + public function testBug15886Review(): void + { + $this->alwaysWrittenTags = []; + $this->alwaysReadTags = []; + + $this->analyse([__DIR__ . '/data/bug-15886-review.php'], [ + [ + 'Property Bug15886Review\TwoBindingsOfThrowawayLocal::$first is never read, only written.', + 77, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + [ + 'Property Bug15886Review\TwoBindingsOfThrowawayLocal::$second is never read, only written.', + 80, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + [ + 'Property Bug15886Review\PromotedByValueNeverRead::$spy is never read, only written.', + 101, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + ]); + } + + #[RequiresPhp('>= 8.0.0')] + public function testBug10068(): void + { + $this->alwaysWrittenTags = []; + $this->alwaysReadTags = []; + + $this->analyse([__DIR__ . '/data/bug-10068.php'], [ + [ + 'Property Bug10068\Bar::$spy is never read, only written.', + 23, + 'See: https://phpstan.org/developing-extensions/always-read-written-properties', + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-10068.php b/tests/PHPStan/Rules/DeadCode/data/bug-10068.php new file mode 100644 index 00000000000..b53ada181f8 --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-10068.php @@ -0,0 +1,38 @@ += 8.0 + +declare(strict_types = 1); + +namespace Bug10068; + +class Foo +{ + /** @param array $spy */ + public function __construct(private array &$spy) + { + } + + public function doSomething(): void + { + $this->spy['doSomething'] = true; + } +} + +class Bar +{ + /** @param array $spy */ + public function __construct(private array $spy) + { + } + + public function doSomething(): void + { + $this->spy['doSomething'] = true; + } +} + +function (): void { + $spy = []; + $foo = new Foo($spy); + $foo->doSomething(); + print_r($spy); +}; diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-15886-array-offset.php b/tests/PHPStan/Rules/DeadCode/data/bug-15886-array-offset.php new file mode 100644 index 00000000000..1c0884b31da --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-15886-array-offset.php @@ -0,0 +1,68 @@ + */ + private array $counters = []; + + public function bind(int &$counter): void + { + $this->counters['requests'] = &$counter; + } + + public function reset(): void + { + $this->counters['requests'] = 0; + } +} + +class NestedArrayOffset +{ + /** @var array> */ + private array $counters = []; + + public function bind(int &$counter): void + { + $this->counters['http']['requests'] = &$counter; + } + + public function reset(): void + { + $this->counters['http']['requests'] = 0; + } +} + +class StaticArrayOffset +{ + /** @var array */ + private static array $counters = []; + + public static function bind(int &$counter): void + { + self::$counters['requests'] = &$counter; + } + + public static function reset(): void + { + self::$counters['requests'] = 0; + } +} + +class ArrayOffsetThrowawayLocal +{ + /** @var array */ + private array $counters = []; + + public function bind(): void + { + $counter = 0; + $this->counters['requests'] = &$counter; + } + + public function reset(): void + { + $this->counters['requests'] = 0; + } +} diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-15886-local.php b/tests/PHPStan/Rules/DeadCode/data/bug-15886-local.php new file mode 100644 index 00000000000..6bbce7b7905 --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-15886-local.php @@ -0,0 +1,186 @@ + */ + private array $cache; + + public function __construct() + { + $tmp = []; + $this->cache = &$tmp; + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class ByValueParameter +{ + + /** @var list */ + private array $cache; + + /** @param list $tmp */ + public function __construct(array $tmp) + { + $this->cache = &$tmp; + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class LocalReadAfterwards +{ + + /** @var list */ + private array $cache; + + public function __construct() + { + $tmp = []; + $this->cache = &$tmp; + $this->add(); + echo count($tmp); + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class LocalPassedOn +{ + + /** @var list */ + private array $cache; + + /** @param \ArrayObject $registry */ + public function __construct(\ArrayObject $registry) + { + $tmp = []; + $this->cache = &$tmp; + $registry->append($tmp); + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class GlobalVariable +{ + + /** @var list */ + private array $cache; + + public function __construct() + { + global $tmp; + $this->cache = &$tmp; + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class StaticVariable +{ + + /** @var list */ + private array $cache; + + public function __construct() + { + static $tmp = []; + $this->cache = &$tmp; + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class CapturedByClosure +{ + + /** @var list */ + private array $cache; + + public \Closure $count; + + public function __construct() + { + $tmp = []; + $this->cache = &$tmp; + $this->count = static function () use (&$tmp): int { + return count($tmp); + }; + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class Compacted +{ + + /** @var list */ + private array $cache; + + /** @return array */ + public function bind(): array + { + $tmp = []; + $this->cache = &$tmp; + + return compact('tmp'); + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class StaticPropertyThrowawayLocal +{ + + /** @var list */ + private static array $cache = []; + + public static function bind(): void + { + $tmp = []; + self::$cache = &$tmp; + } + + public static function add(): void + { + self::$cache[] = 'x'; + } + +} diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-15886-promoted.php b/tests/PHPStan/Rules/DeadCode/data/bug-15886-promoted.php new file mode 100644 index 00000000000..9e5a5627522 --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-15886-promoted.php @@ -0,0 +1,42 @@ += 8.0 + +declare(strict_types = 1); + +namespace Bug15886Promoted; + +/** + * @param list $forwarded + */ +function byRefConsumedArg(array &$forwarded):void { + new class($forwarded) + { + /** + * @param list $forwarded + */ + public function __construct(private array &$forwarded) + { + } + + public function notify(): void + { + $this->forwarded[] = 'suite finished'; + } + }; +} + +class Foo +{ + + /** + * @param list $forwarded + */ + public function __construct(private array &$forwarded) + { + } + + public function notify(): void + { + $this->forwarded[] = 'suite finished'; + } + +} diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-15886-review.php b/tests/PHPStan/Rules/DeadCode/data/bug-15886-review.php new file mode 100644 index 00000000000..1d5b4d0131f --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-15886-review.php @@ -0,0 +1,110 @@ += 8.0 + +declare(strict_types = 1); + +namespace Bug15886Review; + +class ByValueParameterReadAfterwards +{ + + /** @var list */ + private array $cache = []; + + /** + * @param list $tmp + * @return list + */ + public function run(array $tmp): array + { + $this->cache = &$tmp; + $this->add(); + return $tmp; + } + + private function add(): void + { + $this->cache[] = 'x'; + } + +} + +class ClosureByRefParameter +{ + + /** @var list */ + private array $cache = []; + + public function binder(): \Closure + { + /** @param list $forwarded */ + return function (array &$forwarded): void { + $this->cache = &$forwarded; + }; + } + + public function add(): void + { + $this->cache[] = 'x'; + } + +} + +class ForeachByRefValue +{ + + /** @var int */ + private int $last = 0; + + /** @param list $items */ + public function bind(array &$items): void + { + foreach ($items as &$item) { + $this->last = &$item; + } + } + + public function bump(): void + { + $this->last = 5; + } + +} + +class TwoBindingsOfThrowawayLocal +{ + + /** @var list */ + private array $first = []; + + /** @var list */ + private array $second = []; + + public function bind(): void + { + $tmp = []; + $this->first = &$tmp; + $this->second = &$tmp; + } + + public function add(): void + { + $this->first[] = 'x'; + $this->second[] = 'y'; + } + +} + +class PromotedByValueNeverRead +{ + + /** @param list $spy */ + public function __construct(private array $spy) + { + } + + public function add(): void + { + $this->spy[] = 'x'; + } + +} diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-15886-static.php b/tests/PHPStan/Rules/DeadCode/data/bug-15886-static.php new file mode 100644 index 00000000000..3d75347f13e --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-15886-static.php @@ -0,0 +1,49 @@ + + */ + private static array $forwarded = []; + + /** + * @param list $forwarded + */ + public static function init(array &$forwarded): void + { + self::$forwarded = &$forwarded; + } + + public static function notify(): void + { + self::$forwarded[] = 'suite finished'; + } + +} + +class Bar +{ + + /** + * @var list + */ + private static array $forwarded = []; + + /** + * @param list $forwarded + */ + public static function init(array &$forwarded): void + { + static::$forwarded = &$forwarded; + } + + public static function notify(): void + { + static::$forwarded[] = 'suite finished'; + } + +} diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-15886.php b/tests/PHPStan/Rules/DeadCode/data/bug-15886.php new file mode 100644 index 00000000000..3c1d33ceeb3 --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-15886.php @@ -0,0 +1,61 @@ + $forwarded + */ +function byRefConsumedArg(array &$forwarded):void { + new class($forwarded) + { + /** + * @var list + */ + private array $forwarded; + + /** + * @param list $forwarded + */ + public function __construct(array &$forwarded) + { + $this->forwarded = &$forwarded; + } + + public function notify(): void + { + $this->forwarded[] = 'suite finished'; + } + }; +} + +class StaticProperty +{ + + /** @var list */ + private static array $log = []; + + /** @param list $log */ + public static function bind(array &$log): void + { + self::$log = &$log; + } + + public static function notify(): void + { + self::$log[] = 'x'; + } + +} + +class OnlyWritten +{ + + /** @var list */ + private array $log = []; + + public function notify(): void + { + $this->log[] = 'x'; + } + +} diff --git a/tests/PHPStan/Rules/Properties/MissingReadOnlyByPhpDocPropertyAssignRuleTest.php b/tests/PHPStan/Rules/Properties/MissingReadOnlyByPhpDocPropertyAssignRuleTest.php index 6b028fdade8..502044ad850 100644 --- a/tests/PHPStan/Rules/Properties/MissingReadOnlyByPhpDocPropertyAssignRuleTest.php +++ b/tests/PHPStan/Rules/Properties/MissingReadOnlyByPhpDocPropertyAssignRuleTest.php @@ -145,4 +145,9 @@ public function testBug14983(): void ]); } + public function testBug15886(): void + { + $this->analyse([__DIR__ . '/data/bug-15886-readonly-phpdoc.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Properties/UninitializedPropertyRuleTest.php b/tests/PHPStan/Rules/Properties/UninitializedPropertyRuleTest.php index c0f6a1a9262..c50f3ec6ac6 100644 --- a/tests/PHPStan/Rules/Properties/UninitializedPropertyRuleTest.php +++ b/tests/PHPStan/Rules/Properties/UninitializedPropertyRuleTest.php @@ -193,4 +193,10 @@ public function testBug14983(): void $this->analyse([__DIR__ . '/data/bug-14983-uninitialized.php'], []); } + #[RequiresPhp('>= 8.0.0')] + public function testBug15886(): void + { + $this->analyse([__DIR__ . '/data/bug-15886-uninitialized.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Properties/data/bug-15886-readonly-phpdoc.php b/tests/PHPStan/Rules/Properties/data/bug-15886-readonly-phpdoc.php new file mode 100644 index 00000000000..5d38a610f2d --- /dev/null +++ b/tests/PHPStan/Rules/Properties/data/bug-15886-readonly-phpdoc.php @@ -0,0 +1,26 @@ + + */ + private array $cache; + + /** @param list $c */ + public function __construct(array &$c) + { + $this->cache = &$c; + } + + /** @return list */ + public function get(): array + { + return $this->cache; + } + +} diff --git a/tests/PHPStan/Rules/Properties/data/bug-15886-uninitialized.php b/tests/PHPStan/Rules/Properties/data/bug-15886-uninitialized.php new file mode 100644 index 00000000000..3cca960e77e --- /dev/null +++ b/tests/PHPStan/Rules/Properties/data/bug-15886-uninitialized.php @@ -0,0 +1,42 @@ += 8.0 + +declare(strict_types = 1); + +namespace Bug15886Uninitialized; + +/** + * @param list $forwarded + */ +function byRefConsumedArg(array &$forwarded):void { + new class($forwarded) + { + /** + * @var list + */ + private array $forwarded; + + /** + * @param list $forwarded + */ + public function __construct(array &$forwarded) + { + $this->forwarded = &$forwarded; + } + + public function notify(): void + { + $this->forwarded[] = 'suite finished'; + } + }; +} + +class Promoted +{ + + /** @param list $f */ + public function __construct(private array &$f) + { + $this->f[] = 'a'; + } + +} diff --git a/turbo-ext/src/ClassStatementsGatherer.cpp b/turbo-ext/src/ClassStatementsGatherer.cpp index 2754ebdc2ef..f8cadcc8a51 100644 --- a/turbo-ext/src/ClassStatementsGatherer.cpp +++ b/turbo-ext/src/ClassStatementsGatherer.cpp @@ -18,7 +18,7 @@ * read directly. * * State is the twin's properties in declaration order: the untyped - * $nodeCallback, the eight collected arrays, then the promoted + * $nodeCallback, the eight collected arrays, the deferred reference bindings, then the promoted * $classReflection. */ @@ -83,12 +83,14 @@ static NodeProp pt_csg_array_items = PT_NODE_PROP(PT_CLASS_ARRAY_EXPR, "items"); static NodeProp pt_csg_property_assign_fetch = PT_NODE_PROP(PT_CLASS_PROPERTY_ASSIGN_NODE, "propertyFetch"); static NodeProp pt_csg_property_assign_expr = PT_NODE_PROP(PT_CLASS_PROPERTY_ASSIGN_NODE, "assignedExpr"); static NodeProp pt_csg_coalesce_var = PT_NODE_PROP(PT_CLASS_COALESCE_ASSIGN_OP_EXPR, "var"); +static NodeProp pt_csg_assign_ref_var = PT_NODE_PROP(PT_CLASS_ASSIGN_REF_EXPR, "var"); static NodeProp pt_csg_assign_ref_expr = PT_NODE_PROP(PT_CLASS_ASSIGN_REF_EXPR, "expr"); static NodeProp pt_csg_variable_name = PT_NODE_PROP(PT_CLASS_VARIABLE, "name"); static NodeProp pt_csg_array_dim_fetch_var = PT_NODE_PROP(PT_CLASS_ARRAY_DIM_FETCH, "var"); static NodeProp pt_csg_param_flags = PT_NODE_PROP(PT_CLASS_PARAM, "flags"); static NodeProp pt_csg_param_hooks = PT_NODE_PROP(PT_CLASS_PARAM, "hooks"); static NodeProp pt_csg_param_var = PT_NODE_PROP(PT_CLASS_PARAM, "var"); +static NodeProp pt_csg_param_by_ref = PT_NODE_PROP(PT_CLASS_PARAM, "byRef"); static NodeProp pt_csg_arg_value = PT_NODE_PROP(PT_CLASS_ARG, "value"); static NodeProp pt_csg_gathered_class_method_node = PT_NODE_PROP(PT_CLASS_GATHERED_CLASS_METHOD, "node"); @@ -309,6 +311,7 @@ class ClassStatementsGatherer } if (isInstanceOf(node, PT_CLASS_CLASS_CONST_FETCH)) return pushNodeScope(slots::constantFetches, PT_CLASS_CLASS_CONSTANT_FETCH, &nodeZv, scope); if (isInstanceOf(node, PT_CLASS_PROPERTY_ASSIGN_NODE)) return addPropertyAssign(node, &nodeZv, scope); + if (isInstanceOf(node, PT_CLASS_VARIABLE_WRITES_NODE)) return resolveReferenceBindings(node, scope); if (!isInstanceOf(node, PT_CLASS_EXPR)) return !EG(exception); if (isInstanceOf(node, PT_CLASS_COALESCE_ASSIGN_OP_EXPR)) { zval *var = pt_csg_coalesce_var.of(node); @@ -316,6 +319,13 @@ class ClassStatementsGatherer return gatherNodes(Z_OBJ_P(var), scope); } if (isInstanceOf(node, PT_CLASS_ASSIGN_REF_EXPR)) { + zval *var = pt_csg_assign_ref_var.of(node); + if (UNEXPECTED(var == NULL || Z_TYPE_P(var) != IS_OBJECT)) return !EG(exception); + while (isInstanceOf(Z_OBJ_P(var), PT_CLASS_ARRAY_DIM_FETCH)) { + var = pt_csg_array_dim_fetch_var.of(Z_OBJ_P(var)); + if (UNEXPECTED(var == NULL || Z_TYPE_P(var) != IS_OBJECT)) return !EG(exception); + } + if (isPropertyFetchLike(Z_OBJ_P(var)) && UNEXPECTED(!addReferenceBinding(node, var, scope, &nodeZv))) return false; zval *expr = pt_csg_assign_ref_expr.of(node); if (UNEXPECTED(expr == NULL || Z_TYPE_P(expr) != IS_OBJECT)) return !EG(exception); if (!isPropertyFetchLike(Z_OBJ_P(expr))) return gatherNodes(Z_OBJ_P(expr), scope); @@ -395,6 +405,158 @@ class ClassStatementsGatherer return pushNodeScope(slots::propertyAssigns, PT_CLASS_PROPERTY_ASSIGN, nodeZv, scope); } + /* the lowercased $scope->getFunction()->getName() outside closures, NULL + * otherwise (or on a pending exception, which ok = false reports) */ + static zend_string *bindingMethodKey(zval *scope, bool &ok) + { + ok = true; + zv::Val function = pt_mutating_scope_get_function(Z_OBJ_P(scope)); + if (UNEXPECTED(function.isUndef())) { + ok = false; + return NULL; + } + if (Z_TYPE_P(function.raw()) != IS_OBJECT) return NULL; + bool inAnonymousFunction; + if (UNEXPECTED(!pt_mutating_scope_is_in_anonymous_function(Z_OBJ_P(scope), inAnonymousFunction))) { + ok = false; + return NULL; + } + if (inAnonymousFunction) return NULL; + zv::Val functionName = pt_type_call(Z_OBJ_P(function.raw()), PT_LC("getname"), 0, NULL); + if (UNEXPECTED(functionName.isUndef())) { + ok = false; + return NULL; + } + if (Z_TYPE_P(functionName.raw()) != IS_STRING) return NULL; + return zend_string_tolower(Z_STR_P(functionName.raw())); + } + + /* the AssignRef branch's new PropertyWrite: deferred into + * $referenceBindings[method][spl_object_id($node)] when it binds a local + * variable, appended to $propertyUsages otherwise */ + bool addReferenceBinding(zend_object *node, zval *boundVar, zval *scope, zval *nodeZv) + { + zval args[4]; + ZVAL_COPY_VALUE(&args[0], boundVar); + ZVAL_COPY_VALUE(&args[1], scope); + ZVAL_FALSE(&args[2]); + ZVAL_COPY_VALUE(&args[3], nodeZv); + zv::Val write = pt_type_new(PT_CLASS_PROPERTY_WRITE, 4, args); + if (UNEXPECTED(write.isUndef())) return false; + + zval *expr = pt_csg_assign_ref_expr.of(node); + zval *variableName = expr != NULL && Z_TYPE_P(expr) == IS_OBJECT && isInstanceOf(Z_OBJ_P(expr), PT_CLASS_VARIABLE) ? pt_csg_variable_name.of(Z_OBJ_P(expr)) : NULL; + if (variableName == NULL || Z_TYPE_P(variableName) != IS_STRING) { + push(slots::propertyUsages, write.raw()); + return !EG(exception); + } + bool ok; + zend_string *key = bindingMethodKey(scope, ok); + if (UNEXPECTED(!ok)) return false; + if (key == NULL) { + push(slots::propertyUsages, write.raw()); + return true; + } + zval *bindings = OBJ_PROP_NUM(self, slots::referenceBindings); + SEPARATE_ARRAY(bindings); + zval *methodBindings = zend_symtable_find(Z_ARRVAL_P(bindings), key); + if (methodBindings == NULL) { + zval empty; + array_init(&empty); + methodBindings = zend_symtable_update(Z_ARRVAL_P(bindings), key, &empty); + } + zend_string_release(key); + SEPARATE_ARRAY(methodBindings); + zval pair; + array_init_size(&pair, 2); + Z_TRY_ADDREF_P(variableName); + add_next_index_zval(&pair, variableName); + Z_ADDREF_P(write.raw()); + add_next_index_zval(&pair, write.raw()); + zend_hash_index_update(Z_ARRVAL_P(methodBindings), (zend_ulong) node->handle, &pair); + return true; + } + + bool resolveReferenceBindings(zend_object *node, zval *scope) + { + zval *bindingsSlot = OBJ_PROP_NUM(self, slots::referenceBindings); + if (Z_TYPE_P(bindingsSlot) != IS_ARRAY || zend_hash_num_elements(Z_ARRVAL_P(bindingsSlot)) == 0) return true; + bool ok; + zend_string *key = bindingMethodKey(scope, ok); + if (UNEXPECTED(!ok)) return false; + if (key == NULL) return true; + zval *found = zend_symtable_find(Z_ARRVAL_P(bindingsSlot), key); + if (found == NULL) { + zend_string_release(key); + return true; + } + zv::Val bindings = zv::Val::copyOf(zv::Ref(found)); + SEPARATE_ARRAY(bindingsSlot); + zend_symtable_del(Z_ARRVAL_P(bindingsSlot), key); + zend_string_release(key); + + /* by-ref and promoted parameters share the variable with the caller */ + zv::Arr sharedNames = zv::Arr::create(0); + zv::Val functionLike = pt_type_call(node, PT_LC("getfunctionlike"), 0, NULL); + if (UNEXPECTED(functionLike.isUndef())) return false; + if (Z_TYPE_P(functionLike.raw()) == IS_OBJECT) { + zv::Val params = pt_type_call(Z_OBJ_P(functionLike.raw()), PT_LC("getparams"), 0, NULL); + if (UNEXPECTED(params.isUndef())) return false; + if (Z_TYPE_P(params.raw()) == IS_ARRAY) { + for (zv::ArrayEntry entry : zv::ArrRef(params.raw())) { + zval *param = entry.value().deref().raw(); + if (UNEXPECTED(Z_TYPE_P(param) != IS_OBJECT)) continue; + zval *byRef = pt_csg_param_by_ref.of(Z_OBJ_P(param)); + zval *flags = pt_csg_param_flags.of(Z_OBJ_P(param)); + bool shared = (byRef != NULL && zend_is_true(byRef)) || (flags != NULL && Z_TYPE_P(flags) == IS_LONG && Z_LVAL_P(flags) != 0); + if (!shared) continue; + zend_object *var = pt_csg_param_var.objectOf(Z_OBJ_P(param), PT_CLASS_VARIABLE); + zval *paramName = var != NULL ? pt_csg_variable_name.of(var) : NULL; + if (paramName == NULL || Z_TYPE_P(paramName) != IS_STRING) continue; + zval trueValue; + ZVAL_TRUE(&trueValue); + zend_symtable_update(sharedNames.table(), Z_STR_P(paramName), &trueValue); + } + } + } + + zv::Val allReferenced = pt_type_call(node, PT_LC("areallvariablenamesreferenced"), 0, NULL); + if (UNEXPECTED(allReferenced.isUndef())) return false; + zv::Val opaque = pt_type_call(node, PT_LC("isopaque"), 0, NULL); + if (UNEXPECTED(opaque.isUndef())) return false; + bool everyBindingRead = zend_is_true(allReferenced.raw()) || zend_is_true(opaque.raw()); + + zv::Arr bindingCounts = zv::Arr::create(0); + for (zv::ArrayEntry entry : zv::ArrRef(bindings.raw())) { + zval *name = zend_hash_index_find(Z_ARRVAL_P(entry.value().deref().raw()), 0); + if (UNEXPECTED(name == NULL || Z_TYPE_P(name) != IS_STRING)) continue; + zval *count = zend_symtable_find(bindingCounts.table(), Z_STR_P(name)); + if (count != NULL) { + Z_LVAL_P(count)++; + } else { + zval one; + ZVAL_LONG(&one, 1); + zend_symtable_update(bindingCounts.table(), Z_STR_P(name), &one); + } + } + + for (zv::ArrayEntry entry : zv::ArrRef(bindings.raw())) { + HashTable *pair = Z_ARRVAL_P(entry.value().deref().raw()); + zval *name = zend_hash_index_find(pair, 0); + zval *write = zend_hash_index_find(pair, 1); + if (UNEXPECTED(name == NULL || write == NULL || Z_TYPE_P(name) != IS_STRING)) continue; + if (!everyBindingRead && zend_symtable_find(sharedNames.table(), Z_STR_P(name)) == NULL) { + zv::Val accessCount = pt_type_call(node, PT_LC("getobservingaccesscount"), 1, name); + if (UNEXPECTED(accessCount.isUndef())) return false; + zval *count = zend_symtable_find(bindingCounts.table(), Z_STR_P(name)); + /* each binding itself reads the variable and lets it escape once */ + if (zval_get_long(accessCount.raw()) <= 2 * (count != NULL ? Z_LVAL_P(count) : 0)) continue; + } + push(slots::propertyUsages, write); + } + return true; + } + bool tryToApplyPropertyReads(zend_object *node, zval *scope) { zv::Val argsHold; @@ -608,7 +770,7 @@ PT_MINIT_REGISTRATION(pt_register_class_statements_gatherer) { reg::Class cls("PHPStan\\Node\\ClassStatementsGatherer"); ptdecl::ClassStatementsGatherer::declareClass(cls); - /* the slots PT_CSG_PROP_*: the nine class-body properties first, the + /* the slots PT_CSG_PROP_*: the ten class-body properties first, the * promoted constructor property after them */ cls.privateNullProperty("nodeCallback"); cls.privateTypedArrayPropertyDefaultEmpty("properties"); @@ -619,6 +781,7 @@ PT_MINIT_REGISTRATION(pt_register_class_statements_gatherer) cls.privateTypedArrayPropertyDefaultEmpty("constantFetches"); cls.privateTypedArrayPropertyDefaultEmpty("returnStatementNodes"); cls.privateTypedArrayPropertyDefaultEmpty("propertyAssigns"); + cls.privateTypedArrayPropertyDefaultEmpty("referenceBindings"); cls.privateTypedClassProperty("classReflection", "PHPStan\\Reflection\\ClassReflection", false); cls.privateClassConstantValue("PROPERTY_ENUMERATING_FUNCTIONS", pt_csg_property_enumerating_functions_constant); diff --git a/turbo-ext/src/VariableLivenessResolver.cpp b/turbo-ext/src/VariableLivenessResolver.cpp index 4dbe00983e4..ff266a7eaca 100644 --- a/turbo-ext/src/VariableLivenessResolver.cpp +++ b/turbo-ext/src/VariableLivenessResolver.cpp @@ -619,8 +619,28 @@ class VariableLivenessResolver for (auto entry : zv::TableRef(tableOf(self.writes))) { writeList.push(entry.value()); } + /* how many read or escape sites each variable has */ + zv::Arr observingAccessCounts = zv::Arr::create(0); + for (auto entry : zv::TableRef(tableOf(self.accesses))) { + zend_long count = 0; + for (auto access : zv::TableRef(Z_ARRVAL_P(entry.value().deref().raw()))) { + FlowKind kind = self.kindOfFlow(Z_OBJ_P(access.value().deref().raw()), self.slots.accessKind); + if (UNEXPECTED(EG(exception))) return zv::Val(); + if (kind == PT_VLR_READ || kind == PT_VLR_ESCAPE) count++; + } + if (count == 0) continue; + zval countValue; + ZVAL_LONG(&countValue, count); + zend_string *name = entry.stringKeyOrNull(); + if (name != NULL) { + zend_hash_update(observingAccessCounts.table(), name, &countValue); + } else { + zend_hash_index_update(observingAccessCounts.table(), entry.indexKey(), &countValue); + } + } + zv::Val readWriteIds = unionOf(self.observedIds, self.readIds); - zval argv[13]; + zval argv[14]; ZVAL_COPY_VALUE(&argv[0], function); ZVAL_COPY_VALUE(&argv[1], writeList.raw()); ZVAL_COPY_VALUE(&argv[2], readWriteIds.raw()); @@ -634,7 +654,8 @@ class VariableLivenessResolver ZVAL_COPY_VALUE(&argv[10], self.variableOverwritingLoops.raw()); ZVAL_BOOL(&argv[11], self.opaque); ZVAL_BOOL(&argv[12], self.allNamesMentioned); - return pt_type_new(PT_CLASS_VARIABLE_WRITES_NODE, 13, argv); + ZVAL_COPY_VALUE(&argv[13], observingAccessCounts.raw()); + return pt_type_new(PT_CLASS_VARIABLE_WRITES_NODE, 14, argv); } private: diff --git a/turbo-ext/src/generated/ClassStatementsGatherer.h b/turbo-ext/src/generated/ClassStatementsGatherer.h index 866b703bc83..cad9cff4048 100644 --- a/turbo-ext/src/generated/ClassStatementsGatherer.h +++ b/turbo-ext/src/generated/ClassStatementsGatherer.h @@ -19,7 +19,8 @@ inline constexpr uint32_t constants = 5; inline constexpr uint32_t constantFetches = 6; inline constexpr uint32_t returnStatementNodes = 7; inline constexpr uint32_t propertyAssigns = 8; -inline constexpr uint32_t classReflection = 9; +inline constexpr uint32_t referenceBindings = 9; +inline constexpr uint32_t classReflection = 10; } // namespace slot inline void declareClass(reg::Class &cls) @@ -39,6 +40,7 @@ inline void declareProperties(reg::Class &cls) cls.property("constantFetches", ZEND_ACC_PRIVATE, reg::PropertyKind::TypedEmptyArray, MAY_BE_ARRAY); cls.property("returnStatementNodes", ZEND_ACC_PRIVATE, reg::PropertyKind::TypedEmptyArray, MAY_BE_ARRAY); cls.property("propertyAssigns", ZEND_ACC_PRIVATE, reg::PropertyKind::TypedEmptyArray, MAY_BE_ARRAY); + cls.property("referenceBindings", ZEND_ACC_PRIVATE, reg::PropertyKind::TypedEmptyArray, MAY_BE_ARRAY); cls.property("classReflection", ZEND_ACC_PRIVATE, reg::PropertyKind::Typed, 0, "PHPStan\\Reflection\\ClassReflection"); } @@ -64,13 +66,15 @@ inline constexpr char strings[] = "PHPStan\\Analyser\\Scope\0" /* 237 */ "__invoke\0" /* 260 */ "gatherNodes\0" /* 269 */ - "PhpParser\\Node\\Expr\\FuncCall\0" /* 281 */ - "tryToApplyPropertyReads\0" /* 310 */ - "PhpParser\\Node\\Expr\\Variable\0" /* 334 */ - "tryToApplyPromotedParameterRead\0" /* 363 */ - "ancestorConstructorCall\0" /* 395 */ - "PhpParser\\Node\\Expr\\StaticCall\0" /* 419 */ - "tryToApplyPropertyWritesFromAncestorConstructor"; /* 450 */ + "PHPStan\\Node\\VariableWritesNode\0" /* 281 */ + "resolveReferenceBindings\0" /* 313 */ + "PhpParser\\Node\\Expr\\FuncCall\0" /* 338 */ + "tryToApplyPropertyReads\0" /* 367 */ + "PhpParser\\Node\\Expr\\Variable\0" /* 391 */ + "tryToApplyPromotedParameterRead\0" /* 420 */ + "ancestorConstructorCall\0" /* 452 */ + "PhpParser\\Node\\Expr\\StaticCall\0" /* 476 */ + "tryToApplyPropertyWritesFromAncestorConstructor"; /* 507 */ inline constexpr reg::PackedArg args[] = { reg::packed(0, 0, 16), /* __construct $classReflection */ reg::packed(51, MAY_BE_CALLABLE), /* __construct $nodeCallback */ @@ -88,13 +92,16 @@ inline constexpr reg::PackedArg args[] = { reg::packed(211, 0, 216), /* gatherNodes $node */ reg::packed(231, 0, 237), /* gatherNodes $scope */ reg::packed(76, MAY_BE_VOID), /* gatherNodes return */ - reg::packed(211, 0, 281), /* tryToApplyPropertyReads $node */ + reg::packed(211, 0, 281), /* resolveReferenceBindings $node */ + reg::packed(231, 0, 237), /* resolveReferenceBindings $scope */ + reg::packed(76, MAY_BE_VOID), /* resolveReferenceBindings return */ + reg::packed(211, 0, 338), /* tryToApplyPropertyReads $node */ reg::packed(231, 0, 237), /* tryToApplyPropertyReads $scope */ reg::packed(76, MAY_BE_VOID), /* tryToApplyPropertyReads return */ - reg::packed(211, 0, 334), /* tryToApplyPromotedParameterRead $node */ + reg::packed(211, 0, 391), /* tryToApplyPromotedParameterRead $node */ reg::packed(231, 0, 237), /* tryToApplyPromotedParameterRead $scope */ reg::packed(76, MAY_BE_VOID), /* tryToApplyPromotedParameterRead return */ - reg::packed(395, 0, 419), /* tryToApplyPropertyWritesFromAncestorConstructor $ancestorConstructorCall */ + reg::packed(452, 0, 476), /* tryToApplyPropertyWritesFromAncestorConstructor $ancestorConstructorCall */ reg::packed(231, 0, 237), /* tryToApplyPropertyWritesFromAncestorConstructor $scope */ reg::packed(76, MAY_BE_VOID), /* tryToApplyPropertyWritesFromAncestorConstructor return */ }; @@ -114,9 +121,10 @@ inline constexpr sigtab::Sig getReturnStatementsNodes = { { 167 /* getReturnStat inline constexpr sigtab::Sig getPropertyAssigns = { { 192 /* getPropertyAssigns */, 0, 9, 0, 9, ZEND_ACC_PUBLIC } }; inline constexpr sigtab::Sig __invoke = { { 260 /* __invoke */, 2, 10, 2, 12, ZEND_ACC_PUBLIC } }; inline constexpr sigtab::Sig gatherNodes = { { 269 /* gatherNodes */, 2, 13, 2, 15, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig tryToApplyPropertyReads = { { 310 /* tryToApplyPropertyReads */, 2, 16, 2, 18, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig tryToApplyPromotedParameterRead = { { 363 /* tryToApplyPromotedParameterRead */, 2, 19, 2, 21, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig tryToApplyPropertyWritesFromAncestorConstructor = { { 450 /* tryToApplyPropertyWritesFromAncestorConstructor */, 2, 22, 2, 24, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig resolveReferenceBindings = { { 313 /* resolveReferenceBindings */, 2, 16, 2, 18, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig tryToApplyPropertyReads = { { 367 /* tryToApplyPropertyReads */, 2, 19, 2, 21, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig tryToApplyPromotedParameterRead = { { 420 /* tryToApplyPromotedParameterRead */, 2, 22, 2, 24, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig tryToApplyPropertyWritesFromAncestorConstructor = { { 507 /* tryToApplyPropertyWritesFromAncestorConstructor */, 2, 25, 2, 27, ZEND_ACC_PRIVATE } }; } // namespace sig } // namespace ptdecl::ClassStatementsGatherer