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

Skip to content

Commit 312f748

Browse files
committed
minor #2568 Require PHP 5.6+ (keradus)
This PR was squashed before being merged into the 2.3-dev branch (closes #2568). Discussion ---------- Require PHP 5.6+ Current tool release: v2.1.0 Proposed target of this change: v2.3.0 ~Purpose of this PR is not to clean up the old code that could be cleaned after min PHP version bump, but to discuss the change of required version itself.~ I would like to hear community voice. ------------- TODO: - [x] bump requirement - [x] drop checks like `defined(T_POW)` - [x] merge test methods like `provideCases54` - [x] use short array syntax - [x] use `?:` - [x] use `...` Commits ------- b1a3c43 Require PHP 5.6+
2 parents b6cd1aa + b1a3c43 commit 312f748

402 files changed

Lines changed: 9804 additions & 10468 deletions

File tree

Some content is hidden

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

.php_cs.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ EOF;
1313
return PhpCsFixer\Config::create()
1414
->setRiskyAllowed(true)
1515
->setRules(array(
16+
'@PHP56Migration' => true,
1617
'@Symfony' => true,
1718
'@Symfony:risky' => true,
18-
'array_syntax' => array('syntax' => 'long'),
19+
'array_syntax' => array('syntax' => 'short'),
1920
'combine_consecutive_unsets' => true,
2021
// one should use PHPUnit methods to set up expected exception instead of annotations
2122
'general_phpdoc_annotation_remove' => array('expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'),

.travis.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,8 @@ matrix:
2020
env: DEPLOY=yes TASK_TESTS_COVERAGE=1
2121
- php: nightly
2222
env: TASK_SCA=1 COMPOSER_FLAGS="--ignore-platform-reqs" SYMFONY_DEPRECATIONS_HELPER=weak PHP_CS_FIXER_IGNORE_ENV=1
23-
- php: 5.3
24-
env: SKIP_LINT_TEST_CASES=1 COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
25-
- php: 5.4
26-
env: SKIP_LINT_TEST_CASES=1
27-
- php: 5.5
28-
env: SKIP_LINT_TEST_CASES=1
2923
- php: 5.6
24+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
3025
- php: 7.0
3126
env: SYMFONY_VERSION="^2.8"
3227
# Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version
@@ -88,7 +83,7 @@ before_deploy:
8883
- php box.phar --version
8984

9085
# ensure that deps will work on lowest supported PHP version
91-
- composer config platform.php 2> /dev/null || composer config platform.php 5.3.6
86+
- composer config platform.php 2> /dev/null || composer config platform.php 5.6.0
9287

9388
# require suggested packages
9489
- composer require --no-update symfony/polyfill-mbstring

README.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ projects. This tool does not only detect them, but also fixes them for you.
1212
Requirements
1313
------------
1414

15-
PHP needs to be a minimum version of PHP 5.3.6.
15+
PHP needs to be a minimum version of PHP 5.6.0.
1616

1717
Installation
1818
------------
@@ -210,8 +210,7 @@ Choose from the list of available rules:
210210

211211
* **array_syntax**
212212

213-
PHP arrays should be declared using the configured syntax (requires PHP
214-
>= 5.4 for short syntax).
213+
PHP arrays should be declared using the configured syntax.
215214

216215
Configuration options:
217216

@@ -276,7 +275,7 @@ Choose from the list of available rules:
276275

277276
* **class_keyword_remove**
278277

279-
Converts ``::class`` keywords to FQCN strings. Requires PHP >= 5.5.
278+
Converts ``::class`` keywords to FQCN strings.
280279

281280
* **combine_consecutive_unsets**
282281

@@ -930,7 +929,7 @@ Choose from the list of available rules:
930929

931930
* **pow_to_exponentiation** [@PHP56Migration, @PHP70Migration, @PHP71Migration]
932931

933-
Converts ``pow()`` to the ``**`` operator. Requires PHP >= 5.6.
932+
Converts ``pow()`` to the ``**`` operator.
934933

935934
*Risky rule: risky when the function ``pow()`` is overridden.*
936935

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
],
1616
"require": {
17-
"php": "^5.3.6 || >=7.0 <7.2",
17+
"php": "^5.6 || >=7.0 <7.2",
1818
"doctrine/annotations": "^1.2",
1919
"ext-tokenizer": "*",
2020
"sebastian/diff": "^1.4",

php-cs-fixer

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ if (defined('HHVM_VERSION_ID')) {
2626
exit(1);
2727
}
2828
}
29-
} elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50306 || PHP_VERSION_ID >= 70200) {
30-
fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.3.6 and maximum version of PHP 7.1.*.\n");
29+
} elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50600 || PHP_VERSION_ID >= 70200) {
30+
fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.1.*.\n");
3131

3232
if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
3333
fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");

src/AbstractAlignFixerHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ protected function replacePlaceholder(Tokens $tokens)
7979
}
8080

