8000 [3.0] Removed some old hacks · symfony/symfony@56ffc6d · GitHub
[go: up one dir, main page]

Skip to content

Commit 56ffc6d

Browse files
GrahamCampbellnicolas-grekas
authored andcommitted
[3.0] Removed some old hacks
1 parent d282545 commit 56ffc6d

File tree

62 files changed

+108
-756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+108
-756
lines changed

README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,13 @@ README
44
What is Symfony?
55
-----------------
66

7-
Symfony is a PHP 5.3 full-stack web framework. It is written with speed and
7+
Symfony is a PHP full-stack web framework. It is written with speed and
88
flexibility in mind. It allows developers to build better and easy to maintain
99
websites with PHP.
1010

1111
Symfony can be used to develop all kind of websites, from your personal blog
1212
to high traffic ones like Dailymotion or Yahoo! Answers.
1313

14-
Requirements
15-
------------
16-
17-
Symfony is only supported on PHP 5.3.3 and up.
18-
19-
Be warned that PHP versions before 5.3.8 are known to be buggy and might not
20-
work for you:
21-
22-
* before PHP 5.3.4, if you get "Notice: Trying to get property of
23-
non-object", you've hit a known PHP bug (see
24-
https://bugs.php.net/bug.php?id=52083 and
25-
https://bugs.php.net/bug.php?id=50027);
26-
27-
* before PHP 5.3.8, if you get an error involving annotations, you've hit a
28-
known PHP bug (see https://bugs.php.net/bug.php?id=55156).
29-
30-
* PHP 5.3.16 has a major bug in the Reflection subsystem and is not suitable to
31-
run Symfony (https://bugs.php.net/bug.php?id=62715)
32-
3314
Installation
3415
------------
3516

autoload.php.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
4-
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
5-
// https://bugs.php.net/bug.php?id=53976
3+
// Disabling Zend Garbage Collection to prevent segfaults
4+
// https://bugs.php.net/bug.php?id=53976
5+
if (gc_enabled()) {
66
gc_disable();
77
}
88

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,7 @@ public function formatFile($file, $line, $text = null)
174174
$text = "$text at line $line";
175175

176176
if (false !== $link = $this->getFileLink($file, $line)) {
177-
if (PHP_VERSION_ID >= 50400) {
178-
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
179-
} else {
180-
$flags = ENT_QUOTES;
181-
}
177+
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
182178

183179
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
184180
}

src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ public function testCompile()
6666

6767
protected function getVariableGetter($name)
6868
{
69-
if (PHP_VERSION_ID >= 50400) {
70-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
71-
}
72-
73-
return sprintf('$this->getContext($context, "%s")', $name);
69+
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
7470
}
7571
}

src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,6 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
263263

264264
protected function getVariableGetter($name)
265265
{
266-
if (PHP_VERSION_ID >= 50400) {
267-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
268-
}
269-
270-
return sprintf('$this->getContext($context, "%s")', $name);
266+
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
271267
}
272268
}

src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,11 @@ public function testCompileStrict()
3838
}
3939
protected function getVariableGetterWithoutStrictCheck($name)
4040
{
41-
if (PHP_VERSION_ID >= 50400) {
42-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
43-
}
44-
45-
return sprintf('$this->getContext($context, "%s", true)', $name);
41+
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
4642
}
4743

4844
protected function getVariableGetterWithStrictCheck($name)
4945
{
50-
if (PHP_VERSION_ID >= 50400) {
51-
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
52-
}
53-
54-
return sprintf('$this->getContext($context, "%s")', $name);
46+
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
5547
}
5648
}

src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ServerRunCommand extends ContainerAwareCommand
3030
*/
3131
public function isEnabled()
3232
{
33-
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
33+
if (defined('HHVM_VERSION')) {
3434
return false;
3535
}
3636

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,14 +498,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
498498
->validate()
499499
->ifTrue(function ($v) { return !isset($v['validation']['api']) || 'auto' === $v['validation']['api']; })
500500
->then(function ($v) {
501-
// This condition is duplicated in ValidatorBuilder. This
502-
// duplication is necessary in order to know the desired
503-
// API version already during container configuration
504-
// (to adjust service classes etc.)
505-
// See https://github.com/symfony/symfony/issues/11580
506-
$v['validation']['api'] = PHP_VERSION_ID < 50309
507-
? '2.4'
508-
: '2.5-bc';
501+
$v['validation']['api'] = '2.5-bc';
509502

510503
return $v;
511504
})

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ public function formatFile($file, $line, $text = null)
166166
}
167167

