diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index badcce6473..0d66598204 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -1161,7 +1161,7 @@ class Application $lines[] = str_pad($line, $width); $line = $char; } - if (strlen($line)) { + if ('' !== $line) { $lines[] = count($lines) ? str_pad($line, $width) : $line; } diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index a053ac6ba0..331b204fec 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -33,7 +33,7 @@ class OutputFormatter implements OutputFormatterInterface */ public static function escape($text) { - return preg_replace('/([^\\\\]?)#isx", $message, $matches, PREG_OFFSET_CAPTURE); + preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE); foreach ($matches[0] as $i => $match) { $pos = $match[1]; $text = $match[0]; diff --git a/src/Symfony/Component/Console/Shell.php b/src/Symfony/Component/Console/Shell.php index b3cbf16fa8..d0bcb7ee8a 100644 --- a/src/Symfony/Component/Console/Shell.php +++ b/src/Symfony/Component/Console/Shell.php @@ -207,7 +207,7 @@ EOF; } else { $this->output->write($this->getPrompt()); $line = fgets(STDIN, 1024); - $line = (!$line && strlen($line) == 0) ? false : rtrim($line); + $line = (false === $line || '' === $line) ? false : rtrim($line); } return $line; diff --git a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php index fdd71b36ee..ed4f0b1fb3 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php @@ -271,7 +271,7 @@ class GraphvizDumper extends Dumper */ private function dotize($id) { - return strtolower(preg_replace('/[^\w]/i', '_', $id)); + return strtolower(preg_replace('/\W/i', '_', $id)); } /** diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index ad1a0928ab..62dfd9ad91 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -675,7 +675,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase */ public function testRenameThrowsExceptionOnError() { - $file = $this->workspace.DIRECTORY_SEPARATOR.uniqid(); + $file = $this->workspace.DIRECTORY_SEPARATOR.uniqid('fs_test_', true); $newPath = $this->workspace.DIRECTORY_SEPARATOR.'new_file'; $this->filesystem->rename($file, $newPath); diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 3ae88a9db4..92f38ab94c 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -272,7 +272,7 @@ class FinderTest extends Iterator\RealIteratorTestCase public function testFilter($adapter) { $finder = $this->buildFinder($adapter); - $this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return preg_match('/test/', $f) > 0; })); + $this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return false !== strpos($f, 'test'); })); $this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator()); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php index 62629b183f..b036ad13c2 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php @@ -39,7 +39,7 @@ class CustomFilterIteratorTest extends IteratorTestCase { return array( array(array(function (\SplFileInfo $fileinfo) { return false; }), array()), - array(array(function (\SplFileInfo $fileinfo) { return preg_match('/^test/', $fileinfo) > 0; }), array('test.php', 'test.py')), + array(array(function (\SplFileInfo $fileinfo) { return 0 === strpos($fileinfo, 'test'); }), array('test.php', 'test.py')), array(array('is_dir'), array()), ); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php b/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php index f2e8f8e2fd..a895350732 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php @@ -51,7 +51,7 @@ class MockSplFileInfo extends \SplFileInfo public function isFile() { if (null === $this->type) { - return preg_match('/file/', $this->getFilename()); + return false !== strpos($this->getFilename(), 'file'); }; return self::TYPE_FILE === $this->type; @@ -60,7 +60,7 @@ class MockSplFileInfo extends \SplFileInfo public function isDir() { if (null === $this->type) { - return preg_match('/directory/', $this->getFilename()); + return false !== strpos($this->getFilename(), 'directory'); } return self::TYPE_DIRECTORY === $this->type; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php index 96dae6b35c..f2d8bcf5a4 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php @@ -249,7 +249,7 @@ class MockArraySessionStorage implements SessionStorageInterface */ protected function generateId() { - return sha1(uniqid(mt_rand())); + return sha1(uniqid('ss_mock_', true)); } protected function loadSession() diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Esi.php b/src/Symfony/Component/HttpKernel/HttpCache/Esi.php index 58b6265656..bc55bed51a 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Esi.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Esi.php @@ -183,7 +183,7 @@ class Esi $chunks[$i] = sprintf('esi->handle($this, %s, %s, %s) ?>'."\n", var_export($options['src'], true), var_export(isset($options['alt']) ? $options['alt'] : '', true), - isset($options['onerror']) && 'continue' == $options['onerror'] ? 'true' : 'false' + isset($options['onerror']) && 'continue' === $options['onerror'] ? 'true' : 'false' ); ++$i; $chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]); diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index ed3dc35032..2ec608daa0 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -49,7 +49,7 @@ class ProcessUtils $escapedArgument = ''; $quote = false; - foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { + foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { if ('"' === $part) { $escapedArgument .= '\\"'; } elseif (self::isSurroundedBy($part, '%')) { diff --git a/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php b/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php index 89d1f6a1ac..26673ea45a 100644 --- a/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php +++ b/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php @@ -32,7 +32,7 @@ while ($read || $write) { } $out = (binary) substr($out, $written); } - if (null === $read && strlen($out) < 1) { + if (null === $read && '' === $out) { $write = array_diff($write, array(STDOUT)); } @@ -43,7 +43,7 @@ while ($read || $write) { } $err = (binary) substr($err, $written); } - if (null === $read && strlen($err) < 1) { + if (null === $read && '' === $err) { $write = array_diff($write, array(STDERR)); } diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 6d21a48f41..aff4ce7ff5 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -45,7 +45,7 @@ class Inline $value = trim($value); - if (0 == strlen($value)) { + if ('' === $value) { return ''; } diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index ae4f500f7d..fc46ab3caf 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -509,9 +509,9 @@ class Parser // deal with trailing newlines as indicated if ('' === $indicator) { - $text = preg_replace('/\n+$/s', "\n", $text); + $text = preg_replace('/\n+$/', "\n", $text); } elseif ('-' === $indicator) { - $text = preg_replace('/\n+$/s', '', $text); + $text = preg_replace('/\n+$/', '', $text); } return $text; @@ -610,7 +610,7 @@ class Parser $value = $trimmedValue; // remove end of the document marker (...) - $value = preg_replace('#\.\.\.\s*$#s', '', $value); + $value = preg_replace('#\.\.\.\s*$#', '', $value); } return $value;