8181
$lines = explode("\n", $tmpCode);
82-
$linesWithPlaceholder = array();
82+
$linesWithPlaceholder = [];
8383
$blockSize = 0;
8484

85-
$linesWithPlaceholder[$blockSize] = array();
85+
$linesWithPlaceholder[$blockSize] = [];
8686

8787
foreach ($lines as $index => $line) {
8888
if (substr_count($line, $placeholder) > 0) {
8989
$linesWithPlaceholder[$blockSize][] = $index;
9090
} else {
9191
++$blockSize;
92-
$linesWithPlaceholder[$blockSize] = array();
92+
$linesWithPlaceholder[$blockSize] = [];
9393
}
9494
}
9595

src/AbstractDoctrineAnnotationFixer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@ protected function createConfigurationDefinition()
6969
{
7070
$ignoredTags = new FixerOptionBuilder('ignored_tags', 'List of tags that must not be treated as Doctrine Annotations.');
7171
$ignoredTags = $ignoredTags
72-
->setAllowedTypes(array('array'))
73-
->setAllowedValues(array(function ($values) {
72+
->setAllowedTypes(['array'])
73+
->setAllowedValues([function ($values) {
7474
foreach ($values as $value) {
7575
if (!is_string($value)) {
7676
return false;
7777
}
7878
}
7979

8080
return true;
81-
}))
82-
->setDefault(array(
81+
}])
82+
->setDefault([
8383
// PHPDocumentor 1
8484
'abstract',
8585
'access',
@@ -183,11 +183,11 @@ protected function createConfigurationDefinition()
183183
'FIXME',
184184
'fixme',
185185
'override',
186-
))
186+
])
187187
->getOption()
188188
;
189189

190-
return new FixerConfigurationResolver(array($ignoredTags));
190+
return new FixerConfigurationResolver([$ignoredTags]);
191191
}
192192

