ReadmeTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\AutoReview;
  13. use PhpCsFixer\Tests\TestCase;
  14. /**
  15. * @author Victor Bocharsky <bocharsky.bw@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @coversNothing
  20. *
  21. * @group auto-review
  22. * @group covers-nothing
  23. */
  24. final class ReadmeTest extends TestCase
  25. {
  26. public function testSupportedPhpVersions(): void
  27. {
  28. $phpVersionIdLines = [];
  29. $file = new \SplFileObject(__DIR__.'/../../php-cs-fixer');
  30. while (!$file->eof()) {
  31. $line = $file->fgets();
  32. if (str_contains($line, 'PHP_VERSION_ID')) {
  33. $phpVersionIdLines[] = $line;
  34. }
  35. }
  36. // Unset the file to call __destruct(), closing the file handle.
  37. $file = null;
  38. self::assertEqualsCanonicalizing([
  39. ' if (\PHP_VERSION_ID === 80000) {'."\n",
  40. ' if (\PHP_VERSION_ID < 70400 || \PHP_VERSION_ID >= 80400) {'."\n",
  41. ], $phpVersionIdLines, 'Seems supported PHP versions changed in "./php-cs-fixer" - edit the README.md (and this test file) to match them!');
  42. }
  43. }