From 20b7c4a8ae8621ff7aeecfc5d7b3df4fa9b95320 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Wed, 20 Aug 2025 12:28:34 -0700 Subject: [PATCH 1/3] Extractor: Account for attribute changes Ignore the `Since` and `Until` attributes that the extractor adds, and also ignore if the attributes are grouped differently for simplicity. --- extractor/extract.php | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/extractor/extract.php b/extractor/extract.php index 7d1a6031..aba10c25 100755 --- a/extractor/extract.php +++ b/extractor/extract.php @@ -551,6 +551,53 @@ private function compareFunctions(Node\FunctionLike $old, Node\FunctionLike $new if (count($old->getParams()) !== count($new->getParams())) { return $this->stmtDiff($old, $new, $updateTo); } + $oldAttribGroups = $old->getAttrGroups(); + $oldAttribs = []; + foreach ($oldAttribGroups as $group) { + foreach ($group->attrs as $attrib) { + if ($attrib->name->toLowerString() !== 'since' && $attrib->name->toLowerString() !== 'until') { + $oldAttribs[] = $attrib; + } + } + } + $newAttribGroups = $new->getAttrGroups(); + $newAttribs = []; + foreach ($newAttribGroups as $group) { + foreach ($group->attrs as $attrib) { + if ($attrib->name->toLowerString() !== 'since' && $attrib->name->toLowerString() !== 'until') { + $oldAttribs[] = $attrib; + } + } + } + if (count($oldAttribs) !== count($newAttribs)) { + return $this->stmtDiff($old, $new, $updateTo); + } + foreach ($oldAttribs as $idx => $oldAttrib) { + $newAttrib = $newAttribs[$attribIdx]; + if ($oldAttrib->name->name !== $newAttrib->name->name) { + return $this->stmtDiff($old, $new, $updateTo); + } + $oldArgs = $oldAttrib->args; + $newArgs = $newAttrib->args; + if (count($oldArgs) !== count($newArgs)) { + return $this->stmtDiff($old, $new, $updateTo); + } + foreach ($oldArgs as $argIdx => $oldArg) { + $newArg = $newArgs[$argIdx]; + if ($oldArg->name !== null && $newArg->name !== null) { + if ($oldArg->name->name !== $newArg->name->name) { + return $this->stmtDiff($old, $new, $updateTo); + } + } elseif ($oldArg->name !== null || $newArg->name !== null) { + return $this->stmtDiff($old, $new, $updateTo); + } + $oldArgValue = $this->printer->prettyPrintExpr($oldArg->expr); + $newArgValue = $this->printer->prettyPrintExpr($newArg->expr); + if ($oldArgValue !== $newArgValue) { + return $this->stmtDiff($old, $new, $updateTo); + } + } + } foreach ($old->getParams() as $i => $oldParam) { $newParam = $new->getParams()[$i]; From 8808f7e1a2feb870e04da043713f6a8c571fe9ae Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Wed, 20 Aug 2025 12:29:58 -0700 Subject: [PATCH 2/3] phpstan fixes --- extractor/extract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extractor/extract.php b/extractor/extract.php index aba10c25..174d59a8 100755 --- a/extractor/extract.php +++ b/extractor/extract.php @@ -565,7 +565,7 @@ private function compareFunctions(Node\FunctionLike $old, Node\FunctionLike $new foreach ($newAttribGroups as $group) { foreach ($group->attrs as $attrib) { if ($attrib->name->toLowerString() !== 'since' && $attrib->name->toLowerString() !== 'until') { - $oldAttribs[] = $attrib; + $newAttribs[] = $attrib; } } } @@ -573,7 +573,7 @@ private function compareFunctions(Node\FunctionLike $old, Node\FunctionLike $new return $this->stmtDiff($old, $new, $updateTo); } foreach ($oldAttribs as $idx => $oldAttrib) { - $newAttrib = $newAttribs[$attribIdx]; + $newAttrib = $newAttribs[$idx]; if ($oldAttrib->name->name !== $newAttrib->name->name) { return $this->stmtDiff($old, $new, $updateTo); } From b4c8eca199c237fec83c527e133046f0f7f828e5 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Wed, 20 Aug 2025 12:31:21 -0700 Subject: [PATCH 3/3] values --- extractor/extract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extractor/extract.php b/extractor/extract.php index 174d59a8..9e96a42f 100755 --- a/extractor/extract.php +++ b/extractor/extract.php @@ -591,8 +591,8 @@ private function compareFunctions(Node\FunctionLike $old, Node\FunctionLike $new } elseif ($oldArg->name !== null || $newArg->name !== null) { return $this->stmtDiff($old, $new, $updateTo); } - $oldArgValue = $this->printer->prettyPrintExpr($oldArg->expr); - $newArgValue = $this->printer->prettyPrintExpr($newArg->expr); + $oldArgValue = $this->printer->prettyPrintExpr($oldArg->value); + $newArgValue = $this->printer->prettyPrintExpr($newArg->value); if ($oldArgValue !== $newArgValue) { return $this->stmtDiff($old, $new, $updateTo); }