Commit c1be7e7b authored by webchick's avatar webchick

Issue #2565337 by hussainweb, joshtaylor: Upgrade to Symfony 2.7.4

parent bcea7894
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,7 +10,7 @@ Resources
---------
For a simple implementation of a browser based on an HTTP layer, have a look
at [Goutte](https://github.com/fabpot/Goutte).
at [Goutte](https://github.com/FriendsOfPHP/Goutte).
For an implementation based on HttpKernelInterface, have a look at the
[Client](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Client.php)
......
......@@ -118,6 +118,25 @@ private static function findClasses($path)
case T_CLASS:
case T_INTERFACE:
case SYMFONY_TRAIT:
// Skip usage of ::class constant
$isClassConstant = false;
for ($j = $i - 1; $j > 0; --$j) {
if (is_string($tokens[$j])) {
break;
}
if (T_DOUBLE_COLON === $tokens[$j][0]) {
$isClassConstant = true;
break;
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
break;
}
}
if ($isClassConstant) {
continue;
}
// Find the classname
while (($t = $tokens[++$i]) && is_array($t)) {
if (T_STRING === $t[0]) {
......
......@@ -47,7 +47,7 @@ private function clean($file)
/**
* @dataProvider getTestCreateMapTests
*/
public function testDump($directory, $expected)
public function testDump($directory)
{
$this->prepare_workspace();
......@@ -115,6 +115,12 @@ public function getTestCreateMapTests()
));
}
if (PHP_VERSION_ID >= 50500) {
$data[] = array(__DIR__.'/Fixtures/php5.5', array(
'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php',
));
}
return $data;
}
......@@ -134,10 +140,10 @@ public function testCreateMapFinderSupport()
protected function assertEqualsNormalized($expected, $actual, $message = null)
{
foreach ($expected as $ns => $path) {
$expected[$ns] = strtr($path, '\\', '/');
$expected[$ns] = str_replace('\\', '/', $path);
}
foreach ($actual as $ns => $path) {
$actual[$ns] = strtr($path, '\\', '/');
$actual[$ns] = str_replace('\\', '/', $path);
}
$this->assertEquals($expected, $actual, $message);
}
......
<?php
namespace ClassCons;
class Foo
{
public function __construct()
{
\Foo\TBar/* foo */::class;
}
}
......@@ -513,7 +513,7 @@ public function setHelp($help)
*/
public function getHelp()
{
return $this->help;
return $this->help ?: $this->description;
}
/**
......
......@@ -102,7 +102,7 @@ private function getInputArgumentData(InputArgument $argument)
'name' => $argument->getName(),
'is_required' => $argument->isRequired(),
'is_array' => $argument->isArray(),
'description' => preg_replace('/\s*\R\s*/', ' ', $argument->getDescription()),
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
'default' => $argument->getDefault(),
);
}
......@@ -120,7 +120,7 @@ private function getInputOptionData(InputOption $option)
'accept_value' => $option->acceptValue(),
'is_value_required' => $option->isValueRequired(),
'is_multiple' => $option->isArray(),
'description' => preg_replace('/\s*\R\s*/', ' ', $option->getDescription()),
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
'default' => $option->getDefault(),
);
}
......
......@@ -36,7 +36,7 @@ protected function describeInputArgument(InputArgument $argument, array $options
.'* Name: '.($argument->getName() ?: '<none>')."\n"
.'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
.'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
.'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $argument->getDescription() ?: '<none>')."\n"
.'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
.'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
);
}
......@@ -53,7 +53,7 @@ protected function describeInputOption(InputOption $option, array $options = arr
.'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
.'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
.'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
.'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $option->getDescription() ?: '<none>')."\n"
.'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
.'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
);
}
......
......@@ -44,7 +44,7 @@ protected function describeInputArgument(InputArgument $argument, array $options
$argument->getName(),
str_repeat(' ', $spacingWidth),
// + 17 = 2 spaces + <info> + </info> + 2 spaces
preg_replace('/\s*\R\s*/', PHP_EOL.str_repeat(' ', $totalWidth + 17), $argument->getDescription()),
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $argument->getDescription()),
$default
), $options);
}
......@@ -81,7 +81,7 @@ protected function describeInputOption(InputOption $option, array $options = arr
$synopsis,
str_repeat(' ', $spacingWidth),
// + 17 = 2 spaces + <info> + </info> + 2 spaces
preg_replace('/\s*\R\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()),
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()),
$default,
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
), $options);
......@@ -249,12 +249,16 @@ private function formatDefaultValue($default)
*/
private function getColumnWidth(array $commands)
{
$width = 0;
$widths = array();
foreach ($commands as $command) {
$width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width;
$widths[] = strlen($command->getName());
foreach ($command->getAliases() as $alias) {
$widths[] = strlen($alias);
}
}
return $width + 2;
return max($widths) + 2;
}
/**
......
......@@ -19,19 +19,19 @@
class ConsoleCommandEvent extends ConsoleEvent
{
/**
* The return code for skipped commands, this will also be passed into the terminate event
* The return code for skipped commands, this will also be passed into the terminate event.
*/
const RETURN_CODE_DISABLED = 113;
/**
* Indicates if the command should be run or skipped
* Indicates if the command should be run or skipped.
*
* @var bool
*/
private $commandShouldRun = true;
/**
* Disables the command, so it won't be run
* Disables the command, so it won't be run.
*
* @return bool
*/
......@@ -41,7 +41,7 @@ public function disableCommand()
}
/**
* Enables the command
* Enables the command.
*
* @return bool
*/
......@@ -51,7 +51,7 @@ public function enableCommand()
}
/**
* Returns true if the command is runnable, false otherwise
* Returns true if the command is runnable, false otherwise.
*
* @return bool
*/
......
......@@ -25,7 +25,7 @@ class DebugFormatterHelper extends Helper
private $count = -1;
/**
* Starts a debug formatting session
* Starts a debug formatting session.
*
* @param string $id The id of the formatting session
* @param string $message The message to display
......@@ -41,7 +41,7 @@ public function start($id, $message, $prefix = 'RUN')
}
/**
* Adds progress to a formatting session
* Adds progress to a formatting session.
*
* @param string $id The id of the formatting session
* @param string $buffer The message to display
......@@ -61,7 +61,7 @@ public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPr
unset($this->started[$id]['out']);
}
if (!isset($this->started[$id]['err'])) {
$message .= sprintf("%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix);
$message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
$this->started[$id]['err'] = true;
}
......@@ -72,7 +72,7 @@ public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPr
unset($this->started[$id]['err']);
}
if (!isset($this->started[$id]['out'])) {
$message .= sprintf("%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix);
$message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
$this->started[$id]['out'] = true;
}
......@@ -83,7 +83,7 @@ public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPr
}
/**
* Stops a formatting session
* Stops a formatting session.
*
* @param string $id The id of the formatting session
* @param string $message The message to display
......
......@@ -77,7 +77,7 @@ public function setInputStream($stream)
}
/**
* Returns the helper's input stream
* Returns the helper's input stream.
*
* @return resource
*/
......@@ -150,7 +150,7 @@ public function doAsk(OutputInterface $output, Question $question)
* Outputs the question prompt.
*
* @param OutputInterface $output
* @param Question $question
* @param Question $question
*/
protected function writePrompt(OutputInterface $output, Question $question)
{
......@@ -222,7 +222,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu
// Backspace Character
if ("\177" === $c) {
if (0 === $numMatches && 0 !== $i) {
$i--;
--$i;
// Move cursor backwards
$output->write("\033[1D");
}
......@@ -275,7 +275,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu
} else {
$output->write($c);
$ret .= $c;
$i++;
++$i;
$numMatches = 0;
$ofs = 0;
......
......@@ -245,7 +245,7 @@ private function renderRowSeparator()
}
$markup = $this->style->getCrossingChar();
for ($column = 0; $column < $count; $column++) {
for ($column = 0; $column < $count; ++$column) {
$markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->getColumnWidth($column)).$this->style->getCrossingChar();
}
......@@ -338,7 +338,7 @@ private function calculateNumberOfColumns()
private function buildTableRows($rows)
{
$unmergedRows = array();
for ($rowKey = 0; $rowKey < count($rows); $rowKey++) {
for ($rowKey = 0; $rowKey < count($rows); ++$rowKey) {
$rows = $this->fillNextRows($rows, $rowKey);
// Remove any new line breaks and replace it with a new line
......
......@@ -18,9 +18,10 @@
use Symfony\Component\Console\Output\ConsoleOutputInterface;
/**
* PSR-3 compliant console logger
* PSR-3 compliant console logger.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @link http://www.php-fig.org/psr/psr-3/
*/
class ConsoleLogger extends AbstractLogger
......@@ -93,7 +94,7 @@ public function log($level, $message, array $context = array())
}
/**
* Interpolates context values into the message placeholders
* Interpolates context values into the message placeholders.
*
* @author PHP Framework Interoperability Group
*
......
......@@ -23,8 +23,8 @@ class ConfirmationQuestion extends Question
/**
* Constructor.
*
* @param string $question The question to ask to the user
* @param bool $default The default answer to return, true or false
* @param string $question The question to ask to the user
* @param bool $default The default answer to return, true or false
* @param string $trueAnswerRegex A regex to match the "yes" answer
*/
public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
......
......@@ -16,7 +16,7 @@
use Symfony\Component\Console\Output\OutputInterface;
/**
* Decorates output to add console style guide helpers
* Decorates output to add console style guide helpers.
*
* @author Kevin Bond <kevinbond@gmail.com>
*/
......
......@@ -553,6 +553,10 @@ public function testRenderException()
public function testRenderExceptionWithDoubleWidthCharacters()
{
if (!function_exists('mb_strwidth')) {
$this->markTestSkipped('The "mb_strwidth" function is not available');
}
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application->setAutoExit(false);
$application->expects($this->any())
......
......@@ -131,6 +131,8 @@ public function testGetSetHelp()
$ret = $command->setHelp('help1');
$this->assertEquals($command, $ret, '->setHelp() implements a fluent interface');
$this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help');
$command->setHelp('');
$this->assertEquals('description', $command->getHelp(), '->getHelp() fallback to the description');
}
public function testGetProcessedHelp()
......
......@@ -14,7 +14,7 @@
use Symfony\Component\Console\Output\BufferedOutput;
/**
* Dummy output
* Dummy output.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/
......
......@@ -106,7 +106,7 @@
<usage>afoobar</usage>
</usages>
<description>The foo:bar command</description>
<help/>
<help>The foo:bar command</help>
<arguments/>
<options>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
......
......@@ -7,7 +7,7 @@
<usage>afoobar</usage>
</usages>
<description>The foo:bar command</description>
<help/>
<help>The foo:bar command</help>
<arguments/>
<options>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
......
......@@ -75,7 +75,7 @@ public function provideCommandsAndOutput()
EOT;
$syntaxErrorOutputDebug = <<<EOT
RUN php -r "fwrite(STDERR, 'error message');usleep(50000);fwrite(STDOUT, 'out message');exit(252);"
RUN php -r "fwrite(STDERR, 'error message');usleep(500000);fwrite(STDOUT, 'out message');exit(252);"
ERR error message
OUT out message
RES 252 Command did not run successfully
......@@ -94,10 +94,10 @@ public function provideCommandsAndOutput()
array($successOutputDebugWithTags, 'php -r "echo \'<info>42</info>\';"', StreamOutput::VERBOSITY_DEBUG, null),
array('', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null),
array($syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null),
array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null),
array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null),
array($errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage),
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(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $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),
);
......
......@@ -315,7 +315,7 @@ public function testNonDecoratedOutput()
$bar = new ProgressBar($output = $this->getOutputStream(false), 200);
$bar->start();
for ($i = 0; $i < 200; $i++) {
for ($i = 0; $i < 200; ++$i) {
$bar->advance();
}
......@@ -384,7 +384,7 @@ public function testParallelBars()
$output->write("\n");
$bar3->start();
for ($i = 1; $i <= 3; $i++) {
for ($i = 1; $i <= 3; ++$i) {
// up two lines
$output->write("\033[2A");
if ($i <= 2) {
......@@ -492,6 +492,9 @@ public function testMultilineFormat()
);
}
/**
* @requires extension mbstring
*/
public function testAnsiColorsAndEmojis()
{
$bar = new ProgressBar($output = $this->getOutputStream(), 15);
......
......@@ -427,7 +427,7 @@ public function testRenderProvider()
array('ISBN', 'Author'),
array(
array(
new TableCell("9971-5-0210-0", array('rowspan' => 3, 'colspan' => 1)),
new TableCell('9971-5-0210-0', array('rowspan' => 3, 'colspan' => 1)),
'Dante Alighieri',
),
array(new TableSeparator()),
......
......@@ -18,7 +18,7 @@
use Symfony\Component\Console\Output\OutputInterface;
/**
* Console logger test
* Console logger test.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/
......
......@@ -78,7 +78,7 @@ public function getValue()
/**
* Returns -1 if the object specificity is lower than the argument,
* 0 if they are equal, and 1 if the argument is lower
* 0 if they are equal, and 1 if the argument is lower.
*
* @param Specificity $specificity
*
......
......@@ -32,6 +32,7 @@ class DebugClassLoader
private static $caseCheck;
private static $deprecated = array();
private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
private static $darwinCache = array('/' => array('/', array()));
/**
* Constructor.
......@@ -220,33 +221,73 @@ public function loadClass($class)
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
}
if (self::$caseCheck && preg_match('#([/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*)+\.(php|hh)$#D', $file, $tail)) {
if (self::$caseCheck && preg_match('#(?:[/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*+)++\.(?:php|hh)$#D', $file, $tail)) {
$tail = $tail[0];
$tailLen = strlen($tail);
$real = $refl->getFileName();
if (2 === self::$caseCheck) {
// realpath() on MacOSX doesn't normalize the case of characters
$cwd = getcwd();
$basename = strrpos($real, '/');
chdir(substr($real, 0, $basename));
$basename = substr($real, $basename + 1);
// glob() patterns are case-sensitive even if the underlying fs is not
if (!in_array($basename, glob($basename.'*', GLOB_NOSORT), true)) {
$real = getcwd().'/';
$h = opendir('.');
while (false !== $f = readdir($h)) {
if (0 === strcasecmp($f, $basename)) {
$real .= $f;
break;
$i = 1 + strrpos($real, '/');
$file = substr($real, $i);
$real = substr($real, 0, $i);
if (isset(self::$darwinCache[$real])) {
$kDir = $real;
} else {
$kDir = strtolower($real);
if (isset(self::$darwinCache[$kDir])) {
$real = self::$darwinCache[$kDir][0];
} else {
$dir = getcwd();
chdir($real);
$real = getcwd().'/';
chdir($dir);
$dir = $real;
$k = $kDir;
$i = strlen($dir) - 1;
while (!isset(self::$darwinCache[$k])) {
self::$darwinCache[$k] = array($dir, array());
self::$darwinCache[$dir] = &self::$darwinCache[$k];
while ('/' !== $dir[--$i]) {
}
$k = substr($k, 0, ++$i);
$dir = substr($dir, 0, $i--);
}
}
}
$dirFiles = self::$darwinCache[$kDir][1];
if (isset($dirFiles[$file])) {
$kFile = $file;
} else {
$kFile = strtolower($file);
if (!isset($dirFiles[$kFile])) {
foreach (scandir($real, 2) as $f) {
if ('.' !== $f[0]) {
$dirFiles[$f] = $f;
if ($f === $file) {
$kFile = $k = $file;
} elseif ($f !== $k = strtolower($f)) {
$dirFiles[$k] = $f;
}
}
}
self::$darwinCache[$kDir][1] = $dirFiles;
}
closedir($h);
}
chdir($cwd);
$real .= $dirFiles[$kFile];
}
if (0 === substr_compare($real, $tail, -strlen($tail), strlen($tail), true)
&& 0 !== substr_compare($real, $tail, -strlen($tail), strlen($tail), false)
if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
&& 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
) {
throw new \RuntimeException(sprintf('Case mismatch between class and source file names: %s vs %s', $class, $real));
}
......
......@@ -251,7 +251,7 @@ public function setExceptionHandler($handler)
public function throwAt($levels, $replace = false)
{
$prev = $this->thrownErrors;
$this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
$this->thrownErrors = (E_ALL | E_STRICT) & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
if (!$replace) {
$this->thrownErrors |= $prev;
}
......@@ -352,7 +352,7 @@ private function reRegister($prev)
*/
public function handleError($type, $message, $file, $line, array $context, array $backtrace = null)
{
$level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR;
$level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
$log = $this->loggedErrors & $type;
$throw = $this->thrownErrors & $type & $level;
$type &= $level | $this->screamedErrors;
......@@ -445,7 +445,7 @@ public function handleError($type, $message, $file, $line, array $context, array
}
/**
* Handles an exception by logging then forwarding it to an other handler.
* Handles an exception by logging then forwarding it to another handler.
*
* @param \Exception|\Throwable $exception An exception to handle
* @param array $error An array as returned by error_get_last()
......
......@@ -38,7 +38,7 @@ class ExceptionHandler
public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
{
if (false !== strpos($charset, '%') xor false === strpos($fileLinkFormat, '%')) {
if (false !== strpos($charset, '%')) {
// Swap $charset and $fileLinkFormat for BC reasons
$pivot = $fileLinkFormat;
$fileLinkFormat = $charset;
......@@ -153,19 +153,22 @@ public function handle(\Exception $exception)