diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b1bde09..6507f22 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v6 - uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.5' coverage: none - run: composer update --no-progress - run: composer update --no-progress --working-dir=dev-tools @@ -28,12 +28,8 @@ jobs: fail-fast: false matrix: include: - - php-version: '7.0' - composer-flags: '--prefer-stable --prefer-lowest' - - php-version: '7.1' - - php-version: '7.2' - - php-version: '7.3' - php-version: '7.4' + composer-flags: '--prefer-stable --prefer-lowest' - php-version: '8.0' - php-version: '8.1' - php-version: '8.2' diff --git a/composer.json b/composer.json index 627dc10..fa2459f 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ } ], "require": { - "php": "^7.0 || ^8.0", - "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.41 || ^9.6.22 || ^10.5.45 || ^11.5.7 || ^12.0.2 || ^13.0.0" + "php": "^7.4 || ^8.0", + "phpunit/phpunit": "^9.6.34 || ^10.5.53 || ^11.5.55 || ^12.5.14 || ^13.0.5" }, "autoload": { "psr-4": { diff --git a/src/Constraint/IsIdenticalString.php b/src/Constraint/IsIdenticalString.php index 381e6b3..331dab0 100644 --- a/src/Constraint/IsIdenticalString.php +++ b/src/Constraint/IsIdenticalString.php @@ -13,12 +13,4 @@ use PHPUnit\Runner\Version; -if (version_compare(Version::id(), '7.0.0') < 0) { - class_alias(IsIdenticalStringForV5::class, IsIdenticalString::class); -} elseif (version_compare(Version::id(), '8.0.0') < 0) { - class_alias(IsIdenticalStringForV7::class, IsIdenticalString::class); -} elseif (version_compare(Version::id(), '9.0.0') < 0) { - class_alias(IsIdenticalStringForV8::class, IsIdenticalString::class); -} else { - class_alias(IsIdenticalStringForV9::class, IsIdenticalString::class); -} +class_alias(IsIdenticalStringForV9::class, IsIdenticalString::class); diff --git a/src/Constraint/IsIdenticalStringForV5.php b/src/Constraint/IsIdenticalStringForV5.php deleted file mode 100644 index e2a0864..0000000 --- a/src/Constraint/IsIdenticalStringForV5.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace PhpCsFixer\PhpunitConstraintIsIdenticalString\Constraint; - -if (!class_exists('PHPUnit\Framework\Constraint\IsIdentical')) { - class_alias('PHPUnit_Framework_Constraint_IsIdentical', 'PHPUnit\Framework\Constraint\IsIdentical'); -} - -use PHPUnit\Framework\Constraint\IsIdentical; - -/** - * @author Dariusz Rumiński - * - * @internal - */ -final class IsIdenticalStringForV5 extends IsIdentical -{ - protected function additionalFailureDescription($other) - { - if ( - $other === $this->value - || preg_replace('/(\r\n|\n\r|\r)/', "\n", $other) !== preg_replace('/(\r\n|\n\r|\r)/', "\n", $this->value) - ) { - return ''; - } - - return ' #Warning: Strings contain different line endings! Debug using remapping ["\r" => "R", "\n" => "N", "\t" => "T"]:' - ."\n" - .' -'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $other) - ."\n" - .' +'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $this->value); - } -} diff --git a/src/Constraint/IsIdenticalStringForV7.php b/src/Constraint/IsIdenticalStringForV7.php deleted file mode 100644 index ee561e0..0000000 --- a/src/Constraint/IsIdenticalStringForV7.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace PhpCsFixer\PhpunitConstraintIsIdenticalString\Constraint; - -use PHPUnit\Framework\Constraint\IsIdentical; - -/** - * @author Dariusz Rumiński - * - * @internal - */ -final class IsIdenticalStringForV7 extends IsIdentical -{ - /** - * @var mixed - */ - private $value; - - /** - * @param mixed $value - */ - public function __construct($value) - { - parent::__construct($value); - - $this->value = $value; - } - - protected function additionalFailureDescription($other): string - { - if ( - $other === $this->value - || preg_replace('/(\r\n|\n\r|\r)/', "\n", $other) !== preg_replace('/(\r\n|\n\r|\r)/', "\n", $this->value) - ) { - return ''; - } - - return ' #Warning: Strings contain different line endings! Debug using remapping ["\r" => "R", "\n" => "N", "\t" => "T"]:' - ."\n" - .' -'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $other) - ."\n" - .' +'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $this->value); - } -} diff --git a/src/Constraint/IsIdenticalStringForV8.php b/src/Constraint/IsIdenticalStringForV8.php deleted file mode 100644 index 278e5da..0000000 --- a/src/Constraint/IsIdenticalStringForV8.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace PhpCsFixer\PhpunitConstraintIsIdenticalString\Constraint; - -use PHPUnit\Framework\Constraint\Constraint; -use PHPUnit\Framework\Constraint\IsIdentical; -use PHPUnit\Framework\ExpectationFailedException; - -/** - * @author Kuba Werłos - * - * @internal - */ -final class IsIdenticalStringForV8 extends Constraint -{ - /** - * @var mixed - */ - private $value; - - /** - * @var IsIdentical - */ - private $isIdentical; - - /** - * @param mixed $value - */ - public function __construct($value) - { - $this->value = $value; - $this->isIdentical = new IsIdentical($this->value); - } - - public function evaluate($other, string $description = '', bool $returnResult = false) - { - try { - return $this->isIdentical->evaluate($other, $description, $returnResult); - } catch (ExpectationFailedException $exception) { - $message = $exception->getMessage(); - - $additionalFailureDescription = $this->additionalFailureDescription($other); - - if ($additionalFailureDescription) { - $message .= "\n".$additionalFailureDescription; - } - - throw new ExpectationFailedException( - $message, - $exception->getComparisonFailure(), - $exception - ); - } - } - - public function toString(): string - { - return $this->isIdentical->toString(); - } - - protected function additionalFailureDescription($other): string - { - if ( - $other === $this->value - || preg_replace('/(\r\n|\n\r|\r)/', "\n", $other) !== preg_replace('/(\r\n|\n\r|\r)/', "\n", $this->value) - ) { - return ''; - } - - return ' #Warning: Strings contain different line endings! Debug using remapping ["\r" => "R", "\n" => "N", "\t" => "T"]:' - ."\n" - .' -'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $other) - ."\n" - .' +'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $this->value); - } -}