1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #220 - don’t worry about parent property access

This commit is contained in:
Matthew Brown 2017-09-24 08:17:27 -04:00
parent ee655e6f33
commit 5bd6228708
3 changed files with 55 additions and 0 deletions

View File

@ -648,6 +648,11 @@ class AssignmentChecker
if (!ClassLikeChecker::propertyExists($project_checker, $property_id)) {
if ($stmt->var instanceof PhpParser\Node\Expr\Variable && $stmt->var->name === 'this') {
// if this is a proper error, we'll see it on the first pass
if ($context->collect_mutations) {
return;
}
if (IssueBuffer::accepts(
new UndefinedThisPropertyAssignment(
'Instance property ' . $property_id . ' is not defined',

View File

@ -250,6 +250,10 @@ class FetchChecker
if (!ClassLikeChecker::propertyExists($project_checker, $property_id)) {
if ($stmt_var_id === '$this') {
if ($context->collect_mutations) {
return;
}
if (IssueBuffer::accepts(
new UndefinedThisPropertyFetch(
'Instance property ' . $property_id . ' is not defined',

View File

@ -417,6 +417,52 @@ class PropertyTypeTest extends TestCase
public function __construct() { }
}',
],
'extendsClassWithPrivateConstructorSet' => [
'<?php
namespace Q;
class Base
{
/**
* @var string
*/
private $aString;
public function __construct()
{
$this->aString = "aa";
echo($this->aString);
}
}
class Descendant extends Base
{
/**
* @var bool
*/
private $aBool;
public function __construct()
{
parent::__construct();
$this->aBool = true;
}
}',
],
'extendsClassWithPrivateAndException' => [
'<?php
abstract class A extends \Exception {
/** @var string **/
private $p;
/** @param string $p **/
final public function __construct($p) {
$this->p = $p;
}
}
final class B extends A {}',
],
'setInAbstractMethod' => [
'<?php
interface I {