168168
if (false !== $link = $this->getFileLink($file, $line)) {
169-
if (PHP_VERSION_ID >= 50400) {
170-
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
171-
} else {
172-
$flags = ENT_QUOTES;
173-
}
169+
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
174170

175171
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
176172
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515

1616
class JsonDescriptorTest extends AbstractDescriptorTest
1717
{
18-
protected function setUp()
19-
{
20-
if (PHP_VERSION_ID < 50400) {
21-
$this->markTestSkipped('Test skipped on PHP 5.3 as JSON_PRETTY_PRINT does not exist.');
22-
}
23-
}
24-
2518
protected function getDescriptor()
2619
{
2720
return new JsonDescriptor();

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected static function getBundleDefaultConfig()
131131
'static_method' => array('loadValidatorMetadata'),
132132
'translation_domain' => 'validators',
133133
'strict_email' => false,
134-
'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc',
134+
'api' => '2.5-bc',
135135
),
136136
'annotations' => array(
137137
'cache' => 'file',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,7 @@ public function testValidation()
295295
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
296296
$this->assertSame('setApiVersion', $calls[6][0]);
297297

298-
if (PHP_VERSION_ID < 50309) {
299-
$this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]);
300-
} else {
301-
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
302-
}
298+
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
303299
}
304300

305301
public function testFullyConfiguredValidationService()
@@ -448,11 +444,7 @@ public function testValidationImplicitApi()
448444
$this->assertSame('setApiVersion', $calls[5][0]);
449445
// no cache, no annotations
450446

451-
if (PHP_VERSION_ID < 50309) {
452-
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
453-
} else {
454-
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
455-
}
447+
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
456448
}
457449

458450
/**
@@ -472,11 +464,7 @@ public function testValidationAutoApi()
472464
$this->assertSame('setApiVersion', $calls[5][0]);
473465
// no cache, no annotations
474466

475-
if (PHP_VERSION_ID < 50309) {
476-
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
477-
} else {
478-
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
479-
}
467+
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
480468
}
481469

482470
public function testFormsCanBeEnabledWithoutCsrfProtection()

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c
3030
*/
3131
public function testRoutingErrorIsExposedWhenNotProtected($config)
3232
{
33-
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) {
34-
$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');
35-
}
36-
3733
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
3834
$client->insulate();
3935
$client->request('GET', '/unprotected_resource');
@@ -46,10 +42,6 @@ public function testRoutingErrorIsExposedWhenNotProtected($config)
4642
*/
4743
public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config)
4844
{
49-
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) {
50-
$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');
51-
}
52-
5345
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
5446
$client->insulate();
5547

src/Symfony/Component/ClassLoader/ClassMapGenerator.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
if (!defined('SYMFONY_TRAIT')) {
15-
if (PHP_VERSION_ID >= 50400) {
16-
define('SYMFONY_TRAIT', T_TRAIT);
17-
} else {
18-
define('SYMFONY_TRAIT', 0);
19-
}
20-
}
21-
2214
/**
2315
* ClassMapGenerator.
2416
*
@@ -117,7 +109,7 @@ private static function findClasses($path)
117109
break;
118110
case T_CLASS:
119111
case T_INTERFACE:
120-
case SYMFONY_TRAIT:
112+
case T_TRAIT:
121113
// Find the classname
122114
while (($t = $tokens[++$i]) && is_array($t)) {
123115
if (T_STRING === $t[0]) {

src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
2222
{
2323
public function testTraitDependencies()
2424
{
25-
if (PHP_VERSION_ID < 50400) {
26-
$this->markTestSkipped('Requires PHP > 5.4');
27-
28-
return;
29-
}
30-
3125
require_once __DIR__.'/Fixtures/deps/traits.php';
3226

3327
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
@@ -100,12 +94,6 @@ public function getDifferentOrders()
10094
*/
10195
public function testClassWithTraitsReordering(array $classes)
10296
{
103-
if (PHP_VERSION_ID < 50400) {
104-
$this->markTestSkipped('Requires PHP > 5.4');
105-
106-
return;
107-
}
108-
10997
require_once __DIR__.'/Fixtures/ClassesWithParents/ATrait.php';
11098
require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php';
11199
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
@@ -148,12 +136,6 @@ public function getDifferentOrdersForTraits()
148136

149137
public function testFixClassWithTraitsOrdering()
150138
{
151-
if (PHP_VERSION_ID < 50400) {
152-
$this->markTestSkipped('Requires PHP > 5.4');
153-
154-
return;
155-
}
156-
157139
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
158140
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
159141
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';

src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,15 @@ public function getTestCreateMapTests()
102102
'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php',
103103
'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php',
104104
)),
105-
);
106-
107-
if (PHP_VERSION_ID >= 50400) {
108-
$data[] = array(__DIR__.'/Fixtures/php5.4', array(
105+
array(__DIR__.'/Fixtures/php5.4', array(
109106
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
110107
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
111108
'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php',
112109
'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php',
113110
'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php',
114111
'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php',
115-
));
116-
}
112+
)),
113+
);
117114

