From ae9bae7e16fd27e17339f2dbc45bcafc2294949d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 24 Mar 2016 23:24:57 +0100 Subject: [PATCH 01/10] [phpunit] disable prophecy --- phpunit | 1 + 1 file changed, 1 insertion(+) diff --git a/phpunit b/phpunit index d2da42616d..6d66f7b2b2 100755 --- a/phpunit +++ b/phpunit @@ -51,6 +51,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ $zip->extractTo(getcwd()); $zip->close(); chdir("phpunit-$PHPUNIT_VERSION"); + passthru("$COMPOSER remove --no-update phpspec/prophecy"); passthru("$COMPOSER remove --no-update symfony/yaml"); passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.1@dev\""); passthru("$COMPOSER install --prefer-dist --no-progress --ansi", $exit); From bc2182883825061879a6dd35e9eae5951255d4be Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Sun, 27 Mar 2016 13:58:34 +0200 Subject: [PATCH 02/10] [Form] cs fixes in date types --- .../Component/Form/Extension/Core/Type/DateTimeType.php | 2 +- src/Symfony/Component/Form/Extension/Core/Type/DateType.php | 6 +++--- src/Symfony/Component/Form/Extension/Core/Type/TimeType.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index 5a653233b9..dc3a988fb4 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -198,7 +198,7 @@ class DateTimeType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $compound = function (Options $options) { - return $options['widget'] !== 'single_text'; + return 'single_text' !== $options['widget']; }; // Defaults to the value of "widget" diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 4d5935c048..febf86c83f 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -78,7 +78,7 @@ class DateType extends AbstractType $pattern ); - // new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323 + // new \IntlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323 if (!$formatter) { throw new InvalidOptionsException(intl_get_error_message(), intl_get_error_code()); } @@ -171,7 +171,7 @@ class DateType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $compound = function (Options $options) { - return $options['widget'] !== 'single_text'; + return 'single_text' !== $options['widget']; }; $emptyValue = $emptyValueDefault = function (Options $options) { @@ -196,7 +196,7 @@ class DateType extends AbstractType }; $format = function (Options $options) { - return $options['widget'] === 'single_text' ? DateType::HTML5_FORMAT : DateType::DEFAULT_FORMAT; + return 'single_text' === $options['widget'] ? DateType::HTML5_FORMAT : DateType::DEFAULT_FORMAT; }; $resolver->setDefaults(array( diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index fc6362c24c..e6eca1059e 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -157,7 +157,7 @@ class TimeType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $compound = function (Options $options) { - return $options['widget'] !== 'single_text'; + return 'single_text' !== $options['widget']; }; $emptyValue = $emptyValueDefault = function (Options $options) { From 106ed0660c7dc6053bd9b2b9072ca706640a5d78 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 25 Mar 2016 16:27:11 +0100 Subject: [PATCH 03/10] [ClassLoader] Fix storing not-found classes in APC cache --- src/Symfony/Component/ClassLoader/ApcClassLoader.php | 6 ++++-- .../Component/ClassLoader/ApcUniversalClassLoader.php | 6 ++++-- src/Symfony/Component/ClassLoader/DebugClassLoader.php | 2 +- src/Symfony/Component/ClassLoader/WinCacheClassLoader.php | 6 ++++-- src/Symfony/Component/ClassLoader/XcacheClassLoader.php | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/ApcClassLoader.php b/src/Symfony/Component/ClassLoader/ApcClassLoader.php index 4f71ea173d..c21c64e38b 100644 --- a/src/Symfony/Component/ClassLoader/ApcClassLoader.php +++ b/src/Symfony/Component/ClassLoader/ApcClassLoader.php @@ -122,8 +122,10 @@ class ApcClassLoader */ public function findFile($class) { - if (false === $file = apcu_fetch($this->prefix.$class)) { - apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class)); + $file = apcu_fetch($this->prefix.$class, $success); + + if (!$success) { + apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null); } return $file; diff --git a/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php b/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php index bedb30f895..bad90267ff 100644 --- a/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php +++ b/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php @@ -87,8 +87,10 @@ class ApcUniversalClassLoader extends UniversalClassLoader */ public function findFile($class) { - if (false === $file = apcu_fetch($this->prefix.$class)) { - apcu_store($this->prefix.$class, $file = parent::findFile($class)); + $file = apcu_fetch($this->prefix.$class, $success); + + if (!$success) { + apcu_store($this->prefix.$class, $file = parent::findFile($class) ?: null); } return $file; diff --git a/src/Symfony/Component/ClassLoader/DebugClassLoader.php b/src/Symfony/Component/ClassLoader/DebugClassLoader.php index eec68b2c98..53be5b5c87 100644 --- a/src/Symfony/Component/ClassLoader/DebugClassLoader.php +++ b/src/Symfony/Component/ClassLoader/DebugClassLoader.php @@ -74,7 +74,7 @@ class DebugClassLoader */ public function findFile($class) { - return $this->classFinder->findFile($class); + return $this->classFinder->findFile($class) ?: null; } /** diff --git a/src/Symfony/Component/ClassLoader/WinCacheClassLoader.php b/src/Symfony/Component/ClassLoader/WinCacheClassLoader.php index 0fc11d019f..8c846e3c26 100644 --- a/src/Symfony/Component/ClassLoader/WinCacheClassLoader.php +++ b/src/Symfony/Component/ClassLoader/WinCacheClassLoader.php @@ -123,8 +123,10 @@ class WinCacheClassLoader */ public function findFile($class) { - if (false === $file = wincache_ucache_get($this->prefix.$class)) { - wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0); + $file = wincache_ucache_get($this->prefix.$class, $success); + + if (!$success) { + wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null, 0); } return $file; diff --git a/src/Symfony/Component/ClassLoader/XcacheClassLoader.php b/src/Symfony/Component/ClassLoader/XcacheClassLoader.php index bf512273ef..11da39d6f3 100644 --- a/src/Symfony/Component/ClassLoader/XcacheClassLoader.php +++ b/src/Symfony/Component/ClassLoader/XcacheClassLoader.php @@ -126,7 +126,7 @@ class XcacheClassLoader if (xcache_isset($this->prefix.$class)) { $file = xcache_get($this->prefix.$class); } else { - $file = $this->decorated->findFile($class); + $file = $this->decorated->findFile($class) ?: null; xcache_set($this->prefix.$class, $file); } From 0d31c3e9cb63ec41ccd0ee90e688e52e29233405 Mon Sep 17 00:00:00 2001 From: Cameron Porter Date: Mon, 28 Mar 2016 23:46:00 -0500 Subject: [PATCH 04/10] [WebProfilerBundle] Add missing use statement. Request is needed in RouterController::getTraces to be able to create a request. --- .../Bundle/WebProfilerBundle/Controller/RouterController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php index 2be420ba8b..d77eb279f4 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Controller; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; use Symfony\Component\Routing\Matcher\TraceableUrlMatcher; From d5e8f6f20af3fbef2c620978b082064dcccd5cef Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 29 Mar 2016 16:17:20 +0200 Subject: [PATCH 05/10] [Process] remove dead code --- .../Component/Process/Tests/ProcessTest.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index c33e0837b9..ebe6c2057c 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -901,23 +901,6 @@ class ProcessTest extends \PHPUnit_Framework_TestCase return $codes; } - /** - * provides default method names for simple getter/setter. - */ - public function methodProvider() - { - $defaults = array( - array('CommandLine'), - array('Timeout'), - array('WorkingDirectory'), - array('Env'), - array('Stdin'), - array('Options'), - ); - - return $defaults; - } - /** * @param string $commandline * @param null $cwd From 763ed6c1e9575503f19031648c1cc2ee6d9c3377 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 24 Mar 2016 14:09:50 +0100 Subject: [PATCH 06/10] fix testing deprecation messages * always restore the previous error handler * throw `LogicExcetion` when unexpected error type is triggered --- .../Tests/ContainerBuilderTest.php | 23 +++++++++++-------- .../Component/Yaml/Tests/ParserTest.php | 8 +++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 18f7b67f46..442129bb20 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -61,24 +61,27 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase public function testCreateDeprecatedService() { + $deprecations = array(); + set_error_handler(function ($type, $msg) use (&$deprecations) { + if (E_USER_DEPRECATED !== $type) { + restore_error_handler(); + + return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args()); + } + + $deprecations[] = $msg; + }); + $definition = new Definition('stdClass'); $definition->setDeprecated(true); - $that = $this; - $wasTriggered = false; - - set_error_handler(function ($errno, $errstr) use ($that, &$wasTriggered) { - $that->assertSame(E_USER_DEPRECATED, $errno); - $that->assertSame('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $errstr); - $wasTriggered = true; - }); - $builder = new ContainerBuilder(); $builder->createService($definition, 'deprecated_foo'); restore_error_handler(); - $this->assertTrue($wasTriggered); + $this->assertCount(1, $deprecations); + $this->assertContains('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $deprecations[0]); } public function testRegister() diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index d41c583ed5..8fea5e8e84 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -889,9 +889,13 @@ EOF; $deprecations = array(); set_error_handler(function ($type, $msg) use (&$deprecations) { - if (E_USER_DEPRECATED === $type) { - $deprecations[] = $msg; + if (E_USER_DEPRECATED !== $type) { + restore_error_handler(); + + return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args()); } + + $deprecations[] = $msg; }); $this->parser->parse($yaml); From aa4dd4fcf04138da47289f7d5237717527043215 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 29 Mar 2016 21:58:51 +0200 Subject: [PATCH 07/10] fix high deps tests --- .../Twig/Resources/views/Form/form_div_layout.html.twig | 4 ++-- .../Resources/views/Form/widget_attributes.html.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index ae5d7fbed4..4e5b9dd598 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -314,10 +314,10 @@ {%- block widget_attributes -%} id="{{ id }}" name="{{ full_name }}" - {%- if read_only and attr.readonly is not defined %} readonly="readonly"{% endif -%} + {%- if read_only %} readonly="readonly"{% endif -%} {%- if disabled %} disabled="disabled"{% endif -%} {%- if required %} required="required"{% endif -%} - {%- for attrname, attrvalue in attr -%} + {%- for attrname, attrvalue in attr if 'readonly' != attrname or not read_only -%} {{- " " -}} {%- if attrname in ['placeholder', 'title'] -%} {{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}" diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php index 14e65a7991..e90298701c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php @@ -1,7 +1,8 @@ -id="escape($id) ?>" name="escape($full_name) ?>" readonly="readonly" +id="escape($id) ?>" name="escape($full_name) ?>" readonly="readonly" disabled="disabled" required="required" $v): ?> + escape($k), $view->escape($view['translator']->trans($v, array(), $translation_domain))) ?> From b0320967633d5571e211aa80d19e7050a001e096 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 28 Mar 2016 11:08:12 +0200 Subject: [PATCH 08/10] [Debug] Fix handling of php7 throwables --- src/Symfony/Component/Debug/Debug.php | 24 ++++++++++++++++++++ src/Symfony/Component/Debug/ErrorHandler.php | 6 +++++ 2 files changed, 30 insertions(+) diff --git a/src/Symfony/Component/Debug/Debug.php b/src/Symfony/Component/Debug/Debug.php index 82014e4ad4..eca19da9e6 100644 --- a/src/Symfony/Component/Debug/Debug.php +++ b/src/Symfony/Component/Debug/Debug.php @@ -46,6 +46,30 @@ class Debug ErrorHandler::register($errorReportingLevel, $displayErrors); if ('cli' !== PHP_SAPI) { ExceptionHandler::register(); + + if (PHP_VERSION_ID >= 70000) { + $exceptionHandler = set_exception_handler(function ($throwable) use (&$exceptionHandler) { + if ($throwable instanceof \Exception) { + $exception = $throwable; + } else { + static $refl = null; + + if (null === $refl) { + $refl = array(); + foreach (array('file', 'line', 'trace') as $prop) { + $prop = new \ReflectionProperty('Exception', $prop); + $prop->setAccessible(true); + $refl[] = $prop; + } + } + $exception = new \Exception($throwable->getMessage(), $throwable->getCode()); + foreach ($refl as $prop) { + $prop->setValue($exception, $throwable->{'get'.$prop->name}()); + } + } + $exceptionHandler($exception); + }); + } // CLI - display errors only if they're not already logged to STDERR } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { ini_set('display_errors', 1); diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 43e196242a..f12ece7a0d 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -197,6 +197,12 @@ class ErrorHandler $exceptionHandler = set_exception_handler(function () {}); restore_exception_handler(); + if (PHP_VERSION_ID >= 70000 && $exceptionHandler instanceof \Closure) { + $reflector = new \ReflectionFunction($exceptionHandler); + foreach ($reflector->getStaticVariables() as $exceptionHandler) { + break; + } + } if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) { $level = isset($this->levels[$type]) ? $this->levels[$type] : $type; $message = sprintf('%s: %s in %s line %d', $level, $error['message'], $error['file'], $error['line']); From 73361771459f05a598eb14120a5b860270c98e83 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 29 Mar 2016 19:31:32 +0200 Subject: [PATCH 09/10] [Debug] Fix case sensitivity checks --- .../Component/Debug/DebugClassLoader.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index fc036a6286..36afa36930 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -51,15 +51,25 @@ class DebugClassLoader } if (!isset(self::$caseCheck)) { - if(!file_exists(strtolower(__FILE__))) { + $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR); + $i = strrpos($file, DIRECTORY_SEPARATOR); + $dir = substr($file, 0, 1 + $i); + $file = substr($file, 1 + $i); + $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file); + $test = realpath($dir.$test); + + if (false === $test || false === $i) { // filesystem is case sensitive self::$caseCheck = 0; - } elseif(realpath(strtolower(__FILE__)) === __FILE__) { - // filesystem is not case sensitive + } elseif (substr($test, -strlen($file)) === $file) { + // filesystem is case insensitive and realpath() normalizes the case of characters self::$caseCheck = 1; - } else { - // filesystem is not case sensitive AND realpath() fails to normalize case + } elseif (false !== stripos(PHP_OS, 'darwin')) { + // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters self::$caseCheck = 2; + } else { + // filesystem case checks failed, fallback to disabling them + self::$caseCheck = 0; } } } From 8814ed023df4b569e5541a4aed0848f4a868f353 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 Mar 2016 11:37:19 +0200 Subject: [PATCH 10/10] [ci] Get ICU/intl from github instead of nebm.ist.utl.pt/~glopes --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 35d4ba0e81..8491cd23db 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,11 +21,11 @@ install: - IF %PHP%==1 appveyor DownloadFile https://curl.haxx.se/ca/cacert.pem - 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 >nul - - IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/ICU-51.2-dlls.zip + - IF %PHP%==1 appveyor DownloadFile https://raw.githubusercontent.com/symfony/binary-utils/master/ICU-51.2-dlls.zip - IF %PHP%==1 7z x ICU-51.2-dlls.zip -y >nul - IF %PHP%==1 del /Q *.zip - 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.3-nts-vc9-x86.zip + - IF %PHP%==1 appveyor DownloadFile https://raw.githubusercontent.com/symfony/binary-utils/master/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 >nul - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apcu/4.0.10/php_apcu-4.0.10-5.3-nts-vc9-x86.zip - IF %PHP%==1 7z x php_apcu-4.0.10-5.3-nts-vc9-x86.zip -y >nul