Просмотр исходного кода

Initial compatibility with PHP 7.2-DEV

Dariusz Ruminski 8 лет назад
Родитель
Сommit
b8b48e4e19

+ 2 - 0
.travis.yml

@@ -20,6 +20,8 @@ matrix:
           env: DEPLOY=yes TASK_TESTS_COVERAGE=1
           env: DEPLOY=yes TASK_TESTS_COVERAGE=1
         - php: 7.1
         - php: 7.1
           env: TASK_SCA=1
           env: TASK_SCA=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
         - php: 5.3
           env: SKIP_LINT_TEST_CASES=1 COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
           env: SKIP_LINT_TEST_CASES=1 COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
         - php: 5.4
         - php: 5.4

+ 1 - 1
composer.json

@@ -30,7 +30,7 @@
     "require-dev": {
     "require-dev": {
         "gecko-packages/gecko-php-unit": "^2.0",
         "gecko-packages/gecko-php-unit": "^2.0",
         "justinrainbow/json-schema": "^5.0",
         "justinrainbow/json-schema": "^5.0",
-        "phpunit/phpunit": "^4.5|^5",
+        "phpunit/phpunit": "^4.5 || ^5.0",
         "satooshi/php-coveralls": "^1.0",
         "satooshi/php-coveralls": "^1.0",
         "symfony/phpunit-bridge": "^3.2"
         "symfony/phpunit-bridge": "^3.2"
     },
     },

+ 14 - 4
php-cs-fixer

@@ -18,12 +18,22 @@
 
 
 if (defined('HHVM_VERSION_ID')) {
 if (defined('HHVM_VERSION_ID')) {
     if (HHVM_VERSION_ID < 30900) {
     if (HHVM_VERSION_ID < 30900) {
-        fwrite(STDERR, "HHVM needs to be a minimum version of HHVM 3.9.0\n");
-        exit(1);
+        fwrite(STDERR, "HHVM needs to be a minimum version of HHVM 3.9.0.\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");
+        } else {
+            exit(1);
+        }
     }
     }
 } elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50306 || PHP_VERSION_ID >= 70200) {
 } 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");
-    exit(1);
+    fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.3.6 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");
+    } else {
+        exit(1);
+    }
 }
 }
 
 
 set_error_handler(function ($severity, $message, $file, $line) {
 set_error_handler(function ($severity, $message, $file, $line) {

+ 2 - 2
src/Fixer/PhpTag/NoClosingTagFixer.php

@@ -40,10 +40,10 @@ final class NoClosingTagFixer extends AbstractFixer
             return;
             return;
         }
         }
 
 
-        list($index, $token) = each($closeTags);
+        $index = key($closeTags);
 
 
         $tokens->removeLeadingWhitespace($index);
         $tokens->removeLeadingWhitespace($index);
-        $token->clear();
+        $closeTags[$index]->clear();
 
 
         $prevIndex = $tokens->getPrevMeaningfulToken($index);
         $prevIndex = $tokens->getPrevMeaningfulToken($index);
         $prevToken = $tokens[$prevIndex];
         $prevToken = $tokens[$prevIndex];

+ 1 - 0
src/Fixer/Phpdoc/PhpdocAlignFixer.php

@@ -224,6 +224,7 @@ final class PhpdocAlignFixer extends AbstractFixer implements WhitespacesAwareFi
             if (!empty($matches['tag2'])) {
             if (!empty($matches['tag2'])) {
                 $matches['tag'] = $matches['tag2'];
                 $matches['tag'] = $matches['tag2'];
                 $matches['hint'] = $matches['hint2'];
                 $matches['hint'] = $matches['hint2'];
+                $matches['var'] = '';
             }
             }
 
 
             return $matches;
             return $matches;

+ 14 - 4
src/Resources/phar-stub.php

@@ -13,12 +13,22 @@
 
 
 if (defined('HHVM_VERSION_ID')) {
 if (defined('HHVM_VERSION_ID')) {
     if (HHVM_VERSION_ID < 30900) {
     if (HHVM_VERSION_ID < 30900) {
-        fwrite(STDERR, "HHVM needs to be a minimum version of HHVM 3.9.0\n");
-        exit(1);
+        fwrite(STDERR, "HHVM needs to be a minimum version of HHVM 3.9.0.\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");
+        } else {
+            exit(1);
+        }
     }
     }
 } elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50306 || PHP_VERSION_ID >= 70200) {
 } 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");
-    exit(1);
+    fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.3.6 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");
+    } else {
+        exit(1);
+    }
 }
 }
 
 
 set_error_handler(function ($severity, $message, $file, $line) {
 set_error_handler(function ($severity, $message, $file, $line) {

+ 21 - 12
tests/ConfigTest.php

@@ -106,10 +106,13 @@ final class ConfigTest extends \PHPUnit_Framework_TestCase
     {
     {
         $config = new Config();
         $config = new Config();
 
 
-        $iterator = $config->getFinder()->in(__DIR__.'/Fixtures/FinderDirectory')->getIterator();
-        $this->assertSame(1, count($iterator));
-        $iterator->rewind();
-        $this->assertSame('somefile.php', $iterator->current()->getFilename());
+        $items = iterator_to_array(
+            $config->getFinder()->in(__DIR__.'/Fixtures/FinderDirectory'),
+            false
+        );
+
+        $this->assertCount(1, $items);
+        $this->assertSame('somefile.php', $items[0]->getFilename());
     }
     }
 
 
     public function testThatCustomFinderWorks()
     public function testThatCustomFinderWorks()
@@ -119,10 +122,13 @@ final class ConfigTest extends \PHPUnit_Framework_TestCase
 
 
         $config = Config::create()->setFinder($finder);
         $config = Config::create()->setFinder($finder);
 
 
-        $iterator = $config->getFinder()->getIterator();
-        $this->assertSame(1, count($iterator));
-        $iterator->rewind();
-        $this->assertSame('somefile.php', $iterator->current()->getFilename());
+        $items = iterator_to_array(
+            $config->getFinder(),
+            false
+        );
+
+        $this->assertCount(1, $items);
+        $this->assertSame('somefile.php', $items[0]->getFilename());
     }
     }
 
 
     public function testThatCustomSymfonyFinderWorks()
     public function testThatCustomSymfonyFinderWorks()
@@ -132,10 +138,13 @@ final class ConfigTest extends \PHPUnit_Framework_TestCase
 
 
         $config = Config::create()->setFinder($finder);
         $config = Config::create()->setFinder($finder);
 
 
-        $iterator = $config->getFinder()->getIterator();
-        $this->assertSame(1, count($iterator));
-        $iterator->rewind();
-        $this->assertSame('somefile.php', $iterator->current()->getFilename());
+        $items = iterator_to_array(
+            $config->getFinder(),
+            false
+        );
+
+        $this->assertCount(1, $items);
+        $this->assertSame('somefile.php', $items[0]->getFilename());
     }
     }
 
 
     public function testThatCacheFileHasDefaultValue()
     public function testThatCacheFileHasDefaultValue()