[2.3] Static Code Analysis for Components
This commit is contained in:
parent
3d16094e5b
commit
aa5e616511
@ -77,7 +77,7 @@ class Cookie
|
|||||||
if (null !== $expires) {
|
if (null !== $expires) {
|
||||||
$timestampAsDateTime = \DateTime::createFromFormat('U', $expires);
|
$timestampAsDateTime = \DateTime::createFromFormat('U', $expires);
|
||||||
if (false === $timestampAsDateTime) {
|
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();
|
$this->expires = $timestampAsDateTime->getTimestamp();
|
||||||
|
@ -22,7 +22,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function prepare_workspace()
|
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);
|
mkdir($this->workspace, 0777, true);
|
||||||
$this->workspace = realpath($this->workspace);
|
$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->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');
|
$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');
|
$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->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');
|
$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');
|
$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()) {
|
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)) {
|
if (null === $value && $option->acceptValue() && count($this->parsed)) {
|
||||||
|
@ -51,7 +51,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->umask = umask(0);
|
$this->umask = umask(0);
|
||||||
$this->filesystem = new Filesystem();
|
$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);
|
mkdir($this->workspace, 0777, true);
|
||||||
$this->workspace = realpath($this->workspace);
|
$this->workspace = realpath($this->workspace);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class ChoiceTypePerformanceTest extends FormPerformanceTestCase
|
|||||||
$choices = range(1, 300);
|
$choices = range(1, 300);
|
||||||
|
|
||||||
for ($i = 0; $i < 100; ++$i) {
|
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,
|
'choices' => $choices,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -476,10 +476,17 @@ class Request
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
|
$content = '';
|
||||||
|
try {
|
||||||
|
$content = $this->getContent();
|
||||||
|
} catch (\LogicException $e) {
|
||||||
|
trigger_error($e->getMessage(), E_USER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
|
sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
|
||||||
$this->headers."\r\n".
|
$this->headers."\r\n".
|
||||||
$this->getContent();
|
$content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->writer = new JsonBundleWriter();
|
$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 = new Filesystem();
|
||||||
|
|
||||||
$this->filesystem->mkdir($this->directory);
|
$this->filesystem->mkdir($this->directory);
|
||||||
|
@ -35,7 +35,7 @@ class PhpBundleWriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->writer = new PhpBundleWriter();
|
$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 = new Filesystem();
|
||||||
|
|
||||||
$this->filesystem->mkdir($this->directory);
|
$this->filesystem->mkdir($this->directory);
|
||||||
|
@ -36,7 +36,7 @@ class TextBundleWriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->writer = new TextBundleWriter();
|
$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 = new Filesystem();
|
||||||
|
|
||||||
$this->filesystem->mkdir($this->directory);
|
$this->filesystem->mkdir($this->directory);
|
||||||
|
@ -33,7 +33,7 @@ class LocaleScannerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function setUp()
|
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->filesystem = new Filesystem();
|
||||||
$this->scanner = new LocaleScanner();
|
$this->scanner = new LocaleScanner();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class CacheLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testLoad()
|
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);
|
mkdir($dir, 0777, true);
|
||||||
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir);
|
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir);
|
||||||
$loader->setDebugger($debugger = new \Symfony\Component\Templating\Tests\Fixtures\ProjectTemplateDebugger());
|
$loader->setDebugger($debugger = new \Symfony\Component\Templating\Tests\Fixtures\ProjectTemplateDebugger());
|
||||||
|
Reference in New Issue
Block a user