updated core and modules
This commit is contained in:
+1
-1
@@ -139,7 +139,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
|
||||
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
|
||||
foreach ($method->getParameters() as $param) {
|
||||
if (!isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
|
||||
if (false !== strpos($globals['path'].$annot->getPath(), sprintf('{%s}', $param->getName())) && !isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
|
||||
$defaults[$param->getName()] = $param->getDefaultValue();
|
||||
}
|
||||
}
|
||||
|
||||
+41
-2
@@ -38,7 +38,15 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
|
||||
|
||||
$collection = new RouteCollection();
|
||||
$collection->addResource(new DirectoryResource($dir, '/\.php$/'));
|
||||
$files = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY));
|
||||
$files = iterator_to_array(new \RecursiveIteratorIterator(
|
||||
new RecursiveCallbackFilterIterator(
|
||||
new \RecursiveDirectoryIterator($dir),
|
||||
function (\SplFileInfo $current) {
|
||||
return '.' !== substr($current->getBasename(), 0, 1);
|
||||
}
|
||||
),
|
||||
\RecursiveIteratorIterator::LEAVES_ONLY
|
||||
));
|
||||
usort($files, function (\SplFileInfo $a, \SplFileInfo $b) {
|
||||
return (string) $a > (string) $b ? 1 : -1;
|
||||
});
|
||||
@@ -69,7 +77,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
|
||||
if (!is_string($resource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$path = $this->locator->locate($resource);
|
||||
} catch (\Exception $e) {
|
||||
@@ -79,3 +87,34 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
|
||||
return is_dir($path) && (!$type || 'annotation' === $type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal To be removed as RecursiveCallbackFilterIterator is available since PHP 5.4
|
||||
*/
|
||||
class RecursiveCallbackFilterIterator extends \FilterIterator implements \RecursiveIterator
|
||||
{
|
||||
private $iterator;
|
||||
private $callback;
|
||||
|
||||
public function __construct(\RecursiveIterator $iterator, $callback)
|
||||
{
|
||||
$this->iterator = $iterator;
|
||||
$this->callback = $callback;
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
public function accept()
|
||||
{
|
||||
return call_user_func($this->callback, $this->current(), $this->key(), $this->iterator);
|
||||
}
|
||||
|
||||
public function hasChildren()
|
||||
{
|
||||
return $this->iterator->hasChildren();
|
||||
}
|
||||
|
||||
public function getChildren()
|
||||
{
|
||||
return new static($this->iterator->getChildren(), $this->callback);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-1
@@ -112,7 +112,24 @@ class AnnotationFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
if (T_CLASS === $token[0]) {
|
||||
$class = true;
|
||||
// Skip usage of ::class constant
|
||||
$isClassConstant = false;
|
||||
for ($j = $i - 1; $j > 0; --$j) {
|
||||
if (!isset($tokens[$j][1])) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (T_DOUBLE_COLON === $tokens[$j][0]) {
|
||||
$isClassConstant = true;
|
||||
break;
|
||||
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isClassConstant) {
|
||||
$class = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (T_NAMESPACE === $token[0]) {
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ class XmlFileLoader extends FileLoader
|
||||
* @param \DOMElement $node Element to parse that contains the configs
|
||||
* @param string $path Full path of the XML file being processed
|
||||
*
|
||||
* @return array An array with the defaults as first item, requirements as second and options as third.
|
||||
* @return array An array with the defaults as first item, requirements as second and options as third
|
||||
*
|
||||
* @throws \InvalidArgumentException When the XML is invalid
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user