diff --git a/selfouttest.php b/selfouttest.php index 262a110ca..e68a91c4d 100644 --- a/selfouttest.php +++ b/selfouttest.php @@ -1,6 +1,6 @@ storage; $function_stmts = $this->function->getStmts() ?: []; @@ -170,14 +169,6 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer throw new \UnexpectedValueException('$storage must be MethodStorage'); } - //var_dump($context->vars_in_scope); - //var_dump($storage->self_out_type); - //$var_id = '$foo'; - //$context->byref_constraints[$var_id] = new \Psalm\Internal\ReferenceConstraint($by_ref_type); - //$context->vars_possibly_in_scope[$var_id] = true; - //$context->vars_in_scope[$var_id] = new Type\Union([new Type\Atomic\TInt()]); - //return; - $real_method_id = $this->getMethodId(); $method_id = $this->getMethodId($context->self); @@ -551,8 +542,6 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer $this->examineParamTypes($statements_analyzer, $context, $codebase); - $this->examineSelfOut($statements_analyzer, $context, $codebase); - foreach ($storage->params as $offset => $function_param) { // only complain if there's no type defined by a parent type if (!$function_param->type @@ -1520,11 +1509,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer ), $statements_analyzer->getSuppressedIssues() )) { - //var_dump($actual_type->getId()); - //var_dump($context); - //die; // fall through - //throw new \Exception('there'); } } } @@ -1532,18 +1517,6 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer } } - public function examineSelfOut( - StatementsAnalyzer $statements_analyzer, - Context $context, - Codebase $codebase, - PhpParser\Node $stmt = null - ) { - $storage = $this->getFunctionLikeStorage($statements_analyzer); - if ($storage->self_out_type) { - var_dump($context->vars_in_scope); - } - } - /** * @return null|string */ diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index ec904792f..944379a9e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -1303,13 +1303,6 @@ class AssignmentAnalyzer $statements_analyzer ); - $foo_id = '$foo'; - $context->byref_constraints[$foo_id] = new \Psalm\Internal\ReferenceConstraint($by_ref_type); - $context->vars_possibly_in_scope[$foo_id] = true; - $context->vars_in_scope[$foo_id] = new Type\Union([new Type\Atomic\TInt()]); - die; - //return; - if ($var_id) { if (!$by_ref_type->hasMixed() && $constrain_type) { $context->byref_constraints[$var_id] = new \Psalm\Internal\ReferenceConstraint($by_ref_type); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php index e6cb563b4..41153a7cf 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php @@ -829,13 +829,9 @@ class ArgumentsAnalyzer ]); } } - //var_dump($by_ref_type);die; $by_ref_type = $by_ref_type ?: Type::getMixed(); - //var_dump($by_ref_type); - //var_dump($by_ref_out_type); - AssignmentAnalyzer::assignByRefParam( $statements_analyzer, $arg->value, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index bb3e3d518..c044f3470 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -62,7 +62,6 @@ class FunctionCallAnalyzer extends CallAnalyzer Context $context ) : bool { $function_name = $stmt->name; - var_dump($function_name); $function_id = null; $function_params = null; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php index 0b4399c05..a6363883e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php @@ -167,6 +167,7 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\ $result = new Method\AtomicMethodCallAnalysisResult(); $possible_new_class_types = []; + $fq_class_name = null; foreach ($lhs_types as $lhs_type_part) { Method\AtomicMethodCallAnalyzer::analyze( $statements_analyzer, @@ -187,6 +188,8 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\ && !$possible_new_class_type->equals($class_type)) { $possible_new_class_types[] = $context->vars_in_scope[$lhs_var_id]; } + // TODO: How? + $fq_class_name = $lhs_type_part->value; } if (count($possible_new_class_types) > 0) { @@ -404,25 +407,13 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\ $context->vars_in_scope[$lhs_var_id] = $class_type; } - /* - var_dump($lhs_var_id); - var_dump($stmt->name); - var_dump($stmt->var); - var_dump($class_type); - $fq_class_name = (string)$source->getFQCLN(); - var_dump($fq_class_name); - die; - $lhs_types = $class_type->getAtomicTypes(); $method_name = $stmt->name->name; $method_id = new \Psalm\Internal\MethodIdentifier($fq_class_name, strtolower($method_name)); - $declaring_method_id = $codebase->methods->getDeclaringMethodId($method_id); - var_dump($declaring_method_id); - $storage = $codebase->methods->getStorage($declaring_method_id); - die; - */ - $foo_id = '$foo'; - $context->vars_possibly_in_scope[$foo_id] = true; - $context->vars_in_scope[$foo_id] = new Type\Union([new Type\Atomic\TInt()]); + $storage = $codebase->methods->getStorage($method_id); + if ($storage->self_out_type) { + // TODO: Nedd clone? + $context->vars_in_scope[$lhs_var_id] = clone $storage->self_out_type; + } return true; }