From 17ce6492d97c609f0a9db8fdd3279fd7e42c940d Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 26 Aug 2015 20:02:40 +0200 Subject: [PATCH 1/8] consistently use str_replace to unify directory separators (remaining) --- .../SecurityBundle/Tests/Functional/SetAclCommandTest.php | 2 +- .../Component/HttpKernel/DataCollector/DumpDataCollector.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php index 9a4a5e9a10..27cdd41a0d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php @@ -89,7 +89,7 @@ class SetAclCommandTest extends WebTestCase $setAclCommandTester = new CommandTester($setAclCommand); $setAclCommandTester->execute(array( 'command' => 'acl:set', - 'arguments' => array($grantedPermission, sprintf('%s:%s', strtr(self::OBJECT_CLASS, '\\', '/'), $objectId)), + 'arguments' => array($grantedPermission, sprintf('%s:%s', str_replace('\\', '/', self::OBJECT_CLASS), $objectId)), '--role' => array($role), )); diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php index 09abfb125b..efb0bb3e6e 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php @@ -120,7 +120,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface } if (false === $name) { - $name = strtr($file, '\\', '/'); + $name = str_replace('\\', '/', $file); $name = substr($name, strrpos($name, '/') + 1); } From 6dac13bc200dccb8a349d880d58cf3a9e9b35c10 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 26 Aug 2015 21:03:05 +0200 Subject: [PATCH 2/8] Fix appveyor file --- appveyor.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b69816c831..f916d31e66 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,6 @@ environment: cache: - c:\php -> appveyor.yml - .phpunit -> phpunit - - vendor -> composer.json init: - SET PATH=c:\php;%PATH% @@ -46,7 +45,7 @@ install: - cd c:\projects\symfony - php phpunit install - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) - - composer update --prefer-dist --no-progress --ansi + - composer update --prefer-source --no-progress --ansi test_script: - cd c:\projects\symfony From e564805b32dd5a57bfe62eb9111797f936ebf875 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 28 Aug 2015 07:48:22 +0200 Subject: [PATCH 3/8] [ci] Run minimal versions on appveyor only --- .travis.yml | 1 - appveyor.yml | 14 ++++++++------ .../Component/Filesystem/Tests/FilesystemTest.php | 3 ++- .../Intl/DateFormatter/IntlDateFormatter.php | 10 ++++++---- .../Intl/NumberFormatter/NumberFormatter.php | 5 +++-- .../AbstractNumberFormatterTest.php | 2 +- .../AbstractComparisonValidatorTestCase.php | 4 ++++ 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6df49b1e0e..7cc691c2b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ addons: matrix: include: - php: hhvm - - php: 5.3.3 - php: 5.3 - php: 5.4 - php: 5.5 diff --git a/appveyor.yml b/appveyor.yml index f916d31e66..bf278a7588 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,15 +21,17 @@ init: install: - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) - cd c:\php - - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.4.43-nts-Win32-VC9-x86.zip - - IF %PHP%==1 7z x php-5.4.43-nts-Win32-VC9-x86.zip -y > 7z.log + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.3.3-nts-Win32-VC9-x86.zip + - IF %PHP%==1 7z x php-5.3.3-nts-Win32-VC9-x86.zip -y > 7z.log - IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/ICU-51.2-dlls.zip - IF %PHP%==1 7z x ICU-51.2-dlls.zip -y > 7z.log - IF %PHP%==1 cd ext - - IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/php_intl-3.0.0-5.4-nts-vc9-x86.zip - - IF %PHP%==1 7z x php_intl-3.0.0-5.4-nts-vc9-x86.zip -y > 7z.log - - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apc/3.1.13/php_apc-3.1.13-5.4-nts-vc9-x86.zip - - IF %PHP%==1 7z x php_apc-3.1.13-5.4-nts-vc9-x86.zip -y > 7z.log + - IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/php_intl-3.0.0-5.3-nts-vc9-x86.zip + - IF %PHP%==1 7z x php_intl-3.0.0-5.3-nts-vc9-x86.zip -y > 7z.log + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apc/3.1.13/php_apc-3.1.13-5.3-nts-vc9-x86.zip + - IF %PHP%==1 7z x php_apc-3.1.13-5.3-nts-vc9-x86.zip -y > 7z.log + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/php_memcache-3.0.8-5.3-nts-vc9-x86.zip + - IF %PHP%==1 7z x php_memcache-3.0.8-5.3-nts-vc9-x86.zip -y > 7z.log - IF %PHP%==1 cd .. - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat - appveyor DownloadFile https://getcomposer.org/composer.phar diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 80ecb417d6..76f8fc0346 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -37,7 +37,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) { $target = tempnam(sys_get_temp_dir(), 'sl'); $link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand(); - if (self::$symlinkOnWindows = @symlink($target, $link)) { + if (@symlink($target, $link)) { + self::$symlinkOnWindows = @is_link($link); unlink($link); } unlink($target); diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 7de6db2d13..11f8c0f947 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -210,14 +210,16 @@ class IntlDateFormatter // behave like the intl extension $argumentError = null; if (!is_int($timestamp)) { - if (PHP_VERSION_ID < 50304) { - $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; - } elseif (!$timestamp instanceof \DateTime) { - $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; + if (!$timestamp instanceof \DateTime) { if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) { $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp); + } elseif (PHP_VERSION_ID >= 50304) { + $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; } } + if (PHP_VERSION_ID < 50304 && null === $argumentError) { + $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; + } } if (null !== $argumentError) { diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 542cce1a3c..07c8e84c86 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -824,7 +824,7 @@ class NumberFormatter // The negative PHP_INT_MAX was being converted to float if ( $value == self::$int32Range['negative'] && - ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) + ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) ) { return (int) $value; } @@ -837,7 +837,8 @@ class NumberFormatter // A 32 bit integer was being generated instead of a 64 bit integer if ( ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) && - (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) + (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) && + !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone')) ) { $value = (-2147483648 - ($value % -2147483648)) * ($value / abs($value)); } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 569ad776cf..53fd4f7238 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -590,7 +590,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 // The negative PHP_INT_MAX was being converted to float - if ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) { + if ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) { $this->assertInternalType('int', $parsedValue); } else { $this->assertInternalType('float', $parsedValue); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index d42c0aad52..f0737e16ff 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -79,6 +79,10 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal // Make sure we have the correct version loaded if ($dirtyValue instanceof \DateTime) { IntlTestHelper::requireIntl($this); + + if (PHP_VERSION_ID < 50304 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) { + $this->markTestSkipped('Intl supports formatting DateTime objects since 5.3.4'); + } } $constraint = $this->createConstraint(array('value' => $comparedValue)); From ccb3f562c59962de6adfd4d3d57d933e94ac809b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 29 Aug 2015 12:54:54 +0200 Subject: [PATCH 4/8] [Debug] Ignore silencing for deprecations --- src/Symfony/Component/Debug/ErrorHandler.php | 2 +- .../Debug/Tests/ErrorHandlerTest.php | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 332802fe6f..cc698ee533 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -352,7 +352,7 @@ class ErrorHandler */ public function handleError($type, $message, $file, $line, array $context, array $backtrace = null) { - $level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR; + $level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED; $log = $this->loggedErrors & $type; $throw = $this->thrownErrors & $type & $level; $type &= $level | $this->screamedErrors; diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 5d521a1434..c107c0c7cb 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -268,6 +268,28 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase } } + public function testHandleDeprecation() + { + $that = $this; + $logArgCheck = function ($level, $message, $context) use ($that) { + $that->assertEquals(LogLevel::INFO, $level); + $that->assertArrayHasKey('level', $context); + $that->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']); + $that->assertArrayHasKey('stack', $context); + }; + + $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger + ->expects($this->once()) + ->method('log') + ->will($this->returnCallback($logArgCheck)) + ; + + $handler = new ErrorHandler(); + $handler->setDefaultLogger($logger); + @$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array()); + } + public function testHandleException() { try { From b5b10b3d544d5b12b88fcdc5d3f6b5d0a294e01c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 30 Aug 2015 13:26:29 +0200 Subject: [PATCH 5/8] Don't trigger deprecation on interfaces --- .../HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php | 2 -- .../Component/Security/Core/SecurityContextInterface.php | 2 -- src/Symfony/Component/Templating/Asset/PackageInterface.php | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php b/src/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php index 2320867d43..5388e99c9a 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php @@ -15,8 +15,6 @@ namespace Symfony\Component\HttpKernel\HttpCache; -@trigger_error('The '.__NAMESPACE__.'\EsiResponseCacheStrategyInterface class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategyInterface class instead.', E_USER_DEPRECATED); - /** * ResponseCacheStrategyInterface implementations know how to compute the * Response cache HTTP header based on the different response cache headers. diff --git a/src/Symfony/Component/Security/Core/SecurityContextInterface.php b/src/Symfony/Component/Security/Core/SecurityContextInterface.php index a759feb810..2a06ca426a 100644 --- a/src/Symfony/Component/Security/Core/SecurityContextInterface.php +++ b/src/Symfony/Component/Security/Core/SecurityContextInterface.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Security\Core; -@trigger_error('The '.__NAMESPACE__.'\SecurityContextInterface interface is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED); - use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; diff --git a/src/Symfony/Component/Templating/Asset/PackageInterface.php b/src/Symfony/Component/Templating/Asset/PackageInterface.php index 9c880157a5..1bbe24bc7f 100644 --- a/src/Symfony/Component/Templating/Asset/PackageInterface.php +++ b/src/Symfony/Component/Templating/Asset/PackageInterface.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Templating\Asset; -@trigger_error('The Symfony\Component\Templating\Asset\PackageInterface is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED); - /** * Asset package interface. * From a53489e49a6fd6cd2f906639c20891cfc825f50a Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Mon, 24 Aug 2015 20:39:42 +0200 Subject: [PATCH 6/8] Do not normalize the kernel root directory path (see symfony/symfony#15474). --- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 5655275e53..cf3510047d 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -344,7 +344,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface { if (null === $this->rootDir) { $r = new \ReflectionObject($this); - $this->rootDir = str_replace('\\', '/', dirname($r->getFileName())); + $this->rootDir = dirname($r->getFileName()); } return $this->rootDir; From cd446f5e2fd8b066fddb5e5c75208ec7253d1404 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 31 Aug 2015 08:55:10 +0200 Subject: [PATCH 7/8] [travis] disable symfony_debug ext when deps!=no --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 508bc7cde0..3ec165a0a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ before_install: - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" =~ 5.[34] ]]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi; - - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo "extension = $(pwd)/modules/symfony_debug.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini); fi; + - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]] && [ "$deps" = "no" ]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo "extension = $(pwd)/modules/symfony_debug.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini); fi; - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi; - ./phpunit install - export PHPUNIT="$(readlink -f ./phpunit)" From b1bd06800a0a045ace19f255ccd99c0ac253cd00 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 29 Aug 2015 16:31:59 +0200 Subject: [PATCH 8/8] [VarDumper] Fix missing support for dumping PHP7 return type --- src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 0bf91c8204..48c5fd6f36 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -109,6 +109,7 @@ class ReflectionCaster self::addMap($a, $c, array( 'returnsReference' => 'returnsReference', + 'returnType' => 'getReturnType', 'class' => 'getClosureScopeClass', 'this' => 'getClosureThis', ));