193193
/**
@@ -200,13 +200,13 @@ private function nextElementAcceptsDoctrineAnnotations(PhpTokens $tokens, $index
200200
{
201201
do {
202202
$index = $tokens->getNextMeaningfulToken($index);
203-
} while ($tokens[$index]->isGivenKind(array(T_ABSTRACT, T_FINAL)));
203+
} while ($tokens[$index]->isGivenKind([T_ABSTRACT, T_FINAL]));
204204

205205
if ($tokens[$index]->isClassy()) {
206206
return true;
207207
}
208208

209-
while ($tokens[$index]->isGivenKind(array(T_PUBLIC, T_PROTECTED, T_PRIVATE, T_FINAL, T_ABSTRACT))) {
209+
while ($tokens[$index]->isGivenKind([T_PUBLIC, T_PROTECTED, T_PRIVATE, T_FINAL, T_ABSTRACT])) {
210210
$index = $tokens->getNextMeaningfulToken($index);
211211
}
212212

src/AbstractFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct()
5050
{
5151
if ($this instanceof ConfigurableFixerInterface) {
5252
try {
53-
$this->configure(array());
53+
$this->configure([]);
5454
} catch (RequiredFixerConfigurationException $e) {
5555
// ignore
5656
}
@@ -115,7 +115,7 @@ public function configure(array $configuration = null)
115115
E_USER_DEPRECATED
116116
);
117117

118-
$configuration = array();
118+
$configuration = [];
119119
}
120120

121121
try {

src/AbstractFunctionReferenceFixer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function find($functionNameToSearch, Tokens $tokens, $start = 0, $end
6363
$end = null === $end ? $tokens->count() : $end;
6464

6565
// find raw sequence which we can analyse for context
66-
$candidateSequence = array(array(T_STRING, $functionNameToSearch), '(');
66+
$candidateSequence = [[T_STRING, $functionNameToSearch], '('];
6767
$matches = $tokens->findSequence($candidateSequence, $start, $end, false);
6868
if (null === $matches) {
6969
// not found, simply return without further attempts
@@ -76,7 +76,7 @@ protected function find($functionNameToSearch, Tokens $tokens, $start = 0, $end
7676
// first criteria check: shall look like function call
7777
$functionNamePrefix = $tokens->getPrevMeaningfulToken($functionName);
7878
$functionNamePrecedingToken = $tokens[$functionNamePrefix];
79-
if ($functionNamePrecedingToken->isGivenKind(array(T_DOUBLE_COLON, T_NEW, T_OBJECT_OPERATOR, T_FUNCTION, CT::T_RETURN_REF))) {
79+
if ($functionNamePrecedingToken->isGivenKind([T_DOUBLE_COLON, T_NEW, T_OBJECT_OPERATOR, T_FUNCTION, CT::T_RETURN_REF])) {
8080
// this expression is differs from expected, resume
8181
return $this->find($functionNameToSearch, $tokens, $openParenthesis, $end);
8282
}
@@ -85,7 +85,7 @@ protected function find($functionNameToSearch, Tokens $tokens, $start = 0, $end
8585
if ($functionNamePrecedingToken->isGivenKind(T_NS_SEPARATOR)) {
8686
$namespaceCandidate = $tokens->getPrevMeaningfulToken($functionNamePrefix);
8787
$namespaceCandidateToken = $tokens[$namespaceCandidate];
88-
if ($namespaceCandidateToken->isGivenKind(array(T_NEW, T_STRING, CT::T_NAMESPACE_OPERATOR))) {
88+
if ($namespaceCandidateToken->isGivenKind([T_NEW, T_STRING, CT::T_NAMESPACE_OPERATOR])) {
8989
// here can be added complete namespace scan
9090
// this expression is differs from expected, resume
9191
return $this->find($functionNameToSearch, $tokens, $openParenthesis, $end);
@@ -95,7 +95,7 @@ protected function find($functionNameToSearch, Tokens $tokens, $start = 0, $end
9595
// final step: find closing parenthesis
9696
$closeParenthesis = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openParenthesis);
9797

98-
return array($functionName, $openParenthesis, $closeParenthesis);
98+
return [$functionName, $openParenthesis, $closeParenthesis];
9999
}
100100

101101
/**
@@ -114,7 +114,7 @@ protected function find($functionNameToSearch, Tokens $tokens, $start = 0, $end
114114
*/
115115
protected function getArguments(Tokens $tokens, $openParenthesis, $closeParenthesis)
116116
{
117-
$arguments = array();
117+
$arguments = [];
118118
$firstSensibleToken = $tokens->getNextMeaningfulToken($openParenthesis);
119119
if ($tokens[$firstSensibleToken]->equals(')')) {
120120
return $arguments;

src/AbstractPsrAutoloadingFixer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ public function supports(\SplFileInfo $file)
6565
(!isset($filenameParts[1]) || 'php' !== $filenameParts[1])
6666
// ignore file with name that cannot be a class name
6767
|| 0 === preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $filenameParts[0])
68-
// ignore filename that will halt compiler (and cannot be properly tokenized under PHP 5.3)
69-
|| '__halt_compiler' === $filenameParts[0]
7068
) {
7169
return false;
7270
}

0 commit comments

Comments
 (0)