Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7091fb4

Browse files
ogizanaginicolas-grekas
authored andcommitted
Remove PHP < 7.1.3 code
1 parent 619f01c commit 7091fb4

File tree

69 files changed

+119
-567
lines changed

Some content is hidden

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

69 files changed

+119
-567
lines changed

src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ public function getHtmlCallGraph()
9393
public function getProfile()
9494
{
9595
if (null === $this->profile) {
96-
if (PHP_VERSION_ID >= 70000) {
97-
$this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile')));
98-
} else {
99-
$this->profile = unserialize($this->data['profile']);
100-
}
96+
$this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile')));
10197
}
10298

10399
return $this->profile;

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ public function testOneVar()
8282

8383
EOTXT;
8484

85-
if (PHP_VERSION_ID >= 70000) {
86-
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
87-
} else {
88-
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
89-
}
85+
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
9086

9187
$this->assertSame($expected, $compiler->compile($node)->getSource());
9288
}
@@ -113,11 +109,7 @@ public function testMultiVars()
113109

114110
EOTXT;
115111

116-
if (PHP_VERSION_ID >= 70000) {
117-
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
118-
} else {
119-
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
120-
}
112+
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
121113

122114
$this->assertSame($expected, $compiler->compile($node)->getSource());
123115
}

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

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

6868
protected function getVariableGetter($name)
6969
{
70-
if (PHP_VERSION_ID >= 70000) {
71-
return sprintf('($context["%s"] ?? null)', $name, $name);
72-
}
73-
74-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
70+
return sprintf('($context["%s"] ?? null)', $name, $name);
7571
}
7672
}

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

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

265265
protected function getVariableGetter($name)
266266
{
267-
if (PHP_VERSION_ID >= 70000) {
268-
return sprintf('($context["%s"] ?? null)', $name, $name);
269-
}
270-
271-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
267+
return sprintf('($context["%s"] ?? null)', $name, $name);
272268
}
273269
}

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ public function testCompileStrict()
4040

4141
protected function getVariableGetterWithoutStrictCheck($name)
4242
{
43-
if (PHP_VERSION_ID >= 70000) {
44-
return sprintf('($context["%s"] ?? null)', $name, $name);
45-
}
46-
47-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
43+
return sprintf('($context["%s"] ?? null)', $name, $name);
4844
}
4945

5046
protected function getVariableGetterWithStrictCheck($name)
@@ -53,10 +49,6 @@ protected function getVariableGetterWithStrictCheck($name)
5349
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%s" does not exist.\', 0, $this->getSourceContext()); })())', $name, $name, $name, $name);
5450
}
5551

56-
if (PHP_VERSION_ID >= 70000) {
57-
return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name);
58-
}
59-
60-
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
52+
return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name);
6153
}
6254
}

src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ public function extract($resource, MessageCatalogue $catalog)
8585
foreach ($files as $file) {
8686
$this->parseTokens(token_get_all(file_get_contents($file)), $catalog);
8787

88-
if (PHP_VERSION_ID >= 70000) {
89-
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
90-
gc_mem_caches();
91-
}
88+
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
89+
gc_mem_caches();
9290
}
9391
}
9492

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,17 @@ function ($key, $value, $isHit) {
5353
}
5454

5555
/**
56-
* This adapter should only be used on PHP 7.0+ to take advantage of how PHP
57-
* stores arrays in its latest versions. This factory method decorates the given
58-
* fallback pool with this adapter only if the current PHP version is supported.
56+
* This adapter to take advantage of how PHP stores arrays in its latest versions.
5957
*
6058
* @param string $file The PHP file were values are cached
61-
* @param CacheItemPoolInterface $fallbackPool Fallback for old PHP versions or opcache disabled
59+
* @param CacheItemPoolInterface $fallbackPool Fallback when opcache is disabled
6260
*
6361
* @return CacheItemPoolInterface
6462
*/
6563
public static function create($file, CacheItemPoolInterface $fallbackPool)
6664
{
6765
// Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM
68-
if ((PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || defined('HHVM_VERSION')) {
66+
if (ini_get('opcache.enable') || defined('HHVM_VERSION')) {
6967
if (!$fallbackPool instanceof AdapterInterface) {
7068
$fallbackPool = new ProxyAdapter($fallbackPool);
7169
}

src/Symfony/Component/Cache/Simple/PhpArrayCache.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public function __construct($file, CacheInterface $fallbackPool)
3737
}
3838

3939
/**
40-
* This adapter should only be used on PHP 7.0+ to take advantage of how PHP
41-
* stores arrays in its latest versions. This factory method decorates the given
42-
* fallback pool with this adapter only if the current PHP version is supported.
40+
* This adapter to take advantage of how PHP stores arrays in its latest versions.
4341
*
4442
* @param string $file The PHP file were values are cached
4543
*
@@ -48,7 +46,7 @@ public function __construct($file, CacheInterface $fallbackPool)
4846
public static function create($file, CacheInterface $fallbackPool)
4947
{
5048
// Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM
51-
if ((PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || defined('HHVM_VERSION')) {
49+
if (ini_get('opcache.enable') || defined('HHVM_VERSION')) {
5250
return new static($file, $fallbackPool);
5351
}
5452

src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,8 @@ public function provideHashedSignature()
124124
yield array(0, 8, '/** priv docblock */');
125125
yield array(0, 9, 'private $priv = 123;');
126126
yield array(1, 10, '/** pub docblock */');
127-
if (PHP_VERSION_ID >= 50600) {
128-
yield array(1, 11, 'public function pub(...$arg) {}');
129-
}
130-
if (PHP_VERSION_ID >= 70000) {
131-
yield array(1, 11, 'public function pub($arg = null): Foo {}');
132-
}
127+
yield array(1, 11, 'public function pub(...$arg) {}');
128+
yield array(1, 11, 'public function pub($arg = null): Foo {}');
133129
yield array(0, 11, "public function pub(\$arg = null) {\nreturn 123;\n}");
134130
yield array(1, 12, '/** prot docblock */');
135131
yield array(1, 13, 'protected function prot($a = array(123)) {}');

src/Symfony/Component/Console/Command/Command.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,7 @@ public function setCode(callable $code)
286286
if ($code instanceof \Closure) {
287287
$r = new \ReflectionFunction($code);
288288
if (null === $r->getClosureThis()) {
289-
if (PHP_VERSION_ID < 70000) {
290-
// Bug in PHP5: https://bugs.php.net/bug.php?id=64761
291-
// This means that we cannot bind static closures and therefore we must
292-
// ignore any errors here. There is no way to test if the closure is
293-
// bindable.
294-
$code = @\Closure::bind($code, $this);
295-
} else {
296-
$code = \Closure::bind($code, $this);
297-
}
289+
$code = \Closure::bind($code, $this);
298290
}
299291
}
300292

0 commit comments

Comments
 (0)