Skip to content

Commit d4a1d45

Browse files
Extractor: Account for function attribute changes
1 parent c1fe2a4 commit d4a1d45

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

extractor/extract.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,44 @@ 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+
$newAttribGroups = $new->getAttrGroups();
556+
if (count($oldAttribGroups) !== count($newAttribGroups)) {
557+
return $this->stmtDiff($old, $new, $updateTo);
558+
}
559+
foreach ($oldAttribGroups as $groupN => $oldGroups) {
560+
$oldAttribs = $oldGroup->attrs;
561+
$newAttribs = $newAttribGroups[$groupN]->attrs;
562+
if (count($oldAttribs) !== count($newAttribs)) {
563+
return $this->stmtDiff($old, $new, $updateTo);
564+
}
565+
foreach ($oldAttribs as $attribIdx => $oldAttrib) {
566+
$newAttrib = $newAttribs[$attribIdx];
567+
if ($oldAttrib->name->name !== $newAttrib->name->name) {
568+
return $this->stmtDiff($old, $new, $updateTo);
569+
}
570+
$oldArgs = $oldAttrib->args;
571+
$newArgs = $newAttrib->args;
572+
if (count($oldArgs) !== count($newArgs)) {
573+
return $this->stmtDiff($old, $new, $updateTo);
574+
}
575+
foreach ($oldArgs as $argIdx => $oldArg) {
576+
$newArg = $newArgs[$argIdx];
577+
if ($oldArg->name !== null && $newArg->name !== null) {
578+
if ($oldArg->name->name !== $newArg->name->name) {
579+
return $this->stmtDiff($old, $new, $updateTo);
580+
}
581+
} elseif ($oldArg->name !== null || $newArg->name !== null) {
582+
return $this->stmtDiff($old, $new, $updateTo);
583+
}
584+
$oldArgValue = $this->printer->prettyPrintExpr($oldArg->expr);
585+
$newArgValue = $this->printer->prettyPrintExpr($newArg->expr);
586+
if ($oldArgValue !== $newArgValue) {
587+
return $this->stmtDiff($old, $new, $updateTo);
588+
}
589+
}
590+
}
591+
}
554592

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

0 commit comments

Comments
 (0)