Skip to content
Permalink
Browse files

Fix #2363 - catch possible class not found errors when getting method

  • Loading branch information
muglug committed Nov 21, 2019
1 parent c50a17d commit 3d9c94e29a3888b63dd374306a7305292ff13f55
@@ -1752,6 +1752,9 @@ public static function getCallableMethodIdFromObjectLike(
if ($lhs->isSingleStringLiteral()) {
$class_name = $lhs->getSingleStringLiteral()->value;
if ($class_name[0] === '\\') {
$class_name = substr($class_name, 1);
}
} elseif ($lhs->isSingle()) {
foreach ($lhs->getTypes() as $lhs_atomic_type) {
if ($lhs_atomic_type instanceof TNamedObject) {
@@ -913,7 +913,11 @@ public function getStorage($method_id)
{
list($fq_class_name, $method_name) = explode('::', $method_id);
$class_storage = $this->classlike_storage_provider->get($fq_class_name);
try {
$class_storage = $this->classlike_storage_provider->get($fq_class_name);
} catch (\InvalidArgumentException $e) {
throw new \UnexpectedValueException($e->getMessage());
}
$method_name_lc = strtolower($method_name);
@@ -973,6 +973,18 @@ public static function compare($a, $b): int {
}
}',
],
'noFatalErrorOnClassWithSlash' => [
'<?php
class Func {
public function __construct(string $name, callable $callable) {}
}
class Foo {
public static function bar(): string { return "asd"; }
}
new Func("f", ["\Foo", "bar"]);',
],
];
}
@@ -1507,6 +1519,24 @@ function assertInt(int $int): int {
}',
'error_message' => 'MixedReturnStatement'
],
'noFatalErrorOnMissingClassWithSlash' => [
'<?php
class Func {
public function __construct(string $name, callable $callable) {}
}
new Func("f", ["\Foo", "bar"]);',
'error_message' => 'InvalidArgument'
],
'noFatalErrorOnMissingClassWithoutSlash' => [
'<?php
class Func {
public function __construct(string $name, callable $callable) {}
}
new Func("f", ["Foo", "bar"]);',
'error_message' => 'InvalidArgument'
],
];
}
}

0 comments on commit 3d9c94e

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