118115
return $data;
119116
}

src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,6 @@ private function writeText($content, array $options = array())
229229
*/
230230
private function formatDefaultValue($default)
231231
{
232-
if (PHP_VERSION_ID < 50400) {
233-
return str_replace('\/', '/', json_encode($default));
234-
}
235-
236232
return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
237233
}
238234

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,6 @@ public function handleError($type, $message, $file, $line, array $context)
357357
$type &= $level | $this->screamedErrors;
358358

359359
if ($type && ($log || $throw)) {
360-
if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && ($this->scopedErrors & $type)) {
361-
$e = $context; // Whatever the signature of the method,
362-
unset($e['GLOBALS'], $context); // $context is always a reference in 5.3
363-
$context = $e;
364-
}
365-
366360
if ($throw) {
367361
if (($this->scopedErrors & $type) && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
368362
// Checking for class existence is a work around for https://bugs.php.net/42098
@@ -371,14 +365,6 @@ public function handleError($type, $message, $file, $line, array $context)
371365
$throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
372366
}
373367

374-
if (PHP_VERSION_ID <= 50407 && (PHP_VERSION_ID >= 50400 || PHP_VERSION_ID <= 50317)) {
375-
// Exceptions thrown from error handlers are sometimes not caught by the exception
376-
// handler and shutdown handlers are bypassed before 5.4.8/5.3.18.
377-
// We temporarily re-enable display_errors to prevent any blank page related to this bug.
378-
379-
$throw->errorHandlerCanary = new ErrorHandlerCanary();
380-
}
381-
382368
throw $throw;
383369
}
384370

@@ -401,7 +387,7 @@ public function handleError($type, $message, $file, $line, array $context)
401387
$e['stack'] = debug_backtrace(true); // Provide object
402388
}
403389
} elseif ($trace) {
404-
$e['stack'] = debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
390+
$e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
405391
}
406392
}
407393

@@ -658,30 +644,3 @@ public function handleFatal()
658644
static::handleFatalError();
659645
}
660646
}
661-
662-
/**
663-
* Private class used to work around https://bugs.php.net/54275
664-
*
665-
* @author Nicolas Grekas <p@tchwork.com>
666-
*
667-
* @internal
668-
*/
669-
class ErrorHandlerCanary
670-
{
671-
private static $displayErrors = null;
672-
673-
public function __construct()
674-
{
675-
if (null === self::$displayErrors) {
676-
self::$displayErrors = ini_set('display_errors', 1);
677-
}
678-
}
679-
680-
public function __destruct()
681-
{
682-
if (null !== self::$displayErrors) {
683-
ini_set('display_errors', self::$displayErrors);
684-
self::$displayErrors = null;
685-
}
686-
}
687-
}

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,6 @@ protected static function utf8Htmlize($str)
441441
$str = iconv($charset, 'UTF-8', $str);
442442
}
443443

444-
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
444+
return htmlspecialchars($str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
445445
}
446446
}

0 commit comments

Comments
 (0)
0