From 44b69ba77f167cfaa3a903e40ebdcf6ae62e7563 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 27 Oct 2021 16:18:24 +0200 Subject: [PATCH] Upgrade php-cs-fixer to 3.x and fix CS --- .gitignore | 2 +- .php_cs => .php-cs-fixer.php | 33 +++++++++----- src/Composer/Autoload/PhpFileCleaner.php | 12 +++++ src/Composer/Command/HomeCommand.php | 1 + src/Composer/Command/LicensesCommand.php | 1 - src/Composer/Command/SelfUpdateCommand.php | 1 + .../DependencyResolver/LockTransaction.php | 1 - .../DependencyResolver/PoolBuilder.php | 1 - src/Composer/Factory.php | 1 - src/Composer/Repository/RepositorySet.php | 2 - src/Composer/Util/ProcessExecutor.php | 2 - .../Test/Autoload/ClassMapGeneratorTest.php | 12 ++--- .../Test/DependencyResolver/SolverTest.php | 2 +- .../Test/Downloader/GitDownloaderTest.php | 6 ++- tests/Composer/Test/IO/NullIOTest.php | 4 +- tests/Composer/Test/InstallerTest.php | 6 +-- .../Composer/Test/Json/ComposerSchemaTest.php | 1 - tests/Composer/Test/Json/JsonFileTest.php | 3 +- .../Test/Mock/InstallationManagerMock.php | 1 - .../Test/Mock/ProcessExecutorMock.php | 3 +- .../Package/Archiver/ArchiveManagerTest.php | 1 - .../Package/Loader/RootPackageLoaderTest.php | 3 +- .../Package/Version/VersionGuesserTest.php | 9 ++-- .../Test/Plugin/PluginInstallerTest.php | 8 ++-- .../Repository/PlatformRepositoryTest.php | 1 - .../Test/Repository/Vcs/GitHubDriverTest.php | 1 - tests/Composer/Test/TestCase.php | 1 + tests/Composer/Test/Util/GitHubTest.php | 2 - tests/Composer/Test/Util/GitTest.php | 1 - .../Test/Util/ProcessExecutorTest.php | 44 +++++++++---------- 30 files changed, 87 insertions(+), 79 deletions(-) rename .php_cs => .php-cs-fixer.php (72%) diff --git a/.gitignore b/.gitignore index 0b1fb77c0..3db374fdf 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ phpunit.xml .vagrant Vagrantfile .idea -.php_cs.cache +.php-cs-fixer.cache diff --git a/.php_cs b/.php-cs-fixer.php similarity index 72% rename from .php_cs rename to .php-cs-fixer.php index 68b16e224..4031efea1 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -18,10 +18,8 @@ $finder = PhpCsFixer\Finder::create() ->notPath('Fixtures') ; -return PhpCsFixer\Config::create() - ->setUsingCache(true) - ->setRiskyAllowed(true) - ->setRules(array( +$config = new PhpCsFixer\Config(); +return $config->setRules([ '@PSR2' => true, 'array_syntax' => array('syntax' => 'long'), 'binary_operator_spaces' => true, @@ -29,31 +27,42 @@ return PhpCsFixer\Config::create() 'cast_spaces' => array('space' => 'single'), 'header_comment' => array('header' => $header), 'include' => true, - 'class_attributes_separation' => array('elements' => array('method')), + + 'class_attributes_separation' => array('elements' => array('method' => 'one', 'trait_import' => 'none')), 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => true, + 'no_extra_blank_lines' => true, 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, 'no_trailing_comma_in_singleline_array' => true, - 'no_unused_imports' => true, 'no_whitespace_in_blank_line' => true, 'object_operator_without_whitespace' => true, - 'phpdoc_align' => true, + //'phpdoc_align' => true, 'phpdoc_indent' => true, 'phpdoc_no_access' => true, 'phpdoc_no_package' => true, - 'phpdoc_order' => true, + //'phpdoc_order' => true, 'phpdoc_scalar' => true, 'phpdoc_trim' => true, 'phpdoc_types' => true, - 'psr0' => true, + 'psr_autoloading' => true, 'single_blank_line_before_namespace' => true, 'standardize_not_equals' => true, 'ternary_operator_spaces' => true, - 'trailing_comma_in_multiline_array' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], 'unary_operator_spaces' => true, - )) + + // imports + 'no_unused_imports' => true, + 'fully_qualified_strict_types' => true, + 'single_line_after_imports' => true, + 'fully_qualified_strict_types' => true, + //'global_namespace_import' => ['import_classes' => true], + 'no_leading_import_slash' => true, + 'single_import_per_statement' => true, + ]) + ->setUsingCache(true) + ->setRiskyAllowed(true) ->setFinder($finder) ; diff --git a/src/Composer/Autoload/PhpFileCleaner.php b/src/Composer/Autoload/PhpFileCleaner.php index 1d463b285..677f7e978 100644 --- a/src/Composer/Autoload/PhpFileCleaner.php +++ b/src/Composer/Autoload/PhpFileCleaner.php @@ -1,5 +1,15 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Composer\Autoload; /** @@ -118,6 +128,7 @@ class PhpFileCleaner && \preg_match($type['pattern'], $this->contents, $match, 0, $this->index - 1) ) { $clean .= $match[0]; + return $clean; } } @@ -222,6 +233,7 @@ class PhpFileCleaner && $this->match($delimiterPattern) ) { $this->index += $delimiterLength; + return; } break; diff --git a/src/Composer/Command/HomeCommand.php b/src/Composer/Command/HomeCommand.php index d1b66f648..ad4a42713 100644 --- a/src/Composer/Command/HomeCommand.php +++ b/src/Composer/Command/HomeCommand.php @@ -138,6 +138,7 @@ EOT $process = new ProcessExecutor($this->getIO()); if (Platform::isWindows()) { $process->execute('start "web" explorer ' . $url, $output); + return; } diff --git a/src/Composer/Command/LicensesCommand.php b/src/Composer/Command/LicensesCommand.php index 3f19d366e..5375ab08d 100644 --- a/src/Composer/Command/LicensesCommand.php +++ b/src/Composer/Command/LicensesCommand.php @@ -13,7 +13,6 @@ namespace Composer\Command; use Composer\Json\JsonFile; -use Composer\Package\BasePackage; use Composer\Package\CompletePackageInterface; use Composer\Plugin\CommandEvent; use Composer\Plugin\PluginEvents; diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index b21f7bf83..c111580e7 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -113,6 +113,7 @@ EOT if ($input->getOption('update-keys')) { $this->fetchKeys($io, $config); + return 0; } diff --git a/src/Composer/DependencyResolver/LockTransaction.php b/src/Composer/DependencyResolver/LockTransaction.php index e246f2b3d..a3abe1e2a 100644 --- a/src/Composer/DependencyResolver/LockTransaction.php +++ b/src/Composer/DependencyResolver/LockTransaction.php @@ -58,7 +58,6 @@ class LockTransaction extends Transaction parent::__construct($this->presentMap, $this->resultPackages['all']); } - // TODO make this a bit prettier instead of the two text indexes? /** * @return void diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index ef78a44e4..2705f6181 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -22,7 +22,6 @@ use Composer\Package\PackageInterface; use Composer\Package\Version\StabilityFilter; use Composer\Plugin\PluginEvents; use Composer\Plugin\PrePoolCreateEvent; -use Composer\Repository\LockArrayRepository; use Composer\Repository\PlatformRepository; use Composer\Repository\RepositoryInterface; use Composer\Repository\RootPackageRepository; diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index d714b3702..7d08ec4d5 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -20,7 +20,6 @@ use Composer\Package\Version\VersionGuesser; use Composer\Package\RootPackageInterface; use Composer\Repository\RepositoryManager; use Composer\Repository\RepositoryFactory; -use Composer\Repository\WritableRepositoryInterface; use Composer\Util\Filesystem; use Composer\Util\Platform; use Composer\Util\ProcessExecutor; diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php index 019e0d541..44ae258e7 100644 --- a/src/Composer/Repository/RepositorySet.php +++ b/src/Composer/Repository/RepositorySet.php @@ -22,8 +22,6 @@ use Composer\Package\BasePackage; use Composer\Package\AliasPackage; use Composer\Package\CompleteAliasPackage; use Composer\Package\CompletePackage; -use Composer\Package\CompletePackageInterface; -use Composer\Package\PackageInterface; use Composer\Semver\Constraint\ConstraintInterface; use Composer\Package\Version\StabilityFilter; diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index 12e7796a2..ddcf13139 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -13,9 +13,7 @@ namespace Composer\Util; use Composer\IO\IOInterface; -use Composer\Util\Platform; use Symfony\Component\Process\Process; -use Symfony\Component\Process\ProcessUtils; use Symfony\Component\Process\Exception\RuntimeException; use React\Promise\Promise; use React\Promise\PromiseInterface; diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index 6b44dc5a8..ab8ae5625 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -255,13 +255,13 @@ class ClassMapGeneratorTest extends TestCase public function testCreateMapDoesNotHitRegexBacktraceLimit() { $expected = array( - 'Foo\\StripNoise' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/StripNoise.php', - 'Foo\\VeryLongHeredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php', + 'Foo\\StripNoise' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/StripNoise.php', + 'Foo\\VeryLongHeredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php', 'Foo\\ClassAfterLongHereDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php', - 'Foo\\VeryLongPHP73Heredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Heredoc.php', - 'Foo\\VeryLongPHP73Nowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php', - 'Foo\\ClassAfterLongNowDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php', - 'Foo\\VeryLongNowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongNowdoc.php', + 'Foo\\VeryLongPHP73Heredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Heredoc.php', + 'Foo\\VeryLongPHP73Nowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php', + 'Foo\\ClassAfterLongNowDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php', + 'Foo\\VeryLongNowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongNowdoc.php', ); ini_set('pcre.backtrack_limit', '30000'); diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index 629a399a3..178793b33 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -200,7 +200,7 @@ class SolverTest extends TestCase * * This is not something that can happen with packages on e.g. Packagist, but custom installers with custom repositories might do something like this; * in fact, some PaaSes do the exact thing above, installing binary builds of PHP and extensions as Composer packages with a custom installer in a separate step before the "userland" `composer install`. - * + * * If version selectors are sufficiently permissive (e.g. "ourcustom/php":"*", "ourcustom/ext-foobar":"*"), then it may happen that the Solver won't pick the highest possible PHP version, as it has already settled on an "ext-foobar" (they're all the same version to the Solver, it doesn't know about the different requirements in each of the otherwise identical packages) if that was listed in "require" before "php". * That's "unfixable", and not even broken, behavior (what if the "ext-foobar" has higher versions for the lower "PHP"? who wins then? any combination of the packages is "correct"), but it shouldn't randomly change. * This test asserts this behavior to prevent regressions. diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 6b173e7df..bfdefe055 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -151,12 +151,14 @@ class GitDownloaderTest extends TestCase $process = new ProcessExecutorMock; $process->expects(array( - array('cmd' => $this->winCompat(sprintf("git clone --mirror -- 'https://example.com/composer/composer' '%s'", $cachePath)), 'callback' => function () use ($cachePath) { @mkdir($cachePath, 0777, true); }), + array('cmd' => $this->winCompat(sprintf("git clone --mirror -- 'https://example.com/composer/composer' '%s'", $cachePath)), 'callback' => function () use ($cachePath) { + @mkdir($cachePath, 0777, true); + }), array('cmd' => 'git rev-parse --git-dir', 'stdout' => '.'), $this->winCompat('git rev-parse --quiet --verify \'1234567890123456789012345678901234567890^{commit}\''), $this->winCompat(sprintf("git clone --no-checkout '%1\$s' 'composerPath' --dissociate --reference '%1\$s' && cd 'composerPath' && git remote set-url origin -- 'https://example.com/composer/composer' && git remote add composer -- 'https://example.com/composer/composer'", $cachePath)), 'git branch -r', - $this->winCompat("(git checkout 'master' -- || git checkout -B 'master' 'composer/master' --) && git reset --hard '1234567890123456789012345678901234567890' --") + $this->winCompat("(git checkout 'master' -- || git checkout -B 'master' 'composer/master' --) && git reset --hard '1234567890123456789012345678901234567890' --"), ), true); $downloader = $this->getDownloaderMock(null, $config, $process); diff --git a/tests/Composer/Test/IO/NullIOTest.php b/tests/Composer/Test/IO/NullIOTest.php index 2a66807d3..18c5b8361 100644 --- a/tests/Composer/Test/IO/NullIOTest.php +++ b/tests/Composer/Test/IO/NullIOTest.php @@ -65,7 +65,9 @@ class NullIOTest extends TestCase { $io = new NullIO(); - $this->assertEquals('foo', $io->askAndValidate('question', function ($x) { return true; }, null, 'foo')); + $this->assertEquals('foo', $io->askAndValidate('question', function ($x) { + return true; + }, null, 'foo')); } public function testSelect() diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index d5959daf8..5c3548336 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -75,10 +75,10 @@ class InstallerTest extends TestCase switch ($key) { case 'vendor-dir': return 'foo'; - case 'lock'; - case 'notify-on-install'; + case 'lock': + case 'notify-on-install': return true; - case 'platform'; + case 'platform': return array(); } diff --git a/tests/Composer/Test/Json/ComposerSchemaTest.php b/tests/Composer/Test/Json/ComposerSchemaTest.php index 24fc50ca1..e45da5df3 100644 --- a/tests/Composer/Test/Json/ComposerSchemaTest.php +++ b/tests/Composer/Test/Json/ComposerSchemaTest.php @@ -91,7 +91,6 @@ class ComposerSchemaTest extends TestCase } /** - * * @param string $json * @return mixed */ diff --git a/tests/Composer/Test/Json/JsonFileTest.php b/tests/Composer/Test/Json/JsonFileTest.php index 0f53b2442..93b462f7f 100644 --- a/tests/Composer/Test/Json/JsonFileTest.php +++ b/tests/Composer/Test/Json/JsonFileTest.php @@ -370,10 +370,9 @@ class JsonFileTest extends TestCase } /** - * * @param string $json * @param mixed $data - * @param integer|null $options + * @param int|null $options * @return void */ private function assertJsonFormat($json, $data, $options = null) diff --git a/tests/Composer/Test/Mock/InstallationManagerMock.php b/tests/Composer/Test/Mock/InstallationManagerMock.php index 33853e357..ed4b33996 100644 --- a/tests/Composer/Test/Mock/InstallationManagerMock.php +++ b/tests/Composer/Test/Mock/InstallationManagerMock.php @@ -21,7 +21,6 @@ use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation; use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation; -use React\Promise\PromiseInterface; class InstallationManagerMock extends InstallationManager { diff --git a/tests/Composer/Test/Mock/ProcessExecutorMock.php b/tests/Composer/Test/Mock/ProcessExecutorMock.php index 3c09fdbb6..247f815a8 100644 --- a/tests/Composer/Test/Mock/ProcessExecutorMock.php +++ b/tests/Composer/Test/Mock/ProcessExecutorMock.php @@ -45,7 +45,7 @@ class ProcessExecutorMock extends ProcessExecutor * @param array $expectations * @param bool $strict set to true if you want to provide *all* expected commands, and not just a subset you are interested in testing * @param array{return: int, stdout?: string, stderr?: string} $defaultHandler default command handler for undefined commands if not in strict mode - * + * * @return void */ public function expects(array $expectations, $strict = false, array $defaultHandler = array('return' => 0, 'stdout' => '', 'stderr' => '')) @@ -100,7 +100,6 @@ class ProcessExecutorMock extends ProcessExecutor } /** - * * @param string $command * @param string $cwd * @param bool $tty diff --git a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php index 662a84dd8..26dfd9a75 100644 --- a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php @@ -16,7 +16,6 @@ use Composer\IO\NullIO; use Composer\Factory; use Composer\Package\Archiver\ArchiveManager; use Composer\Package\CompletePackage; -use Composer\Package\PackageInterface; use Composer\Util\Loop; use Composer\Test\Mock\FactoryMock; use Composer\Util\ProcessExecutor; diff --git a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php index d83208632..25e74145e 100644 --- a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php @@ -82,7 +82,6 @@ class RootPackageLoaderTest extends TestCase $this->assertEquals("1.0.0.0", $package->getVersion()); $this->assertEquals(RootPackage::DEFAULT_PRETTY_VERSION, $package->getPrettyVersion()); - } public function testPrettyVersionForRootPackageInVersionBranch() @@ -150,7 +149,7 @@ class RootPackageLoaderTest extends TestCase $process->expects(array( array( 'cmd' => 'git branch -a --no-color --no-abbrev -v', - 'stdout' => "* latest-production 38137d2f6c70e775e137b2d8a7a7d3eaebf7c7e5 Commit message\n master 4f6ed96b0bc363d2aa4404c3412de1c011f67c66 Commit message\n" + 'stdout' => "* latest-production 38137d2f6c70e775e137b2d8a7a7d3eaebf7c7e5 Commit message\n master 4f6ed96b0bc363d2aa4404c3412de1c011f67c66 Commit message\n", ), ), true); diff --git a/tests/Composer/Test/Package/Version/VersionGuesserTest.php b/tests/Composer/Test/Package/Version/VersionGuesserTest.php index d932f9223..292c78946 100644 --- a/tests/Composer/Test/Package/Version/VersionGuesserTest.php +++ b/tests/Composer/Test/Package/Version/VersionGuesserTest.php @@ -66,7 +66,7 @@ class VersionGuesserTest extends TestCase $process->expects(array( array( 'cmd' => 'git branch -a --no-color --no-abbrev -v', - 'stdout' => "* master $commitHash Commit message\n(no branch) $anotherCommitHash Commit message\n" + 'stdout' => "* master $commitHash Commit message\n(no branch) $anotherCommitHash Commit message\n", ), ), true); @@ -94,7 +94,7 @@ class VersionGuesserTest extends TestCase array( 'cmd' => 'git branch -a --no-color --no-abbrev -v', // Assumption here is that arbitrary would be the default branch - 'stdout' => " arbitrary $commitHash Commit message\n* current $anotherCommitHash Another message\n" + 'stdout' => " arbitrary $commitHash Commit message\n* current $anotherCommitHash Another message\n", ), ), true); @@ -118,11 +118,11 @@ class VersionGuesserTest extends TestCase $process->expects(array( array( 'cmd' => 'git branch -a --no-color --no-abbrev -v', - 'stdout' => " arbitrary $commitHash Commit message\n* feature $anotherCommitHash Another message\n" + 'stdout' => " arbitrary $commitHash Commit message\n* feature $anotherCommitHash Another message\n", ), array( 'cmd' => 'git rev-list arbitrary..feature', - 'stdout' => "$anotherCommitHash\n" + 'stdout' => "$anotherCommitHash\n", ), ), true); @@ -245,7 +245,6 @@ class VersionGuesserTest extends TestCase { $commitHash = '03a15d220da53c52eddd5f32ffca64a7b3801bea'; - $process = new ProcessExecutorMock; $process->expects(array( array( diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index 4e137b3f4..dc69fbb35 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -249,7 +249,7 @@ class PluginInstallerTest extends TestCase /** * @param string $newPluginApiVersion * @param CompletePackage[] $plugins - * + * * @return void */ private function setPluginApiVersionWithPlugins($newPluginApiVersion, array $plugins = array()) @@ -407,7 +407,7 @@ class PluginInstallerTest extends TestCase * @dataProvider invalidImplementationClassNames * @param callable $invalidImplementationClassNames * @param string $expect - * + * * @return void */ public function testQueryingWithInvalidCapabilityClassNameThrows($invalidImplementationClassNames, $expect = 'UnexpectedValueException') @@ -441,7 +441,7 @@ class PluginInstallerTest extends TestCase ->will($this->returnCallback(function () { return array(); })); - + /** @phpstan-ignore-next-line */ $this->assertNull($this->pm->getPluginCapability($plugin, $capabilityApi)); } @@ -449,7 +449,7 @@ class PluginInstallerTest extends TestCase /** * @dataProvider nonExistingOrInvalidImplementationClassTypes * @param callable $wrongImplementationClassTypes - * + * * @return void */ public function testQueryingWithNonExistingOrWrongCapabilityClassTypesThrows($wrongImplementationClassTypes) diff --git a/tests/Composer/Test/Repository/PlatformRepositoryTest.php b/tests/Composer/Test/Repository/PlatformRepositoryTest.php index 6a77fa318..27a9ddbbf 100644 --- a/tests/Composer/Test/Repository/PlatformRepositoryTest.php +++ b/tests/Composer/Test/Repository/PlatformRepositoryTest.php @@ -13,7 +13,6 @@ namespace Composer\Test\Repository; use Composer\Package\Link; -use Composer\Package\Package; use Composer\Package\PackageInterface; use Composer\Repository\PlatformRepository; use Composer\Test\TestCase; diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index fb07d34f2..d48a8fd1c 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -20,7 +20,6 @@ use Composer\Util\Http\Response; use Composer\Test\Mock\ProcessExecutorMock; use Composer\Config; use Composer\Util\ProcessExecutor; -use Symfony\Component\Process\Process; class GitHubDriverTest extends TestCase { diff --git a/tests/Composer/Test/TestCase.php b/tests/Composer/Test/TestCase.php index 1e6e77c06..8593b4ad5 100644 --- a/tests/Composer/Test/TestCase.php +++ b/tests/Composer/Test/TestCase.php @@ -188,6 +188,7 @@ abstract class TestCase extends PolyfillTestCase $cmd = preg_replace_callback("/('[^']*')/", function ($m) { // Double-quotes are used only when needed $char = (strpbrk($m[1], " \t^&|<>()") !== false || $m[1] === "''") ? '"' : ''; + return str_replace("'", $char, $m[1]); }, $cmd); } diff --git a/tests/Composer/Test/Util/GitHubTest.php b/tests/Composer/Test/Util/GitHubTest.php index 7a77de092..ed605c3c7 100644 --- a/tests/Composer/Test/Util/GitHubTest.php +++ b/tests/Composer/Test/Util/GitHubTest.php @@ -16,8 +16,6 @@ use Composer\Downloader\TransportException; use Composer\Util\GitHub; use Composer\Util\Http\Response; use Composer\Test\TestCase; -use RecursiveArrayIterator; -use RecursiveIteratorIterator; /** * @author Rob Bast diff --git a/tests/Composer/Test/Util/GitTest.php b/tests/Composer/Test/Util/GitTest.php index 4dfe653be..d6e74c7b5 100644 --- a/tests/Composer/Test/Util/GitTest.php +++ b/tests/Composer/Test/Util/GitTest.php @@ -86,7 +86,6 @@ class GitTest extends TestCase $this->mockConfig('https'); - $this->process->expects(array( array('cmd' => 'git command', 'return' => 1), array('cmd' => 'git --version', 'return' => 0), diff --git a/tests/Composer/Test/Util/ProcessExecutorTest.php b/tests/Composer/Test/Util/ProcessExecutorTest.php index 8375f75de..ff2acd82e 100644 --- a/tests/Composer/Test/Util/ProcessExecutorTest.php +++ b/tests/Composer/Test/Util/ProcessExecutorTest.php @@ -155,70 +155,70 @@ class ProcessExecutorTest extends TestCase { return array( // empty argument - must be quoted - 'empty' => array('', '""', "''"), + 'empty' => array('', '""', "''"), // null argument - must be quoted - 'empty null' => array(null, '""', "''"), + 'empty null' => array(null, '""', "''"), // false argument - must be quoted - 'empty false' => array(false, '""', "''"), + 'empty false' => array(false, '""', "''"), // unix single-quote must be escaped - 'unix-sq' => array("a'bc", "a'bc", "'a'\\''bc'"), + 'unix-sq' => array("a'bc", "a'bc", "'a'\\''bc'"), // new lines must be replaced - 'new lines' => array("a\nb\nc", '"a b c"', "'a\nb\nc'"), + 'new lines' => array("a\nb\nc", '"a b c"', "'a\nb\nc'"), // whitespace must be quoted - 'ws space' => array('a b c', '"a b c"', "'a b c'"), + 'ws space' => array('a b c', '"a b c"', "'a b c'"), // whitespace must be quoted - 'ws tab' => array("a\tb\tc", "\"a\tb\tc\"", "'a\tb\tc'"), + 'ws tab' => array("a\tb\tc", "\"a\tb\tc\"", "'a\tb\tc'"), // no whitespace must not be quoted - 'no-ws' => array('abc', 'abc', "'abc'"), + 'no-ws' => array('abc', 'abc', "'abc'"), // double-quotes must be backslash-escaped - 'dq' => array('a"bc', 'a\^"bc', "'a\"bc'"), + 'dq' => array('a"bc', 'a\^"bc', "'a\"bc'"), // double-quotes must be backslash-escaped with preceeding backslashes doubled - 'dq-bslash' => array('a\\"bc', 'a\\\\\^"bc', "'a\\\"bc'"), + 'dq-bslash' => array('a\\"bc', 'a\\\\\^"bc', "'a\\\"bc'"), // backslashes not preceeding a double-quote are treated as literal - 'bslash' => array('ab\\\\c\\', 'ab\\\\c\\', "'ab\\\\c\\'"), + 'bslash' => array('ab\\\\c\\', 'ab\\\\c\\', "'ab\\\\c\\'"), // trailing backslashes must be doubled up when the argument is quoted - 'bslash dq' => array('a b c\\\\', '"a b c\\\\\\\\"', "'a b c\\\\'"), + 'bslash dq' => array('a b c\\\\', '"a b c\\\\\\\\"', "'a b c\\\\'"), // meta: outer double-quotes must be caret-escaped as well - 'meta dq' => array('a "b" c', '^"a \^"b\^" c^"', "'a \"b\" c'"), + 'meta dq' => array('a "b" c', '^"a \^"b\^" c^"', "'a \"b\" c'"), // meta: percent expansion must be caret-escaped - 'meta-pc1' => array('%path%', '^%path^%', "'%path%'"), + 'meta-pc1' => array('%path%', '^%path^%', "'%path%'"), // meta: expansion must have two percent characters - 'meta-pc2' => array('%path', '%path', "'%path'"), + 'meta-pc2' => array('%path', '%path', "'%path'"), // meta: expansion must have have two surrounding percent characters - 'meta-pc3' => array('%%path', '%%path', "'%%path'"), + 'meta-pc3' => array('%%path', '%%path', "'%%path'"), // meta: bang expansion must be double caret-escaped - 'meta-bang1' => array('!path!', '^^!path^^!', "'!path!'"), + 'meta-bang1' => array('!path!', '^^!path^^!', "'!path!'"), // meta: bang expansion must have two bang characters - 'meta-bang2' => array('!path', '!path', "'!path'"), + 'meta-bang2' => array('!path', '!path', "'!path'"), // meta: bang expansion must have two surrounding ang characters - 'meta-bang3' => array('!!path', '!!path', "'!!path'"), + 'meta-bang3' => array('!!path', '!!path', "'!!path'"), // meta: caret-escaping must escape all other meta chars (triggered by double-quote) - 'meta-all-dq' => array('<>"&|()^', '^<^>\^"^&^|^(^)^^', "'<>\"&|()^'"), + 'meta-all-dq' => array('<>"&|()^', '^<^>\^"^&^|^(^)^^', "'<>\"&|()^'"), // other meta: no caret-escaping when whitespace in argument - 'other meta' => array('<> &| ()^', '"<> &| ()^"', "'<> &| ()^'"), + 'other meta' => array('<> &| ()^', '"<> &| ()^"', "'<> &| ()^'"), // other meta: quote escape chars when no whitespace in argument - 'other-meta' => array('<>&|()^', '"<>&|()^"', "'<>&|()^'"), + 'other-meta' => array('<>&|()^', '"<>&|()^"', "'<>&|()^'"), ); } }