Upgrade php-cs-fixer to 3.x and fix CS
parent
c65d09dff7
commit
44b69ba77f
|
@ -9,4 +9,4 @@ phpunit.xml
|
||||||
.vagrant
|
.vagrant
|
||||||
Vagrantfile
|
Vagrantfile
|
||||||
.idea
|
.idea
|
||||||
.php_cs.cache
|
.php-cs-fixer.cache
|
||||||
|
|
|
@ -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)
|
||||||
;
|
;
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -255,13 +255,13 @@ class ClassMapGeneratorTest extends TestCase
|
||||||
public function testCreateMapDoesNotHitRegexBacktraceLimit()
|
public function testCreateMapDoesNotHitRegexBacktraceLimit()
|
||||||
{
|
{
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Foo\\StripNoise' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/StripNoise.php',
|
'Foo\\StripNoise' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/StripNoise.php',
|
||||||
'Foo\\VeryLongHeredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php',
|
'Foo\\VeryLongHeredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php',
|
||||||
'Foo\\ClassAfterLongHereDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php',
|
'Foo\\ClassAfterLongHereDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php',
|
||||||
'Foo\\VeryLongPHP73Heredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Heredoc.php',
|
'Foo\\VeryLongPHP73Heredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Heredoc.php',
|
||||||
'Foo\\VeryLongPHP73Nowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php',
|
'Foo\\VeryLongPHP73Nowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php',
|
||||||
'Foo\\ClassAfterLongNowDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php',
|
'Foo\\ClassAfterLongNowDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php',
|
||||||
'Foo\\VeryLongNowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongNowdoc.php',
|
'Foo\\VeryLongNowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongNowdoc.php',
|
||||||
);
|
);
|
||||||
|
|
||||||
ini_set('pcre.backtrack_limit', '30000');
|
ini_set('pcre.backtrack_limit', '30000');
|
||||||
|
|
|
@ -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;
|
* 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`.
|
* 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".
|
* 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.
|
* 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.
|
* This test asserts this behavior to prevent regressions.
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,6 @@ class ComposerSchemaTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param string $json
|
* @param string $json
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ProcessExecutorMock extends ProcessExecutor
|
||||||
* @param array<string|array{cmd: string, return?: int, stdout?: string, stderr?: string, callback?: callable}> $expectations
|
* @param array<string|array{cmd: string, return?: int, stdout?: string, stderr?: string, callback?: callable}> $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 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
|
* @param array{return: int, stdout?: string, stderr?: string} $defaultHandler default command handler for undefined commands if not in strict mode
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function expects(array $expectations, $strict = false, array $defaultHandler = array('return' => 0, 'stdout' => '', 'stderr' => ''))
|
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 $command
|
||||||
* @param string $cwd
|
* @param string $cwd
|
||||||
* @param bool $tty
|
* @param bool $tty
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -249,7 +249,7 @@ class PluginInstallerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @param string $newPluginApiVersion
|
* @param string $newPluginApiVersion
|
||||||
* @param CompletePackage[] $plugins
|
* @param CompletePackage[] $plugins
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function setPluginApiVersionWithPlugins($newPluginApiVersion, array $plugins = array())
|
private function setPluginApiVersionWithPlugins($newPluginApiVersion, array $plugins = array())
|
||||||
|
@ -407,7 +407,7 @@ class PluginInstallerTest extends TestCase
|
||||||
* @dataProvider invalidImplementationClassNames
|
* @dataProvider invalidImplementationClassNames
|
||||||
* @param callable $invalidImplementationClassNames
|
* @param callable $invalidImplementationClassNames
|
||||||
* @param string $expect
|
* @param string $expect
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testQueryingWithInvalidCapabilityClassNameThrows($invalidImplementationClassNames, $expect = 'UnexpectedValueException')
|
public function testQueryingWithInvalidCapabilityClassNameThrows($invalidImplementationClassNames, $expect = 'UnexpectedValueException')
|
||||||
|
@ -441,7 +441,7 @@ class PluginInstallerTest extends TestCase
|
||||||
->will($this->returnCallback(function () {
|
->will($this->returnCallback(function () {
|
||||||
return array();
|
return array();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
/** @phpstan-ignore-next-line */
|
||||||
$this->assertNull($this->pm->getPluginCapability($plugin, $capabilityApi));
|
$this->assertNull($this->pm->getPluginCapability($plugin, $capabilityApi));
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ class PluginInstallerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @dataProvider nonExistingOrInvalidImplementationClassTypes
|
* @dataProvider nonExistingOrInvalidImplementationClassTypes
|
||||||
* @param callable $wrongImplementationClassTypes
|
* @param callable $wrongImplementationClassTypes
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testQueryingWithNonExistingOrWrongCapabilityClassTypesThrows($wrongImplementationClassTypes)
|
public function testQueryingWithNonExistingOrWrongCapabilityClassTypesThrows($wrongImplementationClassTypes)
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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),
|
||||||
|
|
|
@ -155,70 +155,70 @@ class ProcessExecutorTest extends TestCase
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
// empty argument - must be quoted
|
// empty argument - must be quoted
|
||||||
'empty' => array('', '""', "''"),
|
'empty' => array('', '""', "''"),
|
||||||
|
|
||||||
// null argument - must be quoted
|
// null argument - must be quoted
|
||||||
'empty null' => array(null, '""', "''"),
|
'empty null' => array(null, '""', "''"),
|
||||||
|
|
||||||
// false argument - must be quoted
|
// false argument - must be quoted
|
||||||
'empty false' => array(false, '""', "''"),
|
'empty false' => array(false, '""', "''"),
|
||||||
|
|
||||||
// unix single-quote must be escaped
|
// 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 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 <space> must be quoted
|
// whitespace <space> 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 <tab> must be quoted
|
// whitespace <tab> 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 whitespace must not be quoted
|
||||||
'no-ws' => array('abc', 'abc', "'abc'"),
|
'no-ws' => array('abc', 'abc', "'abc'"),
|
||||||
|
|
||||||
// double-quotes must be backslash-escaped
|
// 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
|
// 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
|
// 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
|
// 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: quote escape chars when no whitespace in argument
|
||||||
'other-meta' => array('<>&|()^', '"<>&|()^"', "'<>&|()^'"),
|
'other-meta' => array('<>&|()^', '"<>&|()^"', "'<>&|()^'"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue