removal of unnecessary file, and composer update

This commit is contained in:
2019-01-09 23:31:31 -06:00
parent a90688deb6
commit e4380f2ffe
604 changed files with 32070 additions and 26824 deletions
+9 -1
View File
@@ -75,7 +75,7 @@ class Application
private $dispatcher;
private $terminal;
private $defaultCommand;
private $singleCommand;
private $singleCommand = false;
private $initialized;
/**
@@ -1098,6 +1098,14 @@ class Application
return $this;
}
/**
* @internal
*/
public function isSingleCommand()
{
return $this->singleCommand;
}
private function splitStringByWidth($string, $width)
{
// str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.
+7 -6
View File
@@ -250,7 +250,7 @@ class Command
$input->validate();
if ($this->code) {
$statusCode = \call_user_func($this->code, $input, $output);
$statusCode = ($this->code)($input, $output);
} else {
$statusCode = $this->execute($input, $output);
}
@@ -361,9 +361,9 @@ class Command
* Adds an argument.
*
* @param string $name The argument name
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
* @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
* @param string $description A description text
* @param string|string[]|null $default The default value (for self::OPTIONAL mode only)
* @param string|string[]|null $default The default value (for InputArgument::OPTIONAL mode only)
*
* @throws InvalidArgumentException When argument mode is not valid
*
@@ -381,9 +381,9 @@ class Command
*
* @param string $name The option name
* @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int|null $mode The option mode: One of the VALUE_* constants
* @param int|null $mode The option mode: One of the InputOption::VALUE_* constants
* @param string $description A description text
* @param string|string[]|int|bool|null $default The default value (must be null for self::VALUE_NONE)
* @param string|string[]|int|bool|null $default The default value (must be null for InputOption::VALUE_NONE)
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
*
@@ -525,6 +525,7 @@ class Command
public function getProcessedHelp()
{
$name = $this->name;
$isSingleCommand = $this->application && $this->application->isSingleCommand();
$placeholders = array(
'%command.name%',
@@ -532,7 +533,7 @@ class Command
);
$replacements = array(
$name,
$_SERVER['PHP_SELF'].' '.$name,
$isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name,
);
return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
+5 -4
View File
@@ -166,7 +166,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
if (!$open && !$tag) {
// </>
$this->styleStack->pop();
} elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
} elseif (false === $style = $this->createStyleFromString($tag)) {
$output .= $this->applyCurrentStyle($text, $output, $width, $currentLineLength);
} elseif ($open) {
$this->styleStack->push($style);
@@ -210,13 +210,14 @@ class OutputFormatter implements WrappableOutputFormatterInterface
$style = new OutputFormatterStyle();
foreach ($matches as $match) {
array_shift($match);
$match[0] = strtolower($match[0]);
if ('fg' == $match[0]) {
$style->setForeground($match[1]);
$style->setForeground(strtolower($match[1]));
} elseif ('bg' == $match[0]) {
$style->setBackground($match[1]);
$style->setBackground(strtolower($match[1]));
} elseif ('options' === $match[0]) {
preg_match_all('([^,;]+)', $match[1], $options);
preg_match_all('([^,;]+)', strtolower($match[1]), $options);
$options = array_shift($options);
foreach ($options as $option) {
$style->setOption($option);
+2 -2
View File
@@ -61,7 +61,7 @@ class ProcessHelper extends Helper
$process = $cmd[0];
unset($cmd[0]);
} else {
throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should an array whose first is element is either the path to the binary to run of a "Process" object.', __METHOD__));
throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__));
}
if ($verbosity <= $output->getVerbosity()) {
@@ -136,7 +136,7 @@ class ProcessHelper extends Helper
$output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type));
if (null !== $callback) {
\call_user_func($callback, $type, $buffer);
$callback($type, $buffer);
}
};
}
+1 -1
View File
@@ -496,7 +496,7 @@ final class ProgressBar
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
$callback = function ($matches) {
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
$text = \call_user_func($formatter, $this, $this->output);
$text = $formatter($this, $this->output);
} elseif (isset($this->messages[$matches[1]])) {
$text = $this->messages[$matches[1]];
} else {
+1 -1
View File
@@ -196,7 +196,7 @@ class ProgressIndicator
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
return \call_user_func($formatter, $self);
return $formatter($self);
}
return $matches[0];
+1 -1
View File
@@ -381,7 +381,7 @@ class QuestionHelper extends Helper
}
try {
return \call_user_func($question->getValidator(), $interviewer());
return $question->getValidator()($interviewer());
} catch (RuntimeException $e) {
throw $e;
} catch (\Exception $error) {
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+4 -1
View File
@@ -162,7 +162,10 @@ trait TesterTrait
{
$stream = fopen('php://memory', 'r+', false);
fwrite($stream, implode(PHP_EOL, $inputs));
foreach ($inputs as $input) {
fwrite($stream, $input.PHP_EOL);
}
rewind($stream);
return $stream;
+2 -2
View File
@@ -1003,7 +1003,7 @@ class ApplicationTest extends TestCase
$application->setAutoExit(false);
$application->expects($this->once())
->method('doRun')
->will($this->throwException($exception));
->willThrowException($exception);
$exitCode = $application->run(new ArrayInput(array()), new NullOutput());
@@ -1042,7 +1042,7 @@ class ApplicationTest extends TestCase
$application->setAutoExit(false);
$application->expects($this->once())
->method('doRun')
->will($this->throwException($exception));
->willThrowException($exception);
$exitCode = $application->run(new ArrayInput(array()), new NullOutput());
+8
View File
@@ -166,6 +166,14 @@ class CommandTest extends TestCase
$command = new \TestCommand();
$command->setHelp('');
$this->assertContains('description', $command->getProcessedHelp(), '->getProcessedHelp() falls back to the description');
$command = new \TestCommand();
$command->setHelp('The %command.name% command does... Example: php %command.full_name%.');
$application = new Application();
$application->add($command);
$application->setDefaultCommand('namespace:name', true);
$this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly in single command applications');
$this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name% in single command applications');
}
public function testGetSetAliases()
@@ -112,6 +112,31 @@ class CommandTesterTest extends TestCase
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
}
public function testCommandWithDefaultInputs()
{
$questions = array(
'What\'s your name?',
'How are you?',
'Where do you come from?',
);
$command = new Command('foo');
$command->setHelperSet(new HelperSet(array(new QuestionHelper())));
$command->setCode(function ($input, $output) use ($questions, $command) {
$helper = $command->getHelper('question');
$helper->ask($input, $output, new Question($questions[0], 'Bobby'));
$helper->ask($input, $output, new Question($questions[1], 'Fine'));
$helper->ask($input, $output, new Question($questions[2], 'France'));
});
$tester = new CommandTester($command);
$tester->setInputs(array('', '', ''));
$tester->execute(array());
$this->assertEquals(0, $tester->getStatusCode());
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
}
/**
* @expectedException \RuntimeException
* @expectedMessage Aborted
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -120,6 +120,9 @@ class ParserTest extends TestCase
array('a[name]', array('Attribute[Element[a][name]]')),
array("a[ name\t]", array('Attribute[Element[a][name]]')),
array('a [name]', array('CombinedSelector[Element[a] <followed> Attribute[Element[*][name]]]')),
array('[name="foo"]', array("Attribute[Element[*][name = 'foo']]")),
array("[name='foo[1]']", array("Attribute[Element[*][name = 'foo[1]']]")),
array("[name='foo[0][bar]']", array("Attribute[Element[*][name = 'foo[0][bar]']]")),
array('a[rel="include"]', array("Attribute[Element[a][rel = 'include']]")),
array('a[rel = include]', array("Attribute[Element[a][rel = 'include']]")),
array("a[hreflang |= 'en']", array("Attribute[Element[a][hreflang |= 'en']]")),
+5 -5
View File
@@ -155,7 +155,7 @@ class Translator implements TranslatorInterface
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
}
return \call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
return $this->nodeTranslators[$node->getNodeName()]($node, $this);
}
/**
@@ -167,7 +167,7 @@ class Translator implements TranslatorInterface
throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
}
return \call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
return $this->combinationTranslators[$combiner]($this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
}
/**
@@ -179,7 +179,7 @@ class Translator implements TranslatorInterface
throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
}
return \call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
return $this->functionTranslators[$function->getName()]($xpath, $function);
}
/**
@@ -191,7 +191,7 @@ class Translator implements TranslatorInterface
throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
}
return \call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
return $this->pseudoClassTranslators[$pseudoClass]($xpath);
}
/**
@@ -203,7 +203,7 @@ class Translator implements TranslatorInterface
throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
}
return \call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
return $this->attributeMatchingTranslators[$operator]($xpath, $attribute, $value);
}
/**
+4 -4
View File
@@ -151,7 +151,7 @@ class DebugClassLoader
require $file;
}
} else {
\call_user_func($this->classLoader, $class);
($this->classLoader)($class);
$file = false;
}
} finally {
@@ -218,7 +218,7 @@ class DebugClassLoader
$len = 0;
$ns = '';
} else {
$ns = \substr($class, 0, $len);
$ns = \str_replace('_', '\\', \substr($class, 0, $len));
}
// Detect annotations on the class
@@ -249,13 +249,13 @@ class DebugClassLoader
if (!isset(self::$checkedClasses[$use])) {
$this->checkClass($use);
}
if (isset(self::$deprecated[$use]) && \strncmp($ns, $use, $len)) {
if (isset(self::$deprecated[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) {
$type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait');
$verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses');
$deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]);
}
if (isset(self::$internal[$use]) && \strncmp($ns, $use, $len)) {
if (isset(self::$internal[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) {
$deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class);
}
}
+1 -1
View File
@@ -560,7 +560,7 @@ class ErrorHandler
$this->exceptionHandler = null;
try {
if (null !== $exceptionHandler) {
return \call_user_func($exceptionHandler, $exception);
return $exceptionHandler($exception);
}
$handlerException = $handlerException ?: $exception;
} catch (\Throwable $handlerException) {
+1 -1
View File
@@ -142,7 +142,7 @@ class ExceptionHandler
$this->caughtBuffer = null;
try {
\call_user_func($this->handler, $exception);
($this->handler)($exception);
$this->caughtLength = $caughtLength;
} catch (\Exception $e) {
if (!$caughtLength) {
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -29,7 +29,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
protected $logger;
protected $stopwatch;
private $called;
private $callStack;
private $dispatcher;
private $wrappedListeners;
private $orphanedEvents;
@@ -39,7 +39,6 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
$this->dispatcher = $dispatcher;
$this->stopwatch = $stopwatch;
$this->logger = $logger;
$this->called = array();
$this->wrappedListeners = array();
$this->orphanedEvents = array();
}
@@ -125,6 +124,10 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
*/
public function dispatch($eventName, Event $event = null)
{
if (null === $this->callStack) {
$this->callStack = new \SplObjectStorage();
}
if (null === $event) {
$event = new Event();
}
@@ -160,11 +163,15 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
*/
public function getCalledListeners()
{
if (null === $this->callStack) {
return array();
}
$called = array();
foreach ($this->called as $eventName => $listeners) {
foreach ($listeners as $listener) {
$called[$eventName.'.'.$listener->getPretty()] = $listener->getInfo($eventName);
}
foreach ($this->callStack as $listener) {
list($eventName) = $this->callStack->getInfo();
$called[] = $listener->getInfo($eventName);
}
return $called;
@@ -190,9 +197,9 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
foreach ($allListeners as $eventName => $listeners) {
foreach ($listeners as $listener) {
$called = false;
if (isset($this->called[$eventName])) {
foreach ($this->called[$eventName] as $l) {
if ($l->getWrappedListener() === $listener) {
if (null !== $this->callStack) {
foreach ($this->callStack as $calledListener) {
if ($calledListener->getWrappedListener() === $listener) {
$called = true;
break;
@@ -204,12 +211,12 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
if (!$listener instanceof WrappedListener) {
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
}
$notCalled[$eventName.'.'.$listener->getPretty()] = $listener->getInfo($eventName);
$notCalled[] = $listener->getInfo($eventName);
}
}
}
uasort($notCalled, array($this, 'sortListenersByPriority'));
uasort($notCalled, array($this, 'sortNotCalledListeners'));
return $notCalled;
}
@@ -221,7 +228,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
public function reset()
{
$this->called = array();
$this->callStack = null;
$this->orphanedEvents = array();
}
@@ -272,6 +279,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
$this->wrappedListeners[$eventName][] = $wrappedListener;
$this->dispatcher->removeListener($eventName, $listener);
$this->dispatcher->addListener($eventName, $wrappedListener, $priority);
$this->callStack->attach($wrappedListener, array($eventName));
}
}
@@ -300,8 +308,8 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
if (!isset($this->called[$eventName])) {
$this->called[$eventName] = new \SplObjectStorage();
}
$this->called[$eventName]->attach($listener);
} else {
$this->callStack->detach($listener);
}
if (null !== $this->logger && $skipped) {
@@ -318,8 +326,12 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
}
}
private function sortListenersByPriority($a, $b)
private function sortNotCalledListeners(array $a, array $b)
{
if (0 !== $cmp = strcmp($a['event'], $b['event'])) {
return $cmp;
}
if (\is_int($a['priority']) && !\is_int($b['priority'])) {
return 1;
}
+1 -1
View File
@@ -108,7 +108,7 @@ class WrappedListener
$e = $this->stopwatch->start($this->name, 'event_listener');
\call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
($this->listener)($event, $eventName, $this->dispatcher ?: $dispatcher);
if ($e->isStarted()) {
$e->stop();
+1 -1
View File
@@ -209,7 +209,7 @@ class EventDispatcher implements EventDispatcherInterface
if ($event->isPropagationStopped()) {
break;
}
\call_user_func($listener, $event, $eventName, $this);
$listener($event, $eventName, $this);
}
}
@@ -23,11 +23,11 @@ interface EventDispatcherInterface
/**
* Dispatches an event to all registered listeners.
*
* @param string $eventName The name of the event to dispatch. The name of
* the event is the name of the method that is
* invoked on listeners.
* @param Event $event The event to pass to the event handlers/listeners
* If not supplied, an empty Event instance is created
* @param string $eventName The name of the event to dispatch. The name of
* the event is the name of the method that is
* invoked on listeners.
* @param Event|null $event The event to pass to the event handlers/listeners
* If not supplied, an empty Event instance is created
*
* @return Event
*/
@@ -46,7 +46,7 @@ interface EventDispatcherInterface
/**
* Adds an event subscriber.
*
* The subscriber is asked for all the events he is
* The subscriber is asked for all the events it is
* interested in and added as a listener for these events.
*/
public function addSubscriber(EventSubscriberInterface $subscriber);
@@ -64,7 +64,7 @@ interface EventDispatcherInterface
/**
* Gets the listeners of a specific event or all listeners sorted by descending priority.
*
* @param string $eventName The name of the event
* @param string|null $eventName The name of the event
*
* @return array The event listeners for the specified event, or all event listeners by event name
*/
@@ -85,7 +85,7 @@ interface EventDispatcherInterface
/**
* Checks whether an event has any registered listeners.
*
* @param string $eventName The name of the event
* @param string|null $eventName The name of the event
*
* @return bool true if the specified event has any listeners, false otherwise
*/
@@ -12,7 +12,7 @@
namespace Symfony\Component\EventDispatcher;
/**
* An EventSubscriber knows himself what events he is interested in.
* An EventSubscriber knows itself what events it is interested in.
* If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events.
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -110,17 +110,17 @@ class TraceableEventDispatcherTest extends TestCase
$tdispatcher->addListener('foo', function () {}, 5);
$listeners = $tdispatcher->getNotCalledListeners();
$this->assertArrayHasKey('stub', $listeners['foo.closure']);
unset($listeners['foo.closure']['stub']);
$this->assertArrayHasKey('stub', $listeners[0]);
unset($listeners[0]['stub']);
$this->assertEquals(array(), $tdispatcher->getCalledListeners());
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
$this->assertEquals(array(array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
$tdispatcher->dispatch('foo');
$listeners = $tdispatcher->getCalledListeners();
$this->assertArrayHasKey('stub', $listeners['foo.closure']);
unset($listeners['foo.closure']['stub']);
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
$this->assertArrayHasKey('stub', $listeners[0]);
unset($listeners[0]['stub']);
$this->assertEquals(array(array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
$this->assertEquals(array(), $tdispatcher->getNotCalledListeners());
}
@@ -133,10 +133,22 @@ class TraceableEventDispatcherTest extends TestCase
$tdispatcher->reset();
$listeners = $tdispatcher->getNotCalledListeners();
$this->assertArrayHasKey('stub', $listeners['foo.closure']);
unset($listeners['foo.closure']['stub']);
$this->assertArrayHasKey('stub', $listeners[0]);
unset($listeners[0]['stub']);
$this->assertEquals(array(), $tdispatcher->getCalledListeners());
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
$this->assertEquals(array(array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
}
public function testDispatchAfterReset()
{
$tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
$tdispatcher->addListener('foo', function () {}, 5);
$tdispatcher->reset();
$tdispatcher->dispatch('foo');
$listeners = $tdispatcher->getCalledListeners();
$this->assertArrayHasKey('stub', $listeners[0]);
}
public function testGetCalledListenersNested()
@@ -30,21 +30,16 @@ class WrappedListenerTest extends TestCase
public function provideListenersToDescribe()
{
$listeners = array(
return array(
array(new FooListener(), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::__invoke'),
array(array(new FooListener(), 'listen'), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::listen'),
array(array('Symfony\Component\EventDispatcher\Tests\Debug\FooListener', 'listenStatic'), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::listenStatic'),
array('var_dump', 'var_dump'),
array(function () {}, 'closure'),
array(\Closure::fromCallable(array(new FooListener(), 'listen')), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::listen'),
array(\Closure::fromCallable(array('Symfony\Component\EventDispatcher\Tests\Debug\FooListener', 'listenStatic')), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::listenStatic'),
array(\Closure::fromCallable(function () {}), 'closure'),
);
if (\PHP_VERSION_ID >= 70100) {
$listeners[] = array(\Closure::fromCallable(array(new FooListener(), 'listen')), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::listen');
$listeners[] = array(\Closure::fromCallable(array('Symfony\Component\EventDispatcher\Tests\Debug\FooListener', 'listenStatic')), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::listenStatic');
$listeners[] = array(\Closure::fromCallable(function () {}), 'closure');
}
return $listeners;
}
}
+1 -1
View File
@@ -51,7 +51,7 @@ class CustomFilterIterator extends \FilterIterator
$fileinfo = $this->current();
foreach ($this->filters as $filter) {
if (false === \call_user_func($filter, $fileinfo)) {
if (false === $filter($fileinfo)) {
return false;
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ class SortableIterator implements \IteratorAggregate
} elseif (self::SORT_BY_NONE === $sort) {
$this->sort = $order;
} elseif (\is_callable($sort)) {
$this->sort = $reverseOrder ? function ($a, $b) use ($sort) { return -\call_user_func($sort, $a, $b); } : $sort;
$this->sort = $reverseOrder ? function ($a, $b) use ($sort) { return -$sort($a, $b); } : $sort;
} else {
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
}
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+2 -2
View File
@@ -1209,7 +1209,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
// restore original permissions
chmod($testDir, 0777);
clearstatcache($testDir);
clearstatcache(true, $testDir);
if ($couldRead) {
$this->markTestSkipped('could read test files while test requires unreadable');
@@ -1248,7 +1248,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
// restore original permissions
chmod($testDir, 0777);
clearstatcache($testDir);
clearstatcache(true, $testDir);
if ($couldRead) {
$this->markTestSkipped('could read test files while test requires unreadable');
+3 -3
View File
@@ -101,9 +101,9 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns a header value by name.
*
* @param string $key The header name
* @param string|string[]|null $default The default value
* @param bool $first Whether to return the first value or all header values
* @param string $key The header name
* @param string|null $default The default value
* @param bool $first Whether to return the first value or all header values
*
* @return string|string[]|null The first header value or default value if $first is true, an array of values otherwise
*/
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+16 -8
View File
@@ -1699,15 +1699,23 @@ class Request
} elseif ($this->server->has('REQUEST_URI')) {
$requestUri = $this->server->get('REQUEST_URI');
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path
$uriComponents = parse_url($requestUri);
if ('' !== $requestUri && '/' === $requestUri[0]) {
// To only use path and query remove the fragment.
if (false !== $pos = strpos($requestUri, '#')) {
$requestUri = substr($requestUri, 0, $pos);
}
} else {
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path,
// only use URL path.
$uriComponents = parse_url($requestUri);
if (isset($uriComponents['path'])) {
$requestUri = $uriComponents['path'];
}
if (isset($uriComponents['path'])) {
$requestUri = $uriComponents['path'];
}
if (isset($uriComponents['query'])) {
$requestUri .= '?'.$uriComponents['query'];
if (isset($uriComponents['query'])) {
$requestUri .= '?'.$uriComponents['query'];
}
}
} elseif ($this->server->has('ORIG_PATH_INFO')) {
// IIS 5.0, PHP as CGI
@@ -1908,7 +1916,7 @@ class Request
private static function createRequestFromFactory(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
{
if (self::$requestFactory) {
$request = \call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content);
$request = (self::$requestFactory)($query, $request, $attributes, $cookies, $files, $server, $content);
if (!$request instanceof self) {
throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.');
@@ -153,7 +153,7 @@ class NativeSessionStorage implements SessionStorageInterface
if (null !== $this->emulateSameSite) {
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
if (null !== $originalCookie) {
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite));
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite), false);
}
}
@@ -225,7 +225,7 @@ class NativeSessionStorage implements SessionStorageInterface
if (null !== $this->emulateSameSite) {
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
if (null !== $originalCookie) {
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite));
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite), false);
}
}
+1 -1
View File
@@ -111,7 +111,7 @@ class StreamedResponse extends Response
throw new \LogicException('The Response callback must not be null.');
}
\call_user_func($this->callback);
($this->callback)();
return $this;
}
+49
View File
@@ -283,6 +283,55 @@ class RequestTest extends TestCase
$this->assertEquals('http://test.com/foo', $request->getUri());
}
/**
* @dataProvider getRequestUriData
*/
public function testGetRequestUri($serverRequestUri, $expected, $message)
{
$request = new Request();
$request->server->add(array(
'REQUEST_URI' => $serverRequestUri,
// For having http://test.com
'SERVER_NAME' => 'test.com',
'SERVER_PORT' => 80,
));
$this->assertSame($expected, $request->getRequestUri(), $message);
$this->assertSame($expected, $request->server->get('REQUEST_URI'), 'Normalize the request URI.');
}
public function getRequestUriData()
{
$message = 'Do not modify the path.';
yield array('/foo', '/foo', $message);
yield array('//bar/foo', '//bar/foo', $message);
yield array('///bar/foo', '///bar/foo', $message);
$message = 'Handle when the scheme, host are on REQUEST_URI.';
yield array('http://test.com/foo?bar=baz', '/foo?bar=baz', $message);
$message = 'Handle when the scheme, host and port are on REQUEST_URI.';
yield array('http://test.com:80/foo', '/foo', $message);
yield array('https://test.com:8080/foo', '/foo', $message);
yield array('https://test.com:443/foo', '/foo', $message);
$message = 'Fragment should not be included in the URI';
yield array('http://test.com/foo#bar', '/foo', $message);
yield array('/foo#bar', '/foo', $message);
}
public function testGetRequestUriWithoutRequiredHeader()
{
$expected = '';
$request = new Request();
$message = 'Fallback to empty URI when headers are missing.';
$this->assertSame($expected, $request->getRequestUri(), $message);
$this->assertSame($expected, $request->server->get('REQUEST_URI'), 'Normalize the request URI.');
}
public function testCreateCheckPrecedence()
{
// server is used by default
@@ -390,7 +390,7 @@ class MockPdo extends \PDO
public function prepare($statement, $driverOptions = array())
{
return \is_callable($this->prepareResult)
? \call_user_func($this->prepareResult, $statement, $driverOptions)
? ($this->prepareResult)($statement, $driverOptions)
: $this->prepareResult;
}
+1 -1
View File
@@ -91,7 +91,7 @@ class FileLinkFormatter implements \Serializable
if ($this->requestStack && $this->baseDir && $this->urlFormat) {
$request = $this->requestStack->getMasterRequest();
if ($request instanceof Request) {
if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) {
if ($this->urlFormat instanceof \Closure && !$this->urlFormat = ($this->urlFormat)()) {
return;
}
@@ -55,7 +55,7 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
* @param array $patterns The class patterns to expand
* @param array $classes The existing classes to match against the patterns
*
* @return array A list of classes derivated from the patterns
* @return array A list of classes derived from the patterns
*/
private function expandClasses(array $patterns, array $classes)
{
+7 -4
View File
@@ -73,11 +73,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
private $requestStackSize = 0;
private $resetServices = false;
const VERSION = '4.2.1';
const VERSION_ID = 40201;
const VERSION = '4.2.2';
const VERSION_ID = 40202;
const MAJOR_VERSION = 4;
const MINOR_VERSION = 2;
const RELEASE_VERSION = 1;
const RELEASE_VERSION = 2;
const EXTRA_VERSION = '';
const END_OF_MAINTENANCE = '07/2019';
@@ -743,7 +743,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$fs->dumpFile($dir.$file, $code);
@chmod($dir.$file, 0666 & ~umask());
}
@unlink(\dirname($dir.$file).'.legacy');
$legacyFile = \dirname($dir.$file).'.legacy';
if (file_exists($legacyFile)) {
@unlink($legacyFile);
}
$cache->write($rootCode, $container->getResources());
}
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -144,11 +144,8 @@ EOTXT;
$collector->dump($data);
$line = __LINE__ - 1;
$output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean());
if (\PHP_VERSION_ID >= 50400) {
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output);
} else {
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", $output);
}
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output);
ob_start();
$collector->__destruct();
@@ -48,7 +48,7 @@ class TranslatorListenerTest extends TestCase
$this->translator
->expects($this->at(0))
->method('setLocale')
->will($this->throwException(new \InvalidArgumentException()));
->willThrowException(new \InvalidArgumentException());
$this->translator
->expects($this->at(1))
->method('setLocale')
@@ -85,7 +85,7 @@ class TranslatorListenerTest extends TestCase
$this->translator
->expects($this->at(0))
->method('setLocale')
->will($this->throwException(new \InvalidArgumentException()));
->willThrowException(new \InvalidArgumentException());
$this->translator
->expects($this->at(1))
->method('setLocale')
@@ -60,7 +60,7 @@ class EsiFragmentRendererTest extends TestCase
$altReference = new ControllerReference('alt_controller', array(), array());
$this->assertEquals(
'<esi:include src="/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dmain_controller&_hash=Jz1P8NErmhKTeI6onI1EdAXTB85359MY3RIk5mSJ60w%3D" alt="/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dalt_controller&_hash=iPJEdRoUpGrM1ztqByiorpfMPtiW%2FOWwdH1DBUXHhEc%3D" />',
'<esi:include src="/_fragment?_hash=Jz1P8NErmhKTeI6onI1EdAXTB85359MY3RIk5mSJ60w%3D&_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dmain_controller" alt="/_fragment?_hash=iPJEdRoUpGrM1ztqByiorpfMPtiW%2FOWwdH1DBUXHhEc%3D&_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dalt_controller" />',
$strategy->render($reference, $request, array('alt' => $altReference))->getContent()
);
}
@@ -32,7 +32,7 @@ class HIncludeFragmentRendererTest extends TestCase
{
$strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo'));
$this->assertEquals('<hx:include src="/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller&amp;_hash=BP%2BOzCD5MRUI%2BHJpgPDOmoju00FnzLhP3TGcSHbbBLs%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
$this->assertEquals('<hx:include src="/_fragment?_hash=BP%2BOzCD5MRUI%2BHJpgPDOmoju00FnzLhP3TGcSHbbBLs%3D&amp;_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
}
public function testRenderWithUri()
@@ -80,7 +80,7 @@ class HIncludeFragmentRendererTest extends TestCase
$engine->expects($this->once())
->method('exists')
->with('default')
->will($this->throwException(new \InvalidArgumentException()));
->willThrowException(new \InvalidArgumentException());
// only default
$strategy = new HIncludeFragmentRenderer($engine);
@@ -93,7 +93,7 @@ class HIncludeFragmentRendererTest extends TestCase
$engine->expects($this->once())
->method('exists')
->with('loading...')
->will($this->throwException(new \RuntimeException()));
->willThrowException(new \RuntimeException());
// only default
$strategy = new HIncludeFragmentRenderer($engine);
@@ -51,7 +51,7 @@ class SsiFragmentRendererTest extends TestCase
$altReference = new ControllerReference('alt_controller', array(), array());
$this->assertEquals(
'<!--#include virtual="/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dmain_controller&_hash=Jz1P8NErmhKTeI6onI1EdAXTB85359MY3RIk5mSJ60w%3D" -->',
'<!--#include virtual="/_fragment?_hash=Jz1P8NErmhKTeI6onI1EdAXTB85359MY3RIk5mSJ60w%3D&_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dmain_controller" -->',
$strategy->render($reference, $request, array('alt' => $altReference))->getContent()
);
}
+4 -4
View File
@@ -183,7 +183,7 @@ class HttpKernelTest extends TestCase
public function testHandleWhenTheControllerIsAnObjectWithInvoke()
{
$dispatcher = new EventDispatcher();
$kernel = $this->getHttpKernel($dispatcher, new Controller());
$kernel = $this->getHttpKernel($dispatcher, new TestController());
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
}
@@ -199,7 +199,7 @@ class HttpKernelTest extends TestCase
public function testHandleWhenTheControllerIsAnArray()
{
$dispatcher = new EventDispatcher();
$kernel = $this->getHttpKernel($dispatcher, array(new Controller(), 'controller'));
$kernel = $this->getHttpKernel($dispatcher, array(new TestController(), 'controller'));
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
}
@@ -207,7 +207,7 @@ class HttpKernelTest extends TestCase
public function testHandleWhenTheControllerIsAStaticArray()
{
$dispatcher = new EventDispatcher();
$kernel = $this->getHttpKernel($dispatcher, array('Symfony\Component\HttpKernel\Tests\Controller', 'staticcontroller'));
$kernel = $this->getHttpKernel($dispatcher, array('Symfony\Component\HttpKernel\Tests\TestController', 'staticcontroller'));
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
}
@@ -372,7 +372,7 @@ class HttpKernelTest extends TestCase
}
}
class Controller
class TestController
{
public function __invoke()
{
+14 -2
View File
@@ -21,7 +21,8 @@ class UriSignerTest extends TestCase
$signer = new UriSigner('foobar');
$this->assertContains('?_hash=', $signer->sign('http://example.com/foo'));
$this->assertContains('&_hash=', $signer->sign('http://example.com/foo?foo=bar'));
$this->assertContains('?_hash=', $signer->sign('http://example.com/foo?foo=bar'));
$this->assertContains('&foo=', $signer->sign('http://example.com/foo?foo=bar'));
}
public function testCheck()
@@ -45,7 +46,7 @@ class UriSignerTest extends TestCase
$signer = new UriSigner('foobar');
$this->assertSame(
'http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D',
'http://example.com/foo?_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D&baz=bay&foo=bar',
$signer->sign('http://example.com/foo?foo=bar&baz=bay')
);
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay')));
@@ -61,4 +62,15 @@ class UriSignerTest extends TestCase
);
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay')));
}
public function testSignerWorksWithFragments()
{
$signer = new UriSigner('foobar');
$this->assertSame(
'http://example.com/foo?_hash=EhpAUyEobiM3QTrKxoLOtQq5IsWyWedoXDPqIjzNj5o%3D&bar=foo&foo=bar#foobar',
$signer->sign('http://example.com/foo?bar=foo&foo=bar#foobar')
);
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?bar=foo&foo=bar#foobar')));
}
}
+4 -3
View File
@@ -51,8 +51,9 @@ class UriSigner
}
$uri = $this->buildUrl($url, $params);
$params[$this->parameter] = $this->computeHash($uri);
return $uri.(false === strpos($uri, '?') ? '?' : '&').$this->parameter.'='.$this->computeHash($uri);
return $this->buildUrl($url, $params);
}
/**
@@ -75,7 +76,7 @@ class UriSigner
return false;
}
$hash = urlencode($params[$this->parameter]);
$hash = $params[$this->parameter];
unset($params[$this->parameter]);
return $this->computeHash($this->buildUrl($url, $params)) === $hash;
@@ -83,7 +84,7 @@ class UriSigner
private function computeHash($uri)
{
return urlencode(base64_encode(hash_hmac('sha256', $uri, $this->secret, true)));
return base64_encode(hash_hmac('sha256', $uri, $this->secret, true));
}
private function buildUrl(array $url, array $params = array())
+4 -4
View File
@@ -42,11 +42,11 @@ class ExecutableFinder
/**
* Finds an executable by name.
*
* @param string $name The executable name (without the extension)
* @param string $default The default to return if no executable is found
* @param array $extraDirs Additional dirs to check into
* @param string $name The executable name (without the extension)
* @param string|null $default The default to return if no executable is found
* @param array $extraDirs Additional dirs to check into
*
* @return string The executable path or default value
* @return string|null The executable path or default value
*/
public function find($name, $default = null, array $extraDirs = array())
{
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+2 -2
View File
@@ -1309,7 +1309,7 @@ class Process implements \IteratorAggregate
if ($this->outputDisabled) {
return function ($type, $data) use ($callback) {
if (null !== $callback) {
return \call_user_func($callback, $type, $data);
return $callback($type, $data);
}
};
}
@@ -1324,7 +1324,7 @@ class Process implements \IteratorAggregate
}
if (null !== $callback) {
return \call_user_func($callback, $type, $data);
return $callback($type, $data);
}
};
}
+15
View File
@@ -65,6 +65,21 @@ class ExecutableFinderTest extends TestCase
$this->assertEquals($expected, $result);
}
public function testFindWithNullAsDefault()
{
if (ini_get('open_basedir')) {
$this->markTestSkipped('Cannot test when open_basedir is set');
}
$this->setPath('');
$finder = new ExecutableFinder();
$result = $finder->find('foo');
$this->assertNull($result);
}
public function testFindWithExtraDirs()
{
if (ini_get('open_basedir')) {
@@ -14,7 +14,6 @@ $outputs = array(
'Second iteration output',
'One more iteration output',
'This took more time',
'This one was sooooo slow',
);
$iterationTime = 10000;
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -67,7 +67,7 @@ abstract class ObjectRouteLoader extends Loader
throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource));
}
$routeCollection = \call_user_func(array($loaderObject, $method), $this);
$routeCollection = $loaderObject->$method($this);
if (!$routeCollection instanceof RouteCollection) {
$type = \is_object($routeCollection) ? \get_class($routeCollection) : \gettype($routeCollection);
+10 -8
View File
@@ -209,7 +209,7 @@ EOF;
foreach ($staticRoutes as $url => $routes) {
$code .= self::export($url)." => array(\n";
foreach ($routes as $name => list($route, $hasTrailingSlash)) {
$code .= $this->compileRoute($route, $name, !$route->compile()->getHostVariables() ? $route->getHost() : $route->compile()->getHostRegex() ?: null, $hasTrailingSlash, $conditions);
$code .= $this->compileRoute($route, $name, !$route->compile()->getHostVariables() ? $route->getHost() : $route->compile()->getHostRegex() ?: null, $hasTrailingSlash, false, $conditions);
}
$code .= "),\n";
}
@@ -321,8 +321,9 @@ EOF;
if ($hasTrailingSlash = '/' !== $regex && '/' === $regex[-1]) {
$regex = substr($regex, 0, -1);
}
$hasTrailingVar = (bool) preg_match('#\{\w+\}/?$#', $route->getPath());
$tree->addRoute($regex, array($name, $regex, $state->vars, $route, $hasTrailingSlash));
$tree->addRoute($regex, array($name, $regex, $state->vars, $route, $hasTrailingSlash, $hasTrailingVar));
}
$code .= $this->compileStaticPrefixCollection($tree, $state, 0, $conditions);
@@ -331,7 +332,7 @@ EOF;
$code .= "\n .')'";
$state->regex .= ')';
}
$rx = ")(?:/?)$}{$modifiers}";
$rx = ")/?$}{$modifiers}";
$code .= "\n .'{$rx}',";
$state->regex .= $rx;
$state->markTail = 0;
@@ -377,12 +378,12 @@ EOF;
continue;
}
list($name, $regex, $vars, $route, $hasTrailingSlash) = $route;
list($name, $regex, $vars, $route, $hasTrailingSlash, $hasTrailingVar) = $route;
$compiledRoute = $route->compile();
$vars = array_merge($state->hostVars, $vars);
if ($compiledRoute->getRegex() === $prevRegex) {
$state->routes = substr_replace($state->routes, $this->compileRoute($route, $name, $vars, $hasTrailingSlash, $conditions), -3, 0);
$state->routes = substr_replace($state->routes, $this->compileRoute($route, $name, $vars, $hasTrailingSlash, $hasTrailingVar, $conditions), -3, 0);
continue;
}
@@ -393,7 +394,7 @@ EOF;
$state->regex .= $rx;
$prevRegex = $compiledRoute->getRegex();
$state->routes .= sprintf("%s => array(\n%s),\n", $state->mark, $this->compileRoute($route, $name, $vars, $hasTrailingSlash, $conditions));
$state->routes .= sprintf("%s => array(\n%s),\n", $state->mark, $this->compileRoute($route, $name, $vars, $hasTrailingSlash, $hasTrailingVar, $conditions));
}
return $code;
@@ -402,7 +403,7 @@ EOF;
/**
* Compiles a single Route to PHP code used to match it against the path info.
*/
private function compileRoute(Route $route, string $name, $vars, bool $hasTrailingSlash, array &$conditions): string
private function compileRoute(Route $route, string $name, $vars, bool $hasTrailingSlash, bool $hasTrailingVar, array &$conditions): string
{
$defaults = $route->getDefaults();
@@ -419,12 +420,13 @@ EOF;
}
return sprintf(
" array(%s, %s, %s, %s, %s, %s),\n",
" array(%s, %s, %s, %s, %s, %s, %s),\n",
self::export(array('_route' => $name) + $defaults),
self::export($vars),
self::export(array_flip($route->getMethods()) ?: null),
self::export(array_flip($route->getSchemes()) ?: null),
self::export($hasTrailingSlash),
self::export($hasTrailingVar),
$condition
);
}
+24 -23
View File
@@ -54,8 +54,8 @@ trait PhpMatcherTrait
} finally {
$this->context->setScheme($scheme);
}
} elseif ('/' !== $pathinfo) {
$pathinfo = '/' !== $pathinfo[-1] ? $pathinfo.'/' : substr($pathinfo, 0, -1);
} elseif ('/' !== $trimmedPathinfo = rtrim($pathinfo, '/') ?: '/') {
$pathinfo = $trimmedPathinfo === $pathinfo ? $pathinfo.'/' : $trimmedPathinfo;
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
return $this->redirect($pathinfo, $ret['_route']) + $ret;
}
@@ -67,13 +67,13 @@ trait PhpMatcherTrait
throw new ResourceNotFoundException();
}
private function doMatch(string $rawPathinfo, array &$allow = array(), array &$allowSchemes = array()): array
private function doMatch(string $pathinfo, array &$allow = array(), array &$allowSchemes = array()): array
{
$allow = $allowSchemes = array();
$pathinfo = rawurldecode($rawPathinfo) ?: '/';
$pathinfo = rawurldecode($pathinfo) ?: '/';
$trimmedPathinfo = rtrim($pathinfo, '/') ?: '/';
$context = $this->context;
$requestMethod = $canonicalMethod = $context->getMethod();
$trimmedPathinfo = '/' !== $pathinfo && '/' === $pathinfo[-1] ? substr($pathinfo, 0, -1) : $pathinfo;
if ($this->matchHost) {
$host = strtolower($context->getHost());
@@ -82,17 +82,17 @@ trait PhpMatcherTrait
if ('HEAD' === $requestMethod) {
$canonicalMethod = 'GET';
}
$supportsRedirections = 'GET' === $canonicalMethod && $this instanceof RedirectableUrlMatcherInterface;
foreach ($this->staticRoutes[$trimmedPathinfo] ?? array() as list($ret, $requiredHost, $requiredMethods, $requiredSchemes, $hasTrailingSlash, $condition)) {
foreach ($this->staticRoutes[$trimmedPathinfo] ?? array() as list($ret, $requiredHost, $requiredMethods, $requiredSchemes, $hasTrailingSlash, , $condition)) {
if ($condition && !($this->checkCondition)($condition, $context, 0 < $condition ? $request ?? $request = $this->request ?: $this->createRequest($pathinfo) : null)) {
continue;
}
if ('/' === $pathinfo || $hasTrailingSlash === ('/' === $pathinfo[-1])) {
// no-op
} elseif ($this instanceof RedirectableUrlMatcherInterface && (!$requiredMethods || isset($requiredMethods['GET'])) && 'GET' === $canonicalMethod) {
return $allow = $allowSchemes = array();
} else {
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) {
return $allow = $allowSchemes = array();
}
continue;
}
@@ -125,23 +125,24 @@ trait PhpMatcherTrait
foreach ($this->regexpList as $offset => $regex) {
while (preg_match($regex, $matchedPathinfo, $matches)) {
foreach ($this->dynamicRoutes[$m = (int) $matches['MARK']] as list($ret, $vars, $requiredMethods, $requiredSchemes, $hasTrailingSlash, $condition)) {
foreach ($this->dynamicRoutes[$m = (int) $matches['MARK']] as list($ret, $vars, $requiredMethods, $requiredSchemes, $hasTrailingSlash, $hasTrailingVar, $condition)) {
if ($condition && !($this->checkCondition)($condition, $context, 0 < $condition ? $request ?? $request = $this->request ?: $this->createRequest($pathinfo) : null)) {
continue;
}
if ('/' !== $pathinfo) {
if ('/' === $pathinfo[-1]) {
if (preg_match($regex, substr($pathinfo, 0, -1), $n) && $m === (int) $n['MARK']) {
$matches = $n;
} else {
$hasTrailingSlash = true;
}
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar) {
// no-op
} elseif (preg_match($regex, $this->matchHost ? $host.'.'.$trimmedPathinfo : $trimmedPathinfo, $n) && $m === (int) $n['MARK']) {
$matches = $n;
} else {
$hasTrailingSlash = true;
}
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) {
return $allow = $allowSchemes = array();
}
if ($hasTrailingSlash !== ('/' === $pathinfo[-1])) {
if ($this instanceof RedirectableUrlMatcherInterface && (!$requiredMethods || isset($requiredMethods['GET'])) && 'GET' === $canonicalMethod) {
return $allow = $allowSchemes = array();
}
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar) {
continue;
}
}
+2 -2
View File
@@ -44,11 +44,11 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable
} finally {
$this->context->setScheme($scheme);
}
} elseif ('/' === $pathinfo) {
} elseif ('/' === $trimmedPathinfo = rtrim($pathinfo, '/') ?: '/') {
throw $e;
} else {
try {
$pathinfo = '/' !== $pathinfo[-1] ? $pathinfo.'/' : substr($pathinfo, 0, -1);
$pathinfo = $trimmedPathinfo === $pathinfo ? $pathinfo.'/' : $trimmedPathinfo;
$ret = parent::match($pathinfo);
return $this->redirect($pathinfo, $ret['_route'] ?? null) + $ret;
+20 -28
View File
@@ -84,7 +84,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
{
$this->allow = $this->allowSchemes = array();
if ($ret = $this->matchCollection(rawurldecode($pathinfo), $this->routes)) {
if ($ret = $this->matchCollection(rawurldecode($pathinfo) ?: '/', $this->routes)) {
return $ret;
}
@@ -134,49 +134,41 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
if ('HEAD' === $method = $this->context->getMethod()) {
$method = 'GET';
}
$supportsTrailingSlash = '/' !== $pathinfo && '' !== $pathinfo && $this instanceof RedirectableUrlMatcherInterface;
$supportsTrailingSlash = 'GET' === $method && $this instanceof RedirectableUrlMatcherInterface;
$trimmedPathinfo = rtrim($pathinfo, '/') ?: '/';
foreach ($routes as $name => $route) {
$compiledRoute = $route->compile();
$staticPrefix = $compiledRoute->getStaticPrefix();
$staticPrefix = rtrim($compiledRoute->getStaticPrefix(), '/');
$requiredMethods = $route->getMethods();
// check the static prefix of the URL first. Only use the more expensive preg_match when it matches
if ('' === $staticPrefix || 0 === strpos($pathinfo, $staticPrefix)) {
// no-op
} elseif (!$supportsTrailingSlash || ($requiredMethods && !\in_array('GET', $requiredMethods)) || 'GET' !== $method) {
continue;
} elseif ('/' === $staticPrefix[-1] && substr($staticPrefix, 0, -1) === $pathinfo) {
return $this->allow = $this->allowSchemes = array();
} elseif ('/' === $pathinfo[-1] && substr($pathinfo, 0, -1) === $staticPrefix) {
return $this->allow = $this->allowSchemes = array();
} else {
if ('' !== $staticPrefix && 0 !== strpos($trimmedPathinfo, $staticPrefix)) {
continue;
}
$regex = $compiledRoute->getRegex();
if ($supportsTrailingSlash) {
$pos = strrpos($regex, '$');
$hasTrailingSlash = '/' === $regex[$pos - 1];
$regex = substr_replace($regex, '/?$', $pos - $hasTrailingSlash, 1 + $hasTrailingSlash);
}
$pos = strrpos($regex, '$');
$hasTrailingSlash = '/' === $regex[$pos - 1];
$regex = substr_replace($regex, '/?$', $pos - $hasTrailingSlash, 1 + $hasTrailingSlash);
if (!preg_match($regex, $pathinfo, $matches)) {
continue;
}
if ($supportsTrailingSlash) {
if ('/' === $pathinfo[-1]) {
if (preg_match($regex, substr($pathinfo, 0, -1), $m)) {
$matches = $m;
} else {
$hasTrailingSlash = true;
}
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar = preg_match('#\{\w+\}/?$#', $route->getPath())) {
// no-op
} elseif (preg_match($regex, $trimmedPathinfo, $m)) {
$matches = $m;
} else {
$hasTrailingSlash = true;
}
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
if ($supportsTrailingSlash && (!$requiredMethods || \in_array('GET', $requiredMethods))) {
return $this->allow = $this->allowSchemes = array();
}
if ($hasTrailingSlash !== ('/' === $pathinfo[-1])) {
if ((!$requiredMethods || \in_array('GET', $requiredMethods)) && 'GET' === $method) {
return $this->allow = $this->allowSchemes = array();
}
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar) {
continue;
}
}
+41 -41
View File
@@ -16,23 +16,23 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$this->context = $context;
$this->matchHost = true;
$this->staticRoutes = array(
'/test/baz' => array(array(array('_route' => 'baz'), null, null, null, false, null)),
'/test/baz.html' => array(array(array('_route' => 'baz2'), null, null, null, false, null)),
'/test/baz3' => array(array(array('_route' => 'baz3'), null, null, null, true, null)),
'/foofoo' => array(array(array('_route' => 'foofoo', 'def' => 'test'), null, null, null, false, null)),
'/spa ce' => array(array(array('_route' => 'space'), null, null, null, false, null)),
'/multi/new' => array(array(array('_route' => 'overridden2'), null, null, null, false, null)),
'/multi/hey' => array(array(array('_route' => 'hey'), null, null, null, true, null)),
'/ababa' => array(array(array('_route' => 'ababa'), null, null, null, false, null)),
'/route1' => array(array(array('_route' => 'route1'), 'a.example.com', null, null, false, null)),
'/c2/route2' => array(array(array('_route' => 'route2'), 'a.example.com', null, null, false, null)),
'/route4' => array(array(array('_route' => 'route4'), 'a.example.com', null, null, false, null)),
'/c2/route3' => array(array(array('_route' => 'route3'), 'b.example.com', null, null, false, null)),
'/route5' => array(array(array('_route' => 'route5'), 'c.example.com', null, null, false, null)),
'/route6' => array(array(array('_route' => 'route6'), null, null, null, false, null)),
'/route11' => array(array(array('_route' => 'route11'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, null)),
'/route12' => array(array(array('_route' => 'route12', 'var1' => 'val'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, null)),
'/route17' => array(array(array('_route' => 'route17'), null, null, null, false, null)),
'/test/baz' => array(array(array('_route' => 'baz'), null, null, null, false, false, null)),
'/test/baz.html' => array(array(array('_route' => 'baz2'), null, null, null, false, false, null)),
'/test/baz3' => array(array(array('_route' => 'baz3'), null, null, null, true, false, null)),
'/foofoo' => array(array(array('_route' => 'foofoo', 'def' => 'test'), null, null, null, false, false, null)),
'/spa ce' => array(array(array('_route' => 'space'), null, null, null, false, false, null)),
'/multi/new' => array(array(array('_route' => 'overridden2'), null, null, null, false, false, null)),
'/multi/hey' => array(array(array('_route' => 'hey'), null, null, null, true, false, null)),
'/ababa' => array(array(array('_route' => 'ababa'), null, null, null, false, false, null)),
'/route1' => array(array(array('_route' => 'route1'), 'a.example.com', null, null, false, false, null)),
'/c2/route2' => array(array(array('_route' => 'route2'), 'a.example.com', null, null, false, false, null)),
'/route4' => array(array(array('_route' => 'route4'), 'a.example.com', null, null, false, false, null)),
'/c2/route3' => array(array(array('_route' => 'route3'), 'b.example.com', null, null, false, false, null)),
'/route5' => array(array(array('_route' => 'route5'), 'c.example.com', null, null, false, false, null)),
'/route6' => array(array(array('_route' => 'route6'), null, null, null, false, false, null)),
'/route11' => array(array(array('_route' => 'route11'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null)),
'/route12' => array(array(array('_route' => 'route12', 'var1' => 'val'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null)),
'/route17' => array(array(array('_route' => 'route17'), null, null, null, false, false, null)),
);
$this->regexpList = array(
0 => '{^(?'
@@ -80,34 +80,34 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
.')'
.')'
.')'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
47 => array(array(array('_route' => 'foo', 'def' => 'test'), array('bar'), null, null, false, null)),
70 => array(array(array('_route' => 'bar'), array('foo'), array('GET' => 0, 'HEAD' => 1), null, false, null)),
90 => array(array(array('_route' => 'barhead'), array('foo'), array('GET' => 0), null, false, null)),
47 => array(array(array('_route' => 'foo', 'def' => 'test'), array('bar'), null, null, false, true, null)),
70 => array(array(array('_route' => 'bar'), array('foo'), array('GET' => 0, 'HEAD' => 1), null, false, true, null)),
90 => array(array(array('_route' => 'barhead'), array('foo'), array('GET' => 0), null, false, true, null)),
115 => array(
array(array('_route' => 'baz4'), array('foo'), null, null, true, null),
array(array('_route' => 'baz5'), array('foo'), array('POST' => 0), null, true, null),
array(array('_route' => 'baz.baz6'), array('foo'), array('PUT' => 0), null, true, null),
array(array('_route' => 'baz4'), array('foo'), null, null, true, true, null),
array(array('_route' => 'baz5'), array('foo'), array('POST' => 0), null, true, true, null),
array(array('_route' => 'baz.baz6'), array('foo'), array('PUT' => 0), null, true, true, null),
),
131 => array(array(array('_route' => 'quoter'), array('quoter'), null, null, false, null)),
160 => array(array(array('_route' => 'foo1'), array('foo'), array('PUT' => 0), null, false, null)),
168 => array(array(array('_route' => 'bar1'), array('bar'), null, null, false, null)),
181 => array(array(array('_route' => 'overridden'), array('var'), null, null, false, null)),
204 => array(array(array('_route' => 'foo2'), array('foo1'), null, null, false, null)),
212 => array(array(array('_route' => 'bar2'), array('bar1'), null, null, false, null)),
248 => array(array(array('_route' => 'helloWorld', 'who' => 'World!'), array('who'), null, null, false, null)),
279 => array(array(array('_route' => 'foo3'), array('_locale', 'foo'), null, null, false, null)),
287 => array(array(array('_route' => 'bar3'), array('_locale', 'bar'), null, null, false, null)),
309 => array(array(array('_route' => 'foo4'), array('foo'), null, null, false, null)),
371 => array(array(array('_route' => 'route13'), array('var1', 'name'), null, null, false, null)),
389 => array(array(array('_route' => 'route14', 'var1' => 'val'), array('var1', 'name'), null, null, false, null)),
441 => array(array(array('_route' => 'route15'), array('name'), null, null, false, null)),
489 => array(array(array('_route' => 'route16', 'var1' => 'val'), array('name'), null, null, false, null)),
510 => array(array(array('_route' => 'a'), array(), null, null, false, null)),
531 => array(array(array('_route' => 'b'), array('var'), null, null, false, null)),
549 => array(array(array('_route' => 'c'), array('var'), null, null, false, null)),
131 => array(array(array('_route' => 'quoter'), array('quoter'), null, null, false, true, null)),
160 => array(array(array('_route' => 'foo1'), array('foo'), array('PUT' => 0), null, false, true, null)),
168 => array(array(array('_route' => 'bar1'), array('bar'), null, null, false, true, null)),
181 => array(array(array('_route' => 'overridden'), array('var'), null, null, false, true, null)),
204 => array(array(array('_route' => 'foo2'), array('foo1'), null, null, false, true, null)),
212 => array(array(array('_route' => 'bar2'), array('bar1'), null, null, false, true, null)),
248 => array(array(array('_route' => 'helloWorld', 'who' => 'World!'), array('who'), null, null, false, true, null)),
279 => array(array(array('_route' => 'foo3'), array('_locale', 'foo'), null, null, false, true, null)),
287 => array(array(array('_route' => 'bar3'), array('_locale', 'bar'), null, null, false, true, null)),
309 => array(array(array('_route' => 'foo4'), array('foo'), null, null, false, true, null)),
371 => array(array(array('_route' => 'route13'), array('var1', 'name'), null, null, false, true, null)),
389 => array(array(array('_route' => 'route14', 'var1' => 'val'), array('var1', 'name'), null, null, false, true, null)),
441 => array(array(array('_route' => 'route15'), array('name'), null, null, false, true, null)),
489 => array(array(array('_route' => 'route16', 'var1' => 'val'), array('name'), null, null, false, true, null)),
510 => array(array(array('_route' => 'a'), array(), null, null, false, false, null)),
531 => array(array(array('_route' => 'b'), array('var'), null, null, false, true, null)),
549 => array(array(array('_route' => 'c'), array('var'), null, null, false, true, null)),
);
}
}
File diff suppressed because it is too large Load Diff
@@ -44,23 +44,23 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
.')'
.')'
.'|/(en|fr)?(*:264)'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
32 => array(array(array('_route' => 'a', '_locale' => 'en'), array('_locale'), null, null, true, null)),
46 => array(array(array('_route' => 'b', '_locale' => 'en'), array('_locale'), null, null, false, null)),
58 => array(array(array('_route' => 'c', '_locale' => 'en'), array('_locale', 'id'), null, null, false, null)),
75 => array(array(array('_route' => 'd', '_locale' => 'en'), array('_locale', 'id'), null, null, false, null)),
94 => array(array(array('_route' => 'e', '_locale' => 'en'), array('_locale', 'id'), null, null, false, null)),
110 => array(array(array('_route' => 'f', '_locale' => 'en'), array('_locale'), null, null, true, null)),
130 => array(array(array('_route' => 'g', '_locale' => 'en'), array('_locale'), null, null, false, null)),
154 => array(array(array('_route' => 'h', '_locale' => 'en'), array('_locale', 'page'), null, null, false, null)),
175 => array(array(array('_route' => 'i', '_locale' => 'en'), array('_locale', 'page'), null, null, false, null)),
202 => array(array(array('_route' => 'j', '_locale' => 'en'), array('_locale', 'id'), null, null, false, null)),
216 => array(array(array('_route' => 'k', '_locale' => 'en'), array('_locale'), null, null, false, null)),
234 => array(array(array('_route' => 'l', '_locale' => 'en'), array('_locale'), null, null, false, null)),
245 => array(array(array('_route' => 'm', '_locale' => 'en'), array('_locale'), null, null, false, null)),
264 => array(array(array('_route' => 'n', '_locale' => 'en'), array('_locale'), null, null, false, null)),
32 => array(array(array('_route' => 'a', '_locale' => 'en'), array('_locale'), null, null, true, false, null)),
46 => array(array(array('_route' => 'b', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
58 => array(array(array('_route' => 'c', '_locale' => 'en'), array('_locale', 'id'), null, null, false, true, null)),
75 => array(array(array('_route' => 'd', '_locale' => 'en'), array('_locale', 'id'), null, null, false, false, null)),
94 => array(array(array('_route' => 'e', '_locale' => 'en'), array('_locale', 'id'), null, null, false, false, null)),
110 => array(array(array('_route' => 'f', '_locale' => 'en'), array('_locale'), null, null, true, false, null)),
130 => array(array(array('_route' => 'g', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
154 => array(array(array('_route' => 'h', '_locale' => 'en'), array('_locale', 'page'), null, null, false, true, null)),
175 => array(array(array('_route' => 'i', '_locale' => 'en'), array('_locale', 'page'), null, null, false, true, null)),
202 => array(array(array('_route' => 'j', '_locale' => 'en'), array('_locale', 'id'), null, null, false, false, null)),
216 => array(array(array('_route' => 'k', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
234 => array(array(array('_route' => 'l', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
245 => array(array(array('_route' => 'm', '_locale' => 'en'), array('_locale'), null, null, false, false, null)),
264 => array(array(array('_route' => 'n', '_locale' => 'en'), array('_locale'), null, null, false, true, null)),
);
}
}
@@ -32,15 +32,15 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
.')'
.')'
.')'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
27 => array(array(array('_route' => 'r1'), array('foo'), null, null, false, null)),
38 => array(array(array('_route' => 'r10'), array('foo'), null, null, false, null)),
46 => array(array(array('_route' => 'r100'), array('foo'), null, null, false, null)),
59 => array(array(array('_route' => 'r2'), array('foo'), null, null, false, null)),
70 => array(array(array('_route' => 'r20'), array('foo'), null, null, false, null)),
78 => array(array(array('_route' => 'r200'), array('foo'), null, null, false, null)),
27 => array(array(array('_route' => 'r1'), array('foo'), null, null, false, false, null)),
38 => array(array(array('_route' => 'r10'), array('foo'), null, null, false, false, null)),
46 => array(array(array('_route' => 'r100'), array('foo'), null, null, false, false, null)),
59 => array(array(array('_route' => 'r2'), array('foo'), null, null, false, false, null)),
70 => array(array(array('_route' => 'r20'), array('foo'), null, null, false, false, null)),
78 => array(array(array('_route' => 'r200'), array('foo'), null, null, false, false, null)),
);
}
}
@@ -22,12 +22,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
.'|(*:56)'
.')'
.')'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
56 => array(
array(array('_route' => 'r1'), array('foo', 'foo'), null, null, false, null),
array(array('_route' => 'r2'), array('foo', 'foo'), null, null, false, null),
array(array('_route' => 'r1'), array('foo', 'foo'), null, null, false, true, null),
array(array('_route' => 'r2'), array('foo', 'foo'), null, null, false, true, null),
),
);
}
+43 -43
View File
@@ -16,25 +16,25 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
$this->context = $context;
$this->matchHost = true;
$this->staticRoutes = array(
'/test/baz' => array(array(array('_route' => 'baz'), null, null, null, false, null)),
'/test/baz.html' => array(array(array('_route' => 'baz2'), null, null, null, false, null)),
'/test/baz3' => array(array(array('_route' => 'baz3'), null, null, null, true, null)),
'/foofoo' => array(array(array('_route' => 'foofoo', 'def' => 'test'), null, null, null, false, null)),
'/spa ce' => array(array(array('_route' => 'space'), null, null, null, false, null)),
'/multi/new' => array(array(array('_route' => 'overridden2'), null, null, null, false, null)),
'/multi/hey' => array(array(array('_route' => 'hey'), null, null, null, true, null)),
'/ababa' => array(array(array('_route' => 'ababa'), null, null, null, false, null)),
'/route1' => array(array(array('_route' => 'route1'), 'a.example.com', null, null, false, null)),
'/c2/route2' => array(array(array('_route' => 'route2'), 'a.example.com', null, null, false, null)),
'/route4' => array(array(array('_route' => 'route4'), 'a.example.com', null, null, false, null)),
'/c2/route3' => array(array(array('_route' => 'route3'), 'b.example.com', null, null, false, null)),
'/route5' => array(array(array('_route' => 'route5'), 'c.example.com', null, null, false, null)),
'/route6' => array(array(array('_route' => 'route6'), null, null, null, false, null)),
'/route11' => array(array(array('_route' => 'route11'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, null)),
'/route12' => array(array(array('_route' => 'route12', 'var1' => 'val'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, null)),
'/route17' => array(array(array('_route' => 'route17'), null, null, null, false, null)),
'/secure' => array(array(array('_route' => 'secure'), null, null, array('https' => 0), false, null)),
'/nonsecure' => array(array(array('_route' => 'nonsecure'), null, null, array('http' => 0), false, null)),
'/test/baz' => array(array(array('_route' => 'baz'), null, null, null, false, false, null)),
'/test/baz.html' => array(array(array('_route' => 'baz2'), null, null, null, false, false, null)),
'/test/baz3' => array(array(array('_route' => 'baz3'), null, null, null, true, false, null)),
'/foofoo' => array(array(array('_route' => 'foofoo', 'def' => 'test'), null, null, null, false, false, null)),
'/spa ce' => array(array(array('_route' => 'space'), null, null, null, false, false, null)),
'/multi/new' => array(array(array('_route' => 'overridden2'), null, null, null, false, false, null)),
'/multi/hey' => array(array(array('_route' => 'hey'), null, null, null, true, false, null)),
'/ababa' => array(array(array('_route' => 'ababa'), null, null, null, false, false, null)),
'/route1' => array(array(array('_route' => 'route1'), 'a.example.com', null, null, false, false, null)),
'/c2/route2' => array(array(array('_route' => 'route2'), 'a.example.com', null, null, false, false, null)),
'/route4' => array(array(array('_route' => 'route4'), 'a.example.com', null, null, false, false, null)),
'/c2/route3' => array(array(array('_route' => 'route3'), 'b.example.com', null, null, false, false, null)),
'/route5' => array(array(array('_route' => 'route5'), 'c.example.com', null, null, false, false, null)),
'/route6' => array(array(array('_route' => 'route6'), null, null, null, false, false, null)),
'/route11' => array(array(array('_route' => 'route11'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null)),
'/route12' => array(array(array('_route' => 'route12', 'var1' => 'val'), '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null)),
'/route17' => array(array(array('_route' => 'route17'), null, null, null, false, false, null)),
'/secure' => array(array(array('_route' => 'secure'), null, null, array('https' => 0), false, false, null)),
'/nonsecure' => array(array(array('_route' => 'nonsecure'), null, null, array('http' => 0), false, false, null)),
);
$this->regexpList = array(
0 => '{^(?'
@@ -82,34 +82,34 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
.')'
.')'
.')'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
47 => array(array(array('_route' => 'foo', 'def' => 'test'), array('bar'), null, null, false, null)),
70 => array(array(array('_route' => 'bar'), array('foo'), array('GET' => 0, 'HEAD' => 1), null, false, null)),
90 => array(array(array('_route' => 'barhead'), array('foo'), array('GET' => 0), null, false, null)),
47 => array(array(array('_route' => 'foo', 'def' => 'test'), array('bar'), null, null, false, true, null)),
70 => array(array(array('_route' => 'bar'), array('foo'), array('GET' => 0, 'HEAD' => 1), null, false, true, null)),
90 => array(array(array('_route' => 'barhead'), array('foo'), array('GET' => 0), null, false, true, null)),
115 => array(
array(array('_route' => 'baz4'), array('foo'), null, null, true, null),
array(array('_route' => 'baz5'), array('foo'), array('POST' => 0), null, true, null),
array(array('_route' => 'baz.baz6'), array('foo'), array('PUT' => 0), null, true, null),
array(array('_route' => 'baz4'), array('foo'), null, null, true, true, null),
array(array('_route' => 'baz5'), array('foo'), array('POST' => 0), null, true, true, null),
array(array('_route' => 'baz.baz6'), array('foo'), array('PUT' => 0), null, true, true, null),
),
131 => array(array(array('_route' => 'quoter'), array('quoter'), null, null, false, null)),
160 => array(array(array('_route' => 'foo1'), array('foo'), array('PUT' => 0), null, false, null)),
168 => array(array(array('_route' => 'bar1'), array('bar'), null, null, false, null)),
181 => array(array(array('_route' => 'overridden'), array('var'), null, null, false, null)),
204 => array(array(array('_route' => 'foo2'), array('foo1'), null, null, false, null)),
212 => array(array(array('_route' => 'bar2'), array('bar1'), null, null, false, null)),
248 => array(array(array('_route' => 'helloWorld', 'who' => 'World!'), array('who'), null, null, false, null)),
279 => array(array(array('_route' => 'foo3'), array('_locale', 'foo'), null, null, false, null)),
287 => array(array(array('_route' => 'bar3'), array('_locale', 'bar'), null, null, false, null)),
309 => array(array(array('_route' => 'foo4'), array('foo'), null, null, false, null)),
371 => array(array(array('_route' => 'route13'), array('var1', 'name'), null, null, false, null)),
389 => array(array(array('_route' => 'route14', 'var1' => 'val'), array('var1', 'name'), null, null, false, null)),
441 => array(array(array('_route' => 'route15'), array('name'), null, null, false, null)),
489 => array(array(array('_route' => 'route16', 'var1' => 'val'), array('name'), null, null, false, null)),
510 => array(array(array('_route' => 'a'), array(), null, null, false, null)),
531 => array(array(array('_route' => 'b'), array('var'), null, null, false, null)),
549 => array(array(array('_route' => 'c'), array('var'), null, null, false, null)),
131 => array(array(array('_route' => 'quoter'), array('quoter'), null, null, false, true, null)),
160 => array(array(array('_route' => 'foo1'), array('foo'), array('PUT' => 0), null, false, true, null)),
168 => array(array(array('_route' => 'bar1'), array('bar'), null, null, false, true, null)),
181 => array(array(array('_route' => 'overridden'), array('var'), null, null, false, true, null)),
204 => array(array(array('_route' => 'foo2'), array('foo1'), null, null, false, true, null)),
212 => array(array(array('_route' => 'bar2'), array('bar1'), null, null, false, true, null)),
248 => array(array(array('_route' => 'helloWorld', 'who' => 'World!'), array('who'), null, null, false, true, null)),
279 => array(array(array('_route' => 'foo3'), array('_locale', 'foo'), null, null, false, true, null)),
287 => array(array(array('_route' => 'bar3'), array('_locale', 'bar'), null, null, false, true, null)),
309 => array(array(array('_route' => 'foo4'), array('foo'), null, null, false, true, null)),
371 => array(array(array('_route' => 'route13'), array('var1', 'name'), null, null, false, true, null)),
389 => array(array(array('_route' => 'route14', 'var1' => 'val'), array('var1', 'name'), null, null, false, true, null)),
441 => array(array(array('_route' => 'route15'), array('name'), null, null, false, true, null)),
489 => array(array(array('_route' => 'route16', 'var1' => 'val'), array('name'), null, null, false, true, null)),
510 => array(array(array('_route' => 'a'), array(), null, null, false, false, null)),
531 => array(array(array('_route' => 'b'), array('var'), null, null, false, true, null)),
549 => array(array(array('_route' => 'c'), array('var'), null, null, false, true, null)),
);
}
}
@@ -15,16 +15,16 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
$this->context = $context;
$this->staticRoutes = array(
'/rootprefix/test' => array(array(array('_route' => 'static'), null, null, null, false, null)),
'/with-condition' => array(array(array('_route' => 'with-condition'), null, null, null, false, -1)),
'/rootprefix/test' => array(array(array('_route' => 'static'), null, null, null, false, false, null)),
'/with-condition' => array(array(array('_route' => 'with-condition'), null, null, null, false, false, -1)),
);
$this->regexpList = array(
0 => '{^(?'
.'|/rootprefix/([^/]++)(*:27)'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
27 => array(array(array('_route' => 'dynamic'), array('var'), null, null, false, null)),
27 => array(array(array('_route' => 'dynamic'), array('var'), null, null, false, true, null)),
);
$this->checkCondition = static function ($condition, $context, $request) {
switch ($condition) {
@@ -15,13 +15,13 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
$this->context = $context;
$this->staticRoutes = array(
'/just_head' => array(array(array('_route' => 'just_head'), null, array('HEAD' => 0), null, false, null)),
'/head_and_get' => array(array(array('_route' => 'head_and_get'), null, array('HEAD' => 0, 'GET' => 1), null, false, null)),
'/get_and_head' => array(array(array('_route' => 'get_and_head'), null, array('GET' => 0, 'HEAD' => 1), null, false, null)),
'/post_and_head' => array(array(array('_route' => 'post_and_head'), null, array('POST' => 0, 'HEAD' => 1), null, false, null)),
'/just_head' => array(array(array('_route' => 'just_head'), null, array('HEAD' => 0), null, false, false, null)),
'/head_and_get' => array(array(array('_route' => 'head_and_get'), null, array('HEAD' => 0, 'GET' => 1), null, false, false, null)),
'/get_and_head' => array(array(array('_route' => 'get_and_head'), null, array('GET' => 0, 'HEAD' => 1), null, false, false, null)),
'/post_and_head' => array(array(array('_route' => 'post_and_head'), null, array('POST' => 0, 'HEAD' => 1), null, false, false, null)),
'/put_and_post' => array(
array(array('_route' => 'put_and_post'), null, array('PUT' => 0, 'POST' => 1), null, false, null),
array(array('_route' => 'put_and_get_and_head'), null, array('PUT' => 0, 'GET' => 1, 'HEAD' => 2), null, false, null),
array(array('_route' => 'put_and_post'), null, array('PUT' => 0, 'POST' => 1), null, false, false, null),
array(array('_route' => 'put_and_get_and_head'), null, array('PUT' => 0, 'GET' => 1, 'HEAD' => 2), null, false, false, null),
),
);
}
+15 -15
View File
@@ -15,28 +15,28 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
{
$this->context = $context;
$this->staticRoutes = array(
'/a/11' => array(array(array('_route' => 'a_first'), null, null, null, false, null)),
'/a/22' => array(array(array('_route' => 'a_second'), null, null, null, false, null)),
'/a/333' => array(array(array('_route' => 'a_third'), null, null, null, false, null)),
'/a/44' => array(array(array('_route' => 'a_fourth'), null, null, null, true, null)),
'/a/55' => array(array(array('_route' => 'a_fifth'), null, null, null, true, null)),
'/a/66' => array(array(array('_route' => 'a_sixth'), null, null, null, true, null)),
'/nested/group/a' => array(array(array('_route' => 'nested_a'), null, null, null, true, null)),
'/nested/group/b' => array(array(array('_route' => 'nested_b'), null, null, null, true, null)),
'/nested/group/c' => array(array(array('_route' => 'nested_c'), null, null, null, true, null)),
'/slashed/group' => array(array(array('_route' => 'slashed_a'), null, null, null, true, null)),
'/slashed/group/b' => array(array(array('_route' => 'slashed_b'), null, null, null, true, null)),
'/slashed/group/c' => array(array(array('_route' => 'slashed_c'), null, null, null, true, null)),
'/a/11' => array(array(array('_route' => 'a_first'), null, null, null, false, false, null)),
'/a/22' => array(array(array('_route' => 'a_second'), null, null, null, false, false, null)),
'/a/333' => array(array(array('_route' => 'a_third'), null, null, null, false, false, null)),
'/a/44' => array(array(array('_route' => 'a_fourth'), null, null, null, true, false, null)),
'/a/55' => array(array(array('_route' => 'a_fifth'), null, null, null, true, false, null)),
'/a/66' => array(array(array('_route' => 'a_sixth'), null, null, null, true, false, null)),
'/nested/group/a' => array(array(array('_route' => 'nested_a'), null, null, null, true, false, null)),
'/nested/group/b' => array(array(array('_route' => 'nested_b'), null, null, null, true, false, null)),
'/nested/group/c' => array(array(array('_route' => 'nested_c'), null, null, null, true, false, null)),
'/slashed/group' => array(array(array('_route' => 'slashed_a'), null, null, null, true, false, null)),
'/slashed/group/b' => array(array(array('_route' => 'slashed_b'), null, null, null, true, false, null)),
'/slashed/group/c' => array(array(array('_route' => 'slashed_c'), null, null, null, true, false, null)),
);
$this->regexpList = array(
0 => '{^(?'
.'|/([^/]++)(*:16)'
.'|/nested/([^/]++)(*:39)'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
16 => array(array(array('_route' => 'a_wildcard'), array('param'), null, null, false, null)),
39 => array(array(array('_route' => 'nested_wildcard'), array('param'), null, null, false, null)),
16 => array(array(array('_route' => 'a_wildcard'), array('param'), null, null, false, true, null)),
39 => array(array(array('_route' => 'nested_wildcard'), array('param'), null, null, false, true, null)),
);
}
}
+17 -17
View File
@@ -15,14 +15,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
$this->context = $context;
$this->staticRoutes = array(
'/trailing/simple/no-methods' => array(array(array('_route' => 'simple_trailing_slash_no_methods'), null, null, null, true, null)),
'/trailing/simple/get-method' => array(array(array('_route' => 'simple_trailing_slash_GET_method'), null, array('GET' => 0), null, true, null)),
'/trailing/simple/head-method' => array(array(array('_route' => 'simple_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, true, null)),
'/trailing/simple/post-method' => array(array(array('_route' => 'simple_trailing_slash_POST_method'), null, array('POST' => 0), null, true, null)),
'/not-trailing/simple/no-methods' => array(array(array('_route' => 'simple_not_trailing_slash_no_methods'), null, null, null, false, null)),
'/not-trailing/simple/get-method' => array(array(array('_route' => 'simple_not_trailing_slash_GET_method'), null, array('GET' => 0), null, false, null)),
'/not-trailing/simple/head-method' => array(array(array('_route' => 'simple_not_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, false, null)),
'/not-trailing/simple/post-method' => array(array(array('_route' => 'simple_not_trailing_slash_POST_method'), null, array('POST' => 0), null, false, null)),
'/trailing/simple/no-methods' => array(array(array('_route' => 'simple_trailing_slash_no_methods'), null, null, null, true, false, null)),
'/trailing/simple/get-method' => array(array(array('_route' => 'simple_trailing_slash_GET_method'), null, array('GET' => 0), null, true, false, null)),
'/trailing/simple/head-method' => array(array(array('_route' => 'simple_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, true, false, null)),
'/trailing/simple/post-method' => array(array(array('_route' => 'simple_trailing_slash_POST_method'), null, array('POST' => 0), null, true, false, null)),
'/not-trailing/simple/no-methods' => array(array(array('_route' => 'simple_not_trailing_slash_no_methods'), null, null, null, false, false, null)),
'/not-trailing/simple/get-method' => array(array(array('_route' => 'simple_not_trailing_slash_GET_method'), null, array('GET' => 0), null, false, false, null)),
'/not-trailing/simple/head-method' => array(array(array('_route' => 'simple_not_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, false, false, null)),
'/not-trailing/simple/post-method' => array(array(array('_route' => 'simple_not_trailing_slash_POST_method'), null, array('POST' => 0), null, false, false, null)),
);
$this->regexpList = array(
0 => '{^(?'
@@ -38,17 +38,17 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
.'|head\\-method/([^/]++)(*:240)'
.'|post\\-method/([^/]++)(*:269)'
.')'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
46 => array(array(array('_route' => 'regex_trailing_slash_no_methods'), array('param'), null, null, true, null)),
73 => array(array(array('_route' => 'regex_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, true, null)),
101 => array(array(array('_route' => 'regex_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, true, null)),
130 => array(array(array('_route' => 'regex_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, true, null)),
183 => array(array(array('_route' => 'regex_not_trailing_slash_no_methods'), array('param'), null, null, false, null)),
211 => array(array(array('_route' => 'regex_not_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, false, null)),
240 => array(array(array('_route' => 'regex_not_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, false, null)),
269 => array(array(array('_route' => 'regex_not_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, false, null)),
46 => array(array(array('_route' => 'regex_trailing_slash_no_methods'), array('param'), null, null, true, true, null)),
73 => array(array(array('_route' => 'regex_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, true, true, null)),
101 => array(array(array('_route' => 'regex_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, true, true, null)),
130 => array(array(array('_route' => 'regex_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, true, true, null)),
183 => array(array(array('_route' => 'regex_not_trailing_slash_no_methods'), array('param'), null, null, false, true, null)),
211 => array(array(array('_route' => 'regex_not_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, false, true, null)),
240 => array(array(array('_route' => 'regex_not_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, false, true, null)),
269 => array(array(array('_route' => 'regex_not_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, false, true, null)),
);
}
}
+17 -17
View File
@@ -15,14 +15,14 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
{
$this->context = $context;
$this->staticRoutes = array(
'/trailing/simple/no-methods' => array(array(array('_route' => 'simple_trailing_slash_no_methods'), null, null, null, true, null)),
'/trailing/simple/get-method' => array(array(array('_route' => 'simple_trailing_slash_GET_method'), null, array('GET' => 0), null, true, null)),
'/trailing/simple/head-method' => array(array(array('_route' => 'simple_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, true, null)),
'/trailing/simple/post-method' => array(array(array('_route' => 'simple_trailing_slash_POST_method'), null, array('POST' => 0), null, true, null)),
'/not-trailing/simple/no-methods' => array(array(array('_route' => 'simple_not_trailing_slash_no_methods'), null, null, null, false, null)),
'/not-trailing/simple/get-method' => array(array(array('_route' => 'simple_not_trailing_slash_GET_method'), null, array('GET' => 0), null, false, null)),
'/not-trailing/simple/head-method' => array(array(array('_route' => 'simple_not_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, false, null)),
'/not-trailing/simple/post-method' => array(array(array('_route' => 'simple_not_trailing_slash_POST_method'), null, array('POST' => 0), null, false, null)),
'/trailing/simple/no-methods' => array(array(array('_route' => 'simple_trailing_slash_no_methods'), null, null, null, true, false, null)),
'/trailing/simple/get-method' => array(array(array('_route' => 'simple_trailing_slash_GET_method'), null, array('GET' => 0), null, true, false, null)),
'/trailing/simple/head-method' => array(array(array('_route' => 'simple_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, true, false, null)),
'/trailing/simple/post-method' => array(array(array('_route' => 'simple_trailing_slash_POST_method'), null, array('POST' => 0), null, true, false, null)),
'/not-trailing/simple/no-methods' => array(array(array('_route' => 'simple_not_trailing_slash_no_methods'), null, null, null, false, false, null)),
'/not-trailing/simple/get-method' => array(array(array('_route' => 'simple_not_trailing_slash_GET_method'), null, array('GET' => 0), null, false, false, null)),
'/not-trailing/simple/head-method' => array(array(array('_route' => 'simple_not_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null, false, false, null)),
'/not-trailing/simple/post-method' => array(array(array('_route' => 'simple_not_trailing_slash_POST_method'), null, array('POST' => 0), null, false, false, null)),
);
$this->regexpList = array(
0 => '{^(?'
@@ -38,17 +38,17 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
.'|head\\-method/([^/]++)(*:240)'
.'|post\\-method/([^/]++)(*:269)'
.')'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
46 => array(array(array('_route' => 'regex_trailing_slash_no_methods'), array('param'), null, null, true, null)),
73 => array(array(array('_route' => 'regex_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, true, null)),
101 => array(array(array('_route' => 'regex_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, true, null)),
130 => array(array(array('_route' => 'regex_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, true, null)),
183 => array(array(array('_route' => 'regex_not_trailing_slash_no_methods'), array('param'), null, null, false, null)),
211 => array(array(array('_route' => 'regex_not_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, false, null)),
240 => array(array(array('_route' => 'regex_not_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, false, null)),
269 => array(array(array('_route' => 'regex_not_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, false, null)),
46 => array(array(array('_route' => 'regex_trailing_slash_no_methods'), array('param'), null, null, true, true, null)),
73 => array(array(array('_route' => 'regex_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, true, true, null)),
101 => array(array(array('_route' => 'regex_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, true, true, null)),
130 => array(array(array('_route' => 'regex_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, true, true, null)),
183 => array(array(array('_route' => 'regex_not_trailing_slash_no_methods'), array('param'), null, null, false, true, null)),
211 => array(array(array('_route' => 'regex_not_trailing_slash_GET_method'), array('param'), array('GET' => 0), null, false, true, null)),
240 => array(array(array('_route' => 'regex_not_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null, false, true, null)),
269 => array(array(array('_route' => 'regex_not_trailing_slash_POST_method'), array('param'), array('POST' => 0), null, false, true, null)),
);
}
}
@@ -17,18 +17,18 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$this->regexpList = array(
0 => '{^(?'
.'|/(a)(*:11)'
.')(?:/?)$}sD',
.')/?$}sD',
11 => '{^(?'
.'|/(.)(*:22)'
.')(?:/?)$}sDu',
.')/?$}sDu',
22 => '{^(?'
.'|/(.)(*:33)'
.')(?:/?)$}sD',
.')/?$}sD',
);
$this->dynamicRoutes = array(
11 => array(array(array('_route' => 'a'), array('a'), null, null, false, null)),
22 => array(array(array('_route' => 'b'), array('a'), null, null, false, null)),
33 => array(array(array('_route' => 'c'), array('a'), null, null, false, null)),
11 => array(array(array('_route' => 'a'), array('a'), null, null, false, true, null)),
22 => array(array(array('_route' => 'b'), array('a'), null, null, false, true, null)),
33 => array(array(array('_route' => 'c'), array('a'), null, null, false, true, null)),
);
}
}
@@ -17,9 +17,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$this->matchHost = true;
$this->staticRoutes = array(
'/' => array(
array(array('_route' => 'a'), '#^(?P<d>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, null),
array(array('_route' => 'c'), '#^(?P<e>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, null),
array(array('_route' => 'b'), 'd.c.b.a', null, null, false, null),
array(array('_route' => 'a'), '#^(?P<d>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, false, null),
array(array('_route' => 'c'), '#^(?P<e>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, false, null),
array(array('_route' => 'b'), 'd.c.b.a', null, null, false, false, null),
),
);
}
+10
View File
@@ -709,6 +709,16 @@ class UrlMatcherTest extends TestCase
$matcher = $this->getUrlMatcher($coll);
$this->assertSame(array('_route' => 'b'), $matcher->match('/bar/'));
$coll = new RouteCollection();
$coll->add('a', new Route('/dav/{foo<.*>?}', array(), array(), array(), '', array(), array('GET', 'OPTIONS')));
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'OPTIONS'));
$expected = array(
'_route' => 'a',
'foo' => 'files/bar',
);
$this->assertEquals($expected, $matcher->match('/dav/files/bar/'));
}
public function testSlashAndVerbPrecedence()
+2 -2
View File
@@ -40,10 +40,10 @@ class TargetOperation extends AbstractOperation
// For 'all' messages, the code can't be simplified as ``$this->messages[$domain]['all'] = $target->all($domain);``,
// because doing so will drop messages like {x: x ∈ source ∧ x ∉ target.all ∧ x ∈ target.fallback}
//
// For 'new' messages, the code can't be simplied as ``array_diff_assoc($this->target->all($domain), $this->source->all($domain));``
// For 'new' messages, the code can't be simplified as ``array_diff_assoc($this->target->all($domain), $this->source->all($domain));``
// because doing so will not exclude messages like {x: x ∈ target ∧ x ∉ source.all ∧ x ∈ source.fallback}
//
// For 'obsolete' messages, the code can't be simplifed as ``array_diff_assoc($this->source->all($domain), $this->target->all($domain))``
// For 'obsolete' messages, the code can't be simplified as ``array_diff_assoc($this->source->all($domain), $this->target->all($domain))``
// because doing so will not exclude messages like {x: x ∈ source ∧ x ∉ target.all ∧ x ∈ target.fallback}
foreach ($this->source->all($domain) as $id => $message) {
+2 -2
View File
@@ -242,7 +242,7 @@ EOF
};
if (null !== $this->directoryIteratorProvider) {
return \call_user_func($this->directoryIteratorProvider, $directory, $default);
return ($this->directoryIteratorProvider)($directory, $default);
}
return $default($directory);
@@ -255,7 +255,7 @@ EOF
};
if (null !== $this->isReadableProvider) {
return \call_user_func($this->isReadableProvider, $fileOrDirectory, $default);
return ($this->isReadableProvider)($fileOrDirectory, $default);
}
return $default($fileOrDirectory);
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -46,7 +46,7 @@ class PluralizationRules
}
if (isset(self::$rules[$locale])) {
$return = \call_user_func(self::$rules[$locale], $number);
$return = self::$rules[$locale]($number);
if (!\is_int($return) || $return < 0) {
return 0;
+2 -2
View File
@@ -127,7 +127,7 @@ class TranslatorCacheTest extends TestCase
{
/*
* Similar to the previous test. After we used the second translator, make
* sure there's still a useable cache for the first one.
* sure there's still a usable cache for the first one.
*/
$locale = 'any_locale';
@@ -146,7 +146,7 @@ class TranslatorCacheTest extends TestCase
$translator->addResource($format, array($msgid => 'FAIL'), $locale);
$translator->trans($msgid);
// Now the first translator must still have a useable cache.
// Now the first translator must still have a usable cache.
$translator = new Translator($locale, null, $this->tmpDir, $debug);
$translator->addLoader($format, $this->createFailingLoader());
$translator->addResource($format, array($msgid => 'OK'), $locale);
+1 -1
View File
@@ -41,7 +41,7 @@ interface TranslatorInterface extends LocaleAwareInterface
* Translates the given choice message by choosing a translation according to a number.
*
* @param string $id The message id (may also be an object that can be cast to string)
* @param int $number The number to use to find the indice of the message
* @param int $number The number to use to find the index of the message
* @param array $parameters An array of parameters for the message
* @param string|null $domain The domain for the message or null to use the default
* @param string|null $locale The locale or null to use the default
+1 -1
View File
@@ -228,7 +228,7 @@ abstract class AbstractCloner implements ClonerInterface
}
if ($this->prevErrorHandler) {
return \call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context);
return ($this->prevErrorHandler)($type, $msg, $file, $line, $context);
}
return false;
+2 -2
View File
@@ -30,8 +30,8 @@ class VarCloner extends AbstractCloner
$queue = array(array($var)); // This breadth-first queue is the return value
$indexedArrays = array(); // Map of queue indexes that hold numerically indexed arrays
$hardRefs = array(); // Map of original zval ids to stub objects
$objRefs = array(); // Map of original object handles to their stub object couterpart
$resRefs = array(); // Map of original resource handles to their stub object couterpart
$objRefs = array(); // Map of original object handles to their stub object counterpart
$resRefs = array(); // Map of original resource handles to their stub object counterpart
$values = array(); // Map of stub objects' ids to original values
$maxItems = $this->maxItems;
$maxString = $this->maxString;
@@ -57,7 +57,7 @@ class HtmlDescriptor implements DumpDescriptorInterface
$sourceDescription = '';
if (isset($context['source'])) {
$source = $context['source'];
$projectDir = $source['project_dir'];
$projectDir = $source['project_dir'] ?? null;
$sourceDescription = sprintf('%s on line %d', $source['name'], $source['line']);
if (isset($source['file_link'])) {
$sourceDescription = sprintf('<a href="%s">%s</a>', $source['file_link'], $sourceDescription);
+1 -1
View File
@@ -164,7 +164,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
*/
protected function dumpLine($depth)
{
\call_user_func($this->lineDumper, $this->line, $depth, $this->indentPad);
($this->lineDumper)($this->line, $depth, $this->indentPad);
$this->line = '';
}
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2014-2018 Fabien Potencier
Copyright (c) 2014-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+3 -3
View File
@@ -35,7 +35,7 @@ SplFileInfo {
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
inode: %d
inode: %i
size: %d
perms: 0%d
owner: %d
@@ -85,7 +85,7 @@ SplFileObject {
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
inode: %d
inode: %i
size: %d
perms: 0%d
owner: %d
@@ -105,7 +105,7 @@ SplFileObject {
maxLineLen: 0
fstat: array:26 [
"dev" => %d
"ino" => %d
"ino" => %i
"nlink" => %d
"rdev" => 0
"blksize" => %i
@@ -0,0 +1,134 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\VarDumper\Tests\Command\Descriptor;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Command\Descriptor\CliDescriptor;
use Symfony\Component\VarDumper\Dumper\CliDumper;
class CliDescriptorTest extends TestCase
{
private static $timezone;
public static function setUpBeforeClass()
{
self::$timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
}
public static function tearDownAfterClass()
{
date_default_timezone_set(self::$timezone);
}
/**
* @dataProvider provideContext
*/
public function testDescribe(array $context, string $expectedOutput)
{
$output = new BufferedOutput();
$descriptor = new CliDescriptor(new CliDumper(function ($s) {
return $s;
}));
$descriptor->describe($output, new Data(array(array(123))), $context + array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat(trim($expectedOutput), str_replace(PHP_EOL, "\n", trim($output->fetch())));
}
public function provideContext()
{
yield 'source' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
),
),
<<<TXT
Received from client #1
-----------------------
-------- ---------------------------------------------------------------------------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
source CliDescriptorTest.php on line 30
file /Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php
-------- ---------------------------------------------------------------------------------------------------
TXT
);
yield 'source full' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file_relative' => 'src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file_link' => 'phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30',
),
),
<<<TXT
Received from client #1
-----------------------
-------- --------------------------------------------------------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
source CliDescriptorTest.php on line 30
file src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php
-------- --------------------------------------------------------------------------------
Open source in your IDE/browser:
phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30
TXT
);
yield 'cli' => array(
array(
'cli' => array(
'identifier' => 'd8bece1c',
'command_line' => 'bin/phpunit',
),
),
<<<TXT
$ bin/phpunit
-------------
------ ---------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
------ ---------------------------------
TXT
);
yield 'request' => array(
array(
'request' => array(
'identifier' => 'd8bece1c',
'controller' => new Data(array(array('FooController.php'))),
'method' => 'GET',
'uri' => 'http://localhost/foo',
),
),
<<<TXT
GET http://localhost/foo
------------------------
------------ ---------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
controller "FooController.php"
------------ ---------------------------------
TXT
);
}
}
@@ -0,0 +1,195 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\VarDumper\Tests\Command\Descriptor;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Command\Descriptor\HtmlDescriptor;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
class HtmlDescriptorTest extends TestCase
{
private static $timezone;
public static function setUpBeforeClass()
{
self::$timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
}
public static function tearDownAfterClass()
{
date_default_timezone_set(self::$timezone);
}
public function testItOutputsStylesAndScriptsOnFirstDescribeCall()
{
$output = new BufferedOutput();
$dumper = $this->createMock(HtmlDumper::class);
$dumper->method('dump')->willReturn('[DUMPED]');
$descriptor = new HtmlDescriptor($dumper);
$descriptor->describe($output, new Data(array(array(123))), array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output');
$descriptor->describe($output, new Data(array(array(123))), array('timestamp' => 1544804268.3668), 1);
$this->assertStringNotMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output only once');
}
/**
* @dataProvider provideContext
*/
public function testDescribe(array $context, string $expectedOutput)
{
$output = new BufferedOutput();
$dumper = $this->createMock(HtmlDumper::class);
$dumper->method('dump')->willReturn('[DUMPED]');
$descriptor = new HtmlDescriptor($dumper);
$descriptor->describe($output, new Data(array(array(123))), $context + array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat(trim($expectedOutput), trim(preg_replace('@<style>.*</style><script>.*</script>@s', '', $output->fetch())));
}
public function provideContext()
{
yield 'source' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
),
),
<<<TXT
<article data-dedup-id="%s">
<header>
<div class="row">
<h2 class="col">-</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
</header>
<section class="body">
<p class="text-small">
CliDescriptorTest.php on line 30
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'source full' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'project_dir' => 'src/Symfony/',
'line' => 30,
'file_relative' => 'src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file_link' => 'phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30',
),
),
<<<TXT
<article data-dedup-id="%s">
<header>
<div class="row">
<h2 class="col">-</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
<div class="row">
<ul class="tags">
<li><span class="badge">project dir</span>src/Symfony/</li>
</ul>
</div>
</header>
<section class="body">
<p class="text-small">
<a href="phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30">CliDescriptorTest.php on line 30</a>
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'cli' => array(
array(
'cli' => array(
'identifier' => 'd8bece1c',
'command_line' => 'bin/phpunit',
),
),
<<<TXT
<article data-dedup-id="d8bece1c">
<header>
<div class="row">
<h2 class="col"><code>$ </code>bin/phpunit</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
</header>
<section class="body">
<p class="text-small">
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'request' => array(
array(
'request' => array(
'identifier' => 'd8bece1c',
'controller' => new Data(array(array('FooController.php'))),
'method' => 'GET',
'uri' => 'http://localhost/foo',
),
),
<<<TXT
<article data-dedup-id="d8bece1c">
<header>
<div class="row">
<h2 class="col"><code>GET</code> <a href="http://localhost/foo">http://localhost/foo</a></h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
<div class="row">
<ul class="tags">
<li><span class="badge">controller</span><span class='dumped-tag'>[DUMPED]</span></li>
</ul>
</div>
</header>
<section class="body">
<p class="text-small">
</p>
[DUMPED]
</section>
</article>
TXT
);
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ class VarDumper
};
}
return \call_user_func(self::$handler, $var);
return (self::$handler)($var);
}
public static function setHandler(callable $callable = null)
+1
View File
@@ -22,6 +22,7 @@
},
"require-dev": {
"ext-iconv": "*",
"symfony/console": "~3.4|~4.0",
"symfony/process": "~3.4|~4.0",
"twig/twig": "~1.34|~2.4"
},