mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Add some tests for things that feel like they should work
This commit is contained in:
parent
61ecd2a5fe
commit
7b2d9eeab7
@ -921,6 +921,82 @@ class AnalyzedMethodTest extends \Psalm\Tests\TestCase
|
||||
],
|
||||
],
|
||||
],
|
||||
'invalidateConstructorWhenDependentMethodInSubclassChanges' => [
|
||||
'start_files' => [
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
namespace Foo;
|
||||
|
||||
abstract class A {
|
||||
public function __construct() {
|
||||
$this->setFoo();
|
||||
}
|
||||
|
||||
abstract protected function setFoo() : void;
|
||||
}',
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => '<?php
|
||||
namespace Foo;
|
||||
|
||||
class AChild extends A {
|
||||
/** @var string */
|
||||
public $foo;
|
||||
|
||||
protected function setFoo() : void {
|
||||
$this->reallySetFoo();
|
||||
}
|
||||
|
||||
private function reallySetFoo() : void {
|
||||
$this->foo = "bar";
|
||||
}
|
||||
}',
|
||||
],
|
||||
'end_files' => [
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
namespace Foo;
|
||||
|
||||
abstract class A {
|
||||
public function __construct() {
|
||||
$this->setFoo();
|
||||
}
|
||||
|
||||
abstract protected function setFoo() : void;
|
||||
}',
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => '<?php
|
||||
namespace Foo;
|
||||
|
||||
class AChild extends A {
|
||||
/** @var string */
|
||||
public $foo;
|
||||
|
||||
protected function setFoo() : void {
|
||||
$this->reallySetFoo();
|
||||
}
|
||||
|
||||
private function reallySetFoo() : void {
|
||||
//$this->foo = "bar";
|
||||
}
|
||||
}',
|
||||
],
|
||||
'initial_analyzed_methods' => [
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => [
|
||||
'foo\a::__construct' => 1,
|
||||
'foo\a::setfoo' => 1,
|
||||
],
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => [
|
||||
'foo\achild::setfoo' => 1,
|
||||
'foo\achild::reallysetfoo' => 1,
|
||||
'foo\achild::__construct' => 2,
|
||||
],
|
||||
],
|
||||
'unaffected_analyzed_methods' => [
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => [
|
||||
'foo\a::__construct' => 1,
|
||||
'foo\a::setfoo' => 1,
|
||||
],
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => [
|
||||
'foo\achild::setfoo' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
'invalidateConstructorWhenDependentTraitMethodChanges' => [
|
||||
'start_files' => [
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
|
@ -855,6 +855,65 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
|
||||
],
|
||||
'error_message' => 'PossiblyUnusedProperty',
|
||||
],
|
||||
'uninitialisedChildProperty' => [
|
||||
'file_stages' => [
|
||||
[
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
namespace Foo;
|
||||
|
||||
abstract class A {
|
||||
public function __construct() {
|
||||
$this->setFoo();
|
||||
}
|
||||
|
||||
abstract protected function setFoo() : void;
|
||||
}',
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => '<?php
|
||||
namespace Foo;
|
||||
|
||||
class AChild extends A {
|
||||
/** @var string */
|
||||
public $foo;
|
||||
|
||||
protected function setFoo() : void {
|
||||
$this->reallySetFoo();
|
||||
}
|
||||
|
||||
private function reallySetFoo() : void {
|
||||
$this->foo = "bar";
|
||||
}
|
||||
}',
|
||||
],
|
||||
[
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
namespace Foo;
|
||||
|
||||
abstract class A {
|
||||
public function __construct() {
|
||||
$this->setFoo();
|
||||
}
|
||||
|
||||
abstract protected function setFoo() : void;
|
||||
}',
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => '<?php
|
||||
namespace Foo;
|
||||
|
||||
class AChild extends A {
|
||||
/** @var string */
|
||||
public $foo;
|
||||
|
||||
protected function setFoo() : void {
|
||||
$this->reallySetFoo();
|
||||
}
|
||||
|
||||
private function reallySetFoo() : void {
|
||||
//$this->foo = "bar";
|
||||
}
|
||||
}',
|
||||
],
|
||||
],
|
||||
'error_message' => 'PropertyNotSetInConstructor',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user