Browse Source

Require PHP 5.6+

Dariusz Ruminski 8 years ago
parent
commit
b1a3c43dbf

+ 2 - 1
.php_cs.dist

@@ -13,9 +13,10 @@ EOF;
 return PhpCsFixer\Config::create()
     ->setRiskyAllowed(true)
     ->setRules(array(
+        '@PHP56Migration' => true,
         '@Symfony' => true,
         '@Symfony:risky' => true,
-        'array_syntax' => array('syntax' => 'long'),
+        'array_syntax' => array('syntax' => 'short'),
         'combine_consecutive_unsets' => true,
         // one should use PHPUnit methods to set up expected exception instead of annotations
         'general_phpdoc_annotation_remove' => array('expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'),

+ 2 - 7
.travis.yml

@@ -20,13 +20,8 @@ matrix:
           env: DEPLOY=yes TASK_TESTS_COVERAGE=1
         - php: nightly
           env: TASK_SCA=1 COMPOSER_FLAGS="--ignore-platform-reqs" SYMFONY_DEPRECATIONS_HELPER=weak PHP_CS_FIXER_IGNORE_ENV=1
-        - php: 5.3
-          env: SKIP_LINT_TEST_CASES=1 COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
-        - php: 5.4
-          env: SKIP_LINT_TEST_CASES=1
-        - php: 5.5
-          env: SKIP_LINT_TEST_CASES=1
         - php: 5.6
+          env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
         - php: 7.0
           env: SYMFONY_VERSION="^2.8"
         # 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:
     - php box.phar --version
 
     # ensure that deps will work on lowest supported PHP version
-    - composer config platform.php 2> /dev/null || composer config platform.php 5.3.6
+    - composer config platform.php 2> /dev/null || composer config platform.php 5.6.0
 
     # require suggested packages
     - composer require --no-update symfony/polyfill-mbstring

+ 4 - 5
README.rst

@@ -12,7 +12,7 @@ projects. This tool does not only detect them, but also fixes them for you.
 Requirements
 ------------
 
-PHP needs to be a minimum version of PHP 5.3.6.
+PHP needs to be a minimum version of PHP 5.6.0.
 
 Installation
 ------------
@@ -210,8 +210,7 @@ Choose from the list of available rules:
 
 * **array_syntax**
 
-  PHP arrays should be declared using the configured syntax (requires PHP
-  >= 5.4 for short syntax).
+  PHP arrays should be declared using the configured syntax.
 
   Configuration options:
 
@@ -276,7 +275,7 @@ Choose from the list of available rules:
 
 * **class_keyword_remove**
 
-  Converts ``::class`` keywords to FQCN strings. Requires PHP >= 5.5.
+  Converts ``::class`` keywords to FQCN strings.
 
 * **combine_consecutive_unsets**
 
@@ -930,7 +929,7 @@ Choose from the list of available rules:
 
 * **pow_to_exponentiation** [@PHP56Migration, @PHP70Migration, @PHP71Migration]
 
-  Converts ``pow()`` to the ``**`` operator. Requires PHP >= 5.6.
+  Converts ``pow()`` to the ``**`` operator.
 
   *Risky rule: risky when the function ``pow()`` is overridden.*
 

+ 1 - 1
composer.json

@@ -14,7 +14,7 @@
         }
     ],
     "require": {
-        "php": "^5.3.6 || >=7.0 <7.2",
+        "php": "^5.6 || >=7.0 <7.2",
         "doctrine/annotations": "^1.2",
         "ext-tokenizer": "*",
         "sebastian/diff": "^1.4",

+ 2 - 2
php-cs-fixer

@@ -26,8 +26,8 @@ if (defined('HHVM_VERSION_ID')) {
             exit(1);
         }
     }
-} elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50306 || PHP_VERSION_ID >= 70200) {
-    fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.3.6 and maximum version of PHP 7.1.*.\n");
+} elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50600 || PHP_VERSION_ID >= 70200) {
+    fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.1.*.\n");
 
     if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
         fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");

+ 3 - 3
src/AbstractAlignFixerHelper.php

@@ -79,17 +79,17 @@ abstract class AbstractAlignFixerHelper
             }
 
             $lines = explode("\n", $tmpCode);
-            $linesWithPlaceholder = array();
+            $linesWithPlaceholder = [];
             $blockSize = 0;
 
-            $linesWithPlaceholder[$blockSize] = array();
+            $linesWithPlaceholder[$blockSize] = [];
 
             foreach ($lines as $index => $line) {
                 if (substr_count($line, $placeholder) > 0) {
                     $linesWithPlaceholder[$blockSize][] = $index;
                 } else {
                     ++$blockSize;
-                    $linesWithPlaceholder[$blockSize] = array();
+                    $linesWithPlaceholder[$blockSize] = [];
                 }
             }
 

+ 8 - 8
src/AbstractDoctrineAnnotationFixer.php

