mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Migrate more things
This commit is contained in:
parent
5e17a9af10
commit
4747ba709a
@ -635,6 +635,16 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer implements Statements
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
|
||||
if ($codebase->alter_code) {
|
||||
$codebase->classlikes->handleDocblockTypeInMigration(
|
||||
$codebase,
|
||||
$this,
|
||||
$input_type,
|
||||
$storage->throw_locations[$expected_exception],
|
||||
$context->calling_method_id
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1076,7 +1076,12 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
|
||||
}
|
||||
}
|
||||
|
||||
if ($codebase->alter_code && $fq_class_name && !$moved_call) {
|
||||
if ($codebase->alter_code
|
||||
&& $fq_class_name
|
||||
&& !$moved_call
|
||||
&& $stmt->class instanceof PhpParser\Node\Name
|
||||
&& !in_array($stmt->class->parts[0], ['parent', 'static'])
|
||||
) {
|
||||
$codebase->classlikes->handleClassLikeReferenceInMigration(
|
||||
$codebase,
|
||||
$statements_analyzer,
|
||||
|
@ -58,7 +58,7 @@ class TArray extends \Psalm\Type\Atomic
|
||||
|
||||
public function canBeFullyExpressedInPhp()
|
||||
{
|
||||
return $this->type_params[0]->isMixed() && $this->type_params[1]->isMixed();
|
||||
return $this->type_params[0]->isArrayKey() && $this->type_params[1]->isMixed();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,32 +205,56 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
|
||||
'<?php
|
||||
namespace Ns;
|
||||
|
||||
class A {
|
||||
class AParent {
|
||||
public static function foo(A $one, A $two) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class A extends AParent {
|
||||
/**
|
||||
* @param self $one
|
||||
* @param A $two
|
||||
*/
|
||||
public static function foo(self $one, A $two) : void {
|
||||
A::foo($one, $two);
|
||||
parent::foo($one, $two);
|
||||
static::foo($one, $two);
|
||||
}
|
||||
}
|
||||
|
||||
$a = A::class;
|
||||
|
||||
$a::foo(new A(), new A());
|
||||
|
||||
function foo() {
|
||||
A::foo(new A(), A::foo());
|
||||
}',
|
||||
'<?php
|
||||
namespace Ns;
|
||||
|
||||
class B {
|
||||
class AParent {
|
||||
public static function foo(B $one, B $two) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class B extends AParent {
|
||||
/**
|
||||
* @param self $one
|
||||
* @param self $two
|
||||
*/
|
||||
public static function foo(self $one, self $two) : void {
|
||||
self::foo($one, $two);
|
||||
parent::foo($one, $two);
|
||||
static::foo($one, $two);
|
||||
}
|
||||
}
|
||||
|
||||
$a = B::class;
|
||||
|
||||
$a::foo(new B(), new B());
|
||||
|
||||
function foo() {
|
||||
B::foo(new B(), B::foo());
|
||||
}',
|
||||
@ -280,10 +304,17 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
|
||||
* @var string
|
||||
*/
|
||||
public static $one = "one";
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $vars = ["one"];
|
||||
}
|
||||
|
||||
echo A::$one;
|
||||
A::$one = "two";',
|
||||
A::$one = "two";
|
||||
|
||||
foreach (A::$vars as $var) {}',
|
||||
'<?php
|
||||
namespace Ns;
|
||||
|
||||
@ -292,10 +323,17 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
|
||||
* @var string
|
||||
*/
|
||||
public static $one = "one";
|
||||
|
||||
/**
|
||||
* @var array<array-key, mixed>
|
||||
*/
|
||||
public static $vars = ["one"];
|
||||
}
|
||||
|
||||
echo B::$one;
|
||||
B::$one = "two";',
|
||||
B::$one = "two";
|
||||
|
||||
foreach (B::$vars as $var) {}',
|
||||
[
|
||||
'Ns\A' => 'Ns\B',
|
||||
],
|
||||
@ -310,6 +348,7 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
|
||||
|
||||
/**
|
||||
* @param ArrayObject<int, A> $a
|
||||
* @throws RunTimeException
|
||||
*/
|
||||
public function foo(ArrayObject $a) : Exception {
|
||||
foreach ($a as $b) {
|
||||
@ -343,6 +382,7 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
|
||||
|
||||
/**
|
||||
* @param \ArrayObject<int, self> $a
|
||||
* @throws \RunTimeException
|
||||
*/
|
||||
public function foo(\ArrayObject $a) : Exception {
|
||||
foreach ($a as $b) {
|
||||
|
Loading…
Reference in New Issue
Block a user