Skip to content

Commit

Permalink
ci: Run the tests against Symfony6 (#1824)
Browse files Browse the repository at this point in the history
This is mostly an extract from #1775.

After this PR what should be left is adding the complementary jobs to the CI (lowest/highest).
---------

Co-authored-by: Oleg Zhulnev <plbsid@gmail.com>
  • Loading branch information
theofidry and sidz committed Apr 3, 2023
1 parent ea40e18 commit 9eb3882
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 106 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tests.yaml
Expand Up @@ -21,8 +21,7 @@ jobs:
php-version: [ '8.0', '8.1', '8.2' ]
dependencies: [ locked, lowest, highest ]
coverage-driver: [ pcov, xdebug ]
# TODO: include Symfony6 later
symfony-version: [ '5.4.*' ]
symfony-version: [ '5.4.*', '6.*.*' ]
include:
- operating-system: windows-latest
php-version: '8.0'
Expand Down
2 changes: 2 additions & 0 deletions devTools/phpstan-src.neon
Expand Up @@ -52,6 +52,8 @@ parameters:
- ../src
excludePaths:
- %currentWorkingDirectory%/src/FileSystem/DummyFileSystem.php
- %currentWorkingDirectory%/src/FileSystem/DummySymfony5FileSystem.php
- %currentWorkingDirectory%/src/FileSystem/DummySymfony6FileSystem.php
stubFiles:
- phpstan.stub
treatPhpDocTypesAsCertain: false
5 changes: 5 additions & 0 deletions infection.json5
Expand Up @@ -4,6 +4,11 @@
"source": {
"directories": [
"src"
],
excludes: [
"FileSystem/DummyFileSystem.php",
"FileSystem/DummySymfony5FileSystem.php",
"FileSystem/DummySymfony6FileSystem.php"
]
},
"logs": {
Expand Down
12 changes: 12 additions & 0 deletions psalm.xml
Expand Up @@ -27,5 +27,17 @@
<directory name="src/Mutator/Regex"/>
</errorLevel>
</ImpureFunctionCall>

<InvalidReturnType>
<errorLevel type="suppress">
<file name="src/FileSystem/DummySymfony6FileSystem.php"/>
</errorLevel>
</InvalidReturnType>

<MethodSignatureMismatch>
<errorLevel type="suppress">
<file name="src/FileSystem/DummySymfony6FileSystem.php"/>
</errorLevel>
</MethodSignatureMismatch>
</issueHandlers>
</psalm>
91 changes: 8 additions & 83 deletions src/FileSystem/DummyFileSystem.php
Expand Up @@ -35,87 +35,12 @@

namespace Infection\FileSystem;

use Symfony\Component\Filesystem\Filesystem;
use Traversable;

/**
* @internal
*/
final class DummyFileSystem extends Filesystem
{
public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false): void
{
}

public function mkdir($dirs, int $mode = 0777): void
{
}

public function exists($files): void
{
}

public function touch($files, ?int $time = null, ?int $atime = null): void
{
}

public function remove($files): void
{
}

public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false): void
{
}

public function chown($files, $user, bool $recursive = false): void
{
}

public function chgrp($files, $group, bool $recursive = false): void
{
}

public function rename(string $origin, string $target, bool $overwrite = false): void
{
}

public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false): void
{
}

public function hardlink(string $originFile, $targetFiles): void
{
}

public function readlink(string $path, bool $canonicalize = false): void
{
}

public function makePathRelative(string $endPath, string $startPath): void
{
}

public function mirror(string $originDir, string $targetDir, ?Traversable $iterator = null, array $options = []): void
{
}

public function isAbsolutePath(string $file): void
{
}

public function tempnam(string $dir, string $prefix): void
{
}

public function dumpFile(string $filename, $content): void
{
}

public function appendToFile(string $filename, $content): void
{
}

public static function handleError($type, $msg): void
{
}
use function class_alias;
use Composer\InstalledVersions;
use function version_compare;

if (version_compare((string) InstalledVersions::getPrettyVersion('symfony/filesystem'), 'v6.0', '<')) {
class_alias(DummySymfony5FileSystem::class, \Infection\FileSystem\DummyFileSystem::class);
} else {
class_alias(DummySymfony6FileSystem::class, \Infection\FileSystem\DummyFileSystem::class);
}
122 changes: 122 additions & 0 deletions src/FileSystem/DummySymfony5FileSystem.php
@@ -0,0 +1,122 @@
<?php
/**
* This code is licensed under the BSD 3-Clause License.
*
* Copyright (c) 2017, Maks Rafalko
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

declare(strict_types=1);

namespace Infection\FileSystem;

use Symfony\Component\Filesystem\Filesystem;
use Traversable;

/**
* @internal
*/
final class DummySymfony5FileSystem extends Filesystem
{
public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false): void
{
}

public function mkdir($dirs, int $mode = 0777): void
{
}

public function exists($files): bool
{
return true;
}

public function touch($files, ?int $time = null, ?int $atime = null): void
{
}

public function remove($files): void
{
}

public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false): void
{
}

public function chown($files, $user, bool $recursive = false): void
{
}

public function chgrp($files, $group, bool $recursive = false): void
{
}

public function rename(string $origin, string $target, bool $overwrite = false): void
{
}

public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false): void
{
}

public function hardlink(string $originFile, $targetFiles): void
{
}

public function readlink(string $path, bool $canonicalize = false): ?string
{
return null;
}

public function makePathRelative(string $endPath, string $startPath): string
{
return '';
}

public function mirror(string $originDir, string $targetDir, ?Traversable $iterator = null, array $options = []): void
{
}

public function isAbsolutePath(string $file): bool
{
return true;
}

public function tempnam(string $dir, string $prefix): string
{
return '';
}

public function dumpFile(string $filename, $content): void
{
}

public function appendToFile(string $filename, $content): void
{
}
}
122 changes: 122 additions & 0 deletions src/FileSystem/DummySymfony6FileSystem.php
@@ -0,0 +1,122 @@
<?php
/**
* This code is licensed under the BSD 3-Clause License.
*
* Copyright (c) 2017, Maks Rafalko
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

declare(strict_types=1);

namespace Infection\FileSystem;

use Symfony\Component\Filesystem\Filesystem;
use Traversable;

/**
* @internal
*/
final class DummySymfony6FileSystem extends Filesystem
{
public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false): void
{
}

public function mkdir($dirs, int $mode = 0777): void
{
}

public function exists(string|iterable $files): bool
{
return false;
}

public function touch($files, ?int $time = null, ?int $atime = null): void
{
}

public function remove($files): void
{
}

public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false): void
{
}

public function chown($files, $user, bool $recursive = false): void
{
}

public function chgrp($files, $group, bool $recursive = false): void
{
}

public function rename(string $origin, string $target, bool $overwrite = false): void
{
}

public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false): void
{
}

public function hardlink(string $originFile, $targetFiles): void
{
}

public function readlink(string $path, bool $canonicalize = false): ?string
{
return '';
}

public function makePathRelative(string $endPath, string $startPath): string
{
return '';
}

public function mirror(string $originDir, string $targetDir, ?Traversable $iterator = null, array $options = []): void
{
}

public function isAbsolutePath(string $file): bool
{
return true;
}

public function tempnam(string $dir, string $prefix, string $suffix = ''): string
{
return '';
}

public function dumpFile(string $filename, $content): void
{
}

public function appendToFile(string $filename, $content): void
{
}
}

0 comments on commit 9eb3882

Please sign in to comment.