Browse Source

minor #5524 DX: drop support of very old deps (keradus)

This PR was squashed before being merged into the 3.0 branch.

Discussion
----------

DX: drop support of very old deps

Commits
-------

b6a5045e0 DX: drop support of very old deps
Dariusz Ruminski 4 years ago
parent
commit
a01d9a5d2f

+ 19 - 19
composer.json

@@ -14,38 +14,38 @@
         }
     ],
     "require": {
-        "php": "^7.1 || ^8.0",
+        "php": "^7.1.3 || ^8.0",
         "ext-json": "*",
         "ext-tokenizer": "*",
-        "composer/semver": "^1.4 || ^2.0 || ^3.0",
-        "composer/xdebug-handler": "^1.2",
-        "doctrine/annotations": "^1.2",
+        "composer/semver": "^3.2",
+        "composer/xdebug-handler": "^1.4",
+        "doctrine/annotations": "^1.12",
         "php-cs-fixer/diff": "^2.0",
-        "symfony/console": "^3.4.43 || ^4.4.11 || ^5.1.3",
-        "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0",
-        "symfony/filesystem": "^3.0 || ^4.0 || ^5.0",
-        "symfony/finder": "^3.0 || ^4.0 || ^5.0",
-        "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0",
-        "symfony/polyfill-php70": "^1.0",
-        "symfony/polyfill-php72": "^1.4",
-        "symfony/process": "^3.0 || ^4.0 || ^5.0",
-        "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0"
+        "symfony/console": "^4.4.20 || ^5.1.3",
+        "symfony/event-dispatcher": "^4.4.20 || ^5.0",
+        "symfony/filesystem": "^4.4.20 || ^5.0",
+        "symfony/finder": "^4.4.20 || ^5.0",
+        "symfony/options-resolver": "^4.4.20 || ^5.0",
+        "symfony/polyfill-php72": "^1.22",
+        "symfony/process": "^4.4.20 || ^5.0",
+        "symfony/stopwatch": "^4.4.20 || ^5.0"
     },
     "require-dev": {
-        "justinrainbow/json-schema": "^5.0",
+        "justinrainbow/json-schema": "^5.2",
         "keradus/cli-executor": "^1.4",
-        "mikey179/vfsstream": "^1.6",
-        "php-coveralls/php-coveralls": "^2.4.2",
-        "php-cs-fixer/accessible-object": "^1.0",
+        "mikey179/vfsstream": "^1.6.8",
+        "php-coveralls/php-coveralls": "^2.4.3",
+        "php-cs-fixer/accessible-object": "^1.1",
         "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2",
         "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1",
+        "phpspec/prophecy": "^1.10.3",
         "phpspec/prophecy-phpunit": "^1.1 || ^2.0",
         "phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5",
         "phpunitgoodpractices/polyfill": "^1.5",
         "phpunitgoodpractices/traits": "^1.9.1",
         "sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1",
-        "symfony/phpunit-bridge": "^5.2.3",
-        "symfony/yaml": "^3.0 || ^4.0 || ^5.0"
+        "symfony/phpunit-bridge": "^5.2.4",
+        "symfony/yaml": "^4.4.20 || ^5.0"
     },
     "suggest": {
         "ext-dom": "For handling output formats in XML",

+ 1 - 1
dev-tools/build.sh

@@ -2,7 +2,7 @@
 set -eu
 
 # ensure that deps will work on lowest supported PHP version
-composer config platform.php 2> /dev/null || composer config platform.php 7.1.0
+composer config platform.php 2> /dev/null || composer config platform.php 7.1.3
 
 # require suggested packages
 composer require --no-update symfony/polyfill-mbstring

+ 2 - 2
php-cs-fixer

@@ -24,10 +24,10 @@ if (defined('HHVM_VERSION_ID')) {
 } elseif (
     !defined('PHP_VERSION_ID')
     || \PHP_VERSION_ID === 80000
-    || \PHP_VERSION_ID < 70100
+    || \PHP_VERSION_ID < 70103
     || \PHP_VERSION_ID >= 80100
 ) {
-    fwrite(STDERR, "PHP needs to be a minimum version of PHP 7.1.0 and maximum version of PHP 8.0.*.\n");
+    fwrite(STDERR, "PHP needs to be a minimum version of PHP 7.1.3 and maximum version of PHP 8.0.*.\n");
     fwrite(STDERR, 'Current PHP version: '.PHP_VERSION.".\n");
 
     if (defined('PHP_VERSION_ID') && \PHP_VERSION_ID === 80000) {

+ 0 - 4
phpstan.neon

@@ -11,12 +11,8 @@ parameters:
     excludes_analyse:
         - tests/Fixtures
     ignoreErrors:
-        - '/^Class (Symfony\\Contracts\\EventDispatcher\\Event|Symfony\\Component\\EventDispatcher\\Event) not found.$/'
         - '/^Constant T_NAME_(RELATIVE|FULLY_QUALIFIED|QUALIFIED) not found\.$/'
         - '/assertInstanceOf\(\) expects class-string.*, string given/'
-        -
-            message: '/^Else branch is unreachable because previous condition is always true\.$/'
-            path: src/Event/Event.php
         -
             message: '/^Strict comparison using !== between ''@git-commit@'' and ''@git-commit@'' will always evaluate to false\.$/'
             path: src/Console/Application.php

+ 0 - 31
src/Event/Event.php

@@ -1,31 +0,0 @@
-<?php
-
-/*
- * This file is part of PHP CS Fixer.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *     Dariusz Rumiński <dariusz.ruminski@gmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace PhpCsFixer\Event;
-
-use Symfony\Component\EventDispatcher\EventDispatcher;
-use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
-
-// @TODO PHP 7.1
-// @TODO PHP CS Fixer 3.0
-// Since PHP-CS-FIXER is PHP 5.6 compliant we can't always use Symfony Contracts (currently needs PHP ^7.1.3)
-// This conditional inheritance will be useless when PHP-CS-FIXER no longer supports PHP versions
-// inferior to Symfony/Contracts PHP minimal version
-if (is_subclass_of(EventDispatcher::class, EventDispatcherInterface::class)) {
-    class Event extends \Symfony\Contracts\EventDispatcher\Event
-    {
-    }
-} else {
-    class Event extends \Symfony\Component\EventDispatcher\Event
-    {
-    }
-}

+ 1 - 1
src/FixerFileProcessedEvent.php

@@ -12,7 +12,7 @@
 
 namespace PhpCsFixer;
 
-use PhpCsFixer\Event\Event;
+use Symfony\Contracts\EventDispatcher\Event;
 
 /**
  * Event that is fired when file was processed by Fixer.

+ 1 - 1
src/Runner/FileFilterIterator.php

@@ -13,10 +13,10 @@
 namespace PhpCsFixer\Runner;
 
 use PhpCsFixer\Cache\CacheManagerInterface;
-use PhpCsFixer\Event\Event;
 use PhpCsFixer\FileReader;
 use PhpCsFixer\FixerFileProcessedEvent;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Contracts\EventDispatcher\Event;
 
 /**
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>

+ 1 - 1
src/Runner/Runner.php

@@ -19,7 +19,6 @@ use PhpCsFixer\Cache\DirectoryInterface;
 use PhpCsFixer\Differ\DifferInterface;
 use PhpCsFixer\Error\Error;
 use PhpCsFixer\Error\ErrorsManager;
-use PhpCsFixer\Event\Event;
 use PhpCsFixer\FileReader;
 use PhpCsFixer\Fixer\FixerInterface;
 use PhpCsFixer\FixerFileProcessedEvent;
@@ -29,6 +28,7 @@ use PhpCsFixer\Linter\LintingResultInterface;
 use PhpCsFixer\Tokenizer\Tokens;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\Filesystem\Exception\IOException;
+use Symfony\Contracts\EventDispatcher\Event;
 
 /**
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>

+ 3 - 15
tests/AutoReview/ProjectCodeTest.php

@@ -13,7 +13,6 @@
 namespace PhpCsFixer\Tests\AutoReview;
 
 use PhpCsFixer\DocBlock\DocBlock;
-use PhpCsFixer\Event\Event;
 use PhpCsFixer\FixerFactory;
 use PhpCsFixer\Preg;
 use PhpCsFixer\Tests\TestCase;
@@ -107,18 +106,12 @@ final class ProjectCodeTest extends TestCase
             'setWhitespacesConfig', // due to AbstractFixer::setWhitespacesConfig
         ];
 
-        // @TODO: 3.0 should be removed
-        $exceptionMethodsPerClass = [
-            \PhpCsFixer\Event\Event::class => ['stopPropagation'],
-        ];
-
         $definedMethods = $this->getPublicMethodNames($rc);
 
         $extraMethods = array_diff(
             $definedMethods,
             $allowedMethods,
-            $exceptionMethods,
-            isset($exceptionMethodsPerClass[$className]) ? $exceptionMethodsPerClass[$className] : []
+            $exceptionMethods
         );
 
         sort($extraMethods);
@@ -472,7 +465,6 @@ final class ProjectCodeTest extends TestCase
         $rc = new \ReflectionClass($className);
         $file = $rc->getFileName();
         $tokens = Tokens::fromCode(file_get_contents($file));
-        $isEvent = Event::class === $rc->getName(); // remove this exception when no longer needed
         $classyIndex = null;
 
         static::assertTrue($tokens->isAnyTokenKindsFound(Token::getClassyTokenKinds()), sprintf('File "%s" should contains a classy.', $file));
@@ -484,7 +476,7 @@ final class ProjectCodeTest extends TestCase
                 break;
             }
 
-            if (!$token->isGivenKind($headerTypes) && !$token->equalsAny([';', '=', '(', ')']) && !$isEvent) {
+            if (!$token->isGivenKind($headerTypes) && !$token->equalsAny([';', '=', '(', ')'])) {
                 static::fail(sprintf('File "%s" should only contains single classy, found "%s" @ %d.', $file, $token->toJson(), $index));
             }
         }
@@ -499,11 +491,7 @@ final class ProjectCodeTest extends TestCase
 
         $classyEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $nextTokenOfKind);
 
-        if ($isEvent) {
-            static::assertNotNull($tokens->getNextNonWhitespace($classyEndIndex), sprintf('File "%s" should not only contains a single classy.', $file));
-        } else {
-            static::assertNull($tokens->getNextNonWhitespace($classyEndIndex), sprintf('File "%s" should only contains a single classy.', $file));
-        }
+        static::assertNull($tokens->getNextNonWhitespace($classyEndIndex), sprintf('File "%s" should only contains a single classy.', $file));
     }
 
     public function provideSrcClassCases()

+ 0 - 33
tests/Event/EventTest.php

@@ -1,33 +0,0 @@
-<?php
-
-/*
- * This file is part of PHP CS Fixer.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *     Dariusz Rumiński <dariusz.ruminski@gmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace PhpCsFixer\Tests\Event;
-
-use PhpCsFixer\Event\Event;
-use PhpCsFixer\Tests\TestCase;
-
-/**
- * @internal
- * @covers \PhpCsFixer\Event\Event
- */
-final class EventTest extends TestCase
-{
-    public function testInheritance()
-    {
-        $event = new Event();
-        if (class_exists(\Symfony\Contracts\EventDispatcher\Event::class)) {
-            static::assertInstanceOf(\Symfony\Contracts\EventDispatcher\Event::class, $event);
-        } else {
-            static::assertInstanceOf(\Symfony\Component\EventDispatcher\Event::class, $event);
-        }
-    }
-}