Skip to content

Commit

Permalink
Helpers::autowireArguments() checks for isDefaultValueAvailable() ins…
Browse files Browse the repository at this point in the history
…tead of isOptional()

Works with signatures like function($a = NULL, $b) since PHP 5.3.17
  • Loading branch information
dg committed Feb 5, 2015
1 parent 43c60cd commit 22494a3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/DI/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ public static function autowireArguments(\ReflectionFunctionAbstract $method, ar
$optCount = 0;
}

} elseif ($parameter->isOptional()) {
// PDO::__construct has optional parameter without default value (and isArray() and allowsNull() returns FALSE)
$res[$num] = $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : NULL;
} elseif ($parameter->isDefaultValueAvailable()) {
$res[$num] = $parameter->getDefaultValue();
$optCount++;

} else {
Expand Down

0 comments on commit 22494a3

Please sign in to comment.