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) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index e7f5386980..88092976ef 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -161,13 +161,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') diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 90df108c8b..f41f156ac4 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -547,7 +547,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/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..cc7db71fd2 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() @@ -332,7 +347,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 +377,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 +407,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 +577,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/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 8976706096..9c6131b803 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 6375542b28..7636bed87b 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 0421ceeae4..6641e51023 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -1080,7 +1080,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 9b3f4d92e1..47e4d4fed8 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 b839cc0a18..23c17a58f7 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -125,7 +125,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) { @@ -144,7 +144,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(), ); } elseif (is_object($controller)) { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 83a7e4e3e9..68ee7ea82d 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -386,7 +386,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/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/Acl/Tests/Domain/EntryTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php index 6a2aac0d80..ab8e481daf 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/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/Security/Acl/Tests/Domain/ObjectIdentityTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityTest.php index 4eab7b2a7f..325bb910b3 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityTest.php @@ -64,6 +64,26 @@ namespace Symfony\Component\Security\Acl\Tests\Domain $this->assertEquals('Symfony\Component\Security\Acl\Tests\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\Acl\Tests\Domain class TestDomainObject { + public $id = 'getId()'; + public function getObjectIdentifier() { return 'getObjectIdentifier()'; @@ -96,7 +118,7 @@ namespace Symfony\Component\Security\Acl\Tests\Domain public function getId() { - return 'getId()'; + return $this->id; } } } diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index 47ca9edcee..a14b6e80ea 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()); $this->assertSame($event, $stopwatch->getEvent('foo')); } @@ -75,7 +75,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); }