1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00

Fix doblocks and invalid refs

This commit is contained in:
Matthew Brown 2016-10-03 11:38:59 -04:00
parent 89bc501e17
commit 49baa62224
11 changed files with 26 additions and 16 deletions

View File

@ -65,7 +65,7 @@ abstract class ClassLikeChecker implements StatementsSource
/**
* The parent class
*
* @var string
* @var string|null
*/
protected $parent_class;

View File

@ -55,6 +55,8 @@ abstract class FunctionLikeChecker implements StatementsSource
$statements_checker = new StatementsChecker($this, $has_context, $check_methods);
$hash = null;
if ($this instanceof MethodChecker) {
if (ClassLikeChecker::getThisClass()) {
$hash = $this->getMethodId() . json_encode([$context->vars_in_scope, $context->vars_possibly_in_scope]);
@ -87,6 +89,8 @@ abstract class FunctionLikeChecker implements StatementsSource
$param_type = null;
if ($param->type) {
$param_type_string = '';
if (is_string($param->type)) {
$param_type_string = $param->type;
}
@ -167,7 +171,7 @@ abstract class FunctionLikeChecker implements StatementsSource
}
}
if (ClassLikeChecker::getThisClass() && $this instanceof MethodChecker) {
if ($hash && ClassLikeChecker::getThisClass() && $this instanceof MethodChecker) {
self::$no_effects_hashes[$hash] = [$context->vars_in_scope, $context->vars_possibly_in_scope];
}
}

View File

@ -922,8 +922,8 @@ class TypeChecker
/**
* Takes two arrays of types and merges them
*
* @param array<UnionType> $new_types
* @param array<UnionType> $existing_types
* @param array<Type\Union> $new_types
* @param array<Type\Union> $existing_types
* @return array
*/
public static function combineKeyedTypes(array $new_types, array $existing_types)
@ -1079,7 +1079,7 @@ class TypeChecker
continue;
}
if (!($inferred_atomic_type instanceof Type\Generic) && $declared_atomic_type instanceof Type\Generic) {
if (!($inferred_atomic_type instanceof Type\Generic)) {
// @todo handle this better
continue;
}

View File

@ -58,7 +58,7 @@ class Config
protected $filetype_handlers = [];
/**
* @var array<string, FileFilter>
* @var array<string,FileFilter>
*/
protected $issue_handlers = [];

View File

@ -7,9 +7,10 @@ use Psalm\Checker\StatementsChecker;
class Context
{
/** @var array<string, Type\Union> */
/** @var array<string,Type\Union> */
public $vars_in_scope = [];
/** @var array<string,bool> */
public $vars_possibly_in_scope = [];
/** @var boolean */

View File

@ -134,7 +134,7 @@ abstract class Type
}
/**
* @return array<int, string>
* @return array<int,string>
*/
public static function tokenize($return_type)
{
@ -411,6 +411,8 @@ abstract class Type
}
$key_types = [];
/** @var array<string,array<string,Union>> */
$value_types = [];
foreach ($types as $type) {

View File

@ -12,7 +12,7 @@ class Generic extends Atomic
/**
* Constructs a new instance of a generic type
* @param string $value
* @param array<Type\Union> $type_params
* @param array<int,Union> $type_params
*/
public function __construct($value, array $type_params)
{

View File

@ -11,7 +11,7 @@ class GenericArray extends Generic
/**
* Constructs a new instance of a generic type
* @param string $value
* @param array<Type\Union> $type_params
* @param array<int,Union> $type_params
*/
public function __construct($value, array $type_params)
{

View File

@ -8,13 +8,13 @@ class ObjectLike extends Atomic
{
public $value = 'object-like';
/** @var array<string,Type\Union> */
/** @var array<string,Union> */
public $properties;
/**
* Constructs a new instance of a generic type
* @param string $value
* @param array<string,Type\Union> $type_params
* @param array<string,Union> $type_params
*/
public function __construct($value, array $properties)
{

View File

@ -10,7 +10,7 @@ class ParseTree
const UNION = '|';
/** @var array<ParseTree> */
public $children;
public $children = [];
/** @var string|null */
public $value;
@ -26,7 +26,6 @@ class ParseTree
{
$this->value = $value;
$this->parent = $parent;
$this->children = [];
}
/**
@ -123,6 +122,10 @@ class ParseTree
continue;
}
if (!$current_parent) {
throw new \InvalidArgumentException('Cannot process colon without parent');
}
$new_parent_leaf = new self(self::OBJECT_PROPERTY, $current_parent);
$new_parent_leaf->children = [$current_leaf];
$current_leaf->parent = $new_parent_leaf;

View File

@ -8,12 +8,12 @@ use Psalm\Checker\ClassChecker;
class Union extends Type
{
/** @var array<string, Atomic> */
/** @var array<string,Atomic> */
public $types = [];
/**
* Constructs an Union instance
* @param array<int, AtomicType> $types
* @param array<int,Atomic> $types
*/
public function __construct(array $types)
{