@@ -69,8 +69,8 @@ abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements
     {
         $ignoredTags = new FixerOptionBuilder('ignored_tags', 'List of tags that must not be treated as Doctrine Annotations.');
         $ignoredTags = $ignoredTags
-            ->setAllowedTypes(array('array'))
-            ->setAllowedValues(array(function ($values) {
+            ->setAllowedTypes(['array'])
+            ->setAllowedValues([function ($values) {
                 foreach ($values as $value) {
                     if (!is_string($value)) {
                         return false;
@@ -78,8 +78,8 @@ abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements
                 }
 
                 return true;
-            }))
-            ->setDefault(array(
+            }])
+            ->setDefault([
                  // PHPDocumentor 1
                  'abstract',
                  'access',
@@ -183,11 +183,11 @@ abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements
                  'FIXME',
                  'fixme',
                  'override',
-            ))
+            ])
             ->getOption()
         ;
 
-        return new FixerConfigurationResolver(array($ignoredTags));
+        return new FixerConfigurationResolver([$ignoredTags]);
     }
 
     /**
@@ -200,13 +200,13 @@ abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements
     {
         do {
             $index = $tokens->getNextMeaningfulToken($index);
-        } while ($tokens[$index]->isGivenKind(array(T_ABSTRACT, T_FINAL)));
+        } while ($tokens[$index]->isGivenKind([T_ABSTRACT, T_FINAL]));
 
         if ($tokens[$index]->isClassy()) {
             return true;
         }
 
-        while ($tokens[$index]->isGivenKind(array(T_PUBLIC, T_PROTECTED, T_PRIVATE, T_FINAL, T_ABSTRACT))) {
+        while ($tokens[$index]->isGivenKind([T_PUBLIC, T_PROTECTED, T_PRIVATE, T_FINAL, T_ABSTRACT])) {
             $index = $tokens->getNextMeaningfulToken($index);
         }
 

+ 2 - 2
src/AbstractFixer.php

@@ -50,7 +50,7 @@ abstract class AbstractFixer implements FixerInterface, DefinedFixerInterface
     {
         if ($this instanceof ConfigurableFixerInterface) {
             try {
-                $this->configure(array());
+                $this->configure([]);
             } catch (RequiredFixerConfigurationException $e) {
                 // ignore
             }
@@ -115,7 +115,7 @@ abstract class AbstractFixer implements FixerInterface, DefinedFixerInterface
                 E_USER_DEPRECATED
             );
 
-            $configuration = array();
+            $configuration = [];
         }
 
         try {

+ 5 - 5
src/AbstractFunctionReferenceFixer.php

@@ -63,7 +63,7 @@ abstract class AbstractFunctionReferenceFixer extends AbstractFixer
         $end = null === $end ? $tokens->count() : $end;
 
         // find raw sequence which we can analyse for context
-        $candidateSequence = array(array(T_STRING, $functionNameToSearch), '(');
+        $candidateSequence = [[T_STRING, $functionNameToSearch], '('];
         $matches = $tokens->findSequence($candidateSequence, $start, $end, false);
         if (null === $matches) {
             // not found, simply return without further attempts
@@ -76,7 +76,7 @@ abstract class AbstractFunctionReferenceFixer extends AbstractFixer
         // first criteria check: shall look like function call
         $functionNamePrefix = $tokens->getPrevMeaningfulToken($functionName);
         $functionNamePrecedingToken = $tokens[$functionNamePrefix];
-        if ($functionNamePrecedingToken->isGivenKind(array(T_DOUBLE_COLON, T_NEW, T_OBJECT_OPERATOR, T_FUNCTION, CT::T_RETURN_REF))) {
+        if ($functionNamePrecedingToken->isGivenKind([T_DOUBLE_COLON, T_NEW, T_OBJECT_OPERATOR, T_FUNCTION, CT::T_RETURN_REF])) {
             // this expression is differs from expected, resume
             return $this->find($functionNameToSearch, $tokens, $openParenthesis, $end);
         }
@@ -85,7 +85,7 @@ abstract class AbstractFunctionReferenceFixer extends AbstractFixer
         if ($functionNamePrecedingToken->isGivenKind(T_NS_SEPARATOR)) {
             $namespaceCandidate = $tokens->getPrevMeaningfulToken($functionNamePrefix);
             $namespaceCandidateToken = $tokens[$namespaceCandidate];
-            if ($namespaceCandidateToken->isGivenKind(array(T_NEW, T_STRING, CT::T_NAMESPACE_OPERATOR))) {
+            if ($namespaceCandidateToken->isGivenKind([T_NEW, T_STRING, CT::T_NAMESPACE_OPERATOR])) {
                 // here can be added complete namespace scan
                 // this expression is differs from expected, resume
                 return $this->find($functionNameToSearch, $tokens, $openParenthesis, $end);
@@ -95,7 +95,7 @@ abstract class AbstractFunctionReferenceFixer extends AbstractFixer
         // final step: find closing parenthesis
         $closeParenthesis = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openParenthesis);
 
-        return array($functionName, $openParenthesis, $closeParenthesis);
+        return [$functionName, $openParenthesis, $closeParenthesis];
     }
 
     /**
@@ -114,7 +114,7 @@ abstract class AbstractFunctionReferenceFixer extends AbstractFixer
      */
     protected function getArguments(Tokens $tokens, $openParenthesis, $closeParenthesis)
     {
-        $arguments = array();
+        $arguments = [];
         $firstSensibleToken = $tokens->getNextMeaningfulToken($openParenthesis);
         if ($tokens[$firstSensibleToken]->equals(')')) {
             return $arguments;

+ 0 - 2
src/AbstractPsrAutoloadingFixer.php

@@ -65,8 +65,6 @@ abstract class AbstractPsrAutoloadingFixer extends AbstractFixer
             (!isset($filenameParts[1]) || 'php' !== $filenameParts[1])
             // ignore file with name that cannot be a class name
             || 0 === preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $filenameParts[0])
-            // ignore filename that will halt compiler (and cannot be properly tokenized under PHP 5.3)
-            || '__halt_compiler' === $filenameParts[0]
         ) {
             return false;
         }

Some files were not shown because too many files changed in this diff