Fix "Found a redundant condition when evaluating docblock-defined type $composerJsonPath and trying to reconcile type 'string' to string" bug pointed by Psalm

This commit is contained in:
Meritoo
2019-06-20 20:05:56 +02:00
parent 1ac1a221ec
commit 6efbf940a3
2 changed files with 10 additions and 23 deletions

View File

@@ -30,14 +30,9 @@ class Composer
* @param string $nodeName Name of node who value should be returned
* @return null|string
*/
public static function getValue($composerJsonPath, $nodeName)
public static function getValue(string $composerJsonPath, string $nodeName): ?string
{
$composerJsonString = is_string($composerJsonPath);
$composerJsonReadable = false;
if ($composerJsonString) {
$composerJsonReadable = is_readable($composerJsonPath);
}
$composerJsonReadable = is_readable($composerJsonPath);
/*
* Provided path or name of node are invalid?
@@ -46,12 +41,12 @@ class Composer
*
* Nothing to do
*/
if (!$composerJsonString || !is_string($nodeName) || !$composerJsonReadable || empty($nodeName)) {
if (!$composerJsonReadable || empty($nodeName)) {
return null;
}
$content = file_get_contents($composerJsonPath);
$data = json_decode($content);
$data = json_decode($content, false);
/*
* Unknown data from the composer.json file or there is no node with given name?