Skip to content
Permalink
Browse files

Fix #1713 - don’t crash when a property is unset

  • Loading branch information...
muglug committed May 31, 2019
1 parent 24a484c commit f5e4b9b45fb45caab4129291d5c190af46adcedc
@@ -1004,11 +1004,12 @@ function (FunctionLikeParameter $param) {
list(,$property_name) = explode('::$', $property_id);
if (!isset($method_context->vars_in_scope['$this->' . $property_name])) {
throw new \UnexpectedValueException('$this->' . $property_name . ' should be in scope');
$end_type = Type::getVoid();
$end_type->initialized = false;
} else {
$end_type = $method_context->vars_in_scope['$this->' . $property_name];
}
$end_type = $method_context->vars_in_scope['$this->' . $property_name];
$constructor_class_property_storage = $property_storage;
$error_location = $property_storage->location;
@@ -135,6 +135,7 @@ public static function analyzeInstance(
if ($property_id
&& $source instanceof FunctionLikeAnalyzer
&& $source->getMethodName() === '__construct'
&& !$context->inside_unset
) {
if (IssueBuffer::accepts(
new UninitializedProperty(
@@ -2374,6 +2374,18 @@ public function setS() : void {
}',
'error_message' => 'PropertyNotSetInConstructor - src' . DIRECTORY_SEPARATOR . 'somefile.php:15'
],
'noCrashWhenUnsettingPropertyWithoutDefaultInConstructor' => [
'<?php
class A {
/** @var bool */
private $foo;
public function __construct() {
unset($this->foo);
}
}',
'error_message' => 'PropertyNotSetInConstructor'
],
];
}
}

0 comments on commit f5e4b9b

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