Navigation Menu

Skip to content

Commit

Permalink
Prevent more offset issues
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 23, 2021
1 parent bf578d1 commit 15b0542
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion psalm.xml.dist
Expand Up @@ -11,7 +11,7 @@
throwExceptionOnError="0"
findUnusedCode="true"
ensureArrayStringOffsetsExist="true"
ensureArrayIntOffsetsExist="false"
ensureArrayIntOffsetsExist="true"
resolveFromConfigFile="true"
xsi:schemaLocation="https://getpsalm.org/schema/config config.xsd"
limitMethodComplexity="true"
Expand Down
Expand Up @@ -478,7 +478,9 @@ private static function handleUnpackedArray(
|| (
$unpacked_atomic_type instanceof Type\Atomic\TGenericObject
&& $unpacked_atomic_type->hasTraversableInterface($codebase)
&& \count($unpacked_atomic_type->type_params) === 2
)) {
/** @psalm-suppress PossiblyUndefinedArrayOffset provably true, but Psalm can’t see it */
if ($unpacked_atomic_type->type_params[1]->isEmpty()) {
continue;
}
Expand Down
Expand Up @@ -19,7 +19,7 @@ class MethodParamsProviderEvent
*/
private $method_name_lowercase;
/**
* @var PhpParser\Node\Arg[]|null
* @var list<PhpParser\Node\Arg>|null
*/
private $call_args;
/**
Expand Down Expand Up @@ -65,7 +65,7 @@ public function getMethodNameLowercase(): string
}

/**
* @return PhpParser\Node\Arg[]|null
* @return list<PhpParser\Node\Arg>|null
*/
public function getCallArgs(): ?array
{
Expand Down
Expand Up @@ -24,7 +24,7 @@ class MethodReturnTypeProviderEvent
*/
private $method_name_lowercase;
/**
* @var PhpParser\Node\Arg[]
* @var list<PhpParser\Node\Arg>
*/
private $call_args;
/**
Expand Down Expand Up @@ -99,7 +99,7 @@ public function getMethodNameLowercase(): string
}

/**
* @return PhpParser\Node\Arg[]
* @return list<PhpParser\Node\Arg>
*/
public function getCallArgs(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Storage/FunctionLikeStorage.php
Expand Up @@ -22,7 +22,7 @@ abstract class FunctionLikeStorage
public $stmt_location;

/**
* @var array<int, FunctionLikeParameter>
* @var list<FunctionLikeParameter>
*/
public $params = [];

Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Type/Atomic/CallableTrait.php
Expand Up @@ -16,7 +16,7 @@
trait CallableTrait
{
/**
* @var array<int, FunctionLikeParameter>|null
* @var list<FunctionLikeParameter>|null
*/
public $params = [];

Expand All @@ -33,7 +33,7 @@ trait CallableTrait
/**
* Constructs a new instance of a generic type
*
* @param array<int, FunctionLikeParameter> $params
* @param list<FunctionLikeParameter> $params
*/
public function __construct(
string $value = 'callable',
Expand Down
5 changes: 0 additions & 5 deletions src/Psalm/Type/Atomic/GenericTrait.php
Expand Up @@ -15,11 +15,6 @@

trait GenericTrait
{
/**
* @var non-empty-list<Union>
*/
public $type_params;

public function __toString(): string
{
$s = '';
Expand Down
5 changes: 5 additions & 0 deletions src/Psalm/Type/Atomic/TArray.php
Expand Up @@ -12,6 +12,11 @@ class TArray extends \Psalm\Type\Atomic
{
use GenericTrait;

/**
* @var array{\Psalm\Type\Union, \Psalm\Type\Union}
*/
public $type_params;

/**
* @var string
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Psalm/Type/Atomic/TGenericObject.php
Expand Up @@ -14,6 +14,11 @@ class TGenericObject extends TNamedObject
{
use GenericTrait;

/**
* @var non-empty-list<\Psalm\Type\Union>
*/
public $type_params;

/** @var bool if the parameters have been remapped to another class */
public $remapped_params = false;

Expand Down

0 comments on commit 15b0542

Please sign in to comment.