Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add supported PHP versions section to the README #6768

Merged
merged 12 commits into from
Mar 12, 2023
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ 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

> 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 RPs.
Copy link
Contributor

@94noni 94noni Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps use GitHub note feature?

Note
foobar foo baz


What about also, as it is main readme new section of Supported PHP Versions
adding something telling that it can be run on new PHP version but "at own risk" leveraging PHP_CS_FIXER_IGNORE_ENV=1 ?
this paragraph alone may stop ppl using/testing/running on newer version
as it is require to manually do something to run it, I may think it is ok for dev

wdty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@94noni I like both suggestions and pushed changes to apply them, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the information will be in README.md then we could have it removed from usage page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I just mention it, but a more detailed explanation is still in the usage section. I think we should just link to it instead of copy/paste everything in the README

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who said anything about copy/pasting? I've suggested moving it, link is also fine.


* 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can put some guard (eg in tests/AutoReview/) to make sure that this list is up to date ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it would be cool, I'll try to look at it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 7910bf5 should be enough to notice any change in supported PHP versions


## 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;

self::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 to match them!');
bocharsky-bw marked this conversation as resolved.
Show resolved Hide resolved
}
}