minor #15051 [2.3] Static Code Analysis for Components (kalessil)
This PR was squashed before being merged into the 2.3 branch (closes #15051).
Discussion
----------
[2.3] Static Code Analysis for Components
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Static Code Analysis with Php Inspections (EA Extended):
- magic methods validity: resolved possible fatals
- random api migration: used mt_* in some of components
- *printf issues resolved
Commits
-------
aa5e616
[2.3] Static Code Analysis for Components
This commit is contained in:
commit
a25f90f7e8
@ -77,7 +77,7 @@ class Cookie
|
||||
if (null !== $expires) {
|
||||
$timestampAsDateTime = \DateTime::createFromFormat('U', $expires);
|
||||
if (false === $timestampAsDateTime) {
|
||||
throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.'), $expires);
|
||||
throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.', $expires));
|
||||
}
|
||||
|
||||
$this->expires = $timestampAsDateTime->getTimestamp();
|
||||
|
@ -22,7 +22,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function prepare_workspace()
|
||||
{
|
||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
|
||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
|
||||
mkdir($this->workspace, 0777, true);
|
||||
$this->workspace = realpath($this->workspace);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed');
|
||||
$this->assertFalse($resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');
|
||||
|
||||
$resource = new DirectoryResource('/____foo/foobar'.rand(1, 999999));
|
||||
$resource = new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
|
||||
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed');
|
||||
$this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated');
|
||||
|
||||
$resource = new FileResource('/____foo/foobar'.rand(1, 999999));
|
||||
$resource = new FileResource('/____foo/foobar'.mt_rand(1, 999999));
|
||||
$this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ class ArgvInput extends Input
|
||||
}
|
||||
|
||||
if (null !== $value && !$option->acceptValue()) {
|
||||
throw new \RuntimeException(sprintf('The "--%s" option does not accept a value.', $name, $value));
|
||||
throw new \RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
|
||||
}
|
||||
|
||||
if (null === $value && $option->acceptValue() && count($this->parsed)) {
|
||||
|
@ -51,7 +51,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->umask = umask(0);
|
||||
$this->filesystem = new Filesystem();
|
||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
|
||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
|
||||
mkdir($this->workspace, 0777, true);
|
||||
$this->workspace = realpath($this->workspace);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class ChoiceTypePerformanceTest extends FormPerformanceTestCase
|
||||
$choices = range(1, 300);
|
||||
|
||||
for ($i = 0; $i < 100; ++$i) {
|
||||
$this->factory->create('choice', rand(1, 400), array(
|
||||
$this->factory->create('choice', mt_rand(1, 400), array(
|
||||
'choices' => $choices,
|
||||
));
|
||||
}
|
||||
|
@ -476,10 +476,17 @@ class Request
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$content = '';
|
||||
try {
|
||||
$content = $this->getContent();
|
||||
} catch (\LogicException $e) {
|
||||
trigger_error($e->getMessage(), E_USER_ERROR);
|
||||
}
|
||||
|
||||
return
|
||||
sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
|
||||
$this->headers."\r\n".
|
||||
$this->getContent();
|
||||
$content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
$this->writer = new JsonBundleWriter();
|
||||
$this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.rand(1000, 9999);
|
||||
$this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.mt_rand(1000, 9999);
|
||||
$this->filesystem = new Filesystem();
|
||||
|
||||
$this->filesystem->mkdir($this->directory);
|
||||
|
@ -35,7 +35,7 @@ class PhpBundleWriterTest extends \PHPUnit_Framework_TestCase
|
||||
protected function setUp()
|
||||
{
|
||||
$this->writer = new PhpBundleWriter();
|
||||
$this->directory = sys_get_temp_dir().'/PhpBundleWriterTest/'.rand(1000, 9999);
|
||||
$this->directory = sys_get_temp_dir().'/PhpBundleWriterTest/'.mt_rand(1000, 9999);
|
||||
$this->filesystem = new Filesystem();
|
||||
|
||||
$this->filesystem->mkdir($this->directory);
|
||||
|
@ -36,7 +36,7 @@ class TextBundleWriterTest extends \PHPUnit_Framework_TestCase
|
||||
protected function setUp()
|
||||
{
|
||||
$this->writer = new TextBundleWriter();
|
||||
$this->directory = sys_get_temp_dir().'/TextBundleWriterTest/'.rand(1000, 9999);
|
||||
$this->directory = sys_get_temp_dir().'/TextBundleWriterTest/'.mt_rand(1000, 9999);
|
||||
$this->filesystem = new Filesystem();
|
||||
|
||||
$this->filesystem->mkdir($this->directory);
|
||||
|
@ -33,7 +33,7 @@ class LocaleScannerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->directory = sys_get_temp_dir().'/LocaleScannerTest/'.rand(1000, 9999);
|
||||
$this->directory = sys_get_temp_dir().'/LocaleScannerTest/'.mt_rand(1000, 9999);
|
||||
$this->filesystem = new Filesystem();
|
||||
$this->scanner = new LocaleScanner();
|
||||
|
||||
|
@ -28,7 +28,7 @@ class CacheLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.rand(111111, 999999);
|
||||
$dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.mt_rand(111111, 999999);
|
||||
mkdir($dir, 0777, true);
|
||||
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir);
|
||||
$loader->setDebugger($debugger = new \Symfony\Component\Templating\Tests\Fixtures\ProjectTemplateDebugger());
|
||||
|
Reference in New Issue
Block a user