package updates
This commit is contained in:
17
vendor/symfony/console/Application.php
vendored
17
vendor/symfony/console/Application.php
vendored
@@ -753,12 +753,20 @@ class Application
|
||||
do {
|
||||
$message = trim($e->getMessage());
|
||||
if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
|
||||
$title = sprintf(' [%s%s] ', \get_class($e), 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
|
||||
$class = \get_class($e);
|
||||
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
|
||||
$title = sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
|
||||
$len = Helper::strlen($title);
|
||||
} else {
|
||||
$len = 0;
|
||||
}
|
||||
|
||||
if (false !== strpos($message, "class@anonymous\0")) {
|
||||
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
|
||||
return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
|
||||
}, $message);
|
||||
}
|
||||
|
||||
$width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX;
|
||||
$lines = array();
|
||||
foreach ('' !== $message ? preg_split('/\r?\n/', $message) : array() as $line) {
|
||||
@@ -793,6 +801,13 @@ class Application
|
||||
// exception related properties
|
||||
$trace = $e->getTrace();
|
||||
|
||||
array_unshift($trace, array(
|
||||
'function' => '',
|
||||
'file' => $e->getFile() ?: 'n/a',
|
||||
'line' => $e->getLine() ?: 'n/a',
|
||||
'args' => array(),
|
||||
));
|
||||
|
||||
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
|
||||
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
|
||||
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
|
||||
|
||||
11
vendor/symfony/console/CHANGELOG.md
vendored
11
vendor/symfony/console/CHANGELOG.md
vendored
@@ -1,6 +1,17 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* allowed passing commands as `array($process, 'ENV_VAR' => 'value')` to
|
||||
`ProcessHelper::run()` to pass environment variables
|
||||
* deprecated passing a command as a string to `ProcessHelper::run()`,
|
||||
pass it the command as an array of its arguments instead
|
||||
* made the `ProcessHelper` class final
|
||||
* added `WrappableOutputFormatterInterface::formatAndWrap()` (implemented in `OutputFormatter`)
|
||||
* added `capture_stderr_separately` option to `CommandTester::execute()`
|
||||
|
||||
4.1.0
|
||||
-----
|
||||
|
||||
|
||||
27
vendor/symfony/console/Command/Command.php
vendored
27
vendor/symfony/console/Command/Command.php
vendored
@@ -301,14 +301,13 @@ class Command
|
||||
|
||||
$this->definition->addOptions($this->application->getDefinition()->getOptions());
|
||||
|
||||
$this->applicationDefinitionMerged = true;
|
||||
|
||||
if ($mergeArgs) {
|
||||
$currentArguments = $this->definition->getArguments();
|
||||
$this->definition->setArguments($this->application->getDefinition()->getArguments());
|
||||
$this->definition->addArguments($currentArguments);
|
||||
}
|
||||
|
||||
$this->applicationDefinitionMerged = true;
|
||||
if ($mergeArgs) {
|
||||
$this->applicationDefinitionMergedWithArgs = true;
|
||||
}
|
||||
}
|
||||
@@ -361,10 +360,12 @@ class Command
|
||||
/**
|
||||
* Adds an argument.
|
||||
*
|
||||
* @param string $name The argument name
|
||||
* @param int $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
|
||||
* @param string $description A description text
|
||||
* @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
|
||||
* @param string $name The argument name
|
||||
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
|
||||
* @param string $description A description text
|
||||
* @param string|string[]|null $default The default value (for self::OPTIONAL mode only)
|
||||
*
|
||||
* @throws InvalidArgumentException When argument mode is not valid
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -378,11 +379,13 @@ class Command
|
||||
/**
|
||||
* Adds an option.
|
||||
*
|
||||
* @param string $name The option name
|
||||
* @param string $shortcut The shortcut (can be null)
|
||||
* @param int $mode The option mode: One of the InputOption::VALUE_* constants
|
||||
* @param string $description A description text
|
||||
* @param mixed $default The default value (must be null for InputOption::VALUE_NONE)
|
||||
* @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 string $description A description text
|
||||
* @param string|string[]|int|bool|null $default The default value (must be null for self::VALUE_NONE)
|
||||
*
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Lock\Factory;
|
||||
use Symfony\Component\Lock\Lock;
|
||||
use Symfony\Component\Lock\Store\FlockStore;
|
||||
@@ -36,7 +35,7 @@ trait LockableTrait
|
||||
private function lock($name = null, $blocking = false)
|
||||
{
|
||||
if (!class_exists(SemaphoreStore::class)) {
|
||||
throw new RuntimeException('To enable the locking feature you must install the symfony/lock component.');
|
||||
throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
|
||||
}
|
||||
|
||||
if (null !== $this->lock) {
|
||||
|
||||
@@ -16,6 +16,6 @@ namespace Symfony\Component\Console\Exception;
|
||||
*
|
||||
* @author Jérôme Tamarelle <jerome@tamarelle.net>
|
||||
*/
|
||||
interface ExceptionInterface
|
||||
interface ExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
* Formatter class for console output.
|
||||
*
|
||||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* @author Roland Franssen <franssen.roland@gmail.com>
|
||||
*/
|
||||
class OutputFormatter implements OutputFormatterInterface
|
||||
class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
{
|
||||
private $decorated;
|
||||
private $styles = array();
|
||||
@@ -130,10 +131,18 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
*/
|
||||
public function format($message)
|
||||
{
|
||||
$message = (string) $message;
|
||||
return $this->formatAndWrap((string) $message, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function formatAndWrap(string $message, int $width)
|
||||
{
|
||||
$offset = 0;
|
||||
$output = '';
|
||||
$tagRegex = '[a-z][a-z0-9,_=;-]*+';
|
||||
$currentLineLength = 0;
|
||||
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
|
||||
foreach ($matches[0] as $i => $match) {
|
||||
$pos = $match[1];
|
||||
@@ -144,7 +153,7 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
}
|
||||
|
||||
// add the text up to the next tag
|
||||
$output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
|
||||
$output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength);
|
||||
$offset = $pos + \strlen($text);
|
||||
|
||||
// opening tag?
|
||||
@@ -158,7 +167,7 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
// </>
|
||||
$this->styleStack->pop();
|
||||
} elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
|
||||
$output .= $this->applyCurrentStyle($text);
|
||||
$output .= $this->applyCurrentStyle($text, $output, $width, $currentLineLength);
|
||||
} elseif ($open) {
|
||||
$this->styleStack->push($style);
|
||||
} else {
|
||||
@@ -166,7 +175,7 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
}
|
||||
}
|
||||
|
||||
$output .= $this->applyCurrentStyle(substr($message, $offset));
|
||||
$output .= $this->applyCurrentStyle(substr($message, $offset), $output, $width, $currentLineLength);
|
||||
|
||||
if (false !== strpos($output, "\0")) {
|
||||
return strtr($output, array("\0" => '\\', '\\<' => '<'));
|
||||
@@ -223,8 +232,46 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
/**
|
||||
* Applies current style from stack to text, if must be applied.
|
||||
*/
|
||||
private function applyCurrentStyle(string $text): string
|
||||
private function applyCurrentStyle(string $text, string $current, int $width, int &$currentLineLength): string
|
||||
{
|
||||
return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
|
||||
if ('' === $text) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!$width) {
|
||||
return $this->isDecorated() ? $this->styleStack->getCurrent()->apply($text) : $text;
|
||||
}
|
||||
|
||||
if (!$currentLineLength && '' !== $current) {
|
||||
$text = ltrim($text);
|
||||
}
|
||||
|
||||
if ($currentLineLength) {
|
||||
$prefix = substr($text, 0, $i = $width - $currentLineLength)."\n";
|
||||
$text = substr($text, $i);
|
||||
} else {
|
||||
$prefix = '';
|
||||
}
|
||||
|
||||
preg_match('~(\\n)$~', $text, $matches);
|
||||
$text = $prefix.preg_replace('~([^\\n]{'.$width.'})\\ *~', "\$1\n", $text);
|
||||
$text = rtrim($text, "\n").($matches[1] ?? '');
|
||||
|
||||
if (!$currentLineLength && '' !== $current && "\n" !== substr($current, -1)) {
|
||||
$text = "\n".$text;
|
||||
}
|
||||
|
||||
$lines = explode("\n", $text);
|
||||
if ($width === $currentLineLength = \strlen(end($lines))) {
|
||||
$currentLineLength = 0;
|
||||
}
|
||||
|
||||
if ($this->isDecorated()) {
|
||||
foreach ($lines as $i => $line) {
|
||||
$lines[$i] = $this->styleStack->getCurrent()->apply($line);
|
||||
}
|
||||
}
|
||||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
namespace Symfony\Component\Console\Formatter;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*/
|
||||
class OutputFormatterStyleStack
|
||||
class OutputFormatterStyleStack implements ResetInterface
|
||||
{
|
||||
/**
|
||||
* @var OutputFormatterStyleInterface[]
|
||||
|
||||
25
vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php
vendored
Normal file
25
vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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\Console\Formatter;
|
||||
|
||||
/**
|
||||
* Formatter interface for console output that supports word wrapping.
|
||||
*
|
||||
* @author Roland Franssen <franssen.roland@gmail.com>
|
||||
*/
|
||||
interface WrappableOutputFormatterInterface extends OutputFormatterInterface
|
||||
{
|
||||
/**
|
||||
* Formats a message according to the given styles, wrapping at `$width` (0 means no wrapping).
|
||||
*/
|
||||
public function formatAndWrap(string $message, int $width);
|
||||
}
|
||||
33
vendor/symfony/console/Helper/ProcessHelper.php
vendored
33
vendor/symfony/console/Helper/ProcessHelper.php
vendored
@@ -20,18 +20,20 @@ use Symfony\Component\Process\Process;
|
||||
* The ProcessHelper class provides helpers to run external processes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.2
|
||||
*/
|
||||
class ProcessHelper extends Helper
|
||||
{
|
||||
/**
|
||||
* Runs an external process.
|
||||
*
|
||||
* @param OutputInterface $output An OutputInterface instance
|
||||
* @param string|array|Process $cmd An instance of Process or an array of arguments to escape and run or a command to run
|
||||
* @param string|null $error An error message that must be displayed if something went wrong
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
* @param int $verbosity The threshold for verbosity
|
||||
* @param OutputInterface $output An OutputInterface instance
|
||||
* @param array|Process $cmd An instance of Process or an array of the command and arguments
|
||||
* @param string|null $error An error message that must be displayed if something went wrong
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
* @param int $verbosity The threshold for verbosity
|
||||
*
|
||||
* @return Process The process that ran
|
||||
*/
|
||||
@@ -44,9 +46,22 @@ class ProcessHelper extends Helper
|
||||
$formatter = $this->getHelperSet()->get('debug_formatter');
|
||||
|
||||
if ($cmd instanceof Process) {
|
||||
$process = $cmd;
|
||||
} else {
|
||||
$cmd = array($cmd);
|
||||
}
|
||||
|
||||
if (!\is_array($cmd)) {
|
||||
@trigger_error(sprintf('Passing a command as a string to "%s()" is deprecated since Symfony 4.2, pass it the command as an array of arguments instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
$cmd = array(\method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd));
|
||||
}
|
||||
|
||||
if (\is_string($cmd[0] ?? null)) {
|
||||
$process = new Process($cmd);
|
||||
$cmd = array();
|
||||
} elseif (($cmd[0] ?? null) instanceof Process) {
|
||||
$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__));
|
||||
}
|
||||
|
||||
if ($verbosity <= $output->getVerbosity()) {
|
||||
@@ -57,7 +72,7 @@ class ProcessHelper extends Helper
|
||||
$callback = $this->wrapCallback($output, $process, $callback);
|
||||
}
|
||||
|
||||
$process->run($callback);
|
||||
$process->run($callback, $cmd);
|
||||
|
||||
if ($verbosity <= $output->getVerbosity()) {
|
||||
$message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
|
||||
|
||||
16
vendor/symfony/console/Helper/QuestionHelper.php
vendored
16
vendor/symfony/console/Helper/QuestionHelper.php
vendored
@@ -47,13 +47,23 @@ class QuestionHelper extends Helper
|
||||
}
|
||||
|
||||
if (!$input->isInteractive()) {
|
||||
if ($question instanceof ChoiceQuestion) {
|
||||
$default = $question->getDefault();
|
||||
|
||||
if (null !== $default && $question instanceof ChoiceQuestion) {
|
||||
$choices = $question->getChoices();
|
||||
|
||||
return $choices[$question->getDefault()];
|
||||
if (!$question->isMultiselect()) {
|
||||
return isset($choices[$default]) ? $choices[$default] : $default;
|
||||
}
|
||||
|
||||
$default = explode(',', $default);
|
||||
foreach ($default as $k => $v) {
|
||||
$v = trim($v);
|
||||
$default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $question->getDefault();
|
||||
return $default;
|
||||
}
|
||||
|
||||
if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) {
|
||||
|
||||
77
vendor/symfony/console/Helper/Table.php
vendored
77
vendor/symfony/console/Helper/Table.php
vendored
@@ -13,6 +13,7 @@ namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
@@ -34,6 +35,9 @@ class Table
|
||||
private const BORDER_OUTSIDE = 0;
|
||||
private const BORDER_INSIDE = 1;
|
||||
|
||||
private $headerTitle;
|
||||
private $footerTitle;
|
||||
|
||||
/**
|
||||
* Table headers.
|
||||
*/
|
||||
@@ -77,6 +81,7 @@ class Table
|
||||
* @var array
|
||||
*/
|
||||
private $columnWidths = array();
|
||||
private $columnMaxWidths = array();
|
||||
|
||||
private static $styles;
|
||||
|
||||
@@ -180,11 +185,7 @@ class Table
|
||||
*/
|
||||
public function getColumnStyle($columnIndex)
|
||||
{
|
||||
if (isset($this->columnStyles[$columnIndex])) {
|
||||
return $this->columnStyles[$columnIndex];
|
||||
}
|
||||
|
||||
return $this->getStyle();
|
||||
return $this->columnStyles[$columnIndex] ?? $this->getStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,6 +220,25 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum width of a column.
|
||||
*
|
||||
* Any cell within this column which contents exceeds the specified width will be wrapped into multiple lines, while
|
||||
* formatted strings are preserved.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnMaxWidth(int $columnIndex, int $width): self
|
||||
{
|
||||
if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
|
||||
throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, \get_class($this->output->getFormatter())));
|
||||
}
|
||||
|
||||
$this->columnMaxWidths[$columnIndex] = $width;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHeaders(array $headers)
|
||||
{
|
||||
$headers = array_values($headers);
|
||||
@@ -290,6 +310,20 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHeaderTitle(?string $title): self
|
||||
{
|
||||
$this->headerTitle = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFooterTitle(?string $title): self
|
||||
{
|
||||
$this->footerTitle = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders table to output.
|
||||
*
|
||||
@@ -330,15 +364,17 @@ class Table
|
||||
}
|
||||
|
||||
if ($isHeader || $isFirstRow) {
|
||||
$this->renderRowSeparator($isFirstRow ? self::SEPARATOR_TOP_BOTTOM : self::SEPARATOR_TOP);
|
||||
if ($isFirstRow) {
|
||||
$this->renderRowSeparator(self::SEPARATOR_TOP_BOTTOM);
|
||||
$isFirstRow = false;
|
||||
} else {
|
||||
$this->renderRowSeparator(self::SEPARATOR_TOP, $this->headerTitle, $this->style->getHeaderTitleFormat());
|
||||
}
|
||||
}
|
||||
|
||||
$this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
|
||||
}
|
||||
$this->renderRowSeparator(self::SEPARATOR_BOTTOM);
|
||||
$this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());
|
||||
|
||||
$this->cleanup();
|
||||
$this->rendered = true;
|
||||
@@ -351,7 +387,7 @@ class Table
|
||||
*
|
||||
* +-----+-----------+-------+
|
||||
*/
|
||||
private function renderRowSeparator(int $type = self::SEPARATOR_MID)
|
||||
private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $title = null, string $titleFormat = null)
|
||||
{
|
||||
if (0 === $count = $this->numberOfColumns) {
|
||||
return;
|
||||
@@ -379,6 +415,23 @@ class Table
|
||||
$markup .= $column === $count - 1 ? $rightChar : $midChar;
|
||||
}
|
||||
|
||||
if (null !== $title) {
|
||||
$titleLength = Helper::strlenWithoutDecoration($formatter = $this->output->getFormatter(), $formattedTitle = sprintf($titleFormat, $title));
|
||||
$markupLength = Helper::strlen($markup);
|
||||
if ($titleLength > $limit = $markupLength - 4) {
|
||||
$titleLength = $limit;
|
||||
$formatLength = Helper::strlenWithoutDecoration($formatter, sprintf($titleFormat, ''));
|
||||
$formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...');
|
||||
}
|
||||
|
||||
$titleStart = ($markupLength - $titleLength) / 2;
|
||||
if (false === mb_detect_encoding($markup, null, true)) {
|
||||
$markup = substr_replace($markup, $formattedTitle, $titleStart, $titleLength);
|
||||
} else {
|
||||
$markup = mb_substr($markup, 0, $titleStart).$formattedTitle.mb_substr($markup, $titleStart + $titleLength);
|
||||
}
|
||||
}
|
||||
|
||||
$this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
|
||||
}
|
||||
|
||||
@@ -461,12 +514,17 @@ class Table
|
||||
|
||||
private function buildTableRows($rows)
|
||||
{
|
||||
/** @var WrappableOutputFormatterInterface $formatter */
|
||||
$formatter = $this->output->getFormatter();
|
||||
$unmergedRows = array();
|
||||
for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
|
||||
$rows = $this->fillNextRows($rows, $rowKey);
|
||||
|
||||
// Remove any new line breaks and replace it with a new line
|
||||
foreach ($rows[$rowKey] as $column => $cell) {
|
||||
if (isset($this->columnMaxWidths[$column]) && Helper::strlenWithoutDecoration($formatter, $cell) > $this->columnMaxWidths[$column]) {
|
||||
$cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column]);
|
||||
}
|
||||
if (!strstr($cell, "\n")) {
|
||||
continue;
|
||||
}
|
||||
@@ -674,8 +732,9 @@ class Table
|
||||
}
|
||||
|
||||
$columnWidth = isset($this->columnWidths[$column]) ? $this->columnWidths[$column] : 0;
|
||||
$cellWidth = max($cellWidth, $columnWidth);
|
||||
|
||||
return max($cellWidth, $columnWidth);
|
||||
return isset($this->columnMaxWidths[$column]) ? min($this->columnMaxWidths[$column], $cellWidth) : $cellWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
28
vendor/symfony/console/Helper/TableStyle.php
vendored
28
vendor/symfony/console/Helper/TableStyle.php
vendored
@@ -40,6 +40,8 @@ class TableStyle
|
||||
private $crossingTopLeftBottomChar = '+';
|
||||
private $crossingTopMidBottomChar = '+';
|
||||
private $crossingTopRightBottomChar = '+';
|
||||
private $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private $cellHeaderFormat = '<info>%s</info>';
|
||||
private $cellRowFormat = '%s';
|
||||
private $cellRowContentFormat = ' %s ';
|
||||
@@ -276,7 +278,7 @@ class TableStyle
|
||||
/**
|
||||
* Gets crossing character.
|
||||
*
|
||||
* @return string $crossingChar
|
||||
* @return string
|
||||
*/
|
||||
public function getCrossingChar()
|
||||
{
|
||||
@@ -429,4 +431,28 @@ class TableStyle
|
||||
{
|
||||
return $this->padType;
|
||||
}
|
||||
|
||||
public function getHeaderTitleFormat(): string
|
||||
{
|
||||
return $this->headerTitleFormat;
|
||||
}
|
||||
|
||||
public function setHeaderTitleFormat(string $format): self
|
||||
{
|
||||
$this->headerTitleFormat = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFooterTitleFormat(): string
|
||||
{
|
||||
return $this->footerTitleFormat;
|
||||
}
|
||||
|
||||
public function setFooterTitleFormat(string $format): self
|
||||
{
|
||||
$this->footerTitleFormat = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ interface InputAwareInterface
|
||||
{
|
||||
/**
|
||||
* Sets the Console Input.
|
||||
*
|
||||
* @param InputInterface
|
||||
*/
|
||||
public function setInput(InputInterface $input);
|
||||
}
|
||||
|
||||
14
vendor/symfony/console/Input/InputOption.php
vendored
14
vendor/symfony/console/Input/InputOption.php
vendored
@@ -33,11 +33,11 @@ class InputOption
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @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 string $description A description text
|
||||
* @param string|string[]|bool|null $default The default value (must be null for self::VALUE_NONE)
|
||||
* @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 string $description A description text
|
||||
* @param string|string[]|int|bool|null $default The default value (must be null for self::VALUE_NONE)
|
||||
*
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*/
|
||||
@@ -149,7 +149,7 @@ class InputOption
|
||||
/**
|
||||
* Sets the default value.
|
||||
*
|
||||
* @param string|string[]|bool|null $default The default value
|
||||
* @param string|string[]|int|bool|null $default The default value
|
||||
*
|
||||
* @throws LogicException When incorrect default value is given
|
||||
*/
|
||||
@@ -173,7 +173,7 @@ class InputOption
|
||||
/**
|
||||
* Returns the default value.
|
||||
*
|
||||
* @return string|string[]|bool|null The default value
|
||||
* @return string|string[]|int|bool|null The default value
|
||||
*/
|
||||
public function getDefault()
|
||||
{
|
||||
|
||||
@@ -70,7 +70,11 @@ class StreamOutput extends Output
|
||||
*/
|
||||
protected function doWrite($message, $newline)
|
||||
{
|
||||
if (false === @fwrite($this->stream, $message) || ($newline && (false === @fwrite($this->stream, PHP_EOL)))) {
|
||||
if ($newline) {
|
||||
$message .= PHP_EOL;
|
||||
}
|
||||
|
||||
if (false === @fwrite($this->stream, $message)) {
|
||||
// should never happen
|
||||
throw new RuntimeException('Unable to write output.');
|
||||
}
|
||||
|
||||
2
vendor/symfony/console/Question/Question.php
vendored
2
vendor/symfony/console/Question/Question.php
vendored
@@ -141,7 +141,7 @@ class Question
|
||||
}
|
||||
|
||||
if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
|
||||
throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
|
||||
throw new InvalidArgumentException('Autocompleter values can be either an array, "null" or a "Traversable" object.');
|
||||
}
|
||||
|
||||
if ($this->hidden) {
|
||||
|
||||
@@ -13,8 +13,6 @@ namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
* Eases the testing of console applications.
|
||||
@@ -33,7 +31,6 @@ class ApplicationTester
|
||||
private $application;
|
||||
private $input;
|
||||
private $statusCode;
|
||||
private $captureStreamsIndependently = false;
|
||||
|
||||
public function __construct(Application $application)
|
||||
{
|
||||
@@ -69,36 +66,7 @@ class ApplicationTester
|
||||
putenv('SHELL_INTERACTIVE=1');
|
||||
}
|
||||
|
||||
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
if (isset($options['decorated'])) {
|
||||
$this->output->setDecorated($options['decorated']);
|
||||
}
|
||||
if (isset($options['verbosity'])) {
|
||||
$this->output->setVerbosity($options['verbosity']);
|
||||
}
|
||||
} else {
|
||||
$this->output = new ConsoleOutput(
|
||||
isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL,
|
||||
isset($options['decorated']) ? $options['decorated'] : null
|
||||
);
|
||||
|
||||
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
$errorOutput->setFormatter($this->output->getFormatter());
|
||||
$errorOutput->setVerbosity($this->output->getVerbosity());
|
||||
$errorOutput->setDecorated($this->output->isDecorated());
|
||||
|
||||
$reflectedOutput = new \ReflectionObject($this->output);
|
||||
$strErrProperty = $reflectedOutput->getProperty('stderr');
|
||||
$strErrProperty->setAccessible(true);
|
||||
$strErrProperty->setValue($this->output, $errorOutput);
|
||||
|
||||
$reflectedParent = $reflectedOutput->getParentClass();
|
||||
$streamProperty = $reflectedParent->getProperty('stream');
|
||||
$streamProperty->setAccessible(true);
|
||||
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
|
||||
}
|
||||
$this->initOutput($options);
|
||||
|
||||
$this->statusCode = $this->application->run($this->input, $this->output);
|
||||
|
||||
@@ -106,28 +74,4 @@ class ApplicationTester
|
||||
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output written to STDERR by the application.
|
||||
*
|
||||
* @param bool $normalize Whether to normalize end of lines to \n or not
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorOutput($normalize = false)
|
||||
{
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
|
||||
}
|
||||
|
||||
rewind($this->output->getErrorOutput()->getStream());
|
||||
|
||||
$display = stream_get_contents($this->output->getErrorOutput()->getStream());
|
||||
|
||||
if ($normalize) {
|
||||
$display = str_replace(PHP_EOL, "\n", $display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
}
|
||||
}
|
||||
|
||||
16
vendor/symfony/console/Tester/CommandTester.php
vendored
16
vendor/symfony/console/Tester/CommandTester.php
vendored
@@ -13,7 +13,6 @@ namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
* Eases the testing of console commands.
|
||||
@@ -39,9 +38,10 @@ class CommandTester
|
||||
*
|
||||
* Available execution options:
|
||||
*
|
||||
* * interactive: Sets the input interactive flag
|
||||
* * decorated: Sets the output decorated flag
|
||||
* * verbosity: Sets the output verbosity flag
|
||||
* * interactive: Sets the input interactive flag
|
||||
* * decorated: Sets the output decorated flag
|
||||
* * verbosity: Sets the output verbosity flag
|
||||
* * capture_stderr_separately: Make output of stdOut and stdErr separately available
|
||||
*
|
||||
* @param array $input An array of command arguments and options
|
||||
* @param array $options An array of execution options
|
||||
@@ -68,12 +68,12 @@ class CommandTester
|
||||
$this->input->setInteractive($options['interactive']);
|
||||
}
|
||||
|
||||
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
$this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
|
||||
if (isset($options['verbosity'])) {
|
||||
$this->output->setVerbosity($options['verbosity']);
|
||||
if (!isset($options['decorated'])) {
|
||||
$options['decorated'] = false;
|
||||
}
|
||||
|
||||
$this->initOutput($options);
|
||||
|
||||
return $this->statusCode = $this->command->run($this->input, $this->output);
|
||||
}
|
||||
}
|
||||
|
||||
75
vendor/symfony/console/Tester/TesterTrait.php
vendored
75
vendor/symfony/console/Tester/TesterTrait.php
vendored
@@ -12,19 +12,19 @@
|
||||
namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
* @author Amrouche Hamza <hamza.simperfit@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
trait TesterTrait
|
||||
{
|
||||
/** @var StreamOutput */
|
||||
private $output;
|
||||
private $inputs = array();
|
||||
private $captureStreamsIndependently = false;
|
||||
|
||||
/**
|
||||
* Gets the display returned by the last execution of the command or application.
|
||||
@@ -46,6 +46,30 @@ trait TesterTrait
|
||||
return $display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output written to STDERR by the application.
|
||||
*
|
||||
* @param bool $normalize Whether to normalize end of lines to \n or not
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorOutput($normalize = false)
|
||||
{
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
|
||||
}
|
||||
|
||||
rewind($this->output->getErrorOutput()->getStream());
|
||||
|
||||
$display = stream_get_contents($this->output->getErrorOutput()->getStream());
|
||||
|
||||
if ($normalize) {
|
||||
$display = str_replace(PHP_EOL, "\n", $display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input instance used by the last execution of the command or application.
|
||||
*
|
||||
@@ -79,8 +103,8 @@ trait TesterTrait
|
||||
/**
|
||||
* Sets the user inputs.
|
||||
*
|
||||
* @param $inputs array An array of strings representing each input
|
||||
* passed to the command input stream
|
||||
* @param array $inputs An array of strings representing each input
|
||||
* passed to the command input stream
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -91,6 +115,49 @@ trait TesterTrait
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the output property.
|
||||
*
|
||||
* Available options:
|
||||
*
|
||||
* * decorated: Sets the output decorated flag
|
||||
* * verbosity: Sets the output verbosity flag
|
||||
* * capture_stderr_separately: Make output of stdOut and stdErr separately available
|
||||
*/
|
||||
private function initOutput(array $options)
|
||||
{
|
||||
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
if (isset($options['decorated'])) {
|
||||
$this->output->setDecorated($options['decorated']);
|
||||
}
|
||||
if (isset($options['verbosity'])) {
|
||||
$this->output->setVerbosity($options['verbosity']);
|
||||
}
|
||||
} else {
|
||||
$this->output = new ConsoleOutput(
|
||||
isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL,
|
||||
isset($options['decorated']) ? $options['decorated'] : null
|
||||
);
|
||||
|
||||
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
$errorOutput->setFormatter($this->output->getFormatter());
|
||||
$errorOutput->setVerbosity($this->output->getVerbosity());
|
||||
$errorOutput->setDecorated($this->output->isDecorated());
|
||||
|
||||
$reflectedOutput = new \ReflectionObject($this->output);
|
||||
$strErrProperty = $reflectedOutput->getProperty('stderr');
|
||||
$strErrProperty->setAccessible(true);
|
||||
$strErrProperty->setValue($this->output, $errorOutput);
|
||||
|
||||
$reflectedParent = $reflectedOutput->getParentClass();
|
||||
$streamProperty = $reflectedParent->getProperty('stream');
|
||||
$streamProperty->setAccessible(true);
|
||||
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
|
||||
}
|
||||
}
|
||||
|
||||
private static function createStream(array $inputs)
|
||||
{
|
||||
$stream = fopen('php://memory', 'r+', false);
|
||||
|
||||
50
vendor/symfony/console/Tests/ApplicationTest.php
vendored
50
vendor/symfony/console/Tests/ApplicationTest.php
vendored
@@ -824,6 +824,56 @@ class ApplicationTest extends TestCase
|
||||
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_linebreaks.txt', $tester->getDisplay(true), '->renderException() keep multiple line breaks');
|
||||
}
|
||||
|
||||
public function testRenderAnonymousException()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->register('foo')->setCode(function () {
|
||||
throw new class('') extends \InvalidArgumentException {
|
||||
};
|
||||
});
|
||||
$tester = new ApplicationTester($application);
|
||||
|
||||
$tester->run(array('command' => 'foo'), array('decorated' => false));
|
||||
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->register('foo')->setCode(function () {
|
||||
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() {
|
||||
})));
|
||||
});
|
||||
$tester = new ApplicationTester($application);
|
||||
|
||||
$tester->run(array('command' => 'foo'), array('decorated' => false));
|
||||
$this->assertContains('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testRenderExceptionStackTraceContainsRootException()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->register('foo')->setCode(function () {
|
||||
throw new class('') extends \InvalidArgumentException {
|
||||
};
|
||||
});
|
||||
$tester = new ApplicationTester($application);
|
||||
|
||||
$tester->run(array('command' => 'foo'), array('decorated' => false));
|
||||
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->register('foo')->setCode(function () {
|
||||
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() {
|
||||
})));
|
||||
});
|
||||
$tester = new ApplicationTester($application);
|
||||
|
||||
$tester->run(array('command' => 'foo'), array('decorated' => false));
|
||||
$this->assertContains('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testRun()
|
||||
{
|
||||
$application = new Application();
|
||||
|
||||
@@ -322,6 +322,25 @@ more text
|
||||
EOF
|
||||
));
|
||||
}
|
||||
|
||||
public function testFormatAndWrap()
|
||||
{
|
||||
$formatter = new OutputFormatter(true);
|
||||
|
||||
$this->assertSame("fo\no\e[37;41mb\e[39;49m\n\e[37;41mar\e[39;49m\nba\nz", $formatter->formatAndWrap('foo<error>bar</error> baz', 2));
|
||||
$this->assertSame("pr\ne \e[37;41m\e[39;49m\n\e[37;41mfo\e[39;49m\n\e[37;41mo \e[39;49m\n\e[37;41mba\e[39;49m\n\e[37;41mr \e[39;49m\n\e[37;41mba\e[39;49m\n\e[37;41mz\e[39;49m \npo\nst", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 2));
|
||||
$this->assertSame("pre\e[37;41m\e[39;49m\n\e[37;41mfoo\e[39;49m\n\e[37;41mbar\e[39;49m\n\e[37;41mbaz\e[39;49m\npos\nt", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 3));
|
||||
$this->assertSame("pre \e[37;41m\e[39;49m\n\e[37;41mfoo \e[39;49m\n\e[37;41mbar \e[39;49m\n\e[37;41mbaz\e[39;49m \npost", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 4));
|
||||
$this->assertSame("pre \e[37;41mf\e[39;49m\n\e[37;41moo ba\e[39;49m\n\e[37;41mr baz\e[39;49m\npost", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 5));
|
||||
|
||||
$formatter = new OutputFormatter();
|
||||
|
||||
$this->assertSame("fo\nob\nar\nba\nz", $formatter->formatAndWrap('foo<error>bar</error> baz', 2));
|
||||
$this->assertSame("pr\ne \nfo\no \nba\nr \nba\nz \npo\nst", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 2));
|
||||
$this->assertSame("pre\nfoo\nbar\nbaz\npos\nt", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 3));
|
||||
$this->assertSame("pre \nfoo \nbar \nbaz \npost", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 4));
|
||||
$this->assertSame("pre f\noo ba\nr baz\npost", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 5));
|
||||
}
|
||||
}
|
||||
|
||||
class TableCell
|
||||
|
||||
@@ -25,6 +25,10 @@ class ProcessHelperTest extends TestCase
|
||||
*/
|
||||
public function testVariousProcessRuns($expected, $cmd, $verbosity, $error)
|
||||
{
|
||||
if (\is_string($cmd)) {
|
||||
$cmd = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd);
|
||||
}
|
||||
|
||||
$helper = new ProcessHelper();
|
||||
$helper->setHelperSet(new HelperSet(array(new DebugFormatterHelper())));
|
||||
$output = $this->getOutputStream($verbosity);
|
||||
@@ -41,7 +45,7 @@ class ProcessHelperTest extends TestCase
|
||||
$executed = false;
|
||||
$callback = function () use (&$executed) { $executed = true; };
|
||||
|
||||
$helper->run($output, 'php -r "echo 42;"', null, $callback);
|
||||
$helper->run($output, array('php', '-r', 'echo 42;'), null, $callback);
|
||||
$this->assertTrue($executed);
|
||||
}
|
||||
|
||||
@@ -81,12 +85,21 @@ EOT;
|
||||
OUT out message
|
||||
RES 252 Command did not run successfully
|
||||
|
||||
EOT;
|
||||
|
||||
$PHP = '\\' === \DIRECTORY_SEPARATOR ? '"!PHP!"' : '"$PHP"';
|
||||
$successOutputPhp = <<<EOT
|
||||
RUN php -r $PHP
|
||||
OUT 42
|
||||
RES Command ran successfully
|
||||
|
||||
EOT;
|
||||
|
||||
$errorMessage = 'An error occurred';
|
||||
$args = new Process(array('php', '-r', 'echo 42;'));
|
||||
$args = $args->getCommandLine();
|
||||
$successOutputProcessDebug = str_replace("'php' '-r' 'echo 42;'", $args, $successOutputProcessDebug);
|
||||
$fromShellCommandline = \method_exists(Process::class, 'fromShellCommandline') ? array(Process::class, 'fromShellCommandline') : function ($cmd) { return new Process($cmd); };
|
||||
|
||||
return array(
|
||||
array('', 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERBOSE, null),
|
||||
@@ -100,7 +113,9 @@ EOT;
|
||||
array($syntaxErrorOutputVerbose.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage),
|
||||
array($syntaxErrorOutputDebug.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage),
|
||||
array($successOutputProcessDebug, array('php', '-r', 'echo 42;'), StreamOutput::VERBOSITY_DEBUG, null),
|
||||
array($successOutputDebug, new Process('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null),
|
||||
array($successOutputDebug, $fromShellCommandline('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null),
|
||||
array($successOutputProcessDebug, array(new Process(array('php', '-r', 'echo 42;'))), StreamOutput::VERBOSITY_DEBUG, null),
|
||||
array($successOutputPhp, array($fromShellCommandline('php -r '.$PHP), 'PHP' => 'echo 42;'), StreamOutput::VERBOSITY_DEBUG, null),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,63 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
$this->assertEquals('Superman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, true), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
public function testAskChoiceNonInteractive()
|
||||
{
|
||||
$questionHelper = new QuestionHelper();
|
||||
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$questionHelper->setHelperSet($helperSet);
|
||||
$inputStream = $this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n");
|
||||
|
||||
$heroes = array('Superman', 'Batman', 'Spiderman');
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0');
|
||||
|
||||
$this->assertSame('Superman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, 'Batman');
|
||||
$this->assertSame('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null);
|
||||
$this->assertNull($questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0');
|
||||
$question->setValidator(null);
|
||||
$this->assertSame('Superman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
|
||||
|
||||
try {
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null);
|
||||
$questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->assertSame('Value "" is invalid', $e->getMessage());
|
||||
}
|
||||
|
||||
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, 1');
|
||||
$question->setMultiselect(true);
|
||||
$this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, 1');
|
||||
$question->setMultiselect(true);
|
||||
$question->setValidator(null);
|
||||
$this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '0, Batman');
|
||||
$question->setMultiselect(true);
|
||||
$this->assertSame(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, null);
|
||||
$question->setMultiselect(true);
|
||||
$this->assertNull($questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question));
|
||||
|
||||
try {
|
||||
$question = new ChoiceQuestion('Who are your favorite superheros?', $heroes, '');
|
||||
$question->setMultiselect(true);
|
||||
$questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream, false), $this->createOutputInterface(), $question);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->assertSame('Value "" is invalid', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testAsk()
|
||||
{
|
||||
$dialog = new QuestionHelper();
|
||||
|
||||
103
vendor/symfony/console/Tests/Helper/TableTest.php
vendored
103
vendor/symfony/console/Tests/Helper/TableTest.php
vendored
@@ -974,6 +974,109 @@ TABLE;
|
||||
Table::getStyleDefinition('absent');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider renderSetTitle
|
||||
*/
|
||||
public function testSetTitle($headerTitle, $footerTitle, $style, $expected)
|
||||
{
|
||||
(new Table($output = $this->getOutputStream()))
|
||||
->setHeaderTitle($headerTitle)
|
||||
->setFooterTitle($footerTitle)
|
||||
->setHeaders(array('ISBN', 'Title', 'Author'))
|
||||
->setRows(array(
|
||||
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
|
||||
array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
|
||||
array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'),
|
||||
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
|
||||
))
|
||||
->setStyle($style)
|
||||
->render()
|
||||
;
|
||||
|
||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
public function renderSetTitle()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'Books',
|
||||
'Page 1/2',
|
||||
'default',
|
||||
<<<'TABLE'
|
||||
+---------------+----------- Books --------+------------------+
|
||||
| ISBN | Title | Author |
|
||||
+---------------+--------------------------+------------------+
|
||||
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
|
||||
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
|
||||
| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
|
||||
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
|
||||
+---------------+--------- Page 1/2 -------+------------------+
|
||||
|
||||
TABLE
|
||||
),
|
||||
array(
|
||||
'Books',
|
||||
'Page 1/2',
|
||||
'box',
|
||||
<<<'TABLE'
|
||||
┌───────────────┬─────────── Books ────────┬──────────────────┐
|
||||
│ ISBN │ Title │ Author │
|
||||
├───────────────┼──────────────────────────┼──────────────────┤
|
||||
│ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │
|
||||
│ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens │
|
||||
│ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien │
|
||||
│ 80-902734-1-6 │ And Then There Were None │ Agatha Christie │
|
||||
└───────────────┴───────── Page 1/2 ───────┴──────────────────┘
|
||||
|
||||
TABLE
|
||||
),
|
||||
array(
|
||||
'Boooooooooooooooooooooooooooooooooooooooooooooooooooooooks',
|
||||
'Page 1/999999999999999999999999999999999999999999999999999',
|
||||
'default',
|
||||
<<<'TABLE'
|
||||
+- Booooooooooooooooooooooooooooooooooooooooooooooooooooo... -+
|
||||
| ISBN | Title | Author |
|
||||
+---------------+--------------------------+------------------+
|
||||
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
|
||||
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
|
||||
| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
|
||||
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
|
||||
+- Page 1/99999999999999999999999999999999999999999999999... -+
|
||||
|
||||
TABLE
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function testColumnMaxWidths()
|
||||
{
|
||||
$table = new Table($output = $this->getOutputStream());
|
||||
$table
|
||||
->setRows(array(
|
||||
array('Divine Comedy', 'A Tale of Two Cities', 'The Lord of the Rings', 'And Then There Were None'),
|
||||
))
|
||||
->setColumnMaxWidth(1, 5)
|
||||
->setColumnMaxWidth(2, 10)
|
||||
->setColumnMaxWidth(3, 15);
|
||||
|
||||
$table->render();
|
||||
|
||||
$expected =
|
||||
<<<TABLE
|
||||
+---------------+-------+------------+-----------------+
|
||||
| Divine Comedy | A Tal | The Lord o | And Then There |
|
||||
| | e of | f the Ring | Were None |
|
||||
| | Two C | s | |
|
||||
| | ities | | |
|
||||
+---------------+-------+------------+-----------------+
|
||||
|
||||
TABLE;
|
||||
|
||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
public function testBoxedStyleWithColspan()
|
||||
{
|
||||
$boxed = new TableStyle();
|
||||
|
||||
@@ -90,4 +90,24 @@ class ApplicationTesterTest extends TestCase
|
||||
{
|
||||
$this->assertSame(0, $this->tester->getStatusCode(), '->getStatusCode() returns the status code');
|
||||
}
|
||||
|
||||
public function testErrorOutput()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->register('foo')
|
||||
->addArgument('foo')
|
||||
->setCode(function ($input, $output) {
|
||||
$output->getErrorOutput()->write('foo');
|
||||
})
|
||||
;
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(
|
||||
array('command' => 'foo', 'foo' => 'bar'),
|
||||
array('capture_stderr_separately' => true)
|
||||
);
|
||||
|
||||
$this->assertSame('foo', $tester->getErrorOutput());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,4 +160,23 @@ class CommandTesterTest extends TestCase
|
||||
|
||||
$this->assertEquals(0, $tester->getStatusCode());
|
||||
}
|
||||
|
||||
public function testErrorOutput()
|
||||
{
|
||||
$command = new Command('foo');
|
||||
$command->addArgument('command');
|
||||
$command->addArgument('foo');
|
||||
$command->setCode(function ($input, $output) {
|
||||
$output->getErrorOutput()->write('foo');
|
||||
}
|
||||
);
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(
|
||||
array('foo' => 'bar'),
|
||||
array('capture_stderr_separately' => true)
|
||||
);
|
||||
|
||||
$this->assertSame('foo', $tester->getErrorOutput());
|
||||
}
|
||||
}
|
||||
|
||||
3
vendor/symfony/console/composer.json
vendored
3
vendor/symfony/console/composer.json
vendored
@@ -17,6 +17,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/contracts": "^1.0",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -46,7 +47,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/symfony/console/phpunit.xml.dist
vendored
2
vendor/symfony/console/phpunit.xml.dist
vendored
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
|
||||
3
vendor/symfony/contracts/.gitignore
vendored
Normal file
3
vendor/symfony/contracts/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
composer.lock
|
||||
phpunit.xml
|
||||
vendor/
|
||||
12
vendor/symfony/contracts/CHANGELOG.md
vendored
Normal file
12
vendor/symfony/contracts/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
1.0.0
|
||||
-----
|
||||
|
||||
* added `Service\ResetInterface` to provide a way to reset an object to its initial state
|
||||
* added `Translation\TranslatorInterface` and `Translation\TranslatorTrait`
|
||||
* added `Cache` contract to extend PSR-6 with tag invalidation, callback-based computation and stampede protection
|
||||
* added `Service\ServiceSubscriberInterface` to declare the dependencies of a class that consumes a service locator
|
||||
* added `Service\ServiceSubscriberTrait` to implement `Service\ServiceSubscriberInterface` using methods' return types
|
||||
* added `Service\ServiceLocatorTrait` to help implement PSR-11 service locators
|
||||
57
vendor/symfony/contracts/Cache/CacheInterface.php
vendored
Normal file
57
vendor/symfony/contracts/Cache/CacheInterface.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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\Contracts\Cache;
|
||||
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Covers most simple to advanced caching needs.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface CacheInterface
|
||||
{
|
||||
/**
|
||||
* Fetches a value from the pool or computes it if not found.
|
||||
*
|
||||
* On cache misses, a callback is called that should return the missing value.
|
||||
* This callback is given a PSR-6 CacheItemInterface instance corresponding to the
|
||||
* requested key, that could be used e.g. for expiration control. It could also
|
||||
* be an ItemInterface instance when its additional features are needed.
|
||||
*
|
||||
* @param string $key The key of the item to retrieve from the cache
|
||||
* @param callable|CallbackInterface $callback Should return the computed value for the given key/item
|
||||
* @param float|null $beta A float that, as it grows, controls the likeliness of triggering
|
||||
* early expiration. 0 disables it, INF forces immediate expiration.
|
||||
* The default (or providing null) is implementation dependent but should
|
||||
* typically be 1.0, which should provide optimal stampede protection.
|
||||
* See https://en.wikipedia.org/wiki/Cache_stampede#Probabilistic_early_expiration
|
||||
* @param array &$metadata The metadata of the cached item {@see ItemInterface::getMetadata()}
|
||||
*
|
||||
* @return mixed The value corresponding to the provided key
|
||||
*
|
||||
* @throws InvalidArgumentException When $key is not valid or when $beta is negative
|
||||
*/
|
||||
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null);
|
||||
|
||||
/**
|
||||
* Removes an item from the pool.
|
||||
*
|
||||
* @param string $key The key to delete
|
||||
*
|
||||
* @throws InvalidArgumentException When $key is not valid
|
||||
*
|
||||
* @return bool True if the item was successfully removed, false if there was any error
|
||||
*/
|
||||
public function delete(string $key): bool;
|
||||
}
|
||||
71
vendor/symfony/contracts/Cache/CacheTrait.php
vendored
Normal file
71
vendor/symfony/contracts/Cache/CacheTrait.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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\Contracts\Cache;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* An implementation of CacheInterface for PSR-6 CacheItemPoolInterface classes.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
trait CacheTrait
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
|
||||
{
|
||||
return $this->doGet($this, $key, $callback, $beta, $metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete(string $key): bool
|
||||
{
|
||||
return $this->deleteItem($key);
|
||||
}
|
||||
|
||||
private function doGet(CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null)
|
||||
{
|
||||
if (0 > $beta = $beta ?? 1.0) {
|
||||
throw new class(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', \get_class($this), $beta)) extends \InvalidArgumentException implements InvalidArgumentException {
|
||||
};
|
||||
}
|
||||
|
||||
$item = $pool->getItem($key);
|
||||
$recompute = !$item->isHit() || INF === $beta;
|
||||
$metadata = $item instanceof ItemInterface ? $item->getMetadata() : array();
|
||||
|
||||
if (!$recompute && $metadata) {
|
||||
$expiry = $metadata[ItemInterface::METADATA_EXPIRY] ?? false;
|
||||
$ctime = $metadata[ItemInterface::METADATA_CTIME] ?? false;
|
||||
|
||||
if ($recompute = $ctime && $expiry && $expiry <= microtime(true) - $ctime / 1000 * $beta * log(random_int(1, PHP_INT_MAX) / PHP_INT_MAX)) {
|
||||
// force applying defaultLifetime to expiry
|
||||
$item->expiresAt(null);
|
||||
}
|
||||
}
|
||||
|
||||
if ($recompute) {
|
||||
$save = true;
|
||||
$item->set($callback($item, $save));
|
||||
if ($save) {
|
||||
$pool->save($item);
|
||||
}
|
||||
}
|
||||
|
||||
return $item->get();
|
||||
}
|
||||
}
|
||||
30
vendor/symfony/contracts/Cache/CallbackInterface.php
vendored
Normal file
30
vendor/symfony/contracts/Cache/CallbackInterface.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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\Contracts\Cache;
|
||||
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
|
||||
/**
|
||||
* Computes and returns the cached value of an item.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface CallbackInterface
|
||||
{
|
||||
/**
|
||||
* @param CacheItemInterface|ItemInterface $item The item to compute the value for
|
||||
* @param bool &$save Should be set to false when the value should not be saved in the pool
|
||||
*
|
||||
* @return mixed The computed value for the passed item
|
||||
*/
|
||||
public function __invoke(CacheItemInterface $item, bool &$save);
|
||||
}
|
||||
60
vendor/symfony/contracts/Cache/ItemInterface.php
vendored
Normal file
60
vendor/symfony/contracts/Cache/ItemInterface.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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\Contracts\Cache;
|
||||
|
||||
use Psr\Cache\CacheException;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Augments PSR-6's CacheItemInterface with support for tags and metadata.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface ItemInterface extends CacheItemInterface
|
||||
{
|
||||
/**
|
||||
* References the Unix timestamp stating when the item will expire.
|
||||
*/
|
||||
const METADATA_EXPIRY = 'expiry';
|
||||
|
||||
/**
|
||||
* References the time the item took to be created, in milliseconds.
|
||||
*/
|
||||
const METADATA_CTIME = 'ctime';
|
||||
|
||||
/**
|
||||
* References the list of tags that were assigned to the item, as string[].
|
||||
*/
|
||||
const METADATA_TAGS = 'tags';
|
||||
|
||||
/**
|
||||
* Adds a tag to a cache item.
|
||||
*
|
||||
* Tags are strings that follow the same validation rules as keys.
|
||||
*
|
||||
* @param string|string[] $tags A tag or array of tags
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException When $tag is not valid
|
||||
* @throws CacheException When the item comes from a pool that is not tag-aware
|
||||
*/
|
||||
public function tag($tags): self;
|
||||
|
||||
/**
|
||||
* Returns a list of metadata info that were saved alongside with the cached value.
|
||||
*
|
||||
* See ItemInterface::METADATA_* consts for keys potentially found in the returned array.
|
||||
*/
|
||||
public function getMetadata(): array;
|
||||
}
|
||||
38
vendor/symfony/contracts/Cache/TagAwareCacheInterface.php
vendored
Normal file
38
vendor/symfony/contracts/Cache/TagAwareCacheInterface.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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\Contracts\Cache;
|
||||
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Allows invalidating cached items using tags.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface TagAwareCacheInterface extends CacheInterface
|
||||
{
|
||||
/**
|
||||
* Invalidates cached items using tags.
|
||||
*
|
||||
* When implemented on a PSR-6 pool, invalidation should not apply
|
||||
* to deferred items. Instead, they should be committed as usual.
|
||||
* This allows replacing old tagged values by new ones without
|
||||
* race conditions.
|
||||
*
|
||||
* @param string[] $tags An array of tags to invalidate
|
||||
*
|
||||
* @return bool True on success
|
||||
*
|
||||
* @throws InvalidArgumentException When $tags is not valid
|
||||
*/
|
||||
public function invalidateTags(array $tags);
|
||||
}
|
||||
19
vendor/symfony/contracts/LICENSE
vendored
Normal file
19
vendor/symfony/contracts/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2018 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
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
70
vendor/symfony/contracts/README.md
vendored
Normal file
70
vendor/symfony/contracts/README.md
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
Symfony Contracts
|
||||
=================
|
||||
|
||||
A set of abstractions extracted out of the Symfony components.
|
||||
|
||||
Can be used to build on semantics that the Symfony components proved useful - and
|
||||
that already have battle tested implementations.
|
||||
|
||||
Design Principles
|
||||
-----------------
|
||||
|
||||
* contracts are split by domain, each into their own sub-namespaces;
|
||||
* contracts are small and consistent sets of PHP interfaces, traits, normative
|
||||
docblocks and reference test suites when applicable, etc.;
|
||||
* all contracts must have a proven implementation to enter this repository;
|
||||
* they must be backward compatible with existing Symfony components.
|
||||
|
||||
Packages that implement specific contracts should list them in the "provide"
|
||||
section of their "composer.json" file, using the `symfony/*-contracts-implementation`
|
||||
convention (e.g. `"provide": { "symfony/cache-contracts-implementation": "1.0" }`).
|
||||
|
||||
FAQ
|
||||
---
|
||||
|
||||
### How to use this package?
|
||||
|
||||
The abstractions in this package are useful to achieve loose coupling and
|
||||
interoperability. By using the provided interfaces as type hints, you are able
|
||||
to reuse any implementations that match their contracts. It could be a Symfony
|
||||
component, or another one provided by the PHP community at large.
|
||||
|
||||
Depending on their semantics, some interfaces can be combined with autowiring to
|
||||
seamlessly inject a service in your classes.
|
||||
|
||||
Others might be useful as labeling interfaces, to hint about a specific behavior
|
||||
that could be enabled when using autoconfiguration or manual service tagging (or
|
||||
any other means provided by your framework.)
|
||||
|
||||
### How is this different from PHP-FIG's PSRs?
|
||||
|
||||
When applicable, the provided contracts are built on top of PHP-FIG's PSRs. But
|
||||
the group has different goals and different processes. Here, we're focusing on
|
||||
providing abstractions that are useful on their own while still compatible with
|
||||
implementations provided by Symfony. Although not the main target, we hope that
|
||||
the declared contracts will directly or indirectly contribute to the PHP-FIG.
|
||||
|
||||
### Why isn't this package split into several packages?
|
||||
|
||||
Putting all interfaces in one package eases discoverability and dependency
|
||||
management. Instead of dealing with a myriad of small packages and the
|
||||
corresponding matrix of versions, you just need to deal with one package and one
|
||||
version. Also when using IDE autocompletion or just reading the source code, it
|
||||
makes it easier to figure out which contracts are provided.
|
||||
|
||||
There are two downsides to this approach: you may have unused files in your
|
||||
`vendor/` directory, and in the future, it will be impossible to use two
|
||||
different sub-namespaces in different major versions of the package. For the
|
||||
"unused files" downside, it has no practical consequences: their file sizes are
|
||||
very small, and there is no performance overhead at all since they are never
|
||||
loaded. For major versions, this package follows the Symfony BC + deprecation
|
||||
policies, with an additional restriction to never remove deprecated interfaces.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/contracts.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
30
vendor/symfony/contracts/Service/ResetInterface.php
vendored
Normal file
30
vendor/symfony/contracts/Service/ResetInterface.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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\Contracts\Service;
|
||||
|
||||
/**
|
||||
* Provides a way to reset an object to its initial state.
|
||||
*
|
||||
* When calling the "reset()" method on an object, it should be put back to its
|
||||
* initial state. This usually means clearing any internal buffers and forwarding
|
||||
* the call to internal dependencies. All properties of the object should be put
|
||||
* back to the same state it had when it was first ready to use.
|
||||
*
|
||||
* This method could be called, for example, to recycle objects that are used as
|
||||
* services, so that they can be used to handle several requests in the same
|
||||
* process loop (note that we advise making your services stateless instead of
|
||||
* implementing this interface when possible.)
|
||||
*/
|
||||
interface ResetInterface
|
||||
{
|
||||
public function reset();
|
||||
}
|
||||
97
vendor/symfony/contracts/Service/ServiceLocatorTrait.php
vendored
Normal file
97
vendor/symfony/contracts/Service/ServiceLocatorTrait.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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\Contracts\Service;
|
||||
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* A trait to help implement PSR-11 service locators.
|
||||
*
|
||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
trait ServiceLocatorTrait
|
||||
{
|
||||
private $factories;
|
||||
private $loading = array();
|
||||
|
||||
/**
|
||||
* @param callable[] $factories
|
||||
*/
|
||||
public function __construct(array $factories)
|
||||
{
|
||||
$this->factories = $factories;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($id)
|
||||
{
|
||||
return isset($this->factories[$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
if (!isset($this->factories[$id])) {
|
||||
throw $this->createNotFoundException($id);
|
||||
}
|
||||
|
||||
if (isset($this->loading[$id])) {
|
||||
$ids = array_values($this->loading);
|
||||
$ids = \array_slice($this->loading, array_search($id, $ids));
|
||||
$ids[] = $id;
|
||||
|
||||
throw $this->createCircularReferenceException($id, $ids);
|
||||
}
|
||||
|
||||
$this->loading[$id] = $id;
|
||||
try {
|
||||
return $this->factories[$id]($this);
|
||||
} finally {
|
||||
unset($this->loading[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
private function createNotFoundException(string $id): NotFoundExceptionInterface
|
||||
{
|
||||
if (!$alternatives = array_keys($this->factories)) {
|
||||
$message = 'is empty...';
|
||||
} else {
|
||||
$last = array_pop($alternatives);
|
||||
if ($alternatives) {
|
||||
$message = sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last);
|
||||
} else {
|
||||
$message = sprintf('only knows about the "%s" service.', $last);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->loading) {
|
||||
$message = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message);
|
||||
} else {
|
||||
$message = sprintf('Service "%s" not found: the current service locator %s', $id, $message);
|
||||
}
|
||||
|
||||
return new class($message) extends \InvalidArgumentException implements NotFoundExceptionInterface {
|
||||
};
|
||||
}
|
||||
|
||||
private function createCircularReferenceException(string $id, array $path): ContainerExceptionInterface
|
||||
{
|
||||
return new class(sprintf('Circular reference detected for service "%s", path: "%s".', $id, implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface {
|
||||
};
|
||||
}
|
||||
}
|
||||
53
vendor/symfony/contracts/Service/ServiceSubscriberInterface.php
vendored
Normal file
53
vendor/symfony/contracts/Service/ServiceSubscriberInterface.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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\Contracts\Service;
|
||||
|
||||
/**
|
||||
* A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method.
|
||||
*
|
||||
* The getSubscribedServices method returns an array of service types required by such instances,
|
||||
* optionally keyed by the service names used internally. Service types that start with an interrogation
|
||||
* mark "?" are optional, while the other ones are mandatory service dependencies.
|
||||
*
|
||||
* The injected service locators SHOULD NOT allow access to any other services not specified by the method.
|
||||
*
|
||||
* It is expected that ServiceSubscriber instances consume PSR-11-based service locators internally.
|
||||
* This interface does not dictate any injection method for these service locators, although constructor
|
||||
* injection is recommended.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface ServiceSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Returns an array of service types required by such instances, optionally keyed by the service names used internally.
|
||||
*
|
||||
* For mandatory dependencies:
|
||||
*
|
||||
* * array('logger' => 'Psr\Log\LoggerInterface') means the objects use the "logger" name
|
||||
* internally to fetch a service which must implement Psr\Log\LoggerInterface.
|
||||
* * array('loggers' => 'Psr\Log\LoggerInterface[]') means the objects use the "loggers" name
|
||||
* internally to fetch an iterable of Psr\Log\LoggerInterface instances.
|
||||
* * array('Psr\Log\LoggerInterface') is a shortcut for
|
||||
* * array('Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface')
|
||||
*
|
||||
* otherwise:
|
||||
*
|
||||
* * array('logger' => '?Psr\Log\LoggerInterface') denotes an optional dependency
|
||||
* * array('loggers' => '?Psr\Log\LoggerInterface[]') denotes an optional iterable dependency
|
||||
* * array('?Psr\Log\LoggerInterface') is a shortcut for
|
||||
* * array('Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface')
|
||||
*
|
||||
* @return array The required service types, optionally keyed by service names
|
||||
*/
|
||||
public static function getSubscribedServices();
|
||||
}
|
||||
61
vendor/symfony/contracts/Service/ServiceSubscriberTrait.php
vendored
Normal file
61
vendor/symfony/contracts/Service/ServiceSubscriberTrait.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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\Contracts\Service;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Implementation of ServiceSubscriberInterface that determines subscribed services from
|
||||
* private method return types. Service ids are available as "ClassName::methodName".
|
||||
*
|
||||
* @author Kevin Bond <kevinbond@gmail.com>
|
||||
*/
|
||||
trait ServiceSubscriberTrait
|
||||
{
|
||||
/** @var ContainerInterface */
|
||||
private $container;
|
||||
|
||||
public static function getSubscribedServices(): array
|
||||
{
|
||||
static $services;
|
||||
|
||||
if (null !== $services) {
|
||||
return $services;
|
||||
}
|
||||
|
||||
$services = \is_callable(array('parent', __FUNCTION__)) ? parent::getSubscribedServices() : array();
|
||||
|
||||
foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
|
||||
if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (self::class === $method->getDeclaringClass()->name && ($returnType = $method->getReturnType()) && !$returnType->isBuiltin()) {
|
||||
$services[self::class.'::'.$method->name] = '?'.$returnType->getName();
|
||||
}
|
||||
}
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* @required
|
||||
*/
|
||||
public function setContainer(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
if (\is_callable(array('parent', __FUNCTION__))) {
|
||||
return parent::setContainer($container);
|
||||
}
|
||||
}
|
||||
}
|
||||
165
vendor/symfony/contracts/Tests/Cache/CacheTraitTest.php
vendored
Normal file
165
vendor/symfony/contracts/Tests/Cache/CacheTraitTest.php
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
<?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\Contracts\Tests\Cache;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Contracts\Cache\CacheTrait;
|
||||
|
||||
/**
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
class CacheTraitTest extends TestCase
|
||||
{
|
||||
public function testSave()
|
||||
{
|
||||
$item = $this->getMockBuilder(CacheItemInterface::class)->getMock();
|
||||
$item->method('set')
|
||||
->willReturn($item);
|
||||
$item->method('isHit')
|
||||
->willReturn(false);
|
||||
|
||||
$item->expects($this->once())
|
||||
->method('set')
|
||||
->with('computed data');
|
||||
|
||||
$cache = $this->getMockBuilder(TestPool::class)
|
||||
->setMethods(array('getItem', 'save'))
|
||||
->getMock();
|
||||
$cache->expects($this->once())
|
||||
->method('getItem')
|
||||
->with('key')
|
||||
->willReturn($item);
|
||||
$cache->expects($this->once())
|
||||
->method('save');
|
||||
|
||||
$callback = function (CacheItemInterface $item) {
|
||||
return 'computed data';
|
||||
};
|
||||
|
||||
$cache->get('key', $callback);
|
||||
}
|
||||
|
||||
public function testNoCallbackCallOnHit()
|
||||
{
|
||||
$item = $this->getMockBuilder(CacheItemInterface::class)->getMock();
|
||||
$item->method('isHit')
|
||||
->willReturn(true);
|
||||
|
||||
$item->expects($this->never())
|
||||
->method('set');
|
||||
|
||||
$cache = $this->getMockBuilder(TestPool::class)
|
||||
->setMethods(array('getItem', 'save'))
|
||||
->getMock();
|
||||
|
||||
$cache->expects($this->once())
|
||||
->method('getItem')
|
||||
->with('key')
|
||||
->willReturn($item);
|
||||
$cache->expects($this->never())
|
||||
->method('save');
|
||||
|
||||
$callback = function (CacheItemInterface $item) {
|
||||
$this->assertTrue(false, 'This code should never be reached');
|
||||
};
|
||||
|
||||
$cache->get('key', $callback);
|
||||
}
|
||||
|
||||
public function testRecomputeOnBetaInf()
|
||||
{
|
||||
$item = $this->getMockBuilder(CacheItemInterface::class)->getMock();
|
||||
$item->method('set')
|
||||
->willReturn($item);
|
||||
$item->method('isHit')
|
||||
// We want to recompute even if it is a hit
|
||||
->willReturn(true);
|
||||
|
||||
$item->expects($this->once())
|
||||
->method('set')
|
||||
->with('computed data');
|
||||
|
||||
$cache = $this->getMockBuilder(TestPool::class)
|
||||
->setMethods(array('getItem', 'save'))
|
||||
->getMock();
|
||||
|
||||
$cache->expects($this->once())
|
||||
->method('getItem')
|
||||
->with('key')
|
||||
->willReturn($item);
|
||||
$cache->expects($this->once())
|
||||
->method('save');
|
||||
|
||||
$callback = function (CacheItemInterface $item) {
|
||||
return 'computed data';
|
||||
};
|
||||
|
||||
$cache->get('key', $callback, INF);
|
||||
}
|
||||
|
||||
public function testExceptionOnNegativeBeta()
|
||||
{
|
||||
$cache = $this->getMockBuilder(TestPool::class)
|
||||
->setMethods(array('getItem', 'save'))
|
||||
->getMock();
|
||||
|
||||
$callback = function (CacheItemInterface $item) {
|
||||
return 'computed data';
|
||||
};
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$cache->get('key', $callback, -2);
|
||||
}
|
||||
}
|
||||
|
||||
class TestPool implements CacheItemPoolInterface
|
||||
{
|
||||
use CacheTrait;
|
||||
|
||||
public function hasItem($key)
|
||||
{
|
||||
}
|
||||
|
||||
public function deleteItem($key)
|
||||
{
|
||||
}
|
||||
|
||||
public function deleteItems(array $keys = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function getItem($key)
|
||||
{
|
||||
}
|
||||
|
||||
public function getItems(array $key = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
}
|
||||
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
}
|
||||
|
||||
public function commit()
|
||||
{
|
||||
}
|
||||
|
||||
public function clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
94
vendor/symfony/contracts/Tests/Service/ServiceLocatorTest.php
vendored
Normal file
94
vendor/symfony/contracts/Tests/Service/ServiceLocatorTest.php
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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\Contracts\Tests\Service;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Contracts\Service\ServiceLocatorTrait;
|
||||
|
||||
class ServiceLocatorTest extends TestCase
|
||||
{
|
||||
public function getServiceLocator(array $factories)
|
||||
{
|
||||
return new class($factories) implements ContainerInterface {
|
||||
use ServiceLocatorTrait;
|
||||
};
|
||||
}
|
||||
|
||||
public function testHas()
|
||||
{
|
||||
$locator = $this->getServiceLocator(array(
|
||||
'foo' => function () { return 'bar'; },
|
||||
'bar' => function () { return 'baz'; },
|
||||
function () { return 'dummy'; },
|
||||
));
|
||||
|
||||
$this->assertTrue($locator->has('foo'));
|
||||
$this->assertTrue($locator->has('bar'));
|
||||
$this->assertFalse($locator->has('dummy'));
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$locator = $this->getServiceLocator(array(
|
||||
'foo' => function () { return 'bar'; },
|
||||
'bar' => function () { return 'baz'; },
|
||||
));
|
||||
|
||||
$this->assertSame('bar', $locator->get('foo'));
|
||||
$this->assertSame('baz', $locator->get('bar'));
|
||||
}
|
||||
|
||||
public function testGetDoesNotMemoize()
|
||||
{
|
||||
$i = 0;
|
||||
$locator = $this->getServiceLocator(array(
|
||||
'foo' => function () use (&$i) {
|
||||
++$i;
|
||||
|
||||
return 'bar';
|
||||
},
|
||||
));
|
||||
|
||||
$this->assertSame('bar', $locator->get('foo'));
|
||||
$this->assertSame('bar', $locator->get('foo'));
|
||||
$this->assertSame(2, $i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Psr\Container\NotFoundExceptionInterface
|
||||
* @expectedExceptionMessage The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.
|
||||
*/
|
||||
public function testThrowsOnUndefinedInternalService()
|
||||
{
|
||||
$locator = $this->getServiceLocator(array(
|
||||
'foo' => function () use (&$locator) { return $locator->get('bar'); },
|
||||
));
|
||||
|
||||
$locator->get('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Psr\Container\ContainerExceptionInterface
|
||||
* @expectedExceptionMessage Circular reference detected for service "bar", path: "bar -> baz -> bar".
|
||||
*/
|
||||
public function testThrowsOnCircularReference()
|
||||
{
|
||||
$locator = $this->getServiceLocator(array(
|
||||
'foo' => function () use (&$locator) { return $locator->get('bar'); },
|
||||
'bar' => function () use (&$locator) { return $locator->get('baz'); },
|
||||
'baz' => function () use (&$locator) { return $locator->get('bar'); },
|
||||
));
|
||||
|
||||
$locator->get('foo');
|
||||
}
|
||||
}
|
||||
65
vendor/symfony/contracts/Tests/Service/ServiceSubscriberTraitTest.php
vendored
Normal file
65
vendor/symfony/contracts/Tests/Service/ServiceSubscriberTraitTest.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\Contracts\Tests\Service;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Contracts\Service\ServiceLocatorTrait;
|
||||
use Symfony\Contracts\Service\ServiceSubscriberInterface;
|
||||
use Symfony\Contracts\Service\ServiceSubscriberTrait;
|
||||
|
||||
class ServiceSubscriberTraitTest extends TestCase
|
||||
{
|
||||
public function testMethodsOnParentsAndChildrenAreIgnoredInGetSubscribedServices()
|
||||
{
|
||||
$expected = array(TestService::class.'::aService' => '?Symfony\Contracts\Tests\Service\Service2');
|
||||
|
||||
$this->assertEquals($expected, ChildTestService::getSubscribedServices());
|
||||
}
|
||||
|
||||
public function testSetContainerIsCalledOnParent()
|
||||
{
|
||||
$container = new class(array()) implements ContainerInterface {
|
||||
use ServiceLocatorTrait;
|
||||
};
|
||||
|
||||
$this->assertSame($container, (new TestService())->setContainer($container));
|
||||
}
|
||||
}
|
||||
|
||||
class ParentTestService
|
||||
{
|
||||
public function aParentService(): Service1
|
||||
{
|
||||
}
|
||||
|
||||
public function setContainer(ContainerInterface $container)
|
||||
{
|
||||
return $container;
|
||||
}
|
||||
}
|
||||
|
||||
class TestService extends ParentTestService implements ServiceSubscriberInterface
|
||||
{
|
||||
use ServiceSubscriberTrait;
|
||||
|
||||
public function aService(): Service2
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class ChildTestService extends TestService
|
||||
{
|
||||
public function aChildService(): Service3
|
||||
{
|
||||
}
|
||||
}
|
||||
353
vendor/symfony/contracts/Tests/Translation/TranslatorTest.php
vendored
Normal file
353
vendor/symfony/contracts/Tests/Translation/TranslatorTest.php
vendored
Normal file
@@ -0,0 +1,353 @@
|
||||
<?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\Contracts\Tests\Translation;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorTrait;
|
||||
|
||||
/**
|
||||
* Test should cover all languages mentioned on http://translate.sourceforge.net/wiki/l10n/pluralforms
|
||||
* and Plural forms mentioned on http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms.
|
||||
*
|
||||
* See also https://developer.mozilla.org/en/Localization_and_Plurals which mentions 15 rules having a maximum of 6 forms.
|
||||
* The mozilla code is also interesting to check for.
|
||||
*
|
||||
* As mentioned by chx http://drupal.org/node/1273968 we can cover all by testing number from 0 to 199
|
||||
*
|
||||
* The goal to cover all languages is to far fetched so this test case is smaller.
|
||||
*
|
||||
* @author Clemens Tolboom clemens@build2be.nl
|
||||
*/
|
||||
class TranslatorTest extends TestCase
|
||||
{
|
||||
public function getTranslator()
|
||||
{
|
||||
return new class() implements TranslatorInterface {
|
||||
use TranslatorTrait;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTransTests
|
||||
*/
|
||||
public function testTrans($expected, $id, $parameters)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTransChoiceTests
|
||||
*/
|
||||
public function testTransChoiceWithExplicitLocale($expected, $id, $number)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
$translator->setLocale('en');
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, array('%count%' => $number)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTransChoiceTests
|
||||
*/
|
||||
public function testTransChoiceWithDefaultLocale($expected, $id, $number)
|
||||
{
|
||||
\Locale::setDefault('en');
|
||||
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, array('%count%' => $number)));
|
||||
}
|
||||
|
||||
public function testGetSetLocale()
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
$translator->setLocale('en');
|
||||
|
||||
$this->assertEquals('en', $translator->getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension intl
|
||||
*/
|
||||
public function testGetLocaleReturnsDefaultLocaleIfNotSet()
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
\Locale::setDefault('pt_BR');
|
||||
$this->assertEquals('pt_BR', $translator->getLocale());
|
||||
|
||||
\Locale::setDefault('en');
|
||||
$this->assertEquals('en', $translator->getLocale());
|
||||
}
|
||||
|
||||
public function getTransTests()
|
||||
{
|
||||
return array(
|
||||
array('Symfony is great!', 'Symfony is great!', array()),
|
||||
array('Symfony is awesome!', 'Symfony is %what%!', array('%what%' => 'awesome')),
|
||||
);
|
||||
}
|
||||
|
||||
public function getTransChoiceTests()
|
||||
{
|
||||
return array(
|
||||
array('There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1),
|
||||
array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10),
|
||||
array('There are 0 apples', 'There is 1 apple|There are %count% apples', 0),
|
||||
array('There is 1 apple', 'There is 1 apple|There are %count% apples', 1),
|
||||
array('There are 10 apples', 'There is 1 apple|There are %count% apples', 10),
|
||||
// custom validation messages may be coded with a fixed value
|
||||
array('There are 2 apples', 'There are 2 apples', 2),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInternal
|
||||
*/
|
||||
public function testInterval($expected, $number, $interval)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($interval.' foo|[1,Inf[ bar', array('%count%' => $number)));
|
||||
}
|
||||
|
||||
public function getInternal()
|
||||
{
|
||||
return array(
|
||||
array('foo', 3, '{1,2, 3 ,4}'),
|
||||
array('bar', 10, '{1,2, 3 ,4}'),
|
||||
array('bar', 3, '[1,2]'),
|
||||
array('foo', 1, '[1,2]'),
|
||||
array('foo', 2, '[1,2]'),
|
||||
array('bar', 1, ']1,2['),
|
||||
array('bar', 2, ']1,2['),
|
||||
array('foo', log(0), '[-Inf,2['),
|
||||
array('foo', -log(0), '[-2,+Inf]'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getChooseTests
|
||||
*/
|
||||
public function testChoose($expected, $id, $number)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, array('%count%' => $number)));
|
||||
}
|
||||
|
||||
public function testReturnMessageIfExactlyOneStandardRuleIsGiven()
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals('There are two apples', $translator->trans('There are two apples', array('%count%' => 2)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNonMatchingMessages
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number)
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$translator->trans($id, array('%count%' => $number));
|
||||
}
|
||||
|
||||
public function getNonMatchingMessages()
|
||||
{
|
||||
return array(
|
||||
array('{0} There are no apples|{1} There is one apple', 2),
|
||||
array('{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('{1} There is one apple|]2,Inf] There are %count% apples', 2),
|
||||
array('{0} There are no apples|There is one apple', 2),
|
||||
);
|
||||
}
|
||||
|
||||
public function getChooseTests()
|
||||
{
|
||||
return array(
|
||||
array('There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('There are no apples', '{0}There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
|
||||
array('There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1),
|
||||
|
||||
array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10),
|
||||
array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf]There are %count% apples', 10),
|
||||
array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10),
|
||||
|
||||
array('There are 0 apples', 'There is one apple|There are %count% apples', 0),
|
||||
array('There is one apple', 'There is one apple|There are %count% apples', 1),
|
||||
array('There are 10 apples', 'There is one apple|There are %count% apples', 10),
|
||||
|
||||
array('There are 0 apples', 'one: There is one apple|more: There are %count% apples', 0),
|
||||
array('There is one apple', 'one: There is one apple|more: There are %count% apples', 1),
|
||||
array('There are 10 apples', 'one: There is one apple|more: There are %count% apples', 10),
|
||||
|
||||
array('There are no apples', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 0),
|
||||
array('There is one apple', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 1),
|
||||
array('There are 10 apples', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 10),
|
||||
|
||||
array('', '{0}|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('', '{0} There are no apples|{1}|]1,Inf] There are %count% apples', 1),
|
||||
|
||||
// Indexed only tests which are Gettext PoFile* compatible strings.
|
||||
array('There are 0 apples', 'There is one apple|There are %count% apples', 0),
|
||||
array('There is one apple', 'There is one apple|There are %count% apples', 1),
|
||||
array('There are 2 apples', 'There is one apple|There are %count% apples', 2),
|
||||
|
||||
// Tests for float numbers
|
||||
array('There is almost one apple', '{0} There are no apples|]0,1[ There is almost one apple|{1} There is one apple|[1,Inf] There is more than one apple', 0.7),
|
||||
array('There is one apple', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 1),
|
||||
array('There is more than one apple', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 1.7),
|
||||
array('There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0),
|
||||
array('There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0.0),
|
||||
array('There are no apples', '{0.0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0),
|
||||
|
||||
// Test texts with new-lines
|
||||
// with double-quotes and \n in id & double-quotes and actual newlines in text
|
||||
array("This is a text with a\n new-line in it. Selector = 0.", '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 0),
|
||||
// with double-quotes and \n in id and single-quotes and actual newlines in text
|
||||
array("This is a text with a\n new-line in it. Selector = 1.", '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 1),
|
||||
array("This is a text with a\n new-line in it. Selector > 1.", '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 5),
|
||||
// with double-quotes and id split accros lines
|
||||
array('This is a text with a
|
||||
new-line in it. Selector = 1.', '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 1),
|
||||
// with single-quotes and id split accros lines
|
||||
array('This is a text with a
|
||||
new-line in it. Selector > 1.', '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 5),
|
||||
// with single-quotes and \n in text
|
||||
array('This is a text with a\nnew-line in it. Selector = 0.', '{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.', 0),
|
||||
// with double-quotes and id split accros lines
|
||||
array("This is a text with a\nnew-line in it. Selector = 1.", "{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.", 1),
|
||||
// esacape pipe
|
||||
array('This is a text with | in it. Selector = 0.', '{0}This is a text with || in it. Selector = 0.|{1}This is a text with || in it. Selector = 1.', 0),
|
||||
// Empty plural set (2 plural forms) from a .PO file
|
||||
array('', '|', 1),
|
||||
// Empty plural set (3 plural forms) from a .PO file
|
||||
array('', '||', 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider failingLangcodes
|
||||
*/
|
||||
public function testFailedLangcodes($nplural, $langCodes)
|
||||
{
|
||||
$matrix = $this->generateTestData($langCodes);
|
||||
$this->validateMatrix($nplural, $matrix, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider successLangcodes
|
||||
*/
|
||||
public function testLangcodes($nplural, $langCodes)
|
||||
{
|
||||
$matrix = $this->generateTestData($langCodes);
|
||||
$this->validateMatrix($nplural, $matrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* This array should contain all currently known langcodes.
|
||||
*
|
||||
* As it is impossible to have this ever complete we should try as hard as possible to have it almost complete.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function successLangcodes()
|
||||
{
|
||||
return array(
|
||||
array('1', array('ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky')),
|
||||
array('2', array('nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM')),
|
||||
array('3', array('be', 'bs', 'cs', 'hr')),
|
||||
array('4', array('cy', 'mt', 'sl')),
|
||||
array('6', array('ar')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This array should be at least empty within the near future.
|
||||
*
|
||||
* This both depends on a complete list trying to add above as understanding
|
||||
* the plural rules of the current failing languages.
|
||||
*
|
||||
* @return array with nplural together with langcodes
|
||||
*/
|
||||
public function failingLangcodes()
|
||||
{
|
||||
return array(
|
||||
array('1', array('fa')),
|
||||
array('2', array('jbo')),
|
||||
array('3', array('cbs')),
|
||||
array('4', array('gd', 'kw')),
|
||||
array('5', array('ga')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* We validate only on the plural coverage. Thus the real rules is not tested.
|
||||
*
|
||||
* @param string $nplural Plural expected
|
||||
* @param array $matrix Containing langcodes and their plural index values
|
||||
* @param bool $expectSuccess
|
||||
*/
|
||||
protected function validateMatrix($nplural, $matrix, $expectSuccess = true)
|
||||
{
|
||||
foreach ($matrix as $langCode => $data) {
|
||||
$indexes = array_flip($data);
|
||||
if ($expectSuccess) {
|
||||
$this->assertEquals($nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms.");
|
||||
} else {
|
||||
$this->assertNotEquals((int) $nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateTestData($langCodes)
|
||||
{
|
||||
$translator = new class() {
|
||||
use TranslatorTrait {
|
||||
getPluralizationRule as public;
|
||||
}
|
||||
};
|
||||
|
||||
$matrix = array();
|
||||
foreach ($langCodes as $langCode) {
|
||||
for ($count = 0; $count < 200; ++$count) {
|
||||
$plural = $translator->getPluralizationRule($count, $langCode);
|
||||
$matrix[$langCode][$count] = $plural;
|
||||
}
|
||||
}
|
||||
|
||||
return $matrix;
|
||||
}
|
||||
}
|
||||
31
vendor/symfony/contracts/Translation/LocaleAwareInterface.php
vendored
Normal file
31
vendor/symfony/contracts/Translation/LocaleAwareInterface.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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\Contracts\Translation;
|
||||
|
||||
interface LocaleAwareInterface
|
||||
{
|
||||
/**
|
||||
* Sets the current locale.
|
||||
*
|
||||
* @param string $locale The locale
|
||||
*
|
||||
* @throws \InvalidArgumentException If the locale contains invalid characters
|
||||
*/
|
||||
public function setLocale($locale);
|
||||
|
||||
/**
|
||||
* Returns the current locale.
|
||||
*
|
||||
* @return string The locale
|
||||
*/
|
||||
public function getLocale();
|
||||
}
|
||||
65
vendor/symfony/contracts/Translation/TranslatorInterface.php
vendored
Normal file
65
vendor/symfony/contracts/Translation/TranslatorInterface.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\Contracts\Translation;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface TranslatorInterface
|
||||
{
|
||||
/**
|
||||
* Translates the given message.
|
||||
*
|
||||
* When a number is provided as a parameter named "%count%", the message is parsed for plural
|
||||
* forms and a translation is chosen according to this number using the following rules:
|
||||
*
|
||||
* Given a message with different plural translations separated by a
|
||||
* pipe (|), this method returns the correct portion of the message based
|
||||
* on the given number, locale and the pluralization rules in the message
|
||||
* itself.
|
||||
*
|
||||
* The message supports two different types of pluralization rules:
|
||||
*
|
||||
* interval: {0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples
|
||||
* indexed: There is one apple|There are %count% apples
|
||||
*
|
||||
* The indexed solution can also contain labels (e.g. one: There is one apple).
|
||||
* This is purely for making the translations more clear - it does not
|
||||
* affect the functionality.
|
||||
*
|
||||
* The two methods can also be mixed:
|
||||
* {0} There are no apples|one: There is one apple|more: There are %count% apples
|
||||
*
|
||||
* An interval can represent a finite set of numbers:
|
||||
* {1,2,3,4}
|
||||
*
|
||||
* An interval can represent numbers between two numbers:
|
||||
* [1, +Inf]
|
||||
* ]-1,2[
|
||||
*
|
||||
* The left delimiter can be [ (inclusive) or ] (exclusive).
|
||||
* The right delimiter can be [ (exclusive) or ] (inclusive).
|
||||
* Beside numbers, you can use -Inf and +Inf for the infinite.
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/ISO_31-11
|
||||
*
|
||||
* @param string $id The message id (may also be an object that can be cast to string)
|
||||
* @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
|
||||
*
|
||||
* @return string The translated string
|
||||
*
|
||||
* @throws \InvalidArgumentException If the locale contains invalid characters
|
||||
*/
|
||||
public function trans($id, array $parameters = array(), $domain = null, $locale = null);
|
||||
}
|
||||
255
vendor/symfony/contracts/Translation/TranslatorTrait.php
vendored
Normal file
255
vendor/symfony/contracts/Translation/TranslatorTrait.php
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
<?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\Contracts\Translation;
|
||||
|
||||
use Symfony\Component\Translation\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A trait to help implement TranslatorInterface and LocaleAwareInterface.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
trait TranslatorTrait
|
||||
{
|
||||
private $locale;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = (string) $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale ?: \Locale::getDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function trans($id, array $parameters = array(), $domain = null, $locale = null)
|
||||
{
|
||||
$id = (string) $id;
|
||||
|
||||
if (!isset($parameters['%count%']) || !is_numeric($parameters['%count%'])) {
|
||||
return strtr($id, $parameters);
|
||||
}
|
||||
|
||||
$number = (float) $parameters['%count%'];
|
||||
$locale = (string) $locale ?: $this->getLocale();
|
||||
|
||||
$parts = array();
|
||||
if (preg_match('/^\|++$/', $id)) {
|
||||
$parts = explode('|', $id);
|
||||
} elseif (preg_match_all('/(?:\|\||[^\|])++/', $id, $matches)) {
|
||||
$parts = $matches[0];
|
||||
}
|
||||
|
||||
$intervalRegexp = <<<'EOF'
|
||||
/^(?P<interval>
|
||||
({\s*
|
||||
(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)
|
||||
\s*})
|
||||
|
||||
|
|
||||
|
||||
(?P<left_delimiter>[\[\]])
|
||||
\s*
|
||||
(?P<left>-Inf|\-?\d+(\.\d+)?)
|
||||
\s*,\s*
|
||||
(?P<right>\+?Inf|\-?\d+(\.\d+)?)
|
||||
\s*
|
||||
(?P<right_delimiter>[\[\]])
|
||||
)\s*(?P<message>.*?)$/xs
|
||||
EOF;
|
||||
|
||||
$standardRules = array();
|
||||
foreach ($parts as $part) {
|
||||
$part = trim(str_replace('||', '|', $part));
|
||||
|
||||
// try to match an explicit rule, then fallback to the standard ones
|
||||
if (preg_match($intervalRegexp, $part, $matches)) {
|
||||
if ($matches[2]) {
|
||||
foreach (explode(',', $matches[3]) as $n) {
|
||||
if ($number == $n) {
|
||||
return strtr($matches['message'], $parameters);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$leftNumber = '-Inf' === $matches['left'] ? -INF : (float) $matches['left'];
|
||||
$rightNumber = \is_numeric($matches['right']) ? (float) $matches['right'] : INF;
|
||||
|
||||
if (('[' === $matches['left_delimiter'] ? $number >= $leftNumber : $number > $leftNumber)
|
||||
&& (']' === $matches['right_delimiter'] ? $number <= $rightNumber : $number < $rightNumber)
|
||||
) {
|
||||
return strtr($matches['message'], $parameters);
|
||||
}
|
||||
}
|
||||
} elseif (preg_match('/^\w+\:\s*(.*?)$/', $part, $matches)) {
|
||||
$standardRules[] = $matches[1];
|
||||
} else {
|
||||
$standardRules[] = $part;
|
||||
}
|
||||
}
|
||||
|
||||
$position = $this->getPluralizationRule($number, $locale);
|
||||
|
||||
if (!isset($standardRules[$position])) {
|
||||
// when there's exactly one rule given, and that rule is a standard
|
||||
// rule, use this rule
|
||||
if (1 === \count($parts) && isset($standardRules[0])) {
|
||||
return strtr($standardRules[0], $parameters);
|
||||
}
|
||||
|
||||
$message = sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number);
|
||||
|
||||
if (\class_exists(InvalidArgumentException::class)) {
|
||||
throw new InvalidArgumentException($message);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException($message);
|
||||
}
|
||||
|
||||
return strtr($standardRules[$position], $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plural position to use for the given locale and number.
|
||||
*
|
||||
* The plural rules are derived from code of the Zend Framework (2010-09-25),
|
||||
* which is subject to the new BSD license (http://framework.zend.com/license/new-bsd).
|
||||
* Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
*/
|
||||
private function getPluralizationRule(int $number, string $locale): int
|
||||
{
|
||||
switch ('pt_BR' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) {
|
||||
case 'af':
|
||||
case 'bn':
|
||||
case 'bg':
|
||||
case 'ca':
|
||||
case 'da':
|
||||
case 'de':
|
||||
case 'el':
|
||||
case 'en':
|
||||
case 'eo':
|
||||
case 'es':
|
||||
case 'et':
|
||||
case 'eu':
|
||||
case 'fa':
|
||||
case 'fi':
|
||||
case 'fo':
|
||||
case 'fur':
|
||||
case 'fy':
|
||||
case 'gl':
|
||||
case 'gu':
|
||||
case 'ha':
|
||||
case 'he':
|
||||
case 'hu':
|
||||
case 'is':
|
||||
case 'it':
|
||||
case 'ku':
|
||||
case 'lb':
|
||||
case 'ml':
|
||||
case 'mn':
|
||||
case 'mr':
|
||||
case 'nah':
|
||||
case 'nb':
|
||||
case 'ne':
|
||||
case 'nl':
|
||||
case 'nn':
|
||||
case 'no':
|
||||
case 'oc':
|
||||
case 'om':
|
||||
case 'or':
|
||||
case 'pa':
|
||||
case 'pap':
|
||||
case 'ps':
|
||||
case 'pt':
|
||||
case 'so':
|
||||
case 'sq':
|
||||
case 'sv':
|
||||
case 'sw':
|
||||
case 'ta':
|
||||
case 'te':
|
||||
case 'tk':
|
||||
case 'ur':
|
||||
case 'zu':
|
||||
return (1 == $number) ? 0 : 1;
|
||||
|
||||
case 'am':
|
||||
case 'bh':
|
||||
case 'fil':
|
||||
case 'fr':
|
||||
case 'gun':
|
||||
case 'hi':
|
||||
case 'hy':
|
||||
case 'ln':
|
||||
case 'mg':
|
||||
case 'nso':
|
||||
case 'pt_BR':
|
||||
case 'ti':
|
||||
case 'wa':
|
||||
return ((0 == $number) || (1 == $number)) ? 0 : 1;
|
||||
|
||||
case 'be':
|
||||
case 'bs':
|
||||
case 'hr':
|
||||
case 'ru':
|
||||
case 'sh':
|
||||
case 'sr':
|
||||
case 'uk':
|
||||
return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
|
||||
|
||||
case 'cs':
|
||||
case 'sk':
|
||||
return (1 == $number) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
|
||||
|
||||
case 'ga':
|
||||
return (1 == $number) ? 0 : ((2 == $number) ? 1 : 2);
|
||||
|
||||
case 'lt':
|
||||
return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
|
||||
|
||||
case 'sl':
|
||||
return (1 == $number % 100) ? 0 : ((2 == $number % 100) ? 1 : (((3 == $number % 100) || (4 == $number % 100)) ? 2 : 3));
|
||||
|
||||
case 'mk':
|
||||
return (1 == $number % 10) ? 0 : 1;
|
||||
|
||||
case 'mt':
|
||||
return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
|
||||
|
||||
case 'lv':
|
||||
return (0 == $number) ? 0 : (((1 == $number % 10) && (11 != $number % 100)) ? 1 : 2);
|
||||
|
||||
case 'pl':
|
||||
return (1 == $number) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
|
||||
|
||||
case 'cy':
|
||||
return (1 == $number) ? 0 : ((2 == $number) ? 1 : (((8 == $number) || (11 == $number)) ? 2 : 3));
|
||||
|
||||
case 'ro':
|
||||
return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
|
||||
|
||||
case 'ar':
|
||||
return (0 == $number) ? 0 : ((1 == $number) ? 1 : ((2 == $number) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
vendor/symfony/contracts/composer.json
vendored
Normal file
44
vendor/symfony/contracts/composer.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "symfony/contracts",
|
||||
"type": "library",
|
||||
"description": "A set of abstractions extracted out of the Symfony components",
|
||||
"keywords": ["abstractions", "contracts", "decoupling", "interfaces", "interoperability", "standards"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/cache": "^1.0",
|
||||
"psr/container": "^1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/cache": "When using the Cache contracts",
|
||||
"psr/container": "When using the Service contracts",
|
||||
"symfony/cache-contracts-implementation": "",
|
||||
"symfony/service-contracts-implementation": "",
|
||||
"symfony/translation-contracts-implementation": ""
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Contracts\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"**/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
31
vendor/symfony/contracts/phpunit.xml.dist
vendored
Normal file
31
vendor/symfony/contracts/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Symfony Contracts Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
</phpunit>
|
||||
@@ -19,6 +19,6 @@ namespace Symfony\Component\CssSelector\Exception;
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*/
|
||||
interface ExceptionInterface
|
||||
interface ExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
||||
|
||||
2
vendor/symfony/css-selector/composer.json
vendored
2
vendor/symfony/css-selector/composer.json
vendored
@@ -31,7 +31,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/symfony/css-selector/phpunit.xml.dist
vendored
2
vendor/symfony/css-selector/phpunit.xml.dist
vendored
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
|
||||
2
vendor/symfony/debug/Debug.php
vendored
2
vendor/symfony/debug/Debug.php
vendored
@@ -45,7 +45,7 @@ class Debug
|
||||
if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
|
||||
ini_set('display_errors', 0);
|
||||
ExceptionHandler::register();
|
||||
} elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
|
||||
} elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
|
||||
// CLI - display errors only if they're not already logged to STDERR
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
62
vendor/symfony/debug/DebugClassLoader.php
vendored
62
vendor/symfony/debug/DebugClassLoader.php
vendored
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Debug;
|
||||
|
||||
use PHPUnit\Framework\MockObject\Matcher\StatelessInvocation;
|
||||
|
||||
/**
|
||||
* Autoloader checking if the class is really defined in the file found.
|
||||
*
|
||||
@@ -21,6 +23,7 @@ namespace Symfony\Component\Debug;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
* @author Guilhem Niot <guilhem.niot@gmail.com>
|
||||
*/
|
||||
class DebugClassLoader
|
||||
{
|
||||
@@ -34,6 +37,7 @@ class DebugClassLoader
|
||||
private static $deprecated = array();
|
||||
private static $internal = array();
|
||||
private static $internalMethods = array();
|
||||
private static $annotatedParameters = array();
|
||||
private static $darwinCache = array('/' => array('/', array()));
|
||||
|
||||
public function __construct(callable $classLoader)
|
||||
@@ -137,14 +141,14 @@ class DebugClassLoader
|
||||
try {
|
||||
if ($this->isFinder && !isset($this->loaded[$class])) {
|
||||
$this->loaded[$class] = true;
|
||||
if ($file = $this->classLoader[0]->findFile($class) ?: false) {
|
||||
$wasCached = \function_exists('opcache_is_script_cached') && @opcache_is_script_cached($file);
|
||||
|
||||
if (!$file = $this->classLoader[0]->findFile($class) ?: false) {
|
||||
// no-op
|
||||
} elseif (\function_exists('opcache_is_script_cached') && @opcache_is_script_cached($file)) {
|
||||
require $file;
|
||||
|
||||
if ($wasCached) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
require $file;
|
||||
}
|
||||
} else {
|
||||
\call_user_func($this->classLoader, $class);
|
||||
@@ -260,11 +264,12 @@ class DebugClassLoader
|
||||
return $deprecations;
|
||||
}
|
||||
|
||||
// Inherit @final and @internal annotations for methods
|
||||
// Inherit @final, @internal and @param annotations for methods
|
||||
self::$finalMethods[$class] = array();
|
||||
self::$internalMethods[$class] = array();
|
||||
self::$annotatedParameters[$class] = array();
|
||||
foreach ($parentAndOwnInterfaces as $use) {
|
||||
foreach (array('finalMethods', 'internalMethods') as $property) {
|
||||
foreach (array('finalMethods', 'internalMethods', 'annotatedParameters') as $property) {
|
||||
if (isset(self::${$property}[$use])) {
|
||||
self::${$property}[$class] = self::${$property}[$class] ? self::${$property}[$use] + self::${$property}[$class] : self::${$property}[$use];
|
||||
}
|
||||
@@ -288,15 +293,52 @@ class DebugClassLoader
|
||||
}
|
||||
}
|
||||
|
||||
// Detect method annotations
|
||||
if (false === $doc = $method->getDocComment()) {
|
||||
// To read method annotations
|
||||
$doc = $method->getDocComment();
|
||||
|
||||
if (isset(self::$annotatedParameters[$class][$method->name])) {
|
||||
$definedParameters = array();
|
||||
foreach ($method->getParameters() as $parameter) {
|
||||
$definedParameters[$parameter->name] = true;
|
||||
}
|
||||
|
||||
foreach (self::$annotatedParameters[$class][$method->name] as $parameterName => $deprecation) {
|
||||
if (!isset($definedParameters[$parameterName]) && !($doc && preg_match("/\\n\\s+\\* @param (.*?)(?<= )\\\${$parameterName}\\b/", $doc))) {
|
||||
$deprecations[] = sprintf($deprecation, $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$doc) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$finalOrInternal = false;
|
||||
|
||||
foreach (array('final', 'internal') as $annotation) {
|
||||
if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) {
|
||||
$message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
|
||||
self::${$annotation.'Methods'}[$class][$method->name] = array($class, $message);
|
||||
$finalOrInternal = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($finalOrInternal || $method->isConstructor() || false === \strpos($doc, '@param') || StatelessInvocation::class === $class) {
|
||||
continue;
|
||||
}
|
||||
if (!preg_match_all('#\n\s+\* @param (.*?)(?<= )\$([a-zA-Z0-9_\x7f-\xff]++)#', $doc, $matches, PREG_SET_ORDER)) {
|
||||
continue;
|
||||
}
|
||||
if (!isset(self::$annotatedParameters[$class][$method->name])) {
|
||||
$definedParameters = array();
|
||||
foreach ($method->getParameters() as $parameter) {
|
||||
$definedParameters[$parameter->name] = true;
|
||||
}
|
||||
}
|
||||
foreach ($matches as list(, $parameterType, $parameterName)) {
|
||||
if (!isset($definedParameters[$parameterName])) {
|
||||
$parameterType = trim($parameterType);
|
||||
self::$annotatedParameters[$class][$method->name][$parameterName] = sprintf('The "%%s::%s()" method will require a new "%s$%s" argument in the next major version of its parent class "%s", not defining it is deprecated.', $method->name, $parameterType ? $parameterType.' ' : '', $parameterName, $method->class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
vendor/symfony/debug/ErrorHandler.php
vendored
33
vendor/symfony/debug/ErrorHandler.php
vendored
@@ -15,6 +15,7 @@ use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Debug\Exception\FatalErrorException;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\Debug\Exception\OutOfMemoryException;
|
||||
use Symfony\Component\Debug\Exception\SilencedErrorContext;
|
||||
use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
|
||||
@@ -405,15 +406,19 @@ class ErrorHandler
|
||||
$context = $e;
|
||||
}
|
||||
|
||||
$logMessage = $this->levels[$type].': '.$message;
|
||||
if (false !== strpos($message, "class@anonymous\0")) {
|
||||
$logMessage = $this->levels[$type].': '.(new FlattenException())->setMessage($message)->getMessage();
|
||||
} else {
|
||||
$logMessage = $this->levels[$type].': '.$message;
|
||||
}
|
||||
|
||||
if (null !== self::$toStringException) {
|
||||
$errorAsException = self::$toStringException;
|
||||
self::$toStringException = null;
|
||||
} elseif (!$throw && !($type & $level)) {
|
||||
if (!isset(self::$silencedErrorCache[$id = $file.':'.$line])) {
|
||||
$lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3), $type, $file, $line, false) : array();
|
||||
$errorAsException = new SilencedErrorContext($type, $file, $line, $lightTrace);
|
||||
$lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5), $type, $file, $line, false) : array();
|
||||
$errorAsException = new SilencedErrorContext($type, $file, $line, isset($lightTrace[1]) ? array($lightTrace[0]) : $lightTrace);
|
||||
} elseif (isset(self::$silencedErrorCache[$id][$message])) {
|
||||
$lightTrace = null;
|
||||
$errorAsException = self::$silencedErrorCache[$id][$message];
|
||||
@@ -436,7 +441,6 @@ class ErrorHandler
|
||||
} else {
|
||||
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
|
||||
|
||||
// Clean the trace by removing function arguments and the first frames added by the error handler itself.
|
||||
if ($throw || $this->tracedErrors & $type) {
|
||||
$backtrace = $errorAsException->getTrace();
|
||||
$lightTrace = $this->cleanTrace($backtrace, $type, $file, $line, $throw);
|
||||
@@ -518,21 +522,24 @@ class ErrorHandler
|
||||
$handlerException = null;
|
||||
|
||||
if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
|
||||
if (false !== strpos($message = $exception->getMessage(), "class@anonymous\0")) {
|
||||
$message = (new FlattenException())->setMessage($message)->getMessage();
|
||||
}
|
||||
if ($exception instanceof FatalErrorException) {
|
||||
if ($exception instanceof FatalThrowableError) {
|
||||
$error = array(
|
||||
'type' => $type,
|
||||
'message' => $message = $exception->getMessage(),
|
||||
'message' => $message,
|
||||
'file' => $exception->getFile(),
|
||||
'line' => $exception->getLine(),
|
||||
);
|
||||
} else {
|
||||
$message = 'Fatal '.$exception->getMessage();
|
||||
$message = 'Fatal '.$message;
|
||||
}
|
||||
} elseif ($exception instanceof \ErrorException) {
|
||||
$message = 'Uncaught '.$exception->getMessage();
|
||||
$message = 'Uncaught '.$message;
|
||||
} else {
|
||||
$message = 'Uncaught Exception: '.$exception->getMessage();
|
||||
$message = 'Uncaught Exception: '.$message;
|
||||
}
|
||||
}
|
||||
if ($this->loggedErrors & $type) {
|
||||
@@ -661,6 +668,9 @@ class ErrorHandler
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader.
|
||||
*/
|
||||
private function cleanTrace($backtrace, $type, $file, $line, $throw)
|
||||
{
|
||||
$lightTrace = $backtrace;
|
||||
@@ -671,6 +681,13 @@ class ErrorHandler
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (class_exists(DebugClassLoader::class, false)) {
|
||||
for ($i = \count($lightTrace) - 2; 0 < $i; --$i) {
|
||||
if (DebugClassLoader::class === ($lightTrace[$i]['class'] ?? null)) {
|
||||
array_splice($lightTrace, --$i, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!($throw || $this->scopedErrors & $type)) {
|
||||
for ($i = 0; isset($lightTrace[$i]); ++$i) {
|
||||
unset($lightTrace[$i]['args'], $lightTrace[$i]['object']);
|
||||
|
||||
@@ -90,9 +90,14 @@ class FlattenException
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatusCode($code)
|
||||
{
|
||||
$this->statusCode = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHeaders()
|
||||
@@ -100,9 +105,14 @@ class FlattenException
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaders(array $headers)
|
||||
{
|
||||
$this->headers = $headers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getClass()
|
||||
@@ -110,9 +120,14 @@ class FlattenException
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setClass($class)
|
||||
{
|
||||
$this->class = $class;
|
||||
$this->class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFile()
|
||||
@@ -120,9 +135,14 @@ class FlattenException
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setFile($file)
|
||||
{
|
||||
$this->file = $file;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLine()
|
||||
@@ -130,9 +150,14 @@ class FlattenException
|
||||
return $this->line;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setLine($line)
|
||||
{
|
||||
$this->line = $line;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMessage()
|
||||
@@ -140,9 +165,20 @@ class FlattenException
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setMessage($message)
|
||||
{
|
||||
if (false !== strpos($message, "class@anonymous\0")) {
|
||||
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
|
||||
return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
|
||||
}, $message);
|
||||
}
|
||||
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
@@ -150,9 +186,14 @@ class FlattenException
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrevious()
|
||||
@@ -160,9 +201,14 @@ class FlattenException
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setPrevious(self $previous)
|
||||
{
|
||||
$this->previous = $previous;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAllPrevious()
|
||||
@@ -191,11 +237,14 @@ class FlattenException
|
||||
$this->setTraceFromThrowable($exception);
|
||||
}
|
||||
|
||||
public function setTraceFromThrowable(\Throwable $throwable): void
|
||||
public function setTraceFromThrowable(\Throwable $throwable)
|
||||
{
|
||||
$this->setTrace($throwable->getTrace(), $throwable->getFile(), $throwable->getLine());
|
||||
return $this->setTrace($throwable->getTrace(), $throwable->getFile(), $throwable->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setTrace($trace, $file, $line)
|
||||
{
|
||||
$this->trace = array();
|
||||
@@ -229,6 +278,8 @@ class FlattenException
|
||||
'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function flattenArgs($args, $level = 0, &$count = 0)
|
||||
|
||||
3
vendor/symfony/debug/ExceptionHandler.php
vendored
3
vendor/symfony/debug/ExceptionHandler.php
vendored
@@ -253,7 +253,8 @@ EOF
|
||||
} catch (\Exception $e) {
|
||||
// something nasty happened and we cannot throw an exception anymore
|
||||
if ($this->debug) {
|
||||
$title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
|
||||
$e = FlattenException::create($e);
|
||||
$title = sprintf('Exception thrown when handling an exception (%s: %s)', $e->getClass(), $this->escapeHtml($e->getMessage()));
|
||||
} else {
|
||||
$title = 'Whoops, looks like something went wrong.';
|
||||
}
|
||||
|
||||
@@ -273,6 +273,24 @@ class DebugClassLoaderTest extends TestCase
|
||||
));
|
||||
}
|
||||
|
||||
public function testExtendedMethodDefinesNewParameters()
|
||||
{
|
||||
$deprecations = array();
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
|
||||
$e = error_reporting(E_USER_DEPRECATED);
|
||||
|
||||
class_exists(__NAMESPACE__.'\\Fixtures\SubClassWithAnnotatedParameters', true);
|
||||
|
||||
error_reporting($e);
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertSame(array(
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::quzMethod()" method will require a new "Quz $quz" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::whereAmI()" method will require a new "bool $matrix" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::isSymfony()" method will require a new "true $yes" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
|
||||
), $deprecations);
|
||||
}
|
||||
|
||||
public function testUseTraitWithInternalMethod()
|
||||
{
|
||||
$deprecations = array();
|
||||
|
||||
@@ -333,6 +333,19 @@ class FlattenExceptionTest extends TestCase
|
||||
$this->assertNotContains('*value1*', $serializeTrace);
|
||||
}
|
||||
|
||||
public function testAnonymousClass()
|
||||
{
|
||||
$flattened = FlattenException::create(new class() extends \RuntimeException {
|
||||
});
|
||||
|
||||
$this->assertSame('RuntimeException@anonymous', $flattened->getClass());
|
||||
|
||||
$flattened = FlattenException::create(new \Exception(sprintf('Class "%s" blah.', \get_class(new class() extends \RuntimeException {
|
||||
}))));
|
||||
|
||||
$this->assertSame('Class "RuntimeException@anonymous" blah.', $flattened->getMessage());
|
||||
}
|
||||
|
||||
private function createException($foo)
|
||||
{
|
||||
return new \Exception();
|
||||
|
||||
34
vendor/symfony/debug/Tests/Fixtures/ClassWithAnnotatedParameters.php
vendored
Normal file
34
vendor/symfony/debug/Tests/Fixtures/ClassWithAnnotatedParameters.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
|
||||
class ClassWithAnnotatedParameters
|
||||
{
|
||||
/**
|
||||
* @param string $foo this is a foo parameter
|
||||
*/
|
||||
public function fooMethod(string $foo)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $bar parameter not implemented yet
|
||||
*/
|
||||
public function barMethod(/* string $bar = null */)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Quz $quz parameter not implemented yet
|
||||
*/
|
||||
public function quzMethod(/* Quz $quz = null */)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param true $yes
|
||||
*/
|
||||
public function isSymfony()
|
||||
{
|
||||
}
|
||||
}
|
||||
14
vendor/symfony/debug/Tests/Fixtures/InterfaceWithAnnotatedParameters.php
vendored
Normal file
14
vendor/symfony/debug/Tests/Fixtures/InterfaceWithAnnotatedParameters.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
|
||||
/**
|
||||
* Ensures a deprecation is triggered when a new parameter is not declared in child classes.
|
||||
*/
|
||||
interface InterfaceWithAnnotatedParameters
|
||||
{
|
||||
/**
|
||||
* @param bool $matrix
|
||||
*/
|
||||
public function whereAmI();
|
||||
}
|
||||
24
vendor/symfony/debug/Tests/Fixtures/SubClassWithAnnotatedParameters.php
vendored
Normal file
24
vendor/symfony/debug/Tests/Fixtures/SubClassWithAnnotatedParameters.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
|
||||
class SubClassWithAnnotatedParameters extends ClassWithAnnotatedParameters implements InterfaceWithAnnotatedParameters
|
||||
{
|
||||
use TraitWithAnnotatedParameters;
|
||||
|
||||
public function fooMethod(string $foo)
|
||||
{
|
||||
}
|
||||
|
||||
public function barMethod($bar = null)
|
||||
{
|
||||
}
|
||||
|
||||
public function quzMethod()
|
||||
{
|
||||
}
|
||||
|
||||
public function whereAmI()
|
||||
{
|
||||
}
|
||||
}
|
||||
13
vendor/symfony/debug/Tests/Fixtures/TraitWithAnnotatedParameters.php
vendored
Normal file
13
vendor/symfony/debug/Tests/Fixtures/TraitWithAnnotatedParameters.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
|
||||
trait TraitWithAnnotatedParameters
|
||||
{
|
||||
/**
|
||||
* `@param` annotations in traits are not parsed.
|
||||
*/
|
||||
public function isSymfony()
|
||||
{
|
||||
}
|
||||
}
|
||||
2
vendor/symfony/debug/composer.json
vendored
2
vendor/symfony/debug/composer.json
vendored
@@ -34,7 +34,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/symfony/debug/phpunit.xml.dist
vendored
2
vendor/symfony/debug/phpunit.xml.dist
vendored
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
|
||||
@@ -134,19 +134,24 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
||||
}
|
||||
|
||||
$this->preProcess($eventName);
|
||||
$this->preDispatch($eventName, $event);
|
||||
|
||||
$e = $this->stopwatch->start($eventName, 'section');
|
||||
|
||||
$this->dispatcher->dispatch($eventName, $event);
|
||||
|
||||
if ($e->isStarted()) {
|
||||
$e->stop();
|
||||
try {
|
||||
$this->preDispatch($eventName, $event);
|
||||
try {
|
||||
$e = $this->stopwatch->start($eventName, 'section');
|
||||
try {
|
||||
$this->dispatcher->dispatch($eventName, $event);
|
||||
} finally {
|
||||
if ($e->isStarted()) {
|
||||
$e->stop();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
$this->postDispatch($eventName, $event);
|
||||
}
|
||||
} finally {
|
||||
$this->postProcess($eventName);
|
||||
}
|
||||
|
||||
$this->postDispatch($eventName, $event);
|
||||
$this->postProcess($eventName);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
@@ -230,7 +235,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
||||
*/
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
return \call_user_func_array(array($this->dispatcher, $method), $arguments);
|
||||
return $this->dispatcher->{$method}(...$arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +268,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
||||
|
||||
foreach ($this->dispatcher->getListeners($eventName) as $listener) {
|
||||
$priority = $this->getListenerPriority($eventName, $listener);
|
||||
$wrappedListener = new WrappedListener($listener, null, $this->stopwatch, $this);
|
||||
$wrappedListener = new WrappedListener($listener instanceof WrappedListener ? $listener->getWrappedListener() : $listener, null, $this->stopwatch, $this);
|
||||
$this->wrappedListeners[$eventName][] = $wrappedListener;
|
||||
$this->dispatcher->removeListener($eventName, $listener);
|
||||
$this->dispatcher->addListener($eventName, $wrappedListener, $priority);
|
||||
|
||||
@@ -12,13 +12,14 @@
|
||||
namespace Symfony\Component\EventDispatcher\Debug;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.1
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface TraceableEventDispatcherInterface extends EventDispatcherInterface
|
||||
interface TraceableEventDispatcherInterface extends EventDispatcherInterface, ResetInterface
|
||||
{
|
||||
/**
|
||||
* Gets the called listeners.
|
||||
@@ -33,9 +34,4 @@ interface TraceableEventDispatcherInterface extends EventDispatcherInterface
|
||||
* @return array An array of not called listeners
|
||||
*/
|
||||
public function getNotCalledListeners();
|
||||
|
||||
/**
|
||||
* Resets the trace.
|
||||
*/
|
||||
public function reset();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ class WrappedListener
|
||||
public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->listener = $listener;
|
||||
$this->name = $name;
|
||||
$this->stopwatch = $stopwatch;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->called = false;
|
||||
@@ -44,7 +43,15 @@ class WrappedListener
|
||||
$this->name = \is_object($listener[0]) ? \get_class($listener[0]) : $listener[0];
|
||||
$this->pretty = $this->name.'::'.$listener[1];
|
||||
} elseif ($listener instanceof \Closure) {
|
||||
$this->pretty = $this->name = 'closure';
|
||||
$r = new \ReflectionFunction($listener);
|
||||
if (false !== strpos($r->name, '{closure}')) {
|
||||
$this->pretty = $this->name = 'closure';
|
||||
} elseif ($class = $r->getClosureScopeClass()) {
|
||||
$this->name = $class->name;
|
||||
$this->pretty = $this->name.'::'.$r->name;
|
||||
} else {
|
||||
$this->pretty = $this->name = $r->name;
|
||||
}
|
||||
} elseif (\is_string($listener)) {
|
||||
$this->pretty = $this->name = $listener;
|
||||
} else {
|
||||
|
||||
@@ -38,7 +38,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
/**
|
||||
* Getter for subject property.
|
||||
*
|
||||
* @return mixed $subject The observer subject
|
||||
* @return mixed The observer subject
|
||||
*/
|
||||
public function getSubject()
|
||||
{
|
||||
|
||||
@@ -426,7 +426,7 @@ class TestEventSubscriberWithPriorities implements EventSubscriberInterface
|
||||
return array(
|
||||
'pre.foo' => array('preFoo', 10),
|
||||
'post.foo' => array('postFoo'),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
64
vendor/symfony/event-dispatcher/Tests/Debug/WrappedListenerTest.php
vendored
Normal file
64
vendor/symfony/event-dispatcher/Tests/Debug/WrappedListenerTest.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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\EventDispatcher\Tests\Debug;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\EventDispatcher\Debug\WrappedListener;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
|
||||
class WrappedListenerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideListenersToDescribe
|
||||
*/
|
||||
public function testListenerDescription(callable $listener, $expected)
|
||||
{
|
||||
$wrappedListener = new WrappedListener($listener, null, $this->getMockBuilder(Stopwatch::class)->getMock(), $this->getMockBuilder(EventDispatcherInterface::class)->getMock());
|
||||
|
||||
$this->assertStringMatchesFormat($expected, $wrappedListener->getPretty());
|
||||
}
|
||||
|
||||
public function provideListenersToDescribe()
|
||||
{
|
||||
$listeners = 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'),
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
class FooListener
|
||||
{
|
||||
public function listen()
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke()
|
||||
{
|
||||
}
|
||||
|
||||
public static function listenStatic()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -31,8 +31,6 @@ class GenericEventTest extends TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->subject = new \stdClass();
|
||||
$this->event = new GenericEvent($this->subject, array('name' => 'Event'));
|
||||
}
|
||||
@@ -44,8 +42,6 @@ class GenericEventTest extends TestCase
|
||||
{
|
||||
$this->subject = null;
|
||||
$this->event = null;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testConstruct()
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
"php": "^7.1.3",
|
||||
"symfony/contracts": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
@@ -41,7 +42,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
|
||||
8
vendor/symfony/finder/CHANGELOG.md
vendored
8
vendor/symfony/finder/CHANGELOG.md
vendored
@@ -1,6 +1,14 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* added $useNaturalSort option to Finder::sortByName() method
|
||||
* the `Finder::sortByName()` method will have a new `$useNaturalSort`
|
||||
argument in version 5.0, not defining it is deprecated
|
||||
* added `Finder::reverseSorting()` to reverse the sorting
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
|
||||
96
vendor/symfony/finder/Finder.php
vendored
96
vendor/symfony/finder/Finder.php
vendored
@@ -48,6 +48,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
private $depths = array();
|
||||
private $sizes = array();
|
||||
private $followLinks = false;
|
||||
private $reverseSorting = false;
|
||||
private $sort = false;
|
||||
private $ignore = 0;
|
||||
private $dirs = array();
|
||||
@@ -107,17 +108,20 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* $finder->depth('> 1') // the Finder will start matching at level 1.
|
||||
* $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
|
||||
* $finder->depth(['>= 1', '< 3'])
|
||||
*
|
||||
* @param string|int $level The depth level expression
|
||||
* @param string|int|string[]|int[] $levels The depth level expression or an array of depth levels
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see DepthRangeFilterIterator
|
||||
* @see NumberComparator
|
||||
*/
|
||||
public function depth($level)
|
||||
public function depth($levels)
|
||||
{
|
||||
$this->depths[] = new Comparator\NumberComparator($level);
|
||||
foreach ((array) $levels as $level) {
|
||||
$this->depths[] = new Comparator\NumberComparator($level);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -131,8 +135,9 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
* $finder->date('until 2 days ago');
|
||||
* $finder->date('> now - 2 hours');
|
||||
* $finder->date('>= 2005-10-15');
|
||||
* $finder->date(['>= 2005-10-15', '<= 2006-05-27']);
|
||||
*
|
||||
* @param string $date A date range string
|
||||
* @param string|string[] $dates A date range string or an array of date ranges
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
@@ -140,9 +145,11 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
* @see DateRangeFilterIterator
|
||||
* @see DateComparator
|
||||
*/
|
||||
public function date($date)
|
||||
public function date($dates)
|
||||
{
|
||||
$this->dates[] = new Comparator\DateComparator($date);
|
||||
foreach ((array) $dates as $date) {
|
||||
$this->dates[] = new Comparator\DateComparator($date);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -155,16 +162,17 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
* $finder->name('*.php')
|
||||
* $finder->name('/\.php$/') // same as above
|
||||
* $finder->name('test.php')
|
||||
* $finder->name(['test.py', 'test.php'])
|
||||
*
|
||||
* @param string $pattern A pattern (a regexp, a glob, or a string)
|
||||
* @param string|string[] $patterns A pattern (a regexp, a glob, or a string) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function name($pattern)
|
||||
public function name($patterns)
|
||||
{
|
||||
$this->names[] = $pattern;
|
||||
$this->names = \array_merge($this->names, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -172,15 +180,15 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Adds rules that files must not match.
|
||||
*
|
||||
* @param string $pattern A pattern (a regexp, a glob, or a string)
|
||||
* @param string|string[] $patterns A pattern (a regexp, a glob, or a string) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function notName($pattern)
|
||||
public function notName($patterns)
|
||||
{
|
||||
$this->notNames[] = $pattern;
|
||||
$this->notNames = \array_merge($this->notNames, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -192,16 +200,17 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* $finder->contains('Lorem ipsum')
|
||||
* $finder->contains('/Lorem ipsum/i')
|
||||
* $finder->contains(['dolor', '/ipsum/i'])
|
||||
*
|
||||
* @param string $pattern A pattern (string or regexp)
|
||||
* @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilecontentFilterIterator
|
||||
*/
|
||||
public function contains($pattern)
|
||||
public function contains($patterns)
|
||||
{
|
||||
$this->contains[] = $pattern;
|
||||
$this->contains = \array_merge($this->contains, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -213,16 +222,17 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* $finder->notContains('Lorem ipsum')
|
||||
* $finder->notContains('/Lorem ipsum/i')
|
||||
* $finder->notContains(['lorem', '/dolor/i'])
|
||||
*
|
||||
* @param string $pattern A pattern (string or regexp)
|
||||
* @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilecontentFilterIterator
|
||||
*/
|
||||
public function notContains($pattern)
|
||||
public function notContains($patterns)
|
||||
{
|
||||
$this->notContains[] = $pattern;
|
||||
$this->notContains = \array_merge($this->notContains, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -234,18 +244,19 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* $finder->path('some/special/dir')
|
||||
* $finder->path('/some\/special\/dir/') // same as above
|
||||
* $finder->path(['some dir', 'another/dir'])
|
||||
*
|
||||
* Use only / as dirname separator.
|
||||
*
|
||||
* @param string $pattern A pattern (a regexp or a string)
|
||||
* @param string|string[] $patterns A pattern (a regexp or a string) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function path($pattern)
|
||||
public function path($patterns)
|
||||
{
|
||||
$this->paths[] = $pattern;
|
||||
$this->paths = \array_merge($this->paths, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -257,18 +268,19 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* $finder->notPath('some/special/dir')
|
||||
* $finder->notPath('/some\/special\/dir/') // same as above
|
||||
* $finder->notPath(['some/file.txt', 'another/file.log'])
|
||||
*
|
||||
* Use only / as dirname separator.
|
||||
*
|
||||
* @param string $pattern A pattern (a regexp or a string)
|
||||
* @param string|string[] $patterns A pattern (a regexp or a string) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function notPath($pattern)
|
||||
public function notPath($patterns)
|
||||
{
|
||||
$this->notPaths[] = $pattern;
|
||||
$this->notPaths = \array_merge($this->notPaths, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -279,17 +291,20 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
* $finder->size('> 10K');
|
||||
* $finder->size('<= 1Ki');
|
||||
* $finder->size(4);
|
||||
* $finder->size(['> 10K', '< 20K'])
|
||||
*
|
||||
* @param string|int $size A size range string or an integer
|
||||
* @param string|int|string[]|int[] $sizes A size range string or an integer or an array of size ranges
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SizeRangeFilterIterator
|
||||
* @see NumberComparator
|
||||
*/
|
||||
public function size($size)
|
||||
public function size($sizes)
|
||||
{
|
||||
$this->sizes[] = new Comparator\NumberComparator($size);
|
||||
foreach ((array) $sizes as $size) {
|
||||
$this->sizes[] = new Comparator\NumberComparator($size);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -397,13 +412,20 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* This can be slow as all the matching files and directories must be retrieved for comparison.
|
||||
*
|
||||
* @param bool $useNaturalSort Whether to use natural sort or not, disabled by default
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByName()
|
||||
public function sortByName(/* bool $useNaturalSort = false */)
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_NAME;
|
||||
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
|
||||
@trigger_error(sprintf('The "%s()" method will have a new "bool $useNaturalSort = false" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
$useNaturalSort = 0 < \func_num_args() && func_get_arg(0);
|
||||
|
||||
$this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -442,6 +464,18 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses the sorting.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function reverseSorting()
|
||||
{
|
||||
$this->reverseSorting = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts files and directories by the last inode changed time.
|
||||
*
|
||||
@@ -716,8 +750,8 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
|
||||
}
|
||||
|
||||
if ($this->sort) {
|
||||
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
|
||||
if ($this->sort || $this->reverseSorting) {
|
||||
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting);
|
||||
$iterator = $iteratorAggregate->getIterator();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ namespace Symfony\Component\Finder\Iterator;
|
||||
*/
|
||||
class SortableIterator implements \IteratorAggregate
|
||||
{
|
||||
const SORT_BY_NONE = 0;
|
||||
const SORT_BY_NAME = 1;
|
||||
const SORT_BY_TYPE = 2;
|
||||
const SORT_BY_ACCESSED_TIME = 3;
|
||||
const SORT_BY_CHANGED_TIME = 4;
|
||||
const SORT_BY_MODIFIED_TIME = 5;
|
||||
const SORT_BY_NAME_NATURAL = 6;
|
||||
|
||||
private $iterator;
|
||||
private $sort;
|
||||
@@ -33,38 +35,45 @@ class SortableIterator implements \IteratorAggregate
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(\Traversable $iterator, $sort)
|
||||
public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = false)
|
||||
{
|
||||
$this->iterator = $iterator;
|
||||
$order = $reverseOrder ? -1 : 1;
|
||||
|
||||
if (self::SORT_BY_NAME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
return $order * strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_NAME_NATURAL === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_TYPE === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
if ($a->isDir() && $b->isFile()) {
|
||||
return -1;
|
||||
return -$order;
|
||||
} elseif ($a->isFile() && $b->isDir()) {
|
||||
return 1;
|
||||
return $order;
|
||||
}
|
||||
|
||||
return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
||||
return $order * strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return $a->getATime() - $b->getATime();
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
return $order * ($a->getATime() - $b->getATime());
|
||||
};
|
||||
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return $a->getCTime() - $b->getCTime();
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
return $order * ($a->getCTime() - $b->getCTime());
|
||||
};
|
||||
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return $a->getMTime() - $b->getMTime();
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
return $order * ($a->getMTime() - $b->getMTime());
|
||||
};
|
||||
} elseif (self::SORT_BY_NONE === $sort) {
|
||||
$this->sort = $order;
|
||||
} elseif (\is_callable($sort)) {
|
||||
$this->sort = $sort;
|
||||
$this->sort = $reverseOrder ? function ($a, $b) use ($sort) { return -\call_user_func($sort, $a, $b); } : $sort;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
|
||||
}
|
||||
@@ -72,8 +81,17 @@ class SortableIterator implements \IteratorAggregate
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
if (1 === $this->sort) {
|
||||
return $this->iterator;
|
||||
}
|
||||
|
||||
$array = iterator_to_array($this->iterator, true);
|
||||
uasort($array, $this->sort);
|
||||
|
||||
if (-1 === $this->sort) {
|
||||
$array = array_reverse($array);
|
||||
} else {
|
||||
uasort($array, $this->sort);
|
||||
}
|
||||
|
||||
return new \ArrayIterator($array);
|
||||
}
|
||||
|
||||
611
vendor/symfony/finder/Tests/FinderTest.php
vendored
611
vendor/symfony/finder/Tests/FinderTest.php
vendored
@@ -24,33 +24,70 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->directories());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'qux', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->directories();
|
||||
$finder->files();
|
||||
$finder->directories();
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'qux', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testFiles()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->files());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'foo bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->files();
|
||||
$finder->directories();
|
||||
$finder->files();
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'foo bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testRemoveTrailingSlash()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
|
||||
$expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar'));
|
||||
$expected = $this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'foo bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
));
|
||||
$in = self::$tmpDir.'//';
|
||||
|
||||
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
|
||||
@@ -89,26 +126,73 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->depth('< 1'));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->depth('<= 0'));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->depth('>= 1'));
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->depth('< 1')->depth('>= 1');
|
||||
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testDepthWithArrayParam()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$finder->depth(array('>= 1', '< 2'));
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testName()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->name('*.php'));
|
||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'test.php',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name('test.ph*');
|
||||
@@ -121,23 +205,53 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name('~\\.php$~i');
|
||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'test.php',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name('test.p{hp,y}');
|
||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testNameWithArrayParam()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name(array('test.php', 'test.py'));
|
||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testNotName()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->notName('*.php'));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->notName('*.php');
|
||||
$finder->notName('*.py');
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name('test.ph*');
|
||||
@@ -153,6 +267,19 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testNotNameWithArrayParam()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$finder->notName(array('*.php', '*.py'));
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getRegexNameTestData
|
||||
*/
|
||||
@@ -160,7 +287,10 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name($regex);
|
||||
$this->assertIterator($this->toAbsolute(array('test.py', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'test.py',
|
||||
'test.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSize()
|
||||
@@ -170,6 +300,13 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSizeWithArrayParam()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->files()->size(array('< 1K', '> 500')));
|
||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testDate()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
@@ -177,83 +314,391 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testDateWithArrayParam()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->files()->date(array('>= 2005-10-15', 'until last month')));
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testExclude()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->exclude('foo'));
|
||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testIgnoreVCS()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
|
||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'.git',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
|
||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'.git',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testIgnoreDotFiles()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
|
||||
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'.git',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
|
||||
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'.git',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->ignoreDotFiles(true)->ignoreVCS(false));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByName()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByName());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByType()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByType());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'toto', 'foo/bar.tmp', 'test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'toto',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByAccessedTime()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByAccessedTime());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'toto',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByChangedTime()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByChangedTime());
|
||||
$this->assertIterator($this->toAbsolute(array('toto', 'test.py', 'test.php', 'foo/bar.tmp', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'toto',
|
||||
'test.py',
|
||||
'test.php',
|
||||
'foo/bar.tmp',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByModifiedTime()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByModifiedTime());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'toto',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testReverseSorting()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByName());
|
||||
$this->assertSame($finder, $finder->reverseSorting());
|
||||
$this->assertOrderedIteratorInForeach($this->toAbsolute(array(
|
||||
'toto',
|
||||
'test.py',
|
||||
'test.php',
|
||||
'qux_2_0.php',
|
||||
'qux_12_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_0_1.php',
|
||||
'qux/baz_1_2.py',
|
||||
'qux/baz_100_1.py',
|
||||
'qux',
|
||||
'foo/bar.tmp',
|
||||
'foo bar',
|
||||
'foo',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByNameNatural()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByName(true));
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByName(false));
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSort()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testFilter()
|
||||
@@ -271,7 +716,23 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->followLinks());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testIn()
|
||||
@@ -283,6 +744,12 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
self::$tmpDir.\DIRECTORY_SEPARATOR.'test.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'FinderTest.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'GlobTest.php',
|
||||
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_0_1.php',
|
||||
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1000_1.php',
|
||||
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1002_0.php',
|
||||
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_10_2.php',
|
||||
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_12_0.php',
|
||||
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_2_0.php',
|
||||
);
|
||||
|
||||
$this->assertIterator($expected, $iterator);
|
||||
@@ -339,7 +806,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$dirs[] = (string) $dir;
|
||||
}
|
||||
|
||||
$expected = $this->toAbsolute(array('foo', 'toto'));
|
||||
$expected = $this->toAbsolute(array('foo', 'qux', 'toto'));
|
||||
|
||||
sort($dirs);
|
||||
sort($expected);
|
||||
@@ -347,7 +814,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertEquals(2, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
|
||||
$this->assertEquals(3, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
|
||||
@@ -366,7 +833,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$paths[] = $file->getRelativePath();
|
||||
}
|
||||
|
||||
$ref = array('', '', '', '', 'foo', '');
|
||||
$ref = array('', '', '', '', '', '', '', '', '', '', '', 'foo', 'qux', 'qux', '');
|
||||
|
||||
sort($ref);
|
||||
sort($paths);
|
||||
@@ -384,7 +851,23 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$paths[] = $file->getRelativePathname();
|
||||
}
|
||||
|
||||
$ref = array('test.php', 'toto', 'test.py', 'foo', 'foo'.\DIRECTORY_SEPARATOR.'bar.tmp', 'foo bar');
|
||||
$ref = array(
|
||||
'test.php',
|
||||
'toto',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo'.\DIRECTORY_SEPARATOR.'bar.tmp',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux'.\DIRECTORY_SEPARATOR.'baz_100_1.py',
|
||||
'qux'.\DIRECTORY_SEPARATOR.'baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
sort($paths);
|
||||
sort($ref);
|
||||
@@ -402,7 +885,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
|
||||
$finder = $finder->append($finder1);
|
||||
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'qux', 'toto')), $finder->getIterator());
|
||||
}
|
||||
|
||||
public function testAppendWithAnArray()
|
||||
@@ -595,13 +1078,15 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
array('lorem', 'foobar', array('lorem.txt')),
|
||||
array('', 'lorem', array('dolor.txt', 'ipsum.txt')),
|
||||
array('ipsum dolor sit amet', '/^IPSUM/m', array('lorem.txt')),
|
||||
array(array('lorem', 'dolor'), array(), array('lorem.txt', 'ipsum.txt', 'dolor.txt')),
|
||||
array('', array('lorem', 'ipsum'), array('dolor.txt')),
|
||||
);
|
||||
}
|
||||
|
||||
public function getRegexNameTestData()
|
||||
{
|
||||
return array(
|
||||
array('~.+\\.p.+~i'),
|
||||
array('~.*t\\.p.+~i'),
|
||||
array('~t.*s~i'),
|
||||
);
|
||||
}
|
||||
@@ -661,6 +1146,33 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
'with space'.\DIRECTORY_SEPARATOR.'foo.txt',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'/^A/',
|
||||
array('a.dat', 'abc.dat'),
|
||||
array(
|
||||
'A',
|
||||
'A'.\DIRECTORY_SEPARATOR.'B',
|
||||
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C',
|
||||
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('/^A/', 'one'),
|
||||
'foobar',
|
||||
array(
|
||||
'A',
|
||||
'A'.\DIRECTORY_SEPARATOR.'B',
|
||||
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C',
|
||||
'A'.\DIRECTORY_SEPARATOR.'a.dat',
|
||||
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat',
|
||||
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat',
|
||||
'one',
|
||||
'one'.\DIRECTORY_SEPARATOR.'a',
|
||||
'one'.\DIRECTORY_SEPARATOR.'b',
|
||||
'one'.\DIRECTORY_SEPARATOR.'b'.\DIRECTORY_SEPARATOR.'c.neon',
|
||||
'one'.\DIRECTORY_SEPARATOR.'b'.\DIRECTORY_SEPARATOR.'d.neon',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -718,7 +1230,20 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
chmod($testDir, 0333);
|
||||
|
||||
if (false === ($couldRead = is_readable($testDir))) {
|
||||
$this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo bar',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)
|
||||
), $finder->getIterator());
|
||||
}
|
||||
|
||||
// restore original permissions
|
||||
@@ -730,8 +1255,26 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "Symfony\Component\Finder\Finder::sortByName()" method will have a new "bool $useNaturalSort = false" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
|
||||
*/
|
||||
public function testInheritedClassCallSortByNameWithNoArguments()
|
||||
{
|
||||
$finderChild = new ClassThatInheritFinder();
|
||||
$finderChild->sortByName();
|
||||
}
|
||||
|
||||
protected function buildFinder()
|
||||
{
|
||||
return Finder::create();
|
||||
}
|
||||
}
|
||||
|
||||
class ClassThatInheritFinder extends Finder
|
||||
{
|
||||
public function sortByName()
|
||||
{
|
||||
parent::sortByName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,15 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo/.bar',
|
||||
'foo bar',
|
||||
'.foo/bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$since2MonthsAgo = array(
|
||||
@@ -58,6 +67,15 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo/.bar',
|
||||
'foo bar',
|
||||
'.foo/bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$untilLastMonth = array(
|
||||
|
||||
@@ -41,6 +41,13 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo',
|
||||
'.bar',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$lessThanOrEqualTo1 = array(
|
||||
@@ -56,6 +63,15 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.bar',
|
||||
'foo bar',
|
||||
'.foo/bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$graterThanOrEqualTo1 = array(
|
||||
@@ -63,6 +79,8 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'foo/bar.tmp',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
);
|
||||
|
||||
$equalTo1 = array(
|
||||
@@ -70,6 +88,8 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'foo/bar.tmp',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
);
|
||||
|
||||
return array(
|
||||
|
||||
@@ -41,6 +41,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$fo = array(
|
||||
@@ -56,6 +65,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$toto = array(
|
||||
@@ -69,6 +87,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
return array(
|
||||
|
||||
@@ -37,11 +37,20 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$onlyDirectories = array(
|
||||
'.git',
|
||||
'foo',
|
||||
'qux',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.foo',
|
||||
|
||||
@@ -33,6 +33,15 @@ abstract class RealIteratorTestCase extends IteratorTestCase
|
||||
'toto/',
|
||||
'toto/.git/',
|
||||
'foo bar',
|
||||
'qux_0_1.php',
|
||||
'qux_2_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux/',
|
||||
'qux/baz_1_2.py',
|
||||
'qux/baz_100_1.py',
|
||||
);
|
||||
|
||||
self::$files = self::toAbsolute(self::$files);
|
||||
|
||||
@@ -34,6 +34,7 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo',
|
||||
'.git',
|
||||
'foo',
|
||||
'qux',
|
||||
'test.php',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
|
||||
@@ -82,6 +82,15 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
@@ -92,6 +101,7 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'.foo',
|
||||
'.git',
|
||||
'foo',
|
||||
'qux',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.bar',
|
||||
@@ -99,25 +109,18 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
);
|
||||
|
||||
$customComparison = array(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
);
|
||||
|
||||
$sortByAccessedTime = array(
|
||||
// For these two files the access time was set to 2005-10-15
|
||||
array('foo/bar.tmp', 'test.php'),
|
||||
@@ -132,6 +135,15 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
),
|
||||
// This file was accessed after sleeping for 1 sec
|
||||
array('.bar'),
|
||||
@@ -149,6 +161,15 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
),
|
||||
array('test.php'),
|
||||
array('test.py'),
|
||||
@@ -166,17 +187,75 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
),
|
||||
array('test.php'),
|
||||
array('test.py'),
|
||||
);
|
||||
|
||||
$sortByNameNatural = array(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_1_2.py',
|
||||
'qux/baz_100_1.py',
|
||||
'qux_0_1.php',
|
||||
'qux_2_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
);
|
||||
|
||||
$customComparison = array(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
);
|
||||
|
||||
return array(
|
||||
array(SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)),
|
||||
array(SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)),
|
||||
array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)),
|
||||
array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)),
|
||||
array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)),
|
||||
array(SortableIterator::SORT_BY_NAME_NATURAL, $this->toAbsolute($sortByNameNatural)),
|
||||
array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)),
|
||||
);
|
||||
}
|
||||
|
||||
2
vendor/symfony/finder/composer.json
vendored
2
vendor/symfony/finder/composer.json
vendored
@@ -27,7 +27,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/symfony/finder/phpunit.xml.dist
vendored
2
vendor/symfony/finder/phpunit.xml.dist
vendored
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
|
||||
@@ -49,7 +49,7 @@ class AcceptHeaderItem
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns header value's string representation.
|
||||
* Returns header value's string representation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
8
vendor/symfony/http-foundation/CHANGELOG.md
vendored
8
vendor/symfony/http-foundation/CHANGELOG.md
vendored
@@ -1,6 +1,14 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* the default value of the "$secure" and "$samesite" arguments of Cookie's constructor
|
||||
will respectively change from "false" to "null" and from "null" to "lax" in Symfony
|
||||
5.0, you should define their values explicitly or use "Cookie::create()" instead.
|
||||
* added `matchPort()` in RequestMatcher
|
||||
|
||||
4.1.3
|
||||
-----
|
||||
|
||||
|
||||
28
vendor/symfony/http-foundation/Cookie.php
vendored
28
vendor/symfony/http-foundation/Cookie.php
vendored
@@ -27,6 +27,7 @@ class Cookie
|
||||
protected $httpOnly;
|
||||
private $raw;
|
||||
private $sameSite;
|
||||
private $secureDefault = false;
|
||||
|
||||
const SAMESITE_LAX = 'lax';
|
||||
const SAMESITE_STRICT = 'strict';
|
||||
@@ -66,21 +67,30 @@ class Cookie
|
||||
return new static($name, $value, $data['expires'], $data['path'], $data['domain'], $data['secure'], $data['httponly'], $data['raw'], $data['samesite']);
|
||||
}
|
||||
|
||||
public static function create(string $name, string $value = null, $expire = 0, ?string $path = '/', string $domain = null, bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = self::SAMESITE_LAX): self
|
||||
{
|
||||
return new self($name, $value, $expire, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name The name of the cookie
|
||||
* @param string|null $value The value of the cookie
|
||||
* @param int|string|\DateTimeInterface $expire The time the cookie expires
|
||||
* @param string $path The path on the server in which the cookie will be available on
|
||||
* @param string|null $domain The domain that the cookie is available to
|
||||
* @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client
|
||||
* @param bool|null $secure Whether the client should send back the cookie only over HTTPS or null to auto-enable this when the request is already using HTTPS
|
||||
* @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol
|
||||
* @param bool $raw Whether the cookie value should be sent with no url encoding
|
||||
* @param string|null $sameSite Whether the cookie will be available for cross-site requests
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(string $name, string $value = null, $expire = 0, ?string $path = '/', string $domain = null, bool $secure = false, bool $httpOnly = true, bool $raw = false, string $sameSite = null)
|
||||
public function __construct(string $name, string $value = null, $expire = 0, ?string $path = '/', string $domain = null, ?bool $secure = false, bool $httpOnly = true, bool $raw = false, string $sameSite = null)
|
||||
{
|
||||
if (9 > \func_num_args()) {
|
||||
@trigger_error(sprintf('The default value of the "$secure" and "$samesite" arguments of "%s"\'s constructor will respectively change from "false" to "null" and from "null" to "lax" in Symfony 5.0, you should define their values explicitly or use "Cookie::create()" instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
// from PHP source code
|
||||
if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
|
||||
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
|
||||
@@ -110,7 +120,9 @@ class Cookie
|
||||
$this->httpOnly = $httpOnly;
|
||||
$this->raw = $raw;
|
||||
|
||||
if (null !== $sameSite) {
|
||||
if ('' === $sameSite) {
|
||||
$sameSite = null;
|
||||
} elseif (null !== $sameSite) {
|
||||
$sameSite = strtolower($sameSite);
|
||||
}
|
||||
|
||||
@@ -232,7 +244,7 @@ class Cookie
|
||||
*/
|
||||
public function isSecure()
|
||||
{
|
||||
return $this->secure;
|
||||
return $this->secure ?? $this->secureDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,4 +286,12 @@ class Cookie
|
||||
{
|
||||
return $this->sameSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $default The default value of the "secure" flag when it is set to null
|
||||
*/
|
||||
public function setSecureDefault(bool $default): void
|
||||
{
|
||||
$this->secureDefault = $default;
|
||||
}
|
||||
}
|
||||
|
||||
51
vendor/symfony/http-foundation/HeaderUtils.php
vendored
51
vendor/symfony/http-foundation/HeaderUtils.php
vendored
@@ -18,6 +18,9 @@ namespace Symfony\Component\HttpFoundation;
|
||||
*/
|
||||
class HeaderUtils
|
||||
{
|
||||
public const DISPOSITION_ATTACHMENT = 'attachment';
|
||||
public const DISPOSITION_INLINE = 'inline';
|
||||
|
||||
/**
|
||||
* This class should not be instantiated.
|
||||
*/
|
||||
@@ -143,6 +146,54 @@ class HeaderUtils
|
||||
return preg_replace('/\\\\(.)|"/', '$1', $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a HTTP Content-Disposition field-value.
|
||||
*
|
||||
* @param string $disposition One of "inline" or "attachment"
|
||||
* @param string $filename A unicode string
|
||||
* @param string $filenameFallback A string containing only ASCII characters that
|
||||
* is semantically equivalent to $filename. If the filename is already ASCII,
|
||||
* it can be omitted, or just copied from $filename
|
||||
*
|
||||
* @return string A string suitable for use as a Content-Disposition field-value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @see RFC 6266
|
||||
*/
|
||||
public static function makeDisposition(string $disposition, string $filename, string $filenameFallback = ''): string
|
||||
{
|
||||
if (!\in_array($disposition, array(self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE))) {
|
||||
throw new \InvalidArgumentException(sprintf('The disposition must be either "%s" or "%s".', self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE));
|
||||
}
|
||||
|
||||
if ('' === $filenameFallback) {
|
||||
$filenameFallback = $filename;
|
||||
}
|
||||
|
||||
// filenameFallback is not ASCII.
|
||||
if (!preg_match('/^[\x20-\x7e]*$/', $filenameFallback)) {
|
||||
throw new \InvalidArgumentException('The filename fallback must only contain ASCII characters.');
|
||||
}
|
||||
|
||||
// percent characters aren't safe in fallback.
|
||||
if (false !== strpos($filenameFallback, '%')) {
|
||||
throw new \InvalidArgumentException('The filename fallback cannot contain the "%" character.');
|
||||
}
|
||||
|
||||
// path separators aren't allowed in either.
|
||||
if (false !== strpos($filename, '/') || false !== strpos($filename, '\\') || false !== strpos($filenameFallback, '/') || false !== strpos($filenameFallback, '\\')) {
|
||||
throw new \InvalidArgumentException('The filename and the fallback cannot contain the "/" and "\\" characters.');
|
||||
}
|
||||
|
||||
$params = array('filename' => $filenameFallback);
|
||||
if ($filename !== $filenameFallback) {
|
||||
$params['filename*'] = "utf-8''".rawurlencode($filename);
|
||||
}
|
||||
|
||||
return $disposition.'; '.self::toString($params, ';');
|
||||
}
|
||||
|
||||
private static function groupParts(array $matches, string $separators): array
|
||||
{
|
||||
$separator = $separators[0];
|
||||
|
||||
@@ -174,7 +174,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
* Returns the parameter value converted to boolean.
|
||||
*
|
||||
* @param string $key The parameter key
|
||||
* @param mixed $default The default value if the parameter key does not exist
|
||||
* @param bool $default The default value if the parameter key does not exist
|
||||
*
|
||||
* @return bool The filtered value
|
||||
*/
|
||||
|
||||
23
vendor/symfony/http-foundation/Request.php
vendored
23
vendor/symfony/http-foundation/Request.php
vendored
@@ -545,10 +545,13 @@ class Request
|
||||
$requestOrder = ini_get('request_order') ?: ini_get('variables_order');
|
||||
$requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';
|
||||
|
||||
$_REQUEST = array();
|
||||
$_REQUEST = array(array());
|
||||
|
||||
foreach (str_split($requestOrder) as $order) {
|
||||
$_REQUEST = array_merge($_REQUEST, $request[$order]);
|
||||
$_REQUEST[] = $request[$order];
|
||||
}
|
||||
|
||||
$_REQUEST = array_merge(...$_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1284,7 +1287,7 @@ class Request
|
||||
{
|
||||
$canonicalMimeType = null;
|
||||
if (false !== $pos = strpos($mimeType, ';')) {
|
||||
$canonicalMimeType = substr($mimeType, 0, $pos);
|
||||
$canonicalMimeType = trim(substr($mimeType, 0, $pos));
|
||||
}
|
||||
|
||||
if (null === static::$formats) {
|
||||
@@ -1448,7 +1451,7 @@ class Request
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc7231#section-4.2.3
|
||||
*
|
||||
* @return bool
|
||||
* @return bool True for GET and HEAD, false otherwise
|
||||
*/
|
||||
public function isMethodCacheable()
|
||||
{
|
||||
@@ -1695,10 +1698,16 @@ class Request
|
||||
$this->server->remove('IIS_WasUrlRewritten');
|
||||
} 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
|
||||
$schemeAndHttpHost = $this->getSchemeAndHttpHost();
|
||||
if (0 === strpos($requestUri, $schemeAndHttpHost)) {
|
||||
$requestUri = substr($requestUri, \strlen($schemeAndHttpHost));
|
||||
$uriComponents = parse_url($requestUri);
|
||||
|
||||
if (isset($uriComponents['path'])) {
|
||||
$requestUri = $uriComponents['path'];
|
||||
}
|
||||
|
||||
if (isset($uriComponents['query'])) {
|
||||
$requestUri .= '?'.$uriComponents['query'];
|
||||
}
|
||||
} elseif ($this->server->has('ORIG_PATH_INFO')) {
|
||||
// IIS 5.0, PHP as CGI
|
||||
|
||||
@@ -28,6 +28,11 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
*/
|
||||
private $host;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $port;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
@@ -56,13 +61,14 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
* @param array $attributes
|
||||
* @param string|string[]|null $schemes
|
||||
*/
|
||||
public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = array(), $schemes = null)
|
||||
public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = array(), $schemes = null, int $port = null)
|
||||
{
|
||||
$this->matchPath($path);
|
||||
$this->matchHost($host);
|
||||
$this->matchMethod($methods);
|
||||
$this->matchIps($ips);
|
||||
$this->matchScheme($schemes);
|
||||
$this->matchPort($port);
|
||||
|
||||
foreach ($attributes as $k => $v) {
|
||||
$this->matchAttribute($k, $v);
|
||||
@@ -89,6 +95,16 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
$this->host = $regexp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a check for the the URL port.
|
||||
*
|
||||
* @param int|null $port The port number to connect to
|
||||
*/
|
||||
public function matchPort(int $port = null)
|
||||
{
|
||||
$this->port = $port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a check for the URL path info.
|
||||
*
|
||||
@@ -167,6 +183,10 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $this->port && 0 < $this->port && $request->getPort() !== $this->port) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IpUtils::checkIp($request->getClientIp(), $this->ips)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
11
vendor/symfony/http-foundation/Response.php
vendored
11
vendor/symfony/http-foundation/Response.php
vendored
@@ -313,6 +313,12 @@ class Response
|
||||
|
||||
$this->ensureIEOverSSLCompatibility($request);
|
||||
|
||||
if ($request->isSecure()) {
|
||||
foreach ($headers->getCookies() as $cookie) {
|
||||
$cookie->setSecureDefault(true);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -330,8 +336,9 @@ class Response
|
||||
|
||||
// headers
|
||||
foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
|
||||
$replace = 0 === strcasecmp($name, 'Content-Type');
|
||||
foreach ($values as $value) {
|
||||
header($name.': '.$value, false, $this->statusCode);
|
||||
header($name.': '.$value, $replace, $this->statusCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,7 +940,7 @@ class Response
|
||||
public function setCache(array $options)
|
||||
{
|
||||
if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'))) {
|
||||
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff))));
|
||||
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff)));
|
||||
}
|
||||
|
||||
if (isset($options['etag'])) {
|
||||
|
||||
@@ -247,55 +247,15 @@ class ResponseHeaderBag extends HeaderBag
|
||||
*/
|
||||
public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true)
|
||||
{
|
||||
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly));
|
||||
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a HTTP Content-Disposition field-value.
|
||||
*
|
||||
* @param string $disposition One of "inline" or "attachment"
|
||||
* @param string $filename A unicode string
|
||||
* @param string $filenameFallback A string containing only ASCII characters that
|
||||
* is semantically equivalent to $filename. If the filename is already ASCII,
|
||||
* it can be omitted, or just copied from $filename
|
||||
*
|
||||
* @return string A string suitable for use as a Content-Disposition field-value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @see RFC 6266
|
||||
* @see HeaderUtils::makeDisposition()
|
||||
*/
|
||||
public function makeDisposition($disposition, $filename, $filenameFallback = '')
|
||||
{
|
||||
if (!\in_array($disposition, array(self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE))) {
|
||||
throw new \InvalidArgumentException(sprintf('The disposition must be either "%s" or "%s".', self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE));
|
||||
}
|
||||
|
||||
if ('' == $filenameFallback) {
|
||||
$filenameFallback = $filename;
|
||||
}
|
||||
|
||||
// filenameFallback is not ASCII.
|
||||
if (!preg_match('/^[\x20-\x7e]*$/', $filenameFallback)) {
|
||||
throw new \InvalidArgumentException('The filename fallback must only contain ASCII characters.');
|
||||
}
|
||||
|
||||
// percent characters aren't safe in fallback.
|
||||
if (false !== strpos($filenameFallback, '%')) {
|
||||
throw new \InvalidArgumentException('The filename fallback cannot contain the "%" character.');
|
||||
}
|
||||
|
||||
// path separators aren't allowed in either.
|
||||
if (false !== strpos($filename, '/') || false !== strpos($filename, '\\') || false !== strpos($filenameFallback, '/') || false !== strpos($filenameFallback, '\\')) {
|
||||
throw new \InvalidArgumentException('The filename and the fallback cannot contain the "/" and "\\" characters.');
|
||||
}
|
||||
|
||||
$params = array('filename' => $filenameFallback);
|
||||
if ($filename !== $filenameFallback) {
|
||||
$params['filename*'] = "utf-8''".rawurlencode($filename);
|
||||
}
|
||||
|
||||
return $disposition.'; '.HeaderUtils::toString($params, ';');
|
||||
return HeaderUtils::makeDisposition((string) $disposition, (string) $filename, (string) $filenameFallback);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
59
vendor/symfony/http-foundation/Session/SessionUtils.php
vendored
Normal file
59
vendor/symfony/http-foundation/Session/SessionUtils.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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\HttpFoundation\Session;
|
||||
|
||||
/**
|
||||
* Session utility functions.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
* @author Rémon van de Kamp <rpkamp@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class SessionUtils
|
||||
{
|
||||
/**
|
||||
* Finds the session header amongst the headers that are to be sent, removes it, and returns
|
||||
* it so the caller can process it further.
|
||||
*/
|
||||
public static function popSessionCookie(string $sessionName, string $sessionId): ?string
|
||||
{
|
||||
$sessionCookie = null;
|
||||
$sessionCookiePrefix = sprintf(' %s=', urlencode($sessionName));
|
||||
$sessionCookieWithId = sprintf('%s%s;', $sessionCookiePrefix, urlencode($sessionId));
|
||||
$otherCookies = array();
|
||||
foreach (headers_list() as $h) {
|
||||
if (0 !== stripos($h, 'Set-Cookie:')) {
|
||||
continue;
|
||||
}
|
||||
if (11 === strpos($h, $sessionCookiePrefix, 11)) {
|
||||
$sessionCookie = $h;
|
||||
|
||||
if (11 !== strpos($h, $sessionCookieWithId, 11)) {
|
||||
$otherCookies[] = $h;
|
||||
}
|
||||
} else {
|
||||
$otherCookies[] = $h;
|
||||
}
|
||||
}
|
||||
if (null === $sessionCookie) {
|
||||
return null;
|
||||
}
|
||||
|
||||
header_remove('Set-Cookie');
|
||||
foreach ($otherCookies as $h) {
|
||||
header($h, false);
|
||||
}
|
||||
|
||||
return $sessionCookie;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\SessionUtils;
|
||||
|
||||
/**
|
||||
* This abstract session handler provides a generic implementation
|
||||
* of the PHP 7.0 SessionUpdateTimestampHandlerInterface,
|
||||
@@ -117,36 +119,20 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
|
||||
*/
|
||||
public function destroy($sessionId)
|
||||
{
|
||||
if (!headers_sent() && ini_get('session.use_cookies')) {
|
||||
if (!headers_sent() && filter_var(ini_get('session.use_cookies'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
if (!$this->sessionName) {
|
||||
throw new \LogicException(sprintf('Session name cannot be empty, did you forget to call "parent::open()" in "%s"?.', \get_class($this)));
|
||||
}
|
||||
$sessionCookie = sprintf(' %s=', urlencode($this->sessionName));
|
||||
$sessionCookieWithId = sprintf('%s%s;', $sessionCookie, urlencode($sessionId));
|
||||
$sessionCookieFound = false;
|
||||
$otherCookies = array();
|
||||
foreach (headers_list() as $h) {
|
||||
if (0 !== stripos($h, 'Set-Cookie:')) {
|
||||
continue;
|
||||
}
|
||||
if (11 === strpos($h, $sessionCookie, 11)) {
|
||||
$sessionCookieFound = true;
|
||||
|
||||
if (11 !== strpos($h, $sessionCookieWithId, 11)) {
|
||||
$otherCookies[] = $h;
|
||||
}
|
||||
$cookie = SessionUtils::popSessionCookie($this->sessionName, $sessionId);
|
||||
if (null === $cookie) {
|
||||
if (\PHP_VERSION_ID < 70300) {
|
||||
setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), filter_var(ini_get('session.cookie_secure'), FILTER_VALIDATE_BOOLEAN), filter_var(ini_get('session.cookie_httponly'), FILTER_VALIDATE_BOOLEAN));
|
||||
} else {
|
||||
$otherCookies[] = $h;
|
||||
$params = session_get_cookie_params();
|
||||
unset($params['lifetime']);
|
||||
setcookie($this->sessionName, '', $params);
|
||||
}
|
||||
}
|
||||
if ($sessionCookieFound) {
|
||||
header_remove('Set-Cookie');
|
||||
foreach ($otherCookies as $h) {
|
||||
header($h, false);
|
||||
}
|
||||
} else {
|
||||
setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->newSessionId === $sessionId || $this->doDestroy($sessionId);
|
||||
|
||||
@@ -637,7 +637,7 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.');
|
||||
}
|
||||
|
||||
if (!ini_get('session.use_strict_mode') && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
|
||||
if (!filter_var(ini_get('session.use_strict_mode'), FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
|
||||
// In strict mode, session fixation is not possible: new sessions always start with a unique
|
||||
// random id, so that concurrency is not possible and this code path can be skipped.
|
||||
// Exclusive-reading of non-existent rows does not block, so we need to do an insert to block
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user