1
0
Fork 0

Upgrade php-cs-fixer to 3.x and fix CS

pull/10234/head
Jordi Boggiano 2021-10-27 16:18:24 +02:00
parent c65d09dff7
commit 44b69ba77f
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
30 changed files with 87 additions and 79 deletions

2
.gitignore vendored
View File

@ -9,4 +9,4 @@ phpunit.xml
.vagrant .vagrant
Vagrantfile Vagrantfile
.idea .idea
.php_cs.cache .php-cs-fixer.cache

View File

@ -18,10 +18,8 @@ $finder = PhpCsFixer\Finder::create()
->notPath('Fixtures') ->notPath('Fixtures')
; ;
return PhpCsFixer\Config::create() $config = new PhpCsFixer\Config();
->setUsingCache(true) return $config->setRules([
->setRiskyAllowed(true)
->setRules(array(
'@PSR2' => true, '@PSR2' => true,
'array_syntax' => array('syntax' => 'long'), 'array_syntax' => array('syntax' => 'long'),
'binary_operator_spaces' => true, 'binary_operator_spaces' => true,
@ -29,31 +27,42 @@ return PhpCsFixer\Config::create()
'cast_spaces' => array('space' => 'single'), 'cast_spaces' => array('space' => 'single'),
'header_comment' => array('header' => $header), 'header_comment' => array('header' => $header),
'include' => true, '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_class_opening' => true,
'no_blank_lines_after_phpdoc' => true, 'no_blank_lines_after_phpdoc' => true,
'no_empty_statement' => true, 'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true, 'no_extra_blank_lines' => true,
'no_leading_import_slash' => true, 'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true, 'no_leading_namespace_whitespace' => true,
'no_trailing_comma_in_singleline_array' => true, 'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true, 'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true, 'object_operator_without_whitespace' => true,
'phpdoc_align' => true, //'phpdoc_align' => true,
'phpdoc_indent' => true, 'phpdoc_indent' => true,
'phpdoc_no_access' => true, 'phpdoc_no_access' => true,
'phpdoc_no_package' => true, 'phpdoc_no_package' => true,
'phpdoc_order' => true, //'phpdoc_order' => true,
'phpdoc_scalar' => true, 'phpdoc_scalar' => true,
'phpdoc_trim' => true, 'phpdoc_trim' => true,
'phpdoc_types' => true, 'phpdoc_types' => true,
'psr0' => true, 'psr_autoloading' => true,
'single_blank_line_before_namespace' => true, 'single_blank_line_before_namespace' => true,
'standardize_not_equals' => true, 'standardize_not_equals' => true,
'ternary_operator_spaces' => true, 'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true, 'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'unary_operator_spaces' => true, '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) ->setFinder($finder)
; ;

View File

@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload; namespace Composer\Autoload;
/** /**
@ -118,6 +128,7 @@ class PhpFileCleaner
&& \preg_match($type['pattern'], $this->contents, $match, 0, $this->index - 1) && \preg_match($type['pattern'], $this->contents, $match, 0, $this->index - 1)
) { ) {
$clean .= $match[0]; $clean .= $match[0];
return $clean; return $clean;
} }
} }
@ -222,6 +233,7 @@ class PhpFileCleaner
&& $this->match($delimiterPattern) && $this->match($delimiterPattern)
) { ) {
$this->index += $delimiterLength; $this->index += $delimiterLength;
return; return;
} }
break; break;

View File

@ -138,6 +138,7 @@ EOT
$process = new ProcessExecutor($this->getIO()); $process = new ProcessExecutor($this->getIO());
if (Platform::isWindows()) { if (Platform::isWindows()) {
$process->execute('start "web" explorer ' . $url, $output); $process->execute('start "web" explorer ' . $url, $output);
return; return;
} }

View File

@ -13,7 +13,6 @@
namespace Composer\Command; namespace Composer\Command;
use Composer\Json\JsonFile; use Composer\Json\JsonFile;
use Composer\Package\BasePackage;
use Composer\Package\CompletePackageInterface; use Composer\Package\CompletePackageInterface;
use Composer\Plugin\CommandEvent; use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents; use Composer\Plugin\PluginEvents;

View File

@ -113,6 +113,7 @@ EOT
if ($input->getOption('update-keys')) { if ($input->getOption('update-keys')) {
$this->fetchKeys($io, $config); $this->fetchKeys($io, $config);
return 0; return 0;
} }

View File

@ -58,7 +58,6 @@ class LockTransaction extends Transaction
parent::__construct($this->presentMap, $this->resultPackages['all']); parent::__construct($this->presentMap, $this->resultPackages['all']);
} }
// TODO make this a bit prettier instead of the two text indexes? // TODO make this a bit prettier instead of the two text indexes?
/** /**
* @return void * @return void

View File

@ -22,7 +22,6 @@ use Composer\Package\PackageInterface;
use Composer\Package\Version\StabilityFilter; use Composer\Package\Version\StabilityFilter;
use Composer\Plugin\PluginEvents; use Composer\Plugin\PluginEvents;
use Composer\Plugin\PrePoolCreateEvent; use Composer\Plugin\PrePoolCreateEvent;
use Composer\Repository\LockArrayRepository;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
use Composer\Repository\RootPackageRepository; use Composer\Repository\RootPackageRepository;

View File

@ -20,7 +20,6 @@ use Composer\Package\Version\VersionGuesser;
use Composer\Package\RootPackageInterface; use Composer\Package\RootPackageInterface;
use Composer\Repository\RepositoryManager; use Composer\Repository\RepositoryManager;
use Composer\Repository\RepositoryFactory; use Composer\Repository\RepositoryFactory;
use Composer\Repository\WritableRepositoryInterface;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\Util\Platform; use Composer\Util\Platform;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;

View File

@ -22,8 +22,6 @@ use Composer\Package\BasePackage;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
use Composer\Package\CompleteAliasPackage; use Composer\Package\CompleteAliasPackage;
use Composer\Package\CompletePackage; use Composer\Package\CompletePackage;
use Composer\Package\CompletePackageInterface;
use Composer\Package\PackageInterface;
use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Package\Version\StabilityFilter; use Composer\Package\Version\StabilityFilter;

View File

@ -13,9 +13,7 @@
namespace Composer\Util; namespace Composer\Util;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Util\Platform;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessUtils;
use Symfony\Component\Process\Exception\RuntimeException; use Symfony\Component\Process\Exception\RuntimeException;
use React\Promise\Promise; use React\Promise\Promise;
use React\Promise\PromiseInterface; use React\Promise\PromiseInterface;

View File

@ -151,12 +151,14 @@ class GitDownloaderTest extends TestCase
$process = new ProcessExecutorMock; $process = new ProcessExecutorMock;
$process->expects(array( $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' => '.'), array('cmd' => 'git rev-parse --git-dir', 'stdout' => '.'),
$this->winCompat('git rev-parse --quiet --verify \'1234567890123456789012345678901234567890^{commit}\''), $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)), $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', '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); ), true);
$downloader = $this->getDownloaderMock(null, $config, $process); $downloader = $this->getDownloaderMock(null, $config, $process);

View File

@ -65,7 +65,9 @@ class NullIOTest extends TestCase
{ {
$io = new NullIO(); $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() public function testSelect()

View File

@ -75,10 +75,10 @@ class InstallerTest extends TestCase
switch ($key) { switch ($key) {
case 'vendor-dir': case 'vendor-dir':
return 'foo'; return 'foo';
case 'lock'; case 'lock':
case 'notify-on-install'; case 'notify-on-install':
return true; return true;
case 'platform'; case 'platform':
return array(); return array();
} }

View File

@ -91,7 +91,6 @@ class ComposerSchemaTest extends TestCase
} }
/** /**
*
* @param string $json * @param string $json
* @return mixed * @return mixed
*/ */

View File

@ -370,10 +370,9 @@ class JsonFileTest extends TestCase
} }
/** /**
*
* @param string $json * @param string $json
* @param mixed $data * @param mixed $data
* @param integer|null $options * @param int|null $options
* @return void * @return void
*/ */
private function assertJsonFormat($json, $data, $options = null) private function assertJsonFormat($json, $data, $options = null)

View File

@ -21,7 +21,6 @@ use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Operation\UninstallOperation;
use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation; use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation; use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
use React\Promise\PromiseInterface;
class InstallationManagerMock extends InstallationManager class InstallationManagerMock extends InstallationManager
{ {

View File

@ -100,7 +100,6 @@ class ProcessExecutorMock extends ProcessExecutor
} }
/** /**
*
* @param string $command * @param string $command
* @param string $cwd * @param string $cwd
* @param bool $tty * @param bool $tty

View File

@ -16,7 +16,6 @@ use Composer\IO\NullIO;
use Composer\Factory; use Composer\Factory;
use Composer\Package\Archiver\ArchiveManager; use Composer\Package\Archiver\ArchiveManager;
use Composer\Package\CompletePackage; use Composer\Package\CompletePackage;
use Composer\Package\PackageInterface;
use Composer\Util\Loop; use Composer\Util\Loop;
use Composer\Test\Mock\FactoryMock; use Composer\Test\Mock\FactoryMock;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;

View File

@ -82,7 +82,6 @@ class RootPackageLoaderTest extends TestCase
$this->assertEquals("1.0.0.0", $package->getVersion()); $this->assertEquals("1.0.0.0", $package->getVersion());
$this->assertEquals(RootPackage::DEFAULT_PRETTY_VERSION, $package->getPrettyVersion()); $this->assertEquals(RootPackage::DEFAULT_PRETTY_VERSION, $package->getPrettyVersion());
} }
public function testPrettyVersionForRootPackageInVersionBranch() public function testPrettyVersionForRootPackageInVersionBranch()
@ -150,7 +149,7 @@ class RootPackageLoaderTest extends TestCase
$process->expects(array( $process->expects(array(
array( array(
'cmd' => 'git branch -a --no-color --no-abbrev -v', '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); ), true);

View File

@ -66,7 +66,7 @@ class VersionGuesserTest extends TestCase
$process->expects(array( $process->expects(array(
array( array(
'cmd' => 'git branch -a --no-color --no-abbrev -v', '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); ), true);
@ -94,7 +94,7 @@ class VersionGuesserTest extends TestCase
array( array(
'cmd' => 'git branch -a --no-color --no-abbrev -v', 'cmd' => 'git branch -a --no-color --no-abbrev -v',
// Assumption here is that arbitrary would be the default branch // 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); ), true);
@ -118,11 +118,11 @@ class VersionGuesserTest extends TestCase
$process->expects(array( $process->expects(array(
array( array(
'cmd' => 'git branch -a --no-color --no-abbrev -v', '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( array(
'cmd' => 'git rev-list arbitrary..feature', 'cmd' => 'git rev-list arbitrary..feature',
'stdout' => "$anotherCommitHash\n" 'stdout' => "$anotherCommitHash\n",
), ),
), true); ), true);
@ -245,7 +245,6 @@ class VersionGuesserTest extends TestCase
{ {
$commitHash = '03a15d220da53c52eddd5f32ffca64a7b3801bea'; $commitHash = '03a15d220da53c52eddd5f32ffca64a7b3801bea';
$process = new ProcessExecutorMock; $process = new ProcessExecutorMock;
$process->expects(array( $process->expects(array(
array( array(

View File

@ -13,7 +13,6 @@
namespace Composer\Test\Repository; namespace Composer\Test\Repository;
use Composer\Package\Link; use Composer\Package\Link;
use Composer\Package\Package;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Test\TestCase; use Composer\Test\TestCase;

View File

@ -20,7 +20,6 @@ use Composer\Util\Http\Response;
use Composer\Test\Mock\ProcessExecutorMock; use Composer\Test\Mock\ProcessExecutorMock;
use Composer\Config; use Composer\Config;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Symfony\Component\Process\Process;
class GitHubDriverTest extends TestCase class GitHubDriverTest extends TestCase
{ {

View File

@ -188,6 +188,7 @@ abstract class TestCase extends PolyfillTestCase
$cmd = preg_replace_callback("/('[^']*')/", function ($m) { $cmd = preg_replace_callback("/('[^']*')/", function ($m) {
// Double-quotes are used only when needed // Double-quotes are used only when needed
$char = (strpbrk($m[1], " \t^&|<>()") !== false || $m[1] === "''") ? '"' : ''; $char = (strpbrk($m[1], " \t^&|<>()") !== false || $m[1] === "''") ? '"' : '';
return str_replace("'", $char, $m[1]); return str_replace("'", $char, $m[1]);
}, $cmd); }, $cmd);
} }

View File

@ -16,8 +16,6 @@ use Composer\Downloader\TransportException;
use Composer\Util\GitHub; use Composer\Util\GitHub;
use Composer\Util\Http\Response; use Composer\Util\Http\Response;
use Composer\Test\TestCase; use Composer\Test\TestCase;
use RecursiveArrayIterator;
use RecursiveIteratorIterator;
/** /**
* @author Rob Bast <rob.bast@gmail.com> * @author Rob Bast <rob.bast@gmail.com>

View File

@ -86,7 +86,6 @@ class GitTest extends TestCase
$this->mockConfig('https'); $this->mockConfig('https');
$this->process->expects(array( $this->process->expects(array(
array('cmd' => 'git command', 'return' => 1), array('cmd' => 'git command', 'return' => 1),
array('cmd' => 'git --version', 'return' => 0), array('cmd' => 'git --version', 'return' => 0),