-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
2 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,77 +64,4 @@ public static function analyze(array $parametersA, array $parametersB) | |
|
||
return $changes; | ||
} | ||
|
||
/** | ||
* @param array $paramsA | ||
* @param array $paramsB | ||
* @return string|bool | ||
*/ | ||
public static function requiredParametersChanges(array $paramsA, array $paramsB) | ||
{ | ||
$iterations = min(count($paramsA), count($paramsB)); | ||
// Verify that all params default value match (either they're both null => parameter is required, or both | ||
// set to the same required value) | ||
for ($i = 0; $i < $iterations; ++$i) { | ||
if ($paramsA[$i]->default !== $paramsB[$i]->default) { | ||
return $paramsB[$i]->default ? 'removed' : 'added'; | ||
} | ||
} | ||
|
||
// Only one of these will return its remaining values, the other returning an empty array | ||
$toCheck = array_slice($paramsA, $iterations) + array_slice($paramsB, $iterations); | ||
$operation = count($paramsA) < count($paramsB) ? 'added' : 'removed'; | ||
// If any additional argument does not have a default value, the signature has changed | ||
foreach ($toCheck as $param) { | ||
if ($param->default === null) { | ||
return $operation; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param array $paramsA | ||
* @param array $paramsB | ||
* @return bool | ||
*/ | ||
public static function isSameTypehints(array $paramsA, array $paramsB) | ||
{ | ||
$iterations = min(count($paramsA), count($paramsB)); | ||
for ($i = 0; $i < $iterations; ++$i) { | ||
// TODO: Allow for contravariance <[email protected]> | ||
if ( ! Type::isSame($paramsA[$i]->type, $paramsB[$i]->type)) { | ||
return false; | ||
} | ||
} | ||
// Only one of these will return its remaining values, the other returning an empty array | ||
$toCheck = array_slice($paramsA, $iterations) + array_slice($paramsB, $iterations); | ||
// If any additional argument does not have a default value, the signature has changed | ||
foreach ($toCheck as $param) { | ||
if ($param->default === null) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* @param array $paramsA | ||
* @param array $paramsB | ||
* @return bool | ||
*/ | ||
public static function isSameVariables(array $paramsA, array $paramsB) | ||
{ | ||
if (count($paramsA) !== count($paramsB)) { | ||
return false; | ||
} | ||
|
||
$iterations = min(count($paramsA), count($paramsB)); | ||
for ($i = 0; $i < $iterations; ++$i) { | ||
if ($paramsA[$i]->name != $paramsB[$i]->name) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters