Skip to content

Commit

Permalink
Merge pull request #1 from spiral/feature/attributes
Browse files Browse the repository at this point in the history
Extra attributes bugfix
  • Loading branch information
SerafimArts committed Jan 12, 2021
2 parents 7bd6e78 + 5693349 commit 6b5b24f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Internal/FallbackAttributeReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,11 @@ private function extractFunctionAttributes(array $attributes, \ReflectionFunctio
* $ast->getEndLine(); // 2 (last significant character of a function)
* </code>
*/
while ($line-- > 0) {
if ($result = $attributes[$line] ?? null) {
return $result;
if ($function->isClosure()) {
while ($line-- > $function->getStartLine()) {
if ($result = $attributes[$line] ?? null) {
return $result;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Instantiator/NamedArgumentsInstantiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ private function resolveParameter(\ReflectionClass $ctx, \ReflectionParameter $p
} finally {
unset($arguments[$param->getName()]);
}
// no actual falling through

case \array_key_exists($param->getPosition(), $arguments):
try {
return $arguments[$param->getPosition()];
} finally {
unset($arguments[$param->getPosition()]);
}
// no actual falling through

case $param->isDefaultValueAvailable():
return $param->getDefaultValue();
Expand Down

0 comments on commit 6b5b24f

Please sign in to comment.