Skip to content

Commit

Permalink
minor #5736 Remove references to PHP 5.6 (kubawerlos, keradus)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 3.0 branch.

Discussion
----------

Remove references to PHP 5.6

Commits
-------

d4ff118 Remove references to PHP 5.6
  • Loading branch information
keradus committed Aug 2, 2021
2 parents ec10484 + d4ff118 commit 8055779
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Installation
Requirements
------------

PHP needs to be a minimum version of PHP 5.6.0.
PHP needs to be a minimum version of PHP 7.1.3.

Installation
------------
Expand Down
5 changes: 0 additions & 5 deletions src/Fixer/Basic/EncodingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$content = $tokens[0]->getContent();

if (0 === strncmp($content, $this->BOM, 3)) {
/** @var false|string $newContent until support for PHP 5.6 is dropped */
$newContent = substr($content, 3);

if (false === $newContent) {
$newContent = ''; // substr returns false rather than an empty string when starting at the end
}

if ('' === $newContent) {
$tokens->clearAt(0);
} else {
Expand Down
17 changes: 17 additions & 0 deletions tests/AutoReview/DocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ public function testRuleSetsDocumentationDirectoryHasNoExtraFiles(): void
);
}

public function testInstallationDocHasCorrectMinimumVersion(): void
{
$composerJsonContent = file_get_contents(__DIR__.'/../../composer.json');
$composerJson = json_decode($composerJsonContent, true);
$phpVersion = $composerJson['require']['php'];
$minimumVersion = ltrim(substr($phpVersion, 0, strpos($phpVersion, ' ')), '^');

$minimumVersionInformation = sprintf('PHP needs to be a minimum version of PHP %s.', $minimumVersion);
$installationDocPath = realpath(__DIR__.'/../../doc/installation.rst');

static::assertStringContainsString(
$minimumVersionInformation,
file_get_contents($installationDocPath),
sprintf('Files %s needs to contain information "%s"', $installationDocPath, $minimumVersionInformation)
);
}

private static function assertFileEqualsString(string $expectedString, string $actualFilePath, string $message = ''): void
{
static::assertFileExists($actualFilePath, $message);
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixer/Alias/ArrayPushFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ public function provideFixCases()
];

yield [
'<?php $a->$c[] = $b;', // invalid on PHP5.6
'<?php $a->$c[] = $b;',
'<?php array_push($a->$c, $b);',
];

yield [
'<?php $a->$c[1]->$d{$a--}->$a[7][] = $b;', // invalid on PHP5.6
'<?php $a->$c[1]->$d{$a--}->$a[7][] = $b;',
'<?php array_push($a->$c[1]->$d{$a--}->$a[7], $b);',
];

Expand Down
6 changes: 3 additions & 3 deletions tests/Fixer/Alias/SetTypeToCastFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ public function provideFixCases()
// do not fix cases
'first argument is not a variable' => [
'<?php
namespace A\B; // needed to keep the linter happy on PHP5.6
namespace A\B; // comment
function settype($a, $b){} // "
settype(1, "double");
',
],
'first argument is variable followed by operation' => [
'<?php
namespace A\B; // needed to keep the linter happy on PHP5.6
namespace A\B; // comment
function settype($a, $b){} // "
settype($foo + 1, "integer"); // function must be overridden, so do not fix it
Expand Down Expand Up @@ -202,7 +202,7 @@ function settype($a, $b){} // "
],
'wrapped statements, not-fixable, even after removing the useless parenthesis brace' => [
'<?php
namespace A\B; // needed to keep the linter happy on PHP5.6
namespace A\B; // comment
function settype($a, $b){} // "
settype($foo1, (("integer")."1"));
Expand Down
3 changes: 0 additions & 3 deletions tests/Fixtures/Integration/misc/meta_insert_64566_tokens.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
--TEST--
Test of super huge file that would require 64566 tokens to be inserted! Basically, this tests Tokens::insertSlices, without which this test would take few hours to execute.
Note: requiring PHP 7+ just to skip PHP 5.6 with memory issues for this huge test case.
--RULESET--
{
"whitespace_after_comma_in_array": true
}
--REQUIREMENTS--
{"php": 70000}
2 changes: 1 addition & 1 deletion tests/Smoke/CiIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function testIntegration(
$optionalDeprecatedVersionWarning = 'You are running PHP CS Fixer v3, which is not maintained anymore. Please update to v4.
';

$optionalIncompatibilityWarning = 'PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.4.*.
$optionalIncompatibilityWarning = 'PHP needs to be a minimum version of PHP 7.1.3 and maximum version of PHP 8.0.*.
Current PHP version: '.PHP_VERSION.'.
Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.
';
Expand Down

0 comments on commit 8055779

Please sign in to comment.