Merged isset, unset and str_replace calls

main
Simon Berger 4 years ago
parent 974e7ba296
commit 80d71ccb3f

@ -277,7 +277,7 @@ EOT
$author_email = $git['user.email'];
}
if (isset($author_name) && isset($author_email)) {
if (isset($author_name, $author_email)) {
$author = sprintf('%s <%s>', $author_name, $author_email);
}
}

@ -124,7 +124,7 @@ EOT
if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
$composeUser = posix_getpwuid(posix_geteuid());
$homeOwner = posix_getpwuid(fileowner($home));
if (isset($composeUser['name']) && isset($homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
if (isset($composeUser['name'], $homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
$io->writeError('<warning>You are running composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
}
}

@ -199,9 +199,14 @@ class Compiler
}
if ($path === 'src/Composer/Composer.php') {
$content = str_replace('@package_version@', $this->version, $content);
$content = str_replace('@package_branch_alias_version@', $this->branchAliasVersion, $content);
$content = str_replace('@release_date@', $this->versionDate->format('Y-m-d H:i:s'), $content);
$content = strtr(
$content,
array(
'@package_version@' => $this->version,
'@package_branch_alias_version@' => $this->branchAliasVersion,
'@release_date@' => $this->versionDate->format('Y-m-d H:i:s')
)
);
$content = preg_replace('{SOURCE_VERSION = \'[^\']+\';}', 'SOURCE_VERSION = \'\';', $content);
}

@ -399,7 +399,7 @@ class PoolBuilder
if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
foreach ($package->getReplaces() as $link) {
$replace = $link->getTarget();
if (isset($this->loadedPackages[$replace]) && isset($this->skippedLoad[$replace])) {
if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
$this->unfixPackage($request, $replace);
$this->markPackageNameForLoading($request, $replace, $link->getConstraint());
@ -488,9 +488,7 @@ class PoolBuilder
$this->unfixPackage($request, $this->skippedLoad[$name]);
}
unset($this->skippedLoad[$name]);
unset($this->loadedPackages[$name]);
unset($this->maxExtendedReqs[$name]);
unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name]);
}
private function removeLoadedPackage(Request $request, PackageInterface $package, $index)

@ -331,7 +331,7 @@ class Problem
}
foreach ($prepared as $name => $package) {
// remove the implicit default branch alias to avoid cruft in the display
if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]) && isset($hasDefaultBranch[$name])) {
if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
}

@ -82,8 +82,7 @@ class Request
public function unfixPackage(PackageInterface $package)
{
unset($this->fixedPackages[spl_object_hash($package)]);
unset($this->unlockables[spl_object_hash($package)]);
unset($this->fixedPackages[spl_object_hash($package)], $this->unlockables[spl_object_hash($package)]);
}
public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies)

@ -88,7 +88,6 @@ class RuleSetIterator implements \Iterator
public function valid()
{
return isset($this->rules[$this->currentType])
&& isset($this->rules[$this->currentType][$this->currentOffset]);
return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
}
}

@ -129,7 +129,7 @@ class ArrayLoader implements LoaderInterface
}
if (isset($config['source'])) {
if (!isset($config['source']['type']) || !isset($config['source']['url']) || !isset($config['source']['reference'])) {
if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
throw new \UnexpectedValueException(sprintf(
"Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
$config['name'],
@ -145,8 +145,7 @@ class ArrayLoader implements LoaderInterface
}
if (isset($config['dist'])) {
if (!isset($config['dist']['type'])
|| !isset($config['dist']['url'])) {
if (!isset($config['dist']['type'], $config['dist']['url'])) {
throw new \UnexpectedValueException(sprintf(
"Package %s's dist key should be specified as ".
"{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",

@ -225,7 +225,7 @@ class SvnDriver extends VcsDriver
foreach ($this->process->splitLines($output) as $line) {
$line = trim($line);
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
if (isset($match[1]) && isset($match[2]) && $match[2] !== './') {
if (isset($match[1], $match[2]) && $match[2] !== './') {
$this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
'/' . $this->tagsPath . '/' . $match[2],
$match[1]
@ -259,7 +259,7 @@ class SvnDriver extends VcsDriver
foreach ($this->process->splitLines($output) as $line) {
$line = trim($line);
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
if (isset($match[1]) && isset($match[2]) && $match[2] === './') {
if (isset($match[1], $match[2]) && $match[2] === './') {
$this->branches['trunk'] = $this->buildIdentifier(
'/' . $this->trunkPath,
$match[1]
@ -278,7 +278,7 @@ class SvnDriver extends VcsDriver
foreach ($this->process->splitLines(trim($output)) as $line) {
$line = trim($line);
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
if (isset($match[1]) && isset($match[2]) && $match[2] !== './') {
if (isset($match[1], $match[2]) && $match[2] !== './') {
$this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
'/' . $this->branchesPath . '/' . $match[2],
$match[1]

@ -236,8 +236,7 @@ class Bitbucket
$authConfig = $this->config->get('bitbucket-oauth');
if (
!isset($authConfig[$originUrl]['access-token'])
|| !isset($authConfig[$originUrl]['access-token-expiration'])
!isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
|| time() > $authConfig[$originUrl]['access-token-expiration']
) {
return false;

@ -132,7 +132,7 @@ class ConfigValidator
}
// check for require-dev overrides
if (isset($manifest['require']) && isset($manifest['require-dev'])) {
if (isset($manifest['require'], $manifest['require-dev'])) {
$requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
if (!empty($requireOverrides)) {

@ -220,7 +220,7 @@ class CurlDownloader
public function abortRequest($id)
{
if (isset($this->jobs[$id]) && isset($this->jobs[$id]['handle'])) {
if (isset($this->jobs[$id], $this->jobs[$id]['handle'])) {
$job = $this->jobs[$id];
curl_multi_remove_handle($this->multiHandle, $job['handle']);
curl_close($job['handle']);

@ -347,10 +347,7 @@ class InstallerTest extends TestCase
$output = str_replace("\r", '', $io->getOutput());
$this->assertEquals($expectResult, $result, $output . stream_get_contents($appOutput));
if ($expectLock && isset($actualLock)) {
unset($actualLock['hash']);
unset($actualLock['content-hash']);
unset($actualLock['_readme']);
unset($actualLock['plugin-api-version']);
unset($actualLock['hash'], $actualLock['content-hash'], $actualLock['_readme'], $actualLock['plugin-api-version']);
$this->assertEquals($expectLock, $actualLock);
}

@ -120,8 +120,7 @@ class ComposerSchemaTest extends TestCase
// remove justinrainbow/json-schema 3.0/5.2 props so it works with all versions
foreach ($errors as &$err) {
unset($err['pointer']);
unset($err['context']);
unset($err['pointer'], $err['context']);
}
return $errors;

@ -82,7 +82,10 @@ class RemoteFilesystemTest extends TestCase
));
$res = $this->callGetOptionsForUrl($io, array('https://example.org', array()), $streamOptions);
$this->assertTrue(isset($res['ssl']) && isset($res['ssl']['allow_self_signed']) && true === $res['ssl']['allow_self_signed'], 'getOptions must return an array with a allow_self_signed set to true');
$this->assertTrue(
isset($res['ssl'], $res['ssl']['allow_self_signed']) && true === $res['ssl']['allow_self_signed'],
'getOptions must return an array with a allow_self_signed set to true'
);
}
public function testGetOptionsForUrlWithCallOptionsKeepsHeader()

@ -19,22 +19,12 @@ class StreamContextFactoryTest extends TestCase
{
protected function setUp()
{
unset($_SERVER['HTTP_PROXY']);
unset($_SERVER['http_proxy']);
unset($_SERVER['HTTPS_PROXY']);
unset($_SERVER['https_proxy']);
unset($_SERVER['NO_PROXY']);
unset($_SERVER['no_proxy']);
unset($_SERVER['HTTP_PROXY'], $_SERVER['http_proxy'], $_SERVER['HTTPS_PROXY'], $_SERVER['https_proxy'], $_SERVER['NO_PROXY'], $_SERVER['no_proxy']);
}
protected function tearDown()
{
unset($_SERVER['HTTP_PROXY']);
unset($_SERVER['http_proxy']);
unset($_SERVER['HTTPS_PROXY']);
unset($_SERVER['https_proxy']);
unset($_SERVER['NO_PROXY']);
unset($_SERVER['no_proxy']);
unset($_SERVER['HTTP_PROXY'], $_SERVER['http_proxy'], $_SERVER['HTTPS_PROXY'], $_SERVER['https_proxy'], $_SERVER['NO_PROXY'], $_SERVER['no_proxy']);
}
/**

Loading…
Cancel
Save