From 376cc0332dcd95ea115980b4bc33f222c8fd6560 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 1 Nov 2014 13:49:09 +0100 Subject: [PATCH 1/9] don't override internal PHP constants --- src/Symfony/Bridge/Twig/Extension/CodeExtension.php | 12 +++++++----- .../Templating/Helper/CodeHelper.php | 12 +++++++----- .../Component/ClassLoader/ClassMapGenerator.php | 8 +++++--- .../Component/Console/Input/InputDefinition.php | 5 ----- src/Symfony/Component/Debug/ExceptionHandler.php | 13 +++++++------ .../Fragment/HIncludeFragmentRenderer.php | 13 +++++++------ src/Symfony/Component/Templating/PhpEngine.php | 13 +++++++------ .../Component/Yaml/Exception/ParseException.php | 12 ++++++------ .../Component/Yaml/Tests/ParseExceptionTest.php | 12 ++++++++++++ 9 files changed, 58 insertions(+), 42 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 0ec48ee036..1df3e5da28 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -11,10 +11,6 @@ namespace Symfony\Bridge\Twig\Extension; -if (!defined('ENT_SUBSTITUTE')) { - define('ENT_SUBSTITUTE', 8); -} - /** * Twig extension relate to PHP code and used by the profiler and the default exception templates. * @@ -176,7 +172,13 @@ class CodeExtension extends \Twig_Extension $text = "$text at line $line"; if (false !== $link = $this->getFileLink($file, $line)) { - return sprintf('%s', htmlspecialchars($link, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), $text); + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $flags = ENT_QUOTES | ENT_SUBSTITUTE; + } else { + $flags = ENT_QUOTES; + } + + return sprintf('%s', htmlspecialchars($link, $flags, $this->charset), $text); } return $text; diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index 795b86e1b6..a72d5bf16a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -13,10 +13,6 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; -if (!defined('ENT_SUBSTITUTE')) { - define('ENT_SUBSTITUTE', 8); -} - /** * CodeHelper. * @@ -170,7 +166,13 @@ class CodeHelper extends Helper } if (false !== $link = $this->getFileLink($file, $line)) { - return sprintf('%s', htmlspecialchars($link, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), $text); + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $flags = ENT_QUOTES | ENT_SUBSTITUTE; + } else { + $flags = ENT_QUOTES; + } + + return sprintf('%s', htmlspecialchars($link, $flags, $this->charset), $text); } return $text; diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 6b618cbe63..24a1d9769a 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -11,8 +11,10 @@ namespace Symfony\Component\ClassLoader; -if (!defined('T_TRAIT')) { - define('T_TRAIT', 0); +if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + define('SYMFONY_TRAIT', T_TRAIT); +} else { + define('SYMFONY_TRAIT', 0); } /** @@ -113,7 +115,7 @@ class ClassMapGenerator break; case T_CLASS: case T_INTERFACE: - case T_TRAIT: + case SYMFONY_TRAIT: // Find the classname while (($t = $tokens[++$i]) && is_array($t)) { if (T_STRING === $t[0]) { diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index 8a989eed7c..a21c350792 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -11,11 +11,6 @@ namespace Symfony\Component\Console\Input; -if (!defined('JSON_UNESCAPED_UNICODE')) { - define('JSON_UNESCAPED_SLASHES', 64); - define('JSON_UNESCAPED_UNICODE', 256); -} - use Symfony\Component\Console\Descriptor\TextDescriptor; use Symfony\Component\Console\Descriptor\XmlDescriptor; diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 74425cb760..acbeae6003 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -14,10 +14,6 @@ namespace Symfony\Component\Debug; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Debug\Exception\FlattenException; -if (!defined('ENT_SUBSTITUTE')) { - define('ENT_SUBSTITUTE', 8); -} - /** * ExceptionHandler converts an exception to a Response object. * @@ -292,6 +288,11 @@ EOF; */ private function formatArgs(array $args) { + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $flags = ENT_QUOTES | ENT_SUBSTITUTE; + } else { + $flags = ENT_QUOTES; + } $result = array(); foreach ($args as $key => $item) { if ('object' === $item[0]) { @@ -299,7 +300,7 @@ EOF; } elseif ('array' === $item[0]) { $formattedValue = sprintf("array(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); } elseif ('string' === $item[0]) { - $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset)); + $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], $flags, $this->charset)); } elseif ('null' === $item[0]) { $formattedValue = 'null'; } elseif ('boolean' === $item[0]) { @@ -307,7 +308,7 @@ EOF; } elseif ('resource' === $item[0]) { $formattedValue = 'resource'; } else { - $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), true)); + $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], $flags, $this->charset), true)); } $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index e9bece0225..4f53f3cf5e 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -11,10 +11,6 @@ namespace Symfony\Component\HttpKernel\Fragment; -if (!defined('ENT_SUBSTITUTE')) { - define('ENT_SUBSTITUTE', 8); -} - use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Templating\EngineInterface; @@ -111,11 +107,16 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer } $renderedAttributes = ''; if (count($attributes) > 0) { + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $flags = ENT_QUOTES | ENT_SUBSTITUTE; + } else { + $flags = ENT_QUOTES; + } foreach ($attributes as $attribute => $value) { $renderedAttributes .= sprintf( ' %s="%s"', - htmlspecialchars($attribute, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false), - htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false) + htmlspecialchars($attribute, $flags, $this->charset, false), + htmlspecialchars($value, $flags, $this->charset, false) ); } } diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 75a581e353..42eebebe1a 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -17,10 +17,6 @@ use Symfony\Component\Templating\Storage\StringStorage; use Symfony\Component\Templating\Helper\HelperInterface; use Symfony\Component\Templating\Loader\LoaderInterface; -if (!defined('ENT_SUBSTITUTE')) { - define('ENT_SUBSTITUTE', 8); -} - /** * PhpEngine is an engine able to render PHP templates. * @@ -466,6 +462,11 @@ class PhpEngine implements EngineInterface, \ArrayAccess protected function initializeEscapers() { $that = $this; + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $flags = ENT_QUOTES | ENT_SUBSTITUTE; + } else { + $flags = ENT_QUOTES; + } $this->escapers = array( 'html' => @@ -476,10 +477,10 @@ class PhpEngine implements EngineInterface, \ArrayAccess * * @return string the escaped value */ - function ($value) use ($that) { + function ($value) use ($that, $flags) { // Numbers and Boolean values get turned into strings which can cause problems // with type comparisons (e.g. === or is_int() etc). - return is_string($value) ? htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $that->getCharset(), false) : $value; + return is_string($value) ? htmlspecialchars($value, $flags, $that->getCharset(), false) : $value; }, 'js' => diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index ff01d6b9a6..eda6efae08 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -11,11 +11,6 @@ namespace Symfony\Component\Yaml\Exception; -if (!defined('JSON_UNESCAPED_UNICODE')) { - define('JSON_UNESCAPED_SLASHES', 64); - define('JSON_UNESCAPED_UNICODE', 256); -} - /** * Exception class thrown when an error occurs during parsing. * @@ -130,7 +125,12 @@ class ParseException extends RuntimeException } if (null !== $this->parsedFile) { - $this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; + } else { + $jsonOptions = 0; + } + $this->message .= sprintf(' in %s', json_encode($this->parsedFile, $jsonOptions)); } if ($this->parsedLine >= 0) { diff --git a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php index 289965e8d9..a45fb76313 100644 --- a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php @@ -27,4 +27,16 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase $this->assertEquals($message, $exception->getMessage()); } + + public function testGetMessageWithUnicodeInFilename() + { + $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml'); + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")'; + } else { + $message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")'; + } + + $this->assertEquals($message, $exception->getMessage()); + } } From 656d45f06aa9208cce73aee1f6343477631ae47d Mon Sep 17 00:00:00 2001 From: Jerome TAMARELLE Date: Mon, 17 Nov 2014 14:53:37 +0100 Subject: [PATCH 2/9] [Form] Add doc for FormEvents --- src/Symfony/Component/Form/FormEvents.php | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Symfony/Component/Form/FormEvents.php b/src/Symfony/Component/Form/FormEvents.php index 2bdd585251..54c72271c7 100644 --- a/src/Symfony/Component/Form/FormEvents.php +++ b/src/Symfony/Component/Form/FormEvents.php @@ -16,26 +16,57 @@ namespace Symfony\Component\Form; final class FormEvents { /** + * The PRE_SUBMIT event is dispatched at the beginning of the Form::submit() method. + * + * It can be used to: + * - Change data from the request, before submitting the data to the form. + * - Add or remove form fields, before submitting the data to the form. + * The event listener method receives a Symfony\Component\Form\FormEvent instance. + * * @Event */ const PRE_SUBMIT = 'form.pre_bind'; /** + * The SUBMIT event is dispatched just before the Form::submit() method + * transforms back the normalized data to the model and view data. + * + * It can be used to change data from the normalized representation of the data. + * The event listener method receives a Symfony\Component\Form\FormEvent instance. + * * @Event */ const SUBMIT = 'form.bind'; /** + * The FormEvents::POST_SUBMIT event is dispatched after the Form::submit() + * once the model and view data have been denormalized. + * + * It can be used to fetch data after denormalization. + * The event listener method receives a Symfony\Component\Form\FormEvent instance. + * * @Event */ const POST_SUBMIT = 'form.post_bind'; /** + * The FormEvents::PRE_SET_DATA event is dispatched at the beginning of the Form::setData() method. + * + * It can be used to: + * - Modify the data given during pre-population; + * - Modify a form depending on the pre-populated data (adding or removing fields dynamically). + * The event listener method receives a Symfony\Component\Form\FormEvent instance. + * * @Event */ const PRE_SET_DATA = 'form.pre_set_data'; /** + * The FormEvents::POST_SET_DATA event is dispatched at the end of the Form::setData() method. + * + * This event is mostly here for reading data after having pre-populated the form. + * The event listener method receives a Symfony\Component\Form\FormEvent instance. + * * @Event */ const POST_SET_DATA = 'form.post_set_data'; From 367ed3ce853943fbf81fb64edb6f20eff8d306e6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 17 Nov 2014 15:32:09 +0100 Subject: [PATCH 3/9] compare version using PHP_VERSION_ID To let opcode caches optimize cached code, the `PHP_VERSION_ID` constant is used to detect the current PHP version instead of calling `version_compare()` with `PHP_VERSION`. --- autoload.php.dist | 2 +- .../Bridge/Twig/Extension/CodeExtension.php | 2 +- .../Bridge/Twig/Tests/Node/FormThemeTest.php | 2 +- .../Node/SearchAndRenderBlockNodeTest.php | 2 +- .../Bridge/Twig/Tests/Node/TransNodeTest.php | 4 ++-- .../Command/ServerRunCommand.php | 2 +- .../Templating/Helper/CodeHelper.php | 2 +- .../SecurityRoutingIntegrationTest.php | 4 ++-- .../ClassLoader/ClassMapGenerator.php | 2 +- .../Tests/ClassCollectionLoaderTest.php | 4 ++-- .../Tests/ClassMapGeneratorTest.php | 2 +- .../Console/Descriptor/TextDescriptor.php | 2 +- src/Symfony/Component/Debug/ErrorHandler.php | 2 +- .../Component/Debug/ExceptionHandler.php | 2 +- src/Symfony/Component/DomCrawler/Crawler.php | 2 +- .../DateTimeToStringTransformer.php | 2 +- .../Csrf/CsrfProvider/DefaultCsrfProvider.php | 2 +- .../DateTimeToStringTransformerTest.php | 4 ++-- .../CsrfProvider/DefaultCsrfProviderTest.php | 2 +- .../Component/HttpFoundation/Response.php | 2 +- .../Storage/Handler/NativeSessionHandler.php | 2 +- .../Session/Storage/NativeSessionStorage.php | 10 ++++----- .../Session/Storage/Proxy/AbstractProxy.php | 4 ++-- .../Handler/NativeFileSessionHandlerTest.php | 2 +- .../Handler/NativeSessionHandlerTest.php | 2 +- .../Storage/NativeSessionStorageTest.php | 8 +++---- .../Storage/PhpBridgeSessionStorageTest.php | 4 ++-- .../Storage/Proxy/AbstractProxyTest.php | 16 +++++++------- .../Storage/Proxy/SessionHandlerProxyTest.php | 2 +- .../Fragment/HIncludeFragmentRenderer.php | 2 +- .../Controller/ControllerResolverTest.php | 2 +- .../Data/Bundle/Writer/JsonBundleWriter.php | 2 +- .../Intl/DateFormatter/IntlDateFormatter.php | 14 ++++++------ .../Intl/NumberFormatter/NumberFormatter.php | 10 ++------- .../Bundle/Writer/JsonBundleWriterTest.php | 4 ++-- .../AbstractIntlDateFormatterTest.php | 22 +++++++++---------- .../DateFormatter/IntlDateFormatterTest.php | 2 +- .../AbstractNumberFormatterTest.php | 15 +++---------- .../Security/Core/Util/SecureRandom.php | 2 +- .../Encoder/BCryptPasswordEncoderTest.php | 2 +- .../Serializer/Encoder/JsonDecode.php | 2 +- .../Component/Templating/PhpEngine.php | 2 +- .../Yaml/Exception/ParseException.php | 2 +- .../Yaml/Tests/ParseExceptionTest.php | 4 ++-- 44 files changed, 85 insertions(+), 100 deletions(-) diff --git a/autoload.php.dist b/autoload.php.dist index 0bb2bc3a85..689f140d09 100644 --- a/autoload.php.dist +++ b/autoload.php.dist @@ -1,6 +1,6 @@ =') && gc_enabled()) { +if (PHP_VERSION_ID >= 50400 && gc_enabled()) { // Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+ // https://bugs.php.net/bug.php?id=53976 gc_disable(); diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 1df3e5da28..cf7f1f576a 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -172,7 +172,7 @@ class CodeExtension extends \Twig_Extension $text = "$text at line $line"; if (false !== $link = $this->getFileLink($file, $line)) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index 7b2cd4f999..a4a4698ed8 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -67,7 +67,7 @@ class FormThemeTest extends TestCase protected function getVariableGetter($name) { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index 91c2f66b73..38be27cfbe 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -264,7 +264,7 @@ class SearchAndRenderBlockNodeTest extends TestCase protected function getVariableGetter($name) { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index e02637f237..df5eb559d8 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -38,7 +38,7 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase } protected function getVariableGetterWithoutStrictCheck($name) { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } @@ -47,7 +47,7 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase protected function getVariableGetterWithStrictCheck($name) { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index f05ec593ca..da66bb9615 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -29,7 +29,7 @@ class ServerRunCommand extends ContainerAwareCommand */ public function isEnabled() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { return false; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index a72d5bf16a..24c217f170 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -166,7 +166,7 @@ class CodeHelper extends Helper } if (false !== $link = $this->getFileLink($file, $line)) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php index bb16373c1b..5ec56deb36 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php @@ -30,7 +30,7 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testRoutingErrorIsExposedWhenNotProtected($config) { - if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) { + if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); } @@ -46,7 +46,7 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config) { - if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) { + if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); } diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 24a1d9769a..5b8ca598de 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -11,7 +11,7 @@ namespace Symfony\Component\ClassLoader; -if (version_compare(PHP_VERSION, '5.4.0', '>=')) { +if (PHP_VERSION_ID >= 50400) { define('SYMFONY_TRAIT', T_TRAIT); } else { define('SYMFONY_TRAIT', 0); diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index 7b71854da3..587f36902f 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -22,7 +22,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase { public function testTraitDependencies() { - if (version_compare(phpversion(), '5.4', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Requires PHP > 5.4'); return; @@ -100,7 +100,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase */ public function testClassWithTraitsReordering(array $classes) { - if (version_compare(phpversion(), '5.4', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Requires PHP > 5.4'); return; diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index 06fa04e454..e49cfdcf9b 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -104,7 +104,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase )), ); - if (version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { $data[] = array(__DIR__.'/Fixtures/php5.4', array( 'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php', diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 2003237441..6a51519f7b 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -186,7 +186,7 @@ class TextDescriptor extends Descriptor */ private function formatDefaultValue($default) { - if (version_compare(PHP_VERSION, '5.4', '<')) { + if (PHP_VERSION_ID < 50400) { return str_replace('\/', '/', json_encode($default)); } diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index c4954bda7a..9987ae4663 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -101,7 +101,7 @@ class ErrorHandler if ($level & (E_USER_DEPRECATED | E_DEPRECATED)) { if (isset(self::$loggers['deprecation'])) { - if (version_compare(PHP_VERSION, '5.4', '<')) { + if (PHP_VERSION_ID < 50400) { $stack = array_map( function ($row) { unset($row['args']); diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index acbeae6003..c7864dc961 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -288,7 +288,7 @@ EOF; */ private function formatArgs(array $args) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 50f00c1ff7..6c1274ef35 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -530,7 +530,7 @@ class Crawler extends \SplObjectStorage $html = ''; foreach ($this->getNode(0)->childNodes as $child) { - if (version_compare(PHP_VERSION, '5.3.6', '>=')) { + if (PHP_VERSION_ID >= 50306) { // node parameter was added to the saveHTML() method in PHP 5.3.6 // @see http://php.net/manual/en/domdocument.savehtml.php $html .= $child->ownerDocument->saveHTML($child); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index 11ffd3791d..4a84e01a52 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -69,7 +69,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer // The pipe in the parser pattern only works as of PHP 5.3.7 // See http://bugs.php.net/54316 $this->parseUsingPipe = null === $parseUsingPipe - ? version_compare(phpversion(), '5.3.7', '>=') + ? PHP_VERSION_ID >= 50307 : $parseUsingPipe; // See http://php.net/manual/en/datetime.createfromformat.php diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php index f0a74b4962..6b4ff984af 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php +++ b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php @@ -65,7 +65,7 @@ class DefaultCsrfProvider implements CsrfProviderInterface */ protected function getSessionId() { - if (version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { if (PHP_SESSION_NONE === session_status()) { session_start(); } 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 d6a6568b86..dbcdad0f96 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -60,7 +60,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase ); // This test will fail < 5.3.9 - see https://bugs.php.net/51994 - if (version_compare(phpversion(), '5.3.9', '>=')) { + if (PHP_VERSION_ID >= 50309) { $data[] = array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC'); } @@ -111,7 +111,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase */ public function testReverseTransformUsingPipe($format, $input, $output) { - if (version_compare(phpversion(), '5.3.7', '<')) { + if (PHP_VERSION_ID < 50307) { $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.'); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php index a99b544406..3cf62f8db3 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php @@ -49,7 +49,7 @@ class DefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase { session_id('touti'); - if (!version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('This test requires PHP >= 5.4'); } diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 0e5d07184e..4eec9cc38f 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -324,7 +324,7 @@ class Response while (($level = ob_get_level()) > 0 && $level !== $previous) { $previous = $level; if ($obStatus[$level - 1]) { - if (version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { if (isset($obStatus[$level - 1]['flags']) && ($obStatus[$level - 1]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE)) { ob_end_flush(); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php index 22acdecf61..0319e0f802 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php @@ -17,7 +17,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; * @see http://php.net/sessionhandler */ -if (version_compare(phpversion(), '5.4.0', '>=')) { +if (PHP_VERSION_ID >= 50400) { class NativeSessionHandler extends \SessionHandler { } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index f15ced587d..b1766503f1 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -100,7 +100,7 @@ class NativeSessionStorage implements SessionStorageInterface session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used) ini_set('session.use_cookies', 1); - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { session_register_shutdown(); } else { register_shutdown_function('session_write_close'); @@ -130,11 +130,11 @@ class NativeSessionStorage implements SessionStorageInterface return true; } - if (version_compare(phpversion(), '5.4.0', '>=') && \PHP_SESSION_ACTIVE === session_status()) { + if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) { throw new \RuntimeException('Failed to start the session: already started by PHP.'); } - if (version_compare(phpversion(), '5.4.0', '<') && isset($_SESSION) && session_id()) { + if (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id()) { // not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3 throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).'); } @@ -366,13 +366,13 @@ class NativeSessionStorage implements SessionStorageInterface if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) { $saveHandler = new SessionHandlerProxy($saveHandler); } elseif (!$saveHandler instanceof AbstractProxy) { - $saveHandler = version_compare(phpversion(), '5.4.0', '>=') ? + $saveHandler = PHP_VERSION_ID >= 50400 ? new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy(); } $this->saveHandler = $saveHandler; if ($this->saveHandler instanceof \SessionHandlerInterface) { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { session_set_save_handler($this->saveHandler, false); } else { session_set_save_handler( diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php index 0b7e5648c0..a46355aac4 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php @@ -72,7 +72,7 @@ abstract class AbstractProxy */ public function isActive() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { return $this->active = \PHP_SESSION_ACTIVE === session_status(); } @@ -93,7 +93,7 @@ abstract class AbstractProxy */ public function setActive($flag) { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { throw new \LogicException('This method is disabled in PHP 5.4.0+'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index 20cefabf49..3f96bdf025 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -27,7 +27,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase { $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); $this->assertEquals('files', ini_get('session.save_handler')); } else { diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php index 7880615db0..8fba843b7d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php @@ -28,7 +28,7 @@ class NativeSessionHandlerTest extends \PHPUnit_Framework_TestCase // note for PHPUnit optimisers - the use of assertTrue/False // here is deliberate since the tests do not require the classes to exist - drak - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->assertFalse($handler instanceof \SessionHandler); $this->assertTrue($handler instanceof NativeSessionHandler); } else { diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 4870115caa..ca8d28e337 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -164,7 +164,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase public function testSetSaveHandler53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -186,7 +186,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase public function testSetSaveHandler54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } @@ -211,7 +211,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase */ public function testStartedOutside53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -234,7 +234,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase */ public function testCanStartOutside54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index 0510f3fe9a..e712632589 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -60,7 +60,7 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase public function testPhpSession53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -84,7 +84,7 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase public function testPhpSession54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index f8ac39c94c..1df28cf1a2 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -87,7 +87,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase public function testIsActivePhp53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -99,7 +99,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase */ public function testIsActivePhp54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } @@ -110,7 +110,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase public function testSetActivePhp53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -126,7 +126,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase */ public function testSetActivePhp54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } @@ -149,7 +149,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase */ public function testNameExceptionPhp53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -163,7 +163,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase */ public function testNameExceptionPhp54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } @@ -187,7 +187,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase */ public function testIdExceptionPhp53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -201,7 +201,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase */ public function testIdExceptionPhp54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index 74d8419060..be9b110d02 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -52,7 +52,7 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->assertTrue($this->proxy->isActive()); } else { $this->assertFalse($this->proxy->isActive()); diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 4f53f3cf5e..e4ee7cea22 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -107,7 +107,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer } $renderedAttributes = ''; if (count($attributes) > 0) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index 652546e393..b9e9f277cf 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -188,7 +188,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase $request->attributes->set('foobar', 'foobar'); $controller = array(new self(), 'controllerMethod3'); - if (version_compare(PHP_VERSION, '5.3.16', '==')) { + if (PHP_VERSION_ID === 50316) { $this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system'); } else { try { diff --git a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php index 2af0815735..6a79340c69 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php @@ -35,7 +35,7 @@ class JsonBundleWriter implements BundleWriterInterface } }); - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { // Use JSON_PRETTY_PRINT so that we can see what changed in Git diffs file_put_contents( $path.'/'.$locale.'.json', diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index dcd418bbb7..32d01c4f1f 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -200,7 +200,7 @@ class IntlDateFormatter { // intl allows timestamps to be passed as arrays - we don't if (is_array($timestamp)) { - $message = version_compare(PHP_VERSION, '5.3.4', '>=') ? + $message = PHP_VERSION_ID >= 50304 ? 'Only integer Unix timestamps and DateTime objects are supported' : 'Only integer Unix timestamps are supported'; @@ -209,11 +209,11 @@ class IntlDateFormatter // behave like the intl extension $argumentError = null; - if (version_compare(PHP_VERSION, '5.3.4', '<') && !is_int($timestamp)) { + if (PHP_VERSION_ID < 50304 && !is_int($timestamp)) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; - } elseif (version_compare(PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) { + } elseif (PHP_VERSION_ID >= 50304 && !is_int($timestamp) && !$timestamp instanceof \DateTime) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=') && !is_int($timestamp)) { + if (PHP_VERSION_ID >= 50500 && !is_int($timestamp)) { $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp); } } @@ -227,7 +227,7 @@ class IntlDateFormatter } // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (version_compare(PHP_VERSION, '5.3.4', '>=') && $timestamp instanceof \DateTime) { + if (PHP_VERSION_ID >= 50304 && $timestamp instanceof \DateTime) { $timestamp = $timestamp->getTimestamp(); } @@ -376,7 +376,7 @@ class IntlDateFormatter } // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { return date_default_timezone_get(); } } @@ -541,7 +541,7 @@ class IntlDateFormatter { if (null === $timeZoneId) { // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $timeZoneId = date_default_timezone_get(); } else { // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index fe7d320624..d908aff34c 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -816,10 +816,7 @@ class NumberFormatter // The negative PHP_INT_MAX was being converted to float if ( $value == self::$int32Range['negative'] && - ( - (version_compare(PHP_VERSION, '5.4.0', '<') && version_compare(PHP_VERSION, '5.3.14', '>=')) || - version_compare(PHP_VERSION, '5.4.4', '>=') - ) + ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) ) { return (int) $value; } @@ -832,10 +829,7 @@ class NumberFormatter // A 32 bit integer was being generated instead of a 64 bit integer if ( ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) && - ( - (version_compare(PHP_VERSION, '5.3.14', '<')) || - (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) - ) + (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) ) { $value = (-2147483648 - ($value % -2147483648)) * ($value / abs($value)); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php index 73d6c20821..69575289cd 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php @@ -34,7 +34,7 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (version_compare(PHP_VERSION, '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('This test requires at least PHP 5.4.0.'); } @@ -47,7 +47,7 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase protected function tearDown() { - if (version_compare(PHP_VERSION, '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { return; } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 2c6f5558ff..dd4e4cd129 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -37,7 +37,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); } else { $this->assertNull($formatter->getTimeZoneId()); @@ -238,7 +238,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase ); // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (version_compare(PHP_VERSION, '5.3.4', '>=')) { + if (PHP_VERSION_ID >= 50304) { $dateTime = new \DateTime('@0'); /* general, DateTime */ @@ -269,7 +269,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase public function formatErrorProvider() { // With PHP 5.5 IntlDateFormatter accepts empty values ('0') - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { return array( array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR'), ); @@ -277,7 +277,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase $message = 'datefmt_format: takes either an array or an integer timestamp value : U_ILLEGAL_ARGUMENT_ERROR'; - if (version_compare(PHP_VERSION, '5.3.4', '>=')) { + if (PHP_VERSION_ID >= 50304) { $message = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object: U_ILLEGAL_ARGUMENT_ERROR'; } @@ -326,7 +326,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase ); // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC - if (!version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID < 50500) { // When time zone not exists, uses UTC by default $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00'); $data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00'); @@ -340,7 +340,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $formatter->setTimeZone('GMT+03:00'); } else { $formatter->setTimeZoneId('GMT+03:00'); @@ -353,7 +353,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $formatter->setTimeZone('GMT+00:30'); } else { $formatter->setTimeZoneId('GMT+00:30'); @@ -366,7 +366,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $formatter->setTimeZone('Pacific/Fiji'); } else { $formatter->setTimeZoneId('Pacific/Fiji'); @@ -388,7 +388,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase public function testFormatWithTimezoneFromEnvironmentVariable() { - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); } @@ -411,7 +411,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase public function testFormatWithTimezoneFromPhp() { - if (!version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID < 50500) { $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); } @@ -842,7 +842,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDefaultDateFormatter(); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $formatter->setTimeZone($timeZoneId); } else { $formatter->setTimeZoneId($timeZoneId); diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 68235a5429..2e7544b39e 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -57,7 +57,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $e); - if (version_compare(PHP_VERSION, '5.3.4', '>=')) { + if (PHP_VERSION_ID >= 50304) { $this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); } else { $this->assertStringEndsWith('Only integer Unix timestamps are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 32f0579908..e94d0c7032 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -593,10 +593,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 ( - (version_compare(PHP_VERSION, '5.4.0', '<') && version_compare(PHP_VERSION, '5.3.14', '>=')) || - version_compare(PHP_VERSION, '5.4.4', '>=') - ) { + if ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) { $this->assertInternalType('int', $parsedValue); } else { $this->assertInternalType('float', $parsedValue); @@ -653,10 +650,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 // A 32 bit integer was being generated instead of a 64 bit integer - if ( - (version_compare(PHP_VERSION, '5.3.14', '<')) || - (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) - ) { + if (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { $this->assertEquals(-2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); } else { $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); @@ -667,10 +661,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 // A 32 bit integer was being generated instead of a 64 bit integer - if ( - (version_compare(PHP_VERSION, '5.3.14', '<')) || - (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) - ) { + if (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { $this->assertEquals(2147483647, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); } else { $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); diff --git a/src/Symfony/Component/Security/Core/Util/SecureRandom.php b/src/Symfony/Component/Security/Core/Util/SecureRandom.php index 841b9af38b..aefc88854a 100644 --- a/src/Symfony/Component/Security/Core/Util/SecureRandom.php +++ b/src/Symfony/Component/Security/Core/Util/SecureRandom.php @@ -43,7 +43,7 @@ final class SecureRandom implements SecureRandomInterface $this->logger = $logger; // determine whether to use OpenSSL - if (defined('PHP_WINDOWS_VERSION_BUILD') && version_compare(PHP_VERSION, '5.3.4', '<')) { + if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50304) { $this->useOpenSsl = false; } elseif (!function_exists('openssl_random_pseudo_bytes')) { if (null !== $this->logger) { diff --git a/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php b/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php index dd962fd095..61e2afef18 100644 --- a/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php @@ -66,7 +66,7 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase private function skipIfPhpVersionIsNotSupported() { - if (version_compare(phpversion(), '5.3.7', '<')) { + if (PHP_VERSION_ID < 50307) { $this->markTestSkipped('Requires PHP >= 5.3.7'); } } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index 91b465535e..e94a1a9b1f 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -92,7 +92,7 @@ class JsonDecode implements DecoderInterface $recursionDepth = $context['json_decode_recursion_depth']; $options = $context['json_decode_options']; - if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + if (PHP_VERSION_ID >= 50400) { $decodedData = json_decode($data, $associative, $recursionDepth, $options); } else { $decodedData = json_decode($data, $associative, $recursionDepth); diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 42eebebe1a..288fddc70f 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -462,7 +462,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess protected function initializeEscapers() { $that = $this; - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index eda6efae08..f5b5e6b456 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -125,7 +125,7 @@ class ParseException extends RuntimeException } if (null !== $this->parsedFile) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; } else { $jsonOptions = 0; diff --git a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php index a45fb76313..8c2b1a49a9 100644 --- a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php @@ -19,7 +19,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase public function testGetMessage() { $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml'); - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")'; } else { $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")'; @@ -31,7 +31,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase public function testGetMessageWithUnicodeInFilename() { $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml'); - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")'; } else { $message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")'; From 0bd19aa49171c9d07225b91e59c01164df47b9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Sat, 8 Nov 2014 10:27:29 +0100 Subject: [PATCH 4/9] [Bridge/Propel1] Changed deps to accepts all upcoming propel1 versions --- composer.json | 2 +- src/Symfony/Bridge/Propel1/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0b8555a2da..9f2904983b 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ "doctrine/dbal": "~2.2", "doctrine/orm": "~2.2,>=2.2.3", "monolog/monolog": "~1.3", - "propel/propel1": "1.6.*", + "propel/propel1": "~1.6", "ircmaxell/password-compat": "1.0.*", "ocramius/proxy-manager": ">=0.3.1,<0.4-dev" }, diff --git a/src/Symfony/Bridge/Propel1/composer.json b/src/Symfony/Bridge/Propel1/composer.json index 3f64580182..027562c224 100644 --- a/src/Symfony/Bridge/Propel1/composer.json +++ b/src/Symfony/Bridge/Propel1/composer.json @@ -20,7 +20,7 @@ "symfony/http-foundation": "~2.0", "symfony/http-kernel": "~2.0", "symfony/form": "~2.2", - "propel/propel1": "1.6.*" + "propel/propel1": "~1.6" }, "require-dev": { "symfony/stopwatch": "~2.2" From d9c2e6d46f48d6a2cced554b799168c66116b710 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 18 Nov 2014 09:38:51 +0100 Subject: [PATCH 5/9] Adjust upgrade file rendering --- UPGRADE-3.0.md | 612 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 586 insertions(+), 26 deletions(-) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 077bac29f2..f8dcd0b5e4 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -6,18 +6,100 @@ UPGRADE FROM 2.x to 3.0 * The `UniversalClassLoader` class has been removed in favor of `ClassLoader`. The only difference is that some method names are different: - * `registerNamespaces()` -> `addPrefixes()` - * `registerPrefixes()` -> `addPrefixes()` - * `registerNamespace()` -> `addPrefix()` - * `registerPrefix()` -> `addPrefix()` - * `getNamespaces()` -> `getPrefixes()` - * `getNamespaceFallbacks()` -> `getFallbackDirs()` - * `getPrefixFallbacks()` -> `getFallbackDirs()` + | Old name | New name + | -------- | --- + | `registerNamespaces()` | `addPrefixes()` + | `registerPrefixes()` | `addPrefixes()` + | `registerNamespaces()` | `addPrefix()` + | `registerPrefixes()` | `addPrefix()` + | `getNamespaces()` | `getPrefixes()` + | `getNamespaceFallbacks()` | `getFallbackDirs()` + | `getPrefixFallbacks()` | `getFallbackDirs()` * The `DebugUniversalClassLoader` class has been removed in favor of `DebugClassLoader`. The difference is that the constructor now takes a loader to wrap. +### Console + + * The `dialog` helper has been removed in favor of the `question` helper. + + * The methods `isQuiet`, `isVerbose`, `isVeryVerbose` and `isDebug` were added + to `Symfony\Component\Console\Output\OutputInterface`. + + * `ProgressHelper` has been removed in favor of `ProgressBar`. + + Before: + + ```php + $h = new ProgressHelper(); + $h->start($output, 10); + for ($i = 1; $i < 5; $i++) { + usleep(200000); + $h->advance(); + } + $h->finish(); + ``` + + After: + + ```php + $bar = new ProgressBar($output, 10); + $bar->start(); + for ($i = 1; $i < 5; $i++) { + usleep(200000); + $bar->advance(); + } + ``` + + * `TableHelper` has been removed in favor of `Table`. + + Before: + + ```php + $table = $app->getHelperSet()->get('table'); + $table + ->setHeaders(array('ISBN', 'Title', 'Author')) + ->setRows(array( + array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), + array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), + array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), + array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), + )) + ; + $table->render($output); + ``` + + After: + + ```php + use Symfony\Component\Console\Helper\Table; + + $table = new Table($output); + $table + ->setHeaders(array('ISBN', 'Title', 'Author')) + ->setRows(array( + array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), + array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), + array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), + array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), + )) + ; + $table->render(); + ``` + +### DependencyInjection + + * The methods `Definition::setFactoryClass()`, + `Definition::setFactoryMethod()`, and `Definition::setFactoryService()` have + been removed in favor of `Definition::setFactory()`. Services defined using + YAML or XML use the same syntax as configurators. + +### EventDispatcher + + * The interface `Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface` + extends `Symfony\Component\EventDispatcher\EventDispatcherInterface`. + ### Form * The methods `Form::bind()` and `Form::isBound()` were removed. You should @@ -77,8 +159,8 @@ UPGRADE FROM 2.x to 3.0 } ``` - * The events PRE_BIND, BIND and POST_BIND were renamed to PRE_SUBMIT, SUBMIT - and POST_SUBMIT. + * The events `PRE_BIND`, `BIND` and `POST_BIND` were renamed to `PRE_SUBMIT`, `SUBMIT` + and `POST_SUBMIT`. Before: @@ -96,7 +178,7 @@ UPGRADE FROM 2.x to 3.0 }); ``` - * The option "virtual" was renamed to "inherit_data". + * The option "`virtual`" was renamed to "`inherit_data`". Before: @@ -114,7 +196,7 @@ UPGRADE FROM 2.x to 3.0 )); ``` - * The class VirtualFormAwareIterator was renamed to InheritDataAwareIterator. + * The class `VirtualFormAwareIterator` was renamed to `InheritDataAwareIterator`. Before: @@ -156,11 +238,81 @@ UPGRADE FROM 2.x to 3.0 } ``` - * The `FormItegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace. + * The `FormIntegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace. + * The constants `ROUND_HALFEVEN`, `ROUND_HALFUP` and `ROUND_HALFDOWN` in class + `NumberToLocalizedStringTransformer` were renamed to `ROUND_HALF_EVEN`, + `ROUND_HALF_UP` and `ROUND_HALF_DOWN`. + + * The methods `ChoiceListInterface::getIndicesForChoices()` and + `ChoiceListInterface::getIndicesForValues()` were removed. No direct + replacement exists, although in most cases + `ChoiceListInterface::getChoicesForValues()` and + `ChoiceListInterface::getValuesForChoices()` should be sufficient. + + * The interface `Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface` + and all of its implementations were removed. Use the new interface + `Symfony\Component\Security\Csrf\CsrfTokenManagerInterface` instead. + + * The options "`csrf_provider`" and "`intention`" were renamed to "`csrf_token_generator`" + and "`csrf_token_id`". + + * The method `Form::getErrorsAsString()` was removed. Use `Form::getErrors()` + instead with the argument `$deep` set to true and `$flatten` set to false + and cast the returned iterator to a string (if not done implicitly by PHP). + + Before: + + ```php + echo $form->getErrorsAsString(); + ``` + + After: + + ```php + echo $form->getErrors(true, false); + ``` ### FrameworkBundle + * The `getRequest` method of the base `Controller` class has been deprecated + since Symfony 2.4 and must be therefore removed in 3.0. The only reliable + way to get the `Request` object is to inject it in the action method. + + Before: + + ```php + namespace Acme\FooBundle\Controller; + + class DemoController + { + public function showAction() + { + $request = $this->getRequest(); + // ... + } + } + ``` + + After: + + ```php + namespace Acme\FooBundle\Controller; + + use Symfony\Component\HttpFoundation\Request; + + class DemoController + { + public function showAction(Request $request) + { + // ... + } + } + ``` + + * The `request` service was removed. You must inject the `request_stack` + service instead. + * The `enctype` method of the `form` helper was removed. You should use the new method `start` instead. @@ -211,16 +363,20 @@ UPGRADE FROM 2.x to 3.0 end($form) ?> ``` + * The `RouterApacheDumperCommand` was removed. + ### HttpKernel * The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in favor of `Psr\Log\LoggerInterface`. The only difference is that some method names are different: - * `emerg()` -> `emergency()` - * `crit()` -> `critical()` - * `err()` -> `error()` - * `warn()` -> `warning()` + | Old name | New name + | -------- | --- + | `emerg()` | `emergency()` + | `crit()` | `critical()` + | `err()` | `error()` + | `warn()` | `warning()` The previous method renames also happened to the following classes: @@ -232,26 +388,33 @@ UPGRADE FROM 2.x to 3.0 * The following classes have been renamed as they have been moved to the Debug component: - * `Symfony\Component\HttpKernel\Debug\ErrorHandler` -> `Symfony\Component\Debug\ErrorHandler` - * `Symfony\Component\HttpKernel\Debug\ExceptionHandler` -> `Symfony\Component\Debug\ExceptionHandler` - * `Symfony\Component\HttpKernel\Exception\FatalErrorException` -> `Symfony\Component\Debug\Exception\FatalErrorException` - * `Symfony\Component\HttpKernel\Exception\FlattenException` -> `Symfony\Component\Debug\Exception\FlattenException` + | Old name | New name + | -------- | --- + | `Symfony\Component\HttpKernel\Debug\ErrorHandler` | `Symfony\Component\Debug\ErrorHandler` + | `Symfony\Component\HttpKernel\Debug\ExceptionHandler` | `Symfony\Component\Debug\ExceptionHandler` + | `Symfony\Component\HttpKernel\Exception\FatalErrorException` | `Symfony\Component\Debug\Exception\FatalErrorException` + | `Symfony\Component\HttpKernel\Exception\FlattenException` | `Symfony\Component\Debug\Exception\FlattenException` * The `Symfony\Component\HttpKernel\EventListener\ExceptionListener` now passes the Request format as the `_format` argument instead of `format`. + * The `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass` has been renamed to + `Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass` and moved to the EventDispatcher component. + ### Locale * The Locale component was removed and replaced by the Intl component. Instead of the methods in `Symfony\Component\Locale\Locale`, you should use these equivalent methods in `Symfony\Component\Intl\Intl` now: - * `Locale::getDisplayCountries()` -> `Intl::getRegionBundle()->getCountryNames()` - * `Locale::getCountries()` -> `array_keys(Intl::getRegionBundle()->getCountryNames())` - * `Locale::getDisplayLanguages()` -> `Intl::getLanguageBundle()->getLanguageNames()` - * `Locale::getLanguages()` -> `array_keys(Intl::getLanguageBundle()->getLanguageNames())` - * `Locale::getDisplayLocales()` -> `Intl::getLocaleBundle()->getLocaleNames()` - * `Locale::getLocales()` -> `array_keys(Intl::getLocaleBundle()->getLocaleNames())` + | Old way | New way + | ------- | --- + | `Locale::getDisplayCountries()` | `Intl::getRegionBundle()->getCountryNames()` + | `Locale::getCountries()` | `array_keys(Intl::getRegionBundle()->getCountryNames())` + | `Locale::getDisplayLanguages()` | `Intl::getLanguageBundle()->getLanguageNames()` + | `Locale::getLanguages()` | `array_keys(Intl::getLanguageBundle()->getLanguageNames())` + | `Locale::getDisplayLocales()` | `Intl::getLocaleBundle()->getLocaleNames()` + | `Locale::getLocales()` | `array_keys(Intl::getLocaleBundle()->getLocaleNames())` ### PropertyAccess @@ -326,6 +489,14 @@ UPGRADE FROM 2.x to 3.0 $route->setSchemes('https'); ``` + * The `ApacheMatcherDumper` and `ApacheUrlMatcher` were removed since + the performance gains were minimal and it's hard to replicate the behaviour + of PHP implementation. + +### Security + + * The `Resources/` directory was moved to `Core/Resources/` + ### Translator * The `Translator::setFallbackLocale()` method has been removed in favor of @@ -387,6 +558,29 @@ UPGRADE FROM 2.x to 3.0 ### Validator + * The class `Symfony\Component\Validator\Mapping\Cache\ApcCache` has been removed in favor + of `Symfony\Component\Validator\Mapping\Cache\DoctrineCache`. + + Before: + + ```php + use Symfony\Component\Validator\Mapping\Cache\ApcCache; + + $cache = new ApcCache('symfony.validator'); + ``` + + After: + + ```php + use Symfony\Component\Validator\Mapping\Cache\DoctrineCache; + use Doctrine\Common\Cache\ApcCache; + + $apcCache = new ApcCache(); + $apcCache->setNamespace('symfony.validator'); + + $cache = new DoctrineCache($apcCache); + ``` + * The constraints `Optional` and `Required` were moved to the `Symfony\Component\Validator\Constraints\` namespace. You should adapt the path wherever you used them. @@ -419,6 +613,366 @@ UPGRADE FROM 2.x to 3.0 private $property; ``` + * The option "`methods`" of the `Callback` constraint was removed. You should + use the option "`callback`" instead. If you have multiple callbacks, add + multiple callback constraints instead. + + Before (YAML): + + ```yaml + constraints: + - Callback: [firstCallback, secondCallback] + ``` + + After (YAML): + + ```yaml + constraints: + - Callback: firstCallback + - Callback: secondCallback + ``` + + When using annotations, you can now put the `Callback` constraint directly on + the method that should be executed. + + Before (Annotations): + + ```php + use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\ExecutionContextInterface; + + /** + * @Assert\Callback({"callback"}) + */ + class MyClass + { + public function callback(ExecutionContextInterface $context) + { + // ... + } + } + ``` + + After (Annotations): + + ```php + use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\ExecutionContextInterface; + + class MyClass + { + /** + * @Assert\Callback + */ + public function callback(ExecutionContextInterface $context) + { + // ... + } + } + ``` + + * The interface `ValidatorInterface` was replaced by the more powerful + interface `Validator\ValidatorInterface`. The signature of the `validate()` + method is slightly different in that interface and accepts a value, zero + or more constraints and validation group. It replaces both + `validate()` and `validateValue()` in the previous interface. + + Before: + + ```php + $validator->validate($object, 'Strict'); + + $validator->validateValue($value, new NotNull()); + ``` + + After: + + ```php + $validator->validate($object, null, 'Strict'); + + $validator->validate($value, new NotNull()); + ``` + + Apart from this change, the new methods `startContext()` and `inContext()` + were added. The first of them allows to run multiple validations in the + same context and aggregate their violations: + + ```php + $violations = $validator->startContext() + ->atPath('firstName')->validate($firstName, new NotNull()) + ->atPath('age')->validate($age, new Type('integer')) + ->getViolations(); + ``` + + The second allows to run validation in an existing context. This is + especially useful when calling the validator from within constraint + validators: + + ```php + $validator->inContext($context)->validate($object); + ``` + + Instead of a `Validator`, the validator builder now returns a + `Validator\RecursiveValidator` instead. + + * The interface `ValidationVisitorInterface` and its implementation + `ValidationVisitor` were removed. The implementation of the visitor pattern + was flawed. Fixing that implementation would have drastically slowed down + the validator execution, so the visitor was removed completely instead. + + Along with the visitor, the method `accept()` was removed from + `MetadataInterface`. + + * The interface `MetadataInterface` was moved to the `Mapping` namespace. + + Before: + + ```php + use Symfony\Component\Validator\MetadataInterface; + ``` + + After: + + ```php + use Symfony\Component\Validator\Mapping\MetadataInterface; + ``` + + The methods `getCascadingStrategy()` and `getTraversalStrategy()` were + added to the interface. The first method should return a bit mask of the + constants in class `CascadingStrategy`. The second should return a bit + mask of the constants in `TraversalStrategy`. + + Example: + + ```php + use Symfony\Component\Validator\Mapping\TraversalStrategy; + + public function getTraversalStrategy() + { + return TraversalStrategy::TRAVERSE; + } + ``` + + * The interface `PropertyMetadataInterface` was moved to the `Mapping` + namespace. + + Before: + + ```php + use Symfony\Component\Validator\PropertyMetadataInterface; + ``` + + After: + + ```php + use Symfony\Component\Validator\Mapping\PropertyMetadataInterface; + ``` + + * The interface `PropertyMetadataContainerInterface` was moved to the `Mapping` + namespace and renamed to `ClassMetadataInterface`. + + Before: + + ```php + use Symfony\Component\Validator\PropertyMetadataContainerInterface; + ``` + + After: + + ```php + use Symfony\Component\Validator\Mapping\ClassMetadataInterface; + ``` + + The interface now contains four additional methods: + + * `getConstrainedProperties()` + * `hasGroupSequence()` + * `getGroupSequence()` + * `isGroupSequenceProvider()` + + See the inline documentation of these methods for more information. + + * The interface `ClassBasedInterface` was removed. You should use + `Mapping\ClassMetadataInterface` instead: + + Before: + + ```php + use Symfony\Component\Validator\ClassBasedInterface; + + class MyClassMetadata implements ClassBasedInterface + { + // ... + } + ``` + + After: + + ```php + use Symfony\Component\Validator\Mapping\ClassMetadataInterface; + + class MyClassMetadata implements ClassMetadataInterface + { + // ... + } + ``` + + * The class `ElementMetadata` was renamed to `GenericMetadata`. + + Before: + + ```php + use Symfony\Component\Validator\Mapping\ElementMetadata; + + class MyMetadata extends ElementMetadata + { + } + ``` + + After: + + ```php + use Symfony\Component\Validator\Mapping\GenericMetadata; + + class MyMetadata extends GenericMetadata + { + } + ``` + + * The interface `ExecutionContextInterface` and its implementation + `ExecutionContext` were moved to the `Context` namespace. + + Before: + + ```php + use Symfony\Component\Validator\ExecutionContextInterface; + ``` + + After: + + ```php + use Symfony\Component\Validator\Context\ExecutionContextInterface; + ``` + + The interface now contains the following additional methods: + + * `getValidator()` + * `getObject()` + * `setNode()` + * `setGroup()` + * `markGroupAsValidated()` + * `isGroupValidated()` + * `markConstraintAsValidated()` + * `isConstraintValidated()` + + See the inline documentation of these methods for more information. + + The method `addViolationAt()` was removed. You should use `buildViolation()` + instead. + + Before: + + ```php + $context->addViolationAt('property', 'The value {{ value }} is invalid.', array( + '{{ value }}' => $invalidValue, + )); + ``` + + After: + + ```php + $context->buildViolation('The value {{ value }} is invalid.') + ->atPath('property') + ->setParameter('{{ value }}', $invalidValue) + ->addViolation(); + ``` + + The methods `validate()` and `validateValue()` were removed. You should use + `getValidator()` together with `inContext()` instead. + + Before: + + ```php + $context->validate($object); + ``` + + After: + + ```php + $context->getValidator() + ->inContext($context) + ->validate($object); + ``` + + The parameters `$invalidValue`, `$plural` and `$code` were removed from + `addViolation()`. You should use `buildViolation()` instead. See above for + an example. + + The method `getMetadataFactory()` was removed. You can use `getValidator()` + instead and use the methods `getMetadataFor()` or `hasMetadataFor()` on the + validator instance. + + Before: + + ```php + $metadata = $context->getMetadataFactory()->getMetadataFor($myClass); + ``` + + After: + + ```php + $metadata = $context->getValidator()->getMetadataFor($myClass); + ``` + + * The interface `GlobalExecutionContextInterface` was removed. Most of the + information provided by that interface can be queried from + `Context\ExecutionContextInterface` instead. + + * The interface `MetadataFactoryInterface` was moved to the `Mapping\Factory` + namespace along with its implementations `BlackholeMetadataFactory` and + `ClassMetadataFactory`. These classes were furthermore renamed to + `BlackHoleMetadataFactory` and `LazyLoadingMetadataFactory`. + + Before: + + ```php + use Symfony\Component\Validator\Mapping\ClassMetadataFactory; + + $factory = new ClassMetadataFactory($loader); + ``` + + After: + + ```php + use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; + + $factory = new LazyLoadingMetadataFactory($loader); + ``` + + * The option `$deep` was removed from the constraint `Valid`. When traversing + arrays, nested arrays are always traversed (same behavior as before). When + traversing nested objects, their traversal strategy is used. + + * The method `ValidatorBuilder::setPropertyAccessor()` was removed. The + validator now functions without a property accessor. + + * The methods `getMessageParameters()` and `getMessagePluralization()` in + `ConstraintViolation` were renamed to `getParameters()` and `getPlural()`. + + Before: + + ```php + $parameters = $violation->getMessageParameters(); + $plural = $violation->getMessagePluralization(); + ``` + + After: + + ```php + $parameters = $violation->getParameters(); + $plural = $violation->getPlural(); + ``` + ### Yaml * The ability to pass file names to `Yaml::parse()` has been removed. @@ -434,3 +988,9 @@ UPGRADE FROM 2.x to 3.0 ```php Yaml::parse(file_get_contents($fileName)); ``` + +### Process + + * `Process::setStdin()` and `Process::getStdin()` have been removed. Use + `Process::setInput()` and `Process::getInput()` that works the same way. + * `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types. From ba8d93705ced93de14657103b77911740fa6db38 Mon Sep 17 00:00:00 2001 From: gerryvdm Date: Tue, 18 Nov 2014 14:29:43 +0100 Subject: [PATCH 6/9] Fixed grammar error in docblock --- src/Symfony/Component/Config/ConfigCache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/ConfigCache.php b/src/Symfony/Component/Config/ConfigCache.php index 4b58e7352a..946e1be424 100644 --- a/src/Symfony/Component/Config/ConfigCache.php +++ b/src/Symfony/Component/Config/ConfigCache.php @@ -90,7 +90,7 @@ class ConfigCache * @param string $content The content to write in the cache * @param ResourceInterface[] $metadata An array of ResourceInterface instances * - * @throws \RuntimeException When cache file can't be wrote + * @throws \RuntimeException When cache file can't be written */ public function write($content, array $metadata = null) { From 7f7b700234c66aa5c1a00cf2c2706068ac44ac1b Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Thu, 13 Nov 2014 13:39:39 +0200 Subject: [PATCH 7/9] Azerbaijani locale --- .../Resources/translations/validators.az.xlf | 19 ++ .../Resources/translations/security.az.xlf | 71 ++++++ .../Resources/translations/security.az.xlf | 71 ++++++ .../Resources/translations/validators.az.xlf | 227 ++++++++++++++++++ 4 files changed, 388 insertions(+) create mode 100644 src/Symfony/Component/Form/Resources/translations/validators.az.xlf create mode 100644 src/Symfony/Component/Security/Core/Resources/translations/security.az.xlf create mode 100644 src/Symfony/Component/Security/Resources/translations/security.az.xlf create mode 100644 src/Symfony/Component/Validator/Resources/translations/validators.az.xlf diff --git a/src/Symfony/Component/Form/Resources/translations/validators.az.xlf b/src/Symfony/Component/Form/Resources/translations/validators.az.xlf new file mode 100644 index 0000000000..69e447385a --- /dev/null +++ b/src/Symfony/Component/Form/Resources/translations/validators.az.xlf @@ -0,0 +1,19 @@ + + + + + + This form should not contain extra fields. + Bu formada əlavə sahə olmamalıdır. + + + The uploaded file was too large. Please try to upload a smaller file. + Yüklənən fayl çox böyükdür. Lütfən daha kiçik fayl yükləyin. + + + The CSRF token is invalid. Please try to resubmit the form. + CSRF nişanı yanlışdır. Lütfen formanı yenidən göndərin. + + + + diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.az.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.az.xlf new file mode 100644 index 0000000000..a974ed0f02 --- /dev/null +++ b/src/Symfony/Component/Security/Core/Resources/translations/security.az.xlf @@ -0,0 +1,71 @@ + + + + + + An authentication exception occurred. + Doğrulama istisnası baş verdi. + + + Authentication credentials could not be found. + Doğrulama məlumatları tapılmadı. + + + Authentication request could not be processed due to a system problem. + Sistem xətası səbəbilə doğrulama istəyi emal edilə bilmədi. + + + Invalid credentials. + Yanlış məlumat. + + + Cookie has already been used by someone else. + Kuki başqası tərəfindən istifadə edilib. + + + Not privileged to request the resource. + Resurs istəyi üçün imtiyaz yoxdur. + + + Invalid CSRF token. + Yanlış CSRF nişanı. + + + Digest nonce has expired. + Dərləmə istifadə müddəti bitib. + + + No authentication provider found to support the authentication token. + Doğrulama nişanını dəstəkləyəcək provayder tapılmadı. + + + No session available, it either timed out or cookies are not enabled. + Uyğun seans yoxdur, vaxtı keçib və ya kuki aktiv deyil. + + + No token could be found. + Nişan tapılmadı. + + + Username could not be found. + İstifadəçi adı tapılmadı. + + + Account has expired. + Hesabın istifadə müddəti bitib. + + + Credentials have expired. + Məlumatların istifadə müddəti bitib. + + + Account is disabled. + Hesab qeyri-aktiv edilib. + + + Account is locked. + Hesab kilitlənib. + + + + diff --git a/src/Symfony/Component/Security/Resources/translations/security.az.xlf b/src/Symfony/Component/Security/Resources/translations/security.az.xlf new file mode 100644 index 0000000000..a974ed0f02 --- /dev/null +++ b/src/Symfony/Component/Security/Resources/translations/security.az.xlf @@ -0,0 +1,71 @@ + + + + + + An authentication exception occurred. + Doğrulama istisnası baş verdi. + + + Authentication credentials could not be found. + Doğrulama məlumatları tapılmadı. + + + Authentication request could not be processed due to a system problem. + Sistem xətası səbəbilə doğrulama istəyi emal edilə bilmədi. + + + Invalid credentials. + Yanlış məlumat. + + + Cookie has already been used by someone else. + Kuki başqası tərəfindən istifadə edilib. + + + Not privileged to request the resource. + Resurs istəyi üçün imtiyaz yoxdur. + + + Invalid CSRF token. + Yanlış CSRF nişanı. + + + Digest nonce has expired. + Dərləmə istifadə müddəti bitib. + + + No authentication provider found to support the authentication token. + Doğrulama nişanını dəstəkləyəcək provayder tapılmadı. + + + No session available, it either timed out or cookies are not enabled. + Uyğun seans yoxdur, vaxtı keçib və ya kuki aktiv deyil. + + + No token could be found. + Nişan tapılmadı. + + + Username could not be found. + İstifadəçi adı tapılmadı. + + + Account has expired. + Hesabın istifadə müddəti bitib. + + + Credentials have expired. + Məlumatların istifadə müddəti bitib. + + + Account is disabled. + Hesab qeyri-aktiv edilib. + + + Account is locked. + Hesab kilitlənib. + + + + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.az.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.az.xlf new file mode 100644 index 0000000000..add868cd42 --- /dev/null +++ b/src/Symfony/Component/Validator/Resources/translations/validators.az.xlf @@ -0,0 +1,227 @@ + + + + + + This value should be false. + Bu dəyər false olmalıdır. + + + This value should be true. + Bu dəyər true olmalıdır. + + + This value should be of type {{ type }}. + Bu dəyərin tipi {{ type }} olmalıdır. + + + This value should be blank. + Bu dəyər boş olmalıdır. + + + The value you selected is not a valid choice. + Seçdiyiniz dəyər düzgün bir seçim değil. + + + You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. + Ən az {{ limit }} seçim qeyd edilməlidir. + + + You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. + Ən çox {{ limit }} seçim qeyd edilməlidir. + + + One or more of the given values is invalid. + Təqdim edilən dəyərlərdən bir və ya bir neçəsi yanlışdır. + + + This field was not expected. + Bu sahə gözlənilmirdi. + + + This field is missing. + Bu sahə əksikdir. + + + This value is not a valid date. + Bu dəyər düzgün bir tarix deyil. + + + This value is not a valid datetime. + Bu dəyər düzgün bir tarixsaat deyil. + + + This value is not a valid email address. + Bu dəyər düzgün bir e-poçt adresi deyil. + + + The file could not be found. + Fayl tapılmadı. + + + The file is not readable. + Fayl oxunabilən deyil. + + + The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. + Fayl çox böyükdür ({{ size }} {{ suffix }}). İcazə verilən maksimum fayl ölçüsü {{ limit }} {{ suffix }}. + + + The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. + Faylın mime tipi yanlışdr ({{ type }}). İcazə verilən mime tipləri {{ types }}. + + + This value should be {{ limit }} or less. + Bu dəyər {{ limit }} və ya altında olmalıdır. + + + This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. + Bu dəyər çox uzundur. {{ limit }} və ya daha az simvol olmalıdır. + + + This value should be {{ limit }} or more. + Bu dəyər {{ limit }} veya daha fazla olmalıdır. + + + This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. + Bu dəyər çox qısadır. {{ limit }} və ya daha çox simvol olmalıdır. + + + This value should not be blank. + Bu dəyər boş olmamalıdır. + + + This value should not be null. + Bu dəyər boş olmamalıdır. + + + This value should be null. + Bu dəyər boş olmamalıdır. + + + This value is not valid. + Bu dəyər doğru deyil. + + + This value is not a valid time. + Bu dəyər doğru bir saat deyil. + + + This value is not a valid URL. + Bu dəyər doğru bir URL değil. + + + The two values should be equal. + İki dəyər eyni olmalıdır. + + + The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. + Fayl çox böyükdür. İcazə verilən ən böyük fayl ölçüsü {{ limit }} {{ suffix }}. + + + The file is too large. + Fayl çox böyükdür. + + + The file could not be uploaded. + Fayl yüklənəbilmir. + + + This value should be a valid number. + Bu dəyər rəqəm olmalıdır. + + + This file is not a valid image. + Bu fayl düzgün bir şəkil deyil. + + + This is not a valid IP address. + Bu düzgün bir IP adresi deyil. + + + This value is not a valid language. + Bu dəyər düzgün bir dil deyil. + + + This value is not a valid locale. + Bu dəyər düzgün bir dil deyil. + + + This value is not a valid country. + Bu dəyər düzgün bir ölkə deyil. + + + This value is already used. + Bu dəyər hal-hazırda istifadədədir. + + + The size of the image could not be detected. + Şəklin ölçüsü hesablana bilmir. + + + The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. + Şəklin genişliyi çox böyükdür ({{ width }}px). İcazə verilən ən böyük genişlik {{ max_width }}px. + + + The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. + Şəklin genişliyi çox kiçikdir ({{ width }}px). Ən az {{ min_width }}px olmalıdır. + + + The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. + Şəklin yüksəkliyi çox böyükdür ({{ height }}px). İcazə verilən ən böyük yüksəklik {{ max_height }}px. + + + The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. + Şəklin yüksəkliyi çox kiçikdir ({{ height }}px). Ən az {{ min_height }}px olmalıdır. + + + This value should be the user's current password. + Bu dəyər istifadəçinin hazırkı parolu olmalıdır. + + + This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. + Bu dəyər tam olaraq {{ limit }} simvol olmaldır. + + + The file was only partially uploaded. + Fayl qismən yükləndi. + + + No file was uploaded. + Fayl yüklənmədi. + + + No temporary folder was configured in php.ini. + php.ini'də müvəqqəti qovluq quraşdırılmayıb. + + + Cannot write temporary file to disk. + Müvəqqəti fayl diskə yazıla bilmir. + + + A PHP extension caused the upload to fail. + Bir PHP əlavəsi faylın yüklənməsinə mane oldu. + + + This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. + Bu kolleksiyada {{ limit }} və ya daha çox element olmalıdır. + + + This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. + Bu kolleksiyada {{ limit }} və ya daha az element olmalıdır. + + + This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. + Bu kolleksiyada tam olaraq {{ limit }} element olmalıdır. + + + Invalid card number. + Yanlış kart nömrəsi. + + + Unsupported card type or invalid card number. + Dəstəklənməyən kart tipi və ya yanlış kart nömrəsi. + + + + From e28f5b8356e020a46e8addec55e311a27b2f8c09 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 20 Nov 2014 10:40:57 +0100 Subject: [PATCH 8/9] be smarter when guessing the document root --- .../Bundle/FrameworkBundle/Command/ServerRunCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index da66bb9615..5f3ea5dffb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -44,7 +44,7 @@ class ServerRunCommand extends ContainerAwareCommand $this ->setDefinition(array( new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', 'localhost:8000'), - new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', 'web/'), + new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null), new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'), )) ->setName('server:run') @@ -83,6 +83,10 @@ EOF { $documentRoot = $input->getOption('docroot'); + if (null === $documentRoot) { + $documentRoot = $this->getContainer()->getParameter('kernel.root_dir').'/../web'; + } + if (!is_dir($documentRoot)) { $output->writeln(sprintf('The given document root directory "%s" does not exist', $documentRoot)); From 92c8dfb5e667df360e23b70dfcaba653bba6b8f4 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Wed, 5 Nov 2014 14:40:47 +0100 Subject: [PATCH 9/9] [SecurityBundle] Authentication entry point is only registered with firewall exception listener, not with authentication listeners --- .../DependencyInjection/SecurityExtension.php | 13 ++--- .../FirewallEntryPointExtension.php | 26 ++++++++++ .../FirewallEntryPointBundle.php | 18 +++++++ .../Resources/config/services.xml | 10 ++++ .../Security/EntryPointStub.php | 27 ++++++++++ .../Functional/FirewallEntryPointTest.php | 51 +++++++++++++++++++ .../app/FirewallEntryPoint/bundles.php | 7 +++ .../app/FirewallEntryPoint/config.yml | 33 ++++++++++++ .../app/FirewallEntryPoint/routing.yml | 2 + 9 files changed, 179 insertions(+), 8 deletions(-) create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/DependencyInjection/FirewallEntryPointExtension.php create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/FirewallEntryPointBundle.php create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Resources/config/services.xml create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/routing.yml diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 957ef17b82..dcc68f44cf 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -333,8 +333,11 @@ class SecurityExtension extends Extension ; } + // Determine default entry point + $defaultEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null; + // Authentication listeners - list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider); + list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider, $defaultEntryPoint); $listeners = array_merge($listeners, $authListeners); @@ -346,11 +349,6 @@ class SecurityExtension extends Extension // Access listener $listeners[] = new Reference('security.access_listener'); - // Determine default entry point - if (isset($firewall['entry_point'])) { - $defaultEntryPoint = $firewall['entry_point']; - } - // Exception listener $exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $defaultEntryPoint)); @@ -370,11 +368,10 @@ class SecurityExtension extends Extension return $this->contextListeners[$contextKey] = $listenerId; } - private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider) + private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider, $defaultEntryPoint) { $listeners = array(); $hasListeners = false; - $defaultEntryPoint = null; foreach ($this->listenerPositions as $position) { foreach ($this->factories[$position] as $factory) { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/DependencyInjection/FirewallEntryPointExtension.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/DependencyInjection/FirewallEntryPointExtension.php new file mode 100644 index 0000000000..e4d5bc30f3 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/DependencyInjection/FirewallEntryPointExtension.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\DependencyInjection; + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; + +class FirewallEntryPointExtension extends Extension +{ + public function load(array $config, ContainerBuilder $container) + { + $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/FirewallEntryPointBundle.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/FirewallEntryPointBundle.php new file mode 100644 index 0000000000..f4247ad050 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/FirewallEntryPointBundle.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class FirewallEntryPointBundle extends Bundle +{ +} diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Resources/config/services.xml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Resources/config/services.xml new file mode 100644 index 0000000000..76abc3d262 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Resources/config/services.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php new file mode 100644 index 0000000000..e1d3280570 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Security\Core\Exception\AuthenticationException; +use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; + +class EntryPointStub implements AuthenticationEntryPointInterface +{ + const RESPONSE_TEXT = '2be8e651259189d841a19eecdf37e771e2431741'; + + public function start(Request $request, AuthenticationException $authException = null) + { + return new Response(self::RESPONSE_TEXT); + } +} diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php new file mode 100644 index 0000000000..23acde45a5 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SecurityBundle\Tests\Functional; + +use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub; + +/** + * @group functional + */ +class FirewallEntryPointTest extends WebTestCase +{ + public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials() + { + $client = $this->createClient(array('test_case' => 'FirewallEntryPoint')); + $client->insulate(); + + $client->request('GET', '/secure/resource', array(), array(), array( + 'PHP_AUTH_USER' => 'unknown', + 'PHP_AUTH_PW' => 'credentials', + )); + + $this->assertEquals( + EntryPointStub::RESPONSE_TEXT, + $client->getResponse()->getContent(), + "Custom entry point wasn't started" + ); + } + + protected function setUp() + { + parent::setUp(); + + $this->deleteTmpDir('FirewallEntryPoint'); + } + + protected function tearDown() + { + parent::tearDown(); + + $this->deleteTmpDir('FirewallEntryPoint'); + } +} diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php new file mode 100644 index 0000000000..c6fd207dd1 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php @@ -0,0 +1,7 @@ +