[2.3] Static Code Analysis for Components
This commit is contained in:
parent
b1003d57f3
commit
4a4fea742b
@ -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;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
*/
|
||||
public static function escape($text)
|
||||
{
|
||||
return preg_replace('/([^\\\\]?)</is', '$1\\<', $text);
|
||||
return preg_replace('/([^\\\\]?)</', '$1\\<', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,7 +146,7 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
$offset = 0;
|
||||
$output = '';
|
||||
$tagRegex = '[a-z][a-z0-9_=;-]*';
|
||||
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#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];
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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()),
|
||||
);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
|
@ -183,7 +183,7 @@ class Esi
|
||||
$chunks[$i] = sprintf('<?php echo $this->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]);
|
||||
|
@ -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, '%')) {
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class Inline
|
||||
|
||||
$value = trim($value);
|
||||
|
||||
if (0 == strlen($value)) {
|
||||
if ('' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user