Skip to content
Permalink
Browse files

Don’t remove null after magic property fetch

  • Loading branch information...
muglug committed May 27, 2019
1 parent e512bc7 commit 5861476765f4218f773702954cfa530d8771ac9e
@@ -373,7 +373,8 @@ public static function analyzeInstance(
\Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(
$statements_analyzer,
$fake_method_call,
$context
$context,
false
);
if (!in_array('PossiblyNullReference', $suppressed_issues, true)) {
@@ -51,7 +51,8 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
public static function analyze(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\MethodCall $stmt,
Context $context
Context $context,
bool $real_method_call = true
) {
$stmt->inferredType = null;
@@ -343,6 +344,7 @@ public static function analyze(
&& !$invalid_method_call_types
&& $existent_method_ids
&& ($class_type->from_docblock || $class_type->isNullable())
&& $real_method_call
) {
$keys_to_remove = [];
@@ -501,7 +501,8 @@ public static function analyzeInstance(
\Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(
$statements_analyzer,
$fake_method_call,
$context
$context,
false
);
if (!in_array('PossiblyNullReference', $suppressed_issues, true)) {
@@ -320,6 +320,22 @@ public function __set(string $name, $value)
'assertions' => [],
'error_level' => ['MixedArgument'],
],
'dontAssumeNonNullAfterPossibleMagicFetch' => [
'<?php
class C {
public function __get(string $name) : string {
return "hello";
}
}
function foo(?C $c) : void {
echo $c->foo;
if ($c) {}
}',
'assertions' => [],
'error_level' => ['PossiblyNullPropertyFetch'],
],
'accessInMagicGet' => [
'<?php
class X {

0 comments on commit 5861476

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