diff --git a/src/Configurator/ComposerScriptsConfigurator.php b/src/Configurator/ComposerScriptsConfigurator.php index 705966448..16c81e65c 100644 --- a/src/Configurator/ComposerScriptsConfigurator.php +++ b/src/Configurator/ComposerScriptsConfigurator.php @@ -26,7 +26,7 @@ public function configure(Recipe $recipe, $scripts) $json = new JsonFile(Factory::getComposerFile()); $jsonContents = $json->read(); - $autoScripts = isset($jsonContents['scripts']['auto-scripts']) ? $jsonContents['scripts']['auto-scripts'] : []; + $autoScripts = $jsonContents['scripts']['auto-scripts'] ?? []; $autoScripts = array_merge($autoScripts, $scripts); $manipulator = new JsonManipulator(file_get_contents($json->getPath())); @@ -40,7 +40,7 @@ public function unconfigure(Recipe $recipe, $scripts) $json = new JsonFile(Factory::getComposerFile()); $jsonContents = $json->read(); - $autoScripts = isset($jsonContents['scripts']['auto-scripts']) ? $jsonContents['scripts']['auto-scripts'] : []; + $autoScripts = $jsonContents['scripts']['auto-scripts'] ?? []; foreach (array_keys($scripts) as $cmd) { unset($autoScripts[$cmd]); } diff --git a/src/Downloader.php b/src/Downloader.php index 7e6d19020..f2c1612b2 100644 --- a/src/Downloader.php +++ b/src/Downloader.php @@ -42,7 +42,7 @@ public function __construct(Composer $composer, IoInterface $io) $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', self::ENDPOINT)); $this->sess = bin2hex(random_bytes(16)); $extra = $this->composer->getPackage()->getExtra(); - if (isset($extra['flex-id']) && $extra['flex-id']) { + if ($extra['flex-id'] ?? false) { $this->options['http'] = [ 'header' => ['Flex-ID: '.$extra['flex-id']], ]; diff --git a/src/Options.php b/src/Options.php index be221f0a0..9e6c51dde 100644 --- a/src/Options.php +++ b/src/Options.php @@ -25,7 +25,7 @@ public function __construct(array $options = []) public function get($name) { - return isset($this->options[$name]) ? $this->options[$name] : null; + return $this->options[$name] ?? null; } public function expandTargetDir($target) diff --git a/src/PackageResolver.php b/src/PackageResolver.php index dc07ef40b..1dde9c15f 100644 --- a/src/PackageResolver.php +++ b/src/PackageResolver.php @@ -61,7 +61,7 @@ public function resolve(array $arguments = []) // third pass to resolve versions $requires= []; foreach ((new VersionParser())->parseNameVersionPairs($packages) as $package) { - $requires[] = $package['name'].$this->parseVersion($package['name'], isset($package['version']) ? $package['version'] : null); + $requires[] = $package['name'].$this->parseVersion($package['name'], $package['version'] ?? null); } return array_unique($requires); diff --git a/src/Recipe.php b/src/Recipe.php index 1235996e0..741e171bd 100644 --- a/src/Recipe.php +++ b/src/Recipe.php @@ -53,10 +53,6 @@ public function getManifest() public function getFiles() { - if (!isset($this->data['files'])) { - return []; - } - - return $this->data['files']; + return $this->data['files'] ?? []; } }