1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Reinstate $this type after parent call

Fixes #444
This commit is contained in:
Matt Brown 2018-01-17 11:00:58 -05:00
parent 157c575a96
commit 2212d7c032
2 changed files with 34 additions and 0 deletions

View File

@ -1360,6 +1360,10 @@ class CallChecker
$context->include_location = $old_context_include_location;
$context->self = $old_self;
if (isset($context->vars_in_scope['$this']) && $old_self) {
$context->vars_in_scope['$this'] = Type::parseString($old_self);
}
}
} else {
$namespace = $statements_checker->getNamespace()

View File

@ -689,6 +689,36 @@ class PropertyTypeTest extends TestCase
}
}',
],
'privatePropertyAccessibleInTwoSubclasses' => [
'<?php
class A {
public function __construct() {}
}
class B extends A {
/**
* @var int
*/
private $prop;
public function __construct()
{
parent::__construct();
$this->prop = 1;
}
}
class C extends A {
/**
* @var int
*/
private $prop;
public function __construct()
{
parent::__construct();
$this->prop = 2;
}
}',
]
];
}