mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 09:37:59 +01:00
Cleanup
This commit is contained in:
parent
8f2a8c0746
commit
d4df856124
@ -554,6 +554,7 @@ class ArrayFunctionArgumentsAnalyzer
|
||||
} else {
|
||||
$properties = $array_atomic_type->properties;
|
||||
unset($properties[$prop_count-1]);
|
||||
assert($properties !== []);
|
||||
$array_atomic_type = $array_atomic_type->setProperties($properties);
|
||||
}
|
||||
} else {
|
||||
|
@ -494,8 +494,6 @@ class CallAnalyzer
|
||||
* @param PhpParser\Node\Scalar\String_|PhpParser\Node\Expr\Array_|PhpParser\Node\Expr\BinaryOp\Concat $callable_arg
|
||||
*
|
||||
* @return list<non-empty-string>
|
||||
*
|
||||
* @psalm-suppress MoreSpecificReturnType
|
||||
*/
|
||||
public static function getFunctionIdsFromCallableArg(
|
||||
FileSource $file_source,
|
||||
|
@ -550,6 +550,7 @@ class SimpleNegatedAssertionReconciler extends Reconciler
|
||||
$properties []= $array_atomic_type->properties[$x]
|
||||
?? $array_atomic_type->fallback_params[1]->setPossiblyUndefined(true);
|
||||
}
|
||||
assert($properties !== []);
|
||||
$existing_var_type->removeType('array');
|
||||
$existing_var_type->addType(new TKeyedArray(
|
||||
$properties,
|
||||
|
@ -574,7 +574,6 @@ class TypeCombiner
|
||||
|
||||
if ($type instanceof TClassStringMap) {
|
||||
foreach ([$type->getStandinKeyParam(), $type->value_param] as $i => $type_param) {
|
||||
/** @psalm-suppress InvalidPropertyAssignmentValue */
|
||||
$combination->array_type_params[$i] = Type::combineUnionTypes(
|
||||
$combination->array_type_params[$i] ?? null,
|
||||
$type_param,
|
||||
|
@ -478,6 +478,9 @@ abstract class Atomic implements TypeNode
|
||||
if ($this->hasTraversableInterface($codebase)) {
|
||||
if (strtolower($this->value) === "traversable") {
|
||||
if ($this instanceof TGenericObject) {
|
||||
if (count($this->type_params) > 2) {
|
||||
throw new InvalidArgumentException('Too many templates!');
|
||||
}
|
||||
return new TIterable($this->type_params);
|
||||
}
|
||||
return new TIterable([Type::getMixed(), Type::getMixed()]);
|
||||
@ -488,6 +491,9 @@ abstract class Atomic implements TypeNode
|
||||
$this,
|
||||
new TGenericObject("Traversable", [Type::getMixed(), Type::getMixed()]),
|
||||
);
|
||||
if (count($implemented_traversable_templates) > 2) {
|
||||
throw new InvalidArgumentException('Too many templates!');
|
||||
}
|
||||
return new TIterable($implemented_traversable_templates);
|
||||
}
|
||||
throw new InvalidArgumentException("{$this->getId()} is not an iterable");
|
||||
|
@ -240,7 +240,7 @@ trait GenericTrait
|
||||
?Codebase $codebase
|
||||
): ?array {
|
||||
$type_params = $this->type_params;
|
||||
foreach ($type_params as $offset => &$type_param) {
|
||||
foreach ($type_params as $offset => $type_param) {
|
||||
$type_param = TemplateInferredTypeReplacer::replace(
|
||||
$type_param,
|
||||
$template_result,
|
||||
@ -250,8 +250,9 @@ trait GenericTrait
|
||||
if ($this instanceof TArray && $offset === 0 && $type_param->isMixed()) {
|
||||
$type_param = Type::getArrayKey();
|
||||
}
|
||||
|
||||
$type_params[$offset] = $type_param;
|
||||
}
|
||||
unset($type_param);
|
||||
|
||||
return $type_params === $this->type_params ? null : $type_params;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user