Skip to content
Permalink
Browse files

Migrate more things

  • Loading branch information
muglug committed Nov 15, 2019
1 parent 5e17a9a commit 4747ba709aee1a4e00778b19cd3a0ea8f1675d5b
@@ -635,6 +635,16 @@ function (FunctionLikeParameter $p) {
// 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 @@ function (Assertion $assertion) use ($generic_params) : Assertion {
}
}
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 @@ public function toPhpString(
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 @@ function foo(B $a) : B {
'<?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 A {
* @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 B {
* @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 A {
/**
* @param ArrayObject<int, A> $a
* @throws RunTimeException
*/
public function foo(ArrayObject $a) : Exception {
foreach ($a as $b) {
@@ -343,6 +382,7 @@ class B {
/**
* @param \ArrayObject<int, self> $a
* @throws \RunTimeException
*/
public function foo(\ArrayObject $a) : Exception {
foreach ($a as $b) {

0 comments on commit 4747ba7

Please sign in to comment.
You can’t perform that action at this time.