From 9eb2b141153214d8d8a1ce9b4a8acecc560fedc8 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Fri, 29 May 2015 19:14:48 +0200 Subject: [PATCH 1/7] Php Inspections (EA Extended): - resolved possible PHP Fatal in \Symfony\Component\BrowserKit\Cookie::__toString -resolved implicit magic methods calls -resolved callable name case mismatches --- src/Symfony/Component/BrowserKit/Cookie.php | 17 ++++++++++------- .../Component/BrowserKit/Tests/ClientTest.php | 8 ++++---- .../Component/BrowserKit/Tests/CookieTest.php | 18 +++++++++--------- .../Component/BrowserKit/Tests/HistoryTest.php | 6 +++--- .../Component/Debug/Tests/ErrorHandlerTest.php | 2 +- .../Tests/Dumper/PhpDumperTest.php | 2 +- .../Component/Finder/Tests/FinderTest.php | 2 +- .../Tests/Iterator/SortableIteratorTest.php | 2 +- .../DateTimeToStringTransformer.php | 2 +- .../Form/Tests/AbstractLayoutTest.php | 2 +- .../DateTimeToStringTransformerTest.php | 2 +- .../Component/HttpFoundation/Response.php | 2 +- .../Tests/BinaryFileResponseTest.php | 2 +- .../DataCollector/RequestDataCollector.php | 4 ++-- .../HttpKernel/HttpCache/HttpCache.php | 2 +- .../Profiler/MemcacheProfilerStorage.php | 2 +- .../DataCollector/ConfigDataCollectorTest.php | 4 ++-- .../AbstractIntlDateFormatterTest.php | 2 +- .../Process/Tests/PhpExecutableFinderTest.php | 2 +- .../Security/Tests/Acl/Domain/EntryTest.php | 2 +- .../Stopwatch/Tests/StopwatchTest.php | 4 ++-- 21 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php index b225056f4b..424f78bab4 100644 --- a/src/Symfony/Component/BrowserKit/Cookie.php +++ b/src/Symfony/Component/BrowserKit/Cookie.php @@ -69,11 +69,20 @@ class Cookie $this->rawValue = urlencode($value); } $this->name = $name; - $this->expires = null === $expires ? null : (int) $expires; $this->path = empty($path) ? '/' : $path; $this->domain = $domain; $this->secure = (bool) $secure; $this->httponly = (bool) $httponly; + + if (null !== $expires) { + $timestampAsDateTime = \DateTime::createFromFormat('U', $expires); + if (false === $timestampAsDateTime) { + throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.'), $expires); + } + + $this->expires = $timestampAsDateTime->getTimestamp(); + } + } /** @@ -91,12 +100,6 @@ class Cookie if (null !== $this->expires) { $dateTime = \DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('GMT')); - - if ($dateTime === false) { - // this throw will provoke PHP fatal - throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.'), $this->expires); - } - $cookie .= '; expires='.str_replace('+0000', '', $dateTime->format(self::$dateFormats[0])); } diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index a6e5ba9e9a..58a5c6cc71 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -332,7 +332,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request was not redirected'); } catch (\Exception $e) { - $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected'); + $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected'); } $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); @@ -362,7 +362,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); } catch (\Exception $e) { - $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); + $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); } } @@ -392,7 +392,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); } catch (\Exception $e) { - $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); + $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); } $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); @@ -562,7 +562,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $this->fail('->request() throws a \RuntimeException if the script has an error'); } catch (\Exception $e) { - $this->assertInstanceof('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error'); + $this->assertInstanceOf('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error'); } } diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php index 8e3578a28e..e1dd0df2c1 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -74,30 +74,30 @@ class CookieTest extends \PHPUnit_Framework_TestCase public function testFromStringWithUrl() { - $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com/')); - $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com')); - $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com?foo')); - $this->assertEquals('foo=bar; domain=www.example.com; path=/foo', (string) Cookie::FromString('foo=bar', 'http://www.example.com/foo/bar')); - $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar; path=/', 'http://www.example.com/foo/bar')); - $this->assertEquals('foo=bar; domain=www.myotherexample.com; path=/', (string) Cookie::FromString('foo=bar; domain=www.myotherexample.com', 'http://www.example.com/')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com/')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar', 'http://www.example.com?foo')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/foo', (string) Cookie::fromString('foo=bar', 'http://www.example.com/foo/bar')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::fromString('foo=bar; path=/', 'http://www.example.com/foo/bar')); + $this->assertEquals('foo=bar; domain=www.myotherexample.com; path=/', (string) Cookie::fromString('foo=bar; domain=www.myotherexample.com', 'http://www.example.com/')); } public function testFromStringThrowsAnExceptionIfCookieIsNotValid() { $this->setExpectedException('InvalidArgumentException'); - Cookie::FromString('foo'); + Cookie::fromString('foo'); } public function testFromStringThrowsAnExceptionIfCookieDateIsNotValid() { $this->setExpectedException('InvalidArgumentException'); - Cookie::FromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT'); + Cookie::fromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT'); } public function testFromStringThrowsAnExceptionIfUrlIsNotValid() { $this->setExpectedException('InvalidArgumentException'); - Cookie::FromString('foo=bar', 'foobar'); + Cookie::fromString('foo=bar', 'foobar'); } public function testGetName() diff --git a/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php b/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php index 882b730ef4..d6d830e83e 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php @@ -54,7 +54,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase $history->current(); $this->fail('->current() throws a \LogicException if the history is empty'); } catch (\Exception $e) { - $this->assertInstanceof('LogicException', $e, '->current() throws a \LogicException if the history is empty'); + $this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is empty'); } $history->add(new Request('http://www.example.com/', 'get')); @@ -71,7 +71,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase $history->back(); $this->fail('->back() throws a \LogicException if the history is already on the first page'); } catch (\Exception $e) { - $this->assertInstanceof('LogicException', $e, '->current() throws a \LogicException if the history is already on the first page'); + $this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is already on the first page'); } $history->add(new Request('http://www.example1.com/', 'get')); @@ -90,7 +90,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase $history->forward(); $this->fail('->forward() throws a \LogicException if the history is already on the last page'); } catch (\Exception $e) { - $this->assertInstanceof('LogicException', $e, '->forward() throws a \LogicException if the history is already on the last page'); + $this->assertInstanceOf('LogicException', $e, '->forward() throws a \LogicException if the history is already on the last page'); } $history->back(); diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 40b726b5e8..942240bafe 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -107,7 +107,7 @@ PHP $that->assertEquals(E_NOTICE, $exception->getSeverity()); $that->assertEquals(__LINE__ + 40, $exception->getLine()); $that->assertEquals(__FILE__, $exception->getFile()); - $that->assertRegexp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); + $that->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); $that->assertArrayHasKey('foobar', $exception->getContext()); $trace = $exception->getTrace(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index c993e40104..7d2e665ad0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -49,7 +49,7 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase $dumpedString = $dumper->dump(); $this->assertStringEqualsFile(self::$fixturesPath.'/php/services11.php', $dumpedString, '->dump() does not add getDefaultParameters() method call if container have no parameters.'); - $this->assertNotRegexp("/function getDefaultParameters\(/", $dumpedString, '->dump() does not add getDefaultParameters() method definition.'); + $this->assertNotRegExp("/function getDefaultParameters\(/", $dumpedString, '->dump() does not add getDefaultParameters() method definition.'); } public function testDumpOptimizationString() diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index b65b5a3e2f..3ae88a9db4 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -262,7 +262,7 @@ class FinderTest extends Iterator\RealIteratorTestCase public function testSort($adapter) { $finder = $this->buildFinder($adapter); - $this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealpath(), $b->getRealpath()); })); + $this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); })); $this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator()); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php index e2f433f8e7..effaf76868 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php @@ -163,7 +163,7 @@ class SortableIteratorTest extends RealIteratorTestCase array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)), array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)), array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)), - array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealpath(), $b->getRealpath()); }, $this->toAbsolute($customComparison)), + array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)), ); } } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index f5ba9948d0..8fa1622a36 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -219,7 +219,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer } if ($this->inputTimezone !== $this->outputTimezone) { - $dateTime->setTimeZone(new \DateTimeZone($this->inputTimezone)); + $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); } } catch (TransformationFailedException $e) { throw $e; diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index f741ce0b68..8bbf9aab5d 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -60,7 +60,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg try { // Wrap in node so we can load HTML with multiple tags at // the top level - $dom->loadXml(''.$html.''); + $dom->loadXML(''.$html.''); } catch (\Exception $e) { $this->fail(sprintf( "Failed loading HTML:\n\n%s\n\nError: %s", diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index dbcdad0f96..a0aede7c85 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -147,7 +147,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase $output = new \DateTime('2010-02-03 16:05:06 Asia/Hong_Kong'); $input = $output->format('Y-m-d H:i:s'); - $output->setTimeZone(new \DateTimeZone('America/New_York')); + $output->setTimezone(new \DateTimeZone('America/New_York')); $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); } diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 841ea0c595..9b399189b4 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -1037,7 +1037,7 @@ class Response $lastModified = $this->headers->get('Last-Modified'); $modifiedSince = $request->headers->get('If-Modified-Since'); - if ($etags = $request->getEtags()) { + if ($etags = $request->getETags()) { $notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 1d8731c665..b239ef30a4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -179,7 +179,7 @@ class BinaryFileResponseTest extends ResponseTestCase $file = new FakeFile($realpath, __DIR__.'/File/Fixtures/test'); - BinaryFileResponse::trustXSendFileTypeHeader(); + BinaryFileResponse::trustXSendfileTypeHeader(); $response = new BinaryFileResponse($file); $reflection = new \ReflectionObject($response); $property = $reflection->getProperty('file'); diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 84d4347fbd..49f252a81c 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -122,7 +122,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter $this->data['controller'] = array( 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], - 'file' => $r->getFilename(), + 'file' => $r->getFileName(), 'line' => $r->getStartLine(), ); } catch (\ReflectionException $re) { @@ -141,7 +141,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter $this->data['controller'] = array( 'class' => $r->getName(), 'method' => null, - 'file' => $r->getFilename(), + 'file' => $r->getFileName(), 'line' => $r->getStartLine(), ); } else { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 3231a7a498..5ddd4a6ef1 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -367,7 +367,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface // We keep the etags from the client to handle the case when the client // has a different private valid entry which is not cached here. $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array(); - $requestEtags = $request->getEtags(); + $requestEtags = $request->getETags(); if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) { $subRequest->headers->set('if_none_match', implode(', ', $etags)); } diff --git a/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php index e90083fb7e..2727405cb1 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php @@ -41,7 +41,7 @@ class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage $port = $matches[3]; $memcache = new \Memcache(); - $memcache->addServer($host, $port); + $memcache->addserver($host, $port); $this->memcache = $memcache; } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 0d672a1f0c..fea95b4e2b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -36,9 +36,9 @@ class ConfigDataCollectorTest extends \PHPUnit_Framework_TestCase // if else clause because we don't know it if (extension_loaded('xdebug')) { - $this->assertTrue($c->hasXdebug()); + $this->assertTrue($c->hasXDebug()); } else { - $this->assertFalse($c->hasXdebug()); + $this->assertFalse($c->hasXDebug()); } // if else clause because we don't know it diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 40f5fd71c1..71ef473960 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -875,7 +875,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $dateTime = new \DateTime(); $dateTime->setTimestamp(null === $timestamp ? time() : $timestamp); - $dateTime->setTimeZone(new \DateTimeZone($timeZone)); + $dateTime->setTimezone(new \DateTimeZone($timeZone)); return $dateTime; } diff --git a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php index 3acccacc3b..8f8623930f 100644 --- a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php @@ -91,7 +91,7 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase //TODO maybe php executable is custom or even Windows if ('\\' === DIRECTORY_SEPARATOR) { $this->assertTrue(is_executable($current)); - $this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes'); + $this->assertTrue((bool) preg_match('/'.addslashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes'); } } } diff --git a/src/Symfony/Component/Security/Tests/Acl/Domain/EntryTest.php b/src/Symfony/Component/Security/Tests/Acl/Domain/EntryTest.php index 55c8f0a429..966f2f103d 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Domain/EntryTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Domain/EntryTest.php @@ -36,7 +36,7 @@ class EntryTest extends \PHPUnit_Framework_TestCase $this->assertTrue($ace->isAuditSuccess()); $ace->setAuditSuccess(false); $this->assertFalse($ace->isAuditSuccess()); - $ace->setAuditsuccess(true); + $ace->setAuditSuccess(true); $this->assertTrue($ace->isAuditSuccess()); } diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index 6415bba9e5..74ad1d8da1 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -27,7 +27,7 @@ class StopwatchTest extends \PHPUnit_Framework_TestCase $stopwatch = new Stopwatch(); $event = $stopwatch->start('foo', 'cat'); - $this->assertInstanceof('Symfony\Component\Stopwatch\StopwatchEvent', $event); + $this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event); $this->assertEquals('cat', $event->getCategory()); } @@ -74,7 +74,7 @@ class StopwatchTest extends \PHPUnit_Framework_TestCase usleep(200000); $event = $stopwatch->stop('foo'); - $this->assertInstanceof('Symfony\Component\Stopwatch\StopwatchEvent', $event); + $this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event); $this->assertEquals(200, $event->getDuration(), null, self::DELTA); } From cceb63e6d5b818037b7a52273d234475343b41d9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 30 May 2015 00:03:51 +0200 Subject: [PATCH 2/7] updated CHANGELOG for 2.3.30 --- CHANGELOG-2.3.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index 24e7c937f5..84a17f9fdc 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,10 @@ in 2.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 +* 2.3.30 (2015-05-30) + + * bug #14262 [REVERTED] [TwigBundle] Refresh twig paths when resources change. (aitboudad) + * 2.3.29 (2015-05-26) * security #14759 CVE-2015-4050 [HttpKernel] Do not call the FragmentListener if _controller is already defined (jakzal) From 6dfe5551b71d156739a0df1043ba81b326e36f4a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 30 May 2015 00:16:04 +0200 Subject: [PATCH 3/7] updated VERSION for 2.3.30 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 4f2a819dc9..06e3d1ba2d 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -60,12 +60,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.30-DEV'; + const VERSION = '2.3.30'; const VERSION_ID = '20330'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; const RELEASE_VERSION = '30'; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From cff69aa18b5db9aac978b35f186ff670ff75d3e9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 30 May 2015 00:42:49 +0200 Subject: [PATCH 4/7] bumped Symfony version to 2.3.31 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 06e3d1ba2d..5391021318 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -60,12 +60,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.30'; - const VERSION_ID = '20330'; + const VERSION = '2.3.31-DEV'; + const VERSION_ID = '20331'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; - const RELEASE_VERSION = '30'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '31'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From 6d3ec633cd8db3b49864a078282fc0d1c8946505 Mon Sep 17 00:00:00 2001 From: Hassan Amouhzi Date: Sat, 30 May 2015 00:07:08 +0200 Subject: [PATCH 5/7] [BrowserKit] Fix bug when uri starts with http. | Q | A | ------------- | --- | Fixed tickets | | License | MIT --- src/Symfony/Component/BrowserKit/Client.php | 2 +- .../Component/BrowserKit/Tests/ClientTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 7f640a7919..06add6c34a 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -556,7 +556,7 @@ abstract class Client protected function getAbsoluteUri($uri) { // already absolute? - if (0 === strpos($uri, 'http')) { + if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) { return $uri; } diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index a6e5ba9e9a..3a8de92096 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -207,6 +207,21 @@ class ClientTest extends \PHPUnit_Framework_TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar'); $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo/'); + $client->request('GET', 'http'); + $this->assertEquals('http://www.example.com/foo/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo'); + $client->request('GET', 'http/bar'); + $this->assertEquals('http://www.example.com/http/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/'); + $client->request('GET', 'http'); + $this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); } public function testRequestURIConversionByServerHost() From bbb1064c99b1d6aa2162eb3cf8b20c51dd6074b1 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 31 May 2015 17:00:49 +0200 Subject: [PATCH 6/7] [Security][Acl] enforce string identifiers --- .../Security/Acl/Domain/ObjectIdentity.php | 4 ++-- .../Tests/Acl/Domain/ObjectIdentityTest.php | 24 ++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php b/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php index 907b1d8df8..fc5b9c6de6 100644 --- a/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php +++ b/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php @@ -36,7 +36,7 @@ final class ObjectIdentity implements ObjectIdentityInterface */ public function __construct($identifier, $type) { - if (empty($identifier)) { + if ('' === $identifier) { throw new \InvalidArgumentException('$identifier cannot be empty.'); } if (empty($type)) { @@ -66,7 +66,7 @@ final class ObjectIdentity implements ObjectIdentityInterface if ($domainObject instanceof DomainObjectInterface) { return new self($domainObject->getObjectIdentifier(), ClassUtils::getRealClass($domainObject)); } elseif (method_exists($domainObject, 'getId')) { - return new self($domainObject->getId(), ClassUtils::getRealClass($domainObject)); + return new self((string) $domainObject->getId(), ClassUtils::getRealClass($domainObject)); } } catch (\InvalidArgumentException $invalid) { throw new InvalidDomainObjectException($invalid->getMessage(), 0, $invalid); diff --git a/src/Symfony/Component/Security/Tests/Acl/Domain/ObjectIdentityTest.php b/src/Symfony/Component/Security/Tests/Acl/Domain/ObjectIdentityTest.php index 9281fd53e4..111ae8a984 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Domain/ObjectIdentityTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Domain/ObjectIdentityTest.php @@ -64,6 +64,26 @@ namespace Symfony\Component\Security\Tests\Acl\Domain $this->assertEquals('Symfony\Component\Security\Tests\Acl\Domain\TestDomainObject', $id->getType()); } + public function testFromDomainObjectWithoutInterfaceEnforcesStringIdentifier() + { + $domainObject = new TestDomainObject(); + $domainObject->id = 1; + $id = ObjectIdentity::fromDomainObject($domainObject); + + $this->assertSame('1', $id->getIdentifier()); + $this->assertEquals('Symfony\Component\Security\Tests\Acl\Domain\TestDomainObject', $id->getType()); + } + + public function testFromDomainObjectWithoutInterfaceAllowsZeroAsIdentifier() + { + $domainObject = new TestDomainObject(); + $domainObject->id = '0'; + $id = ObjectIdentity::fromDomainObject($domainObject); + + $this->assertSame('0', $id->getIdentifier()); + $this->assertEquals('Symfony\Component\Security\Tests\Acl\Domain\TestDomainObject', $id->getType()); + } + /** * @dataProvider getCompareData */ @@ -89,6 +109,8 @@ namespace Symfony\Component\Security\Tests\Acl\Domain class TestDomainObject { + public $id = 'getId()'; + public function getObjectIdentifier() { return 'getObjectIdentifier()'; @@ -96,7 +118,7 @@ namespace Symfony\Component\Security\Tests\Acl\Domain public function getId() { - return 'getId()'; + return $this->id; } } } From f4dfee3beaabf7858361243296df0f3b00838958 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 4 Jun 2015 12:31:30 +0200 Subject: [PATCH 7/7] Improve the config validation in TwigBundle --- .../TwigBundle/DependencyInjection/Configuration.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 8cc114ab29..30c6f6ffab 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -129,13 +129,13 @@ class Configuration implements ConfigurationInterface ->end() ->scalarNode('autoescape_service')->defaultNull()->end() ->scalarNode('autoescape_service_method')->defaultNull()->end() - ->scalarNode('base_template_class')->example('Twig_Template')->end() + ->scalarNode('base_template_class')->example('Twig_Template')->cannotBeEmpty()->end() ->scalarNode('cache')->defaultValue('%kernel.cache_dir%/twig')->end() ->scalarNode('charset')->defaultValue('%kernel.charset%')->end() - ->scalarNode('debug')->defaultValue('%kernel.debug%')->end() - ->scalarNode('strict_variables')->end() + ->booleanNode('debug')->defaultValue('%kernel.debug%')->end() + ->booleanNode('strict_variables')->end() ->scalarNode('auto_reload')->end() - ->scalarNode('optimizations')->end() + ->integerNode('optimizations')->min(-1)->end() ->arrayNode('paths') ->normalizeKeys(false) ->useAttributeAsKey('paths')