Skip to content
Permalink
Browse files

Fix #1666 - complain about properties in interfaces

  • Loading branch information...
muglug committed May 23, 2019
1 parent 83fe545 commit c64a654ece3e66ac1c92a65b5425b6feb93d0057
Showing with 28 additions and 0 deletions.
  1. +9 −0 src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php
  2. +19 −0 tests/BadFormatTest.php
@@ -89,6 +89,15 @@ public function analyze()
$method_analyzer = new MethodAnalyzer($stmt, $this);
$method_analyzer->analyze(new \Psalm\Context($this->getFQCLN()));
} elseif ($stmt instanceof PhpParser\Node\Stmt\Property) {
\Psalm\IssueBuffer::add(
new \Psalm\Issue\ParseError(
'Interfaces cannot have properties',
new CodeLocation($this, $stmt)
)
);
return;
}
}
}
@@ -49,6 +49,25 @@ public function foo() : void;
$this->analyzeFile('somefile.php', new Context());
}
/**
*
* @return void
*/
public function testInterfaceWithProperties()
{
$this->expectExceptionMessage('ParseError - somefile.php:3');
$this->expectException(\Psalm\Exception\CodeException::class);
$this->addFile(
'somefile.php',
'<?php
interface foo {
public static $foo = ["bar"];
}'
);
$this->analyzeFile('somefile.php', new Context());
}
/**
*
* @return void

0 comments on commit c64a654

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