Skip to content

Commit 8792897

Browse files
Extractor: Account for function attribute changes
1 parent a783dcc commit 8792897

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

extractor/extract.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,53 @@ private function compareFunctions(Node\FunctionLike $old, Node\FunctionLike $new
551551
if (count($old->getParams()) !== count($new->getParams())) {
552552
return $this->stmtDiff($old, $new, $updateTo);
553553
}
554+
$oldAttribGroups = $old->getAttrGroups();
555+
$oldAttribs = [];
556+
foreach ($oldAttribGroups as $group) {
557+
foreach ($group->attrs as $attrib) {
558+
if ($attrib->name->toLowerString() !== 'since' && $attrib->name->toLowerString() !== 'until') {
559+
$oldAttribs[] = $attrib;
560+
}
561+
}
562+
}
563+
$newAttribGroups = $new->getAttrGroups();
564+
$newAttribs = [];
565+
foreach ($newAttribGroups as $group) {
566+
foreach ($group->attrs as $attrib) {
567+
if ($attrib->name->toLowerString() !== 'since' && $attrib->name->toLowerString() !== 'until') {
568+
$newAttribs[] = $attrib;
569+
}
570+
}
571+
}
572+
if (count($oldAttribs) !== count($newAttribs)) {
573+
return $this->stmtDiff($old, $new, $updateTo);
574+
}
575+
foreach ($oldAttribs as $idx => $oldAttrib) {
576+
$newAttrib = $newAttribs[$idx];
577+
if ($oldAttrib->name->name !== $newAttrib->name->name) {
578+
return $this->stmtDiff($old, $new, $updateTo);
579+
}
580+
$oldArgs = $oldAttrib->args;
581+
$newArgs = $newAttrib->args;
582+
if (count($oldArgs) !== count($newArgs)) {
583+
return $this->stmtDiff($old, $new, $updateTo);
584+
}
585+
foreach ($oldArgs as $argIdx => $oldArg) {
586+
$newArg = $newArgs[$argIdx];
587+
if ($oldArg->name !== null && $newArg->name !== null) {
588+
if ($oldArg->name->name !== $newArg->name->name) {
589+
return $this->stmtDiff($old, $new, $updateTo);
590+
}
591+
} elseif ($oldArg->name !== null || $newArg->name !== null) {
592+
return $this->stmtDiff($old, $new, $updateTo);
593+
}
594+
$oldArgValue = $this->printer->prettyPrintExpr($oldArg->value);
595+
$newArgValue = $this->printer->prettyPrintExpr($newArg->value);
596+
if ($oldArgValue !== $newArgValue) {
597+
return $this->stmtDiff($old, $new, $updateTo);
598+
}
599+
}
600+
}
554601

555602
foreach ($old->getParams() as $i => $oldParam) {
556603
$newParam = $new->getParams()[$i];

0 commit comments

Comments
 (0)