Skip to content
Permalink
Browse files

Add transformations for new A, param A

  • Loading branch information...
muglug committed Jun 1, 2019
1 parent 7e4de61 commit bee87c25ebfd4080b591672ce53ace0f792523d8
@@ -361,6 +361,45 @@ function (FunctionLikeParameter $p) {
$check_stmts = true;
if ($codebase->method_migrations
&& $context->calling_method_id
&& isset($codebase->method_migrations[strtolower($context->calling_method_id)])
) {
$destination_method_id = $codebase->method_migrations[strtolower($context->calling_method_id)];
foreach ($this->function->params as $param) {
$param_name_node = null;
if ($param->type instanceof PhpParser\Node\Name) {
$param_name_node = $param->type;
} elseif ($param->type instanceof PhpParser\Node\NullableType
&& $param->type->type instanceof PhpParser\Node\Name
) {
$param_name_node = $param->type->type;
}
if ($param_name_node) {
$resolved_name = (string) $param_name_node->getAttribute('resolvedName');
$parent_fqcln = $this->getParentFQCLN();
if ($resolved_name === 'self' && $context->self) {
$resolved_name = (string) $context->self;
} elseif ($resolved_name === 'parent' && $parent_fqcln) {
$resolved_name = $parent_fqcln;
}
$codebase->classlikes->airliftClassLikeReference(
$resolved_name,
explode('::', $destination_method_id)[0],
$statements_analyzer->getFilePath(),
(int) $param_name_node->getAttribute('startFilePos'),
(int) $param_name_node->getAttribute('endFilePos') + 1
);
}
}
}
foreach ($params as $offset => $function_param) {
$signature_type = $function_param->signature_type;
$signature_type_location = $function_param->signature_type_location;
@@ -246,6 +246,22 @@ public static function analyze(
}
if ($fq_class_name) {
if ($stmt->class instanceof PhpParser\Node\Name
&& $codebase->method_migrations
&& $context->calling_method_id
&& isset($codebase->method_migrations[strtolower($context->calling_method_id)])
) {
$destination_method_id = $codebase->method_migrations[strtolower($context->calling_method_id)];
$codebase->classlikes->airliftClassLikeReference(
$fq_class_name,
explode('::', $destination_method_id)[0],
$statements_analyzer->getFilePath(),
(int) $stmt->class->getAttribute('startFilePos'),
(int) $stmt->class->getAttribute('endFilePos') + 1
);
}
if ($context->check_classes) {
if ($context->isPhantomClass($fq_class_name)) {
return null;
@@ -172,12 +172,15 @@ class A {
/**
* @return void
*/
public static function Foo() : void {
public static function Foo(self $a1, ?self $a2) : void {
echo self::C;
echo A::C;
self::Bar();
A::Bar();
echo \Ns\B::D;
new A();
new self();
new B();
}
public static function Bar() : void {}
@@ -203,12 +206,15 @@ class B {
/**
* @return void
*/
public static function Fedbca() : void {
public static function Fedbca(A $a1, ?A $a2) : void {
echo A::C;
echo A::C;
A::Bar();
A::Bar();
echo self::D;
new A();
new A();
new self();
}
}',
[

0 comments on commit bee87c2

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