Skip to content

Commit

Permalink
docs: Add supported PHP versions section to the README (#6768)
Browse files Browse the repository at this point in the history
Co-authored-by: Kuba Werłos <werlos@gmail.com>
Co-authored-by: Grzegorz Korba <wirone@gmail.com>
  • Loading branch information
3 people committed Mar 12, 2023
1 parent fb62107 commit 3d13b83
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ If you are already using a linter to identify coding standards problems in your
code, you know that fixing them by hand is tedious, especially on large
projects. This tool does not only detect them, but also fixes them for you.

## Supported PHP Versions

* PHP 7.4
* PHP 8.0 (except PHP 8.0.0 due to [bug in PHP tokenizer](https://bugs.php.net/bug.php?id=80462))
* PHP 8.1

> **Note**
> Each new PHP version requires a huge effort to support the new syntax.
> That's why the latest PHP version might not be supported yet. If you need it,
> please, consider supporting the project in any convenient way, for example
> with code contribution or reviewing existing PRs. To run PHP CS Fixer on yet
> unsupported versions "at your own risk" - leverage the
> [PHP_CS_FIXER_IGNORE_ENV](./doc/usage.rst#environment-options).
## Documentation

### Installation
Expand Down
50 changes: 50 additions & 0 deletions tests/AutoReview/ReadmeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

/*
* 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\AutoReview;

use PhpCsFixer\Tests\TestCase;

/**
* @author Victor Bocharsky <bocharsky.bw@gmail.com>
*
* @internal
*
* @coversNothing
*
* @group auto-review
* @group covers-nothing
*/
final class ReadmeTest extends TestCase
{
public function testSupportedPhpVersions(): void
{
$phpVersionIdLines = [];

$file = new \SplFileObject(__DIR__.'/../../php-cs-fixer');
while (!$file->eof()) {
$line = $file->fgets();
if (str_contains($line, 'PHP_VERSION_ID')) {
$phpVersionIdLines[] = $line;
}
}
// Unset the file to call __destruct(), closing the file handle.
$file = null;

static::assertEqualsCanonicalizing([
' if (\PHP_VERSION_ID === 80000) {'."\n",
' if (\PHP_VERSION_ID < 70400 || \PHP_VERSION_ID >= 80200) {'."\n",
], $phpVersionIdLines, 'Seems supported PHP versions changed in "./php-cs-fixer" - edit the README.md (and this test file) to match them!');
}
}

0 comments on commit 3d13b83

Please sign in to comment.