Skip to content

Commit

Permalink
Reworked tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 8, 2020
1 parent 5d602c5 commit b86f3a4
Show file tree
Hide file tree
Showing 13 changed files with 323 additions and 200 deletions.
10 changes: 10 additions & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9869,6 +9869,15 @@ public function dataBug3009(): array
return $this->gatherAssertTypes(__DIR__ . '/data/bug-3009.php');
}

public function dataInheritPhpDocMerging(): array
{
return array_merge(
$this->gatherAssertTypes(__DIR__ . '/data/inherit-phpdoc-merging-var.php'),
$this->gatherAssertTypes(__DIR__ . '/data/inherit-phpdoc-merging-param.php'),
$this->gatherAssertTypes(__DIR__ . '/data/inherit-phpdoc-merging-return.php')
);
}

/**
* @dataProvider dataBug2574
* @dataProvider dataBug2577
Expand Down Expand Up @@ -9912,6 +9921,7 @@ public function dataBug3009(): array
* @dataProvider dataBug2001
* @dataProvider dataBug2232
* @dataProvider dataBug3009
* @dataProvider dataInheritPhpDocMerging
* @param ConstantStringType $expectedType
* @param Type $actualType
*/
Expand Down
36 changes: 36 additions & 0 deletions tests/PHPStan/Analyser/data/inherit-phpdoc-merging-param.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php declare(strict_types = 1);

namespace InheritDocMergingParam;

use function PHPStan\Analyser\assertType;

class A {}
class B extends A {}
class C extends B {}

class GrandparentClass
{
/** @param A $one */
public function method($one, $two): void {}
}

class ParentClass extends GrandparentClass
{
/** @param B $dos */
public function method($uno, $dos): void
{
assertType('InheritDocMergingParam\A', $uno);
assertType('InheritDocMergingParam\B', $dos);
}
}

class ChildClass extends ParentClass
{
/** @param C $one */
public function method($one, $two): void
{
assertType('InheritDocMergingParam\C', $one);
assertType('InheritDocMergingParam\B', $two);
}

}
60 changes: 60 additions & 0 deletions tests/PHPStan/Analyser/data/inherit-phpdoc-merging-return.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php declare(strict_types = 1);

namespace InheritDocMergingReturn;

use function PHPStan\Analyser\assertType;

class A {}
class B extends A {}
class C extends B {}
class D extends A {}

class GrandparentClass
{
/** @return B */
public function method() { return new B(); }
}

interface InterfaceC
{
/** @return C */
public function method();
}

interface InterfaceA
{
/** @return A */
public function method();
}

class ParentClass extends GrandparentClass implements InterfaceC, InterfaceA
{
/** Some comment */
public function method() { }
}

class ChildClass extends ParentClass
{
public function method() { }
}

class ChildClass2 extends ParentClass
{
/**
* @return D
*/
public function method() { }
}


function (ParentClass $foo): void {
assertType('InheritDocMergingReturn\C', $foo->method());
};

function (ChildClass $foo): void {
assertType('InheritDocMergingReturn\C', $foo->method());
};

function (ChildClass2 $foo): void {
assertType('InheritDocMergingReturn\D', $foo->method());
};
82 changes: 82 additions & 0 deletions tests/PHPStan/Analyser/data/inherit-phpdoc-merging-var.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php declare(strict_types = 1);

namespace InheritDocMergingVar;

use function PHPStan\Analyser\assertType;

class A {}
class B extends A {}

class One
{
/** @var A */
protected $property;

public function method(): void
{
assertType('InheritDocMergingVar\A', $this->property);
}
}

class Two extends One
{
/** @var B */
protected $property;

public function method(): void
{
assertType('InheritDocMergingVar\B', $this->property);
}
}

class Three extends Two
{
/** Some comment */
protected $property;

public function method(): void
{
assertType('InheritDocMergingVar\B', $this->property);
}
}

class Four extends Three
{
protected $property;

public function method(): void
{
assertType('InheritDocMergingVar\B', $this->property);
}
}

class Five extends Four
{

public function method(): void
{
assertType('InheritDocMergingVar\B', $this->property);
}

}

class Six extends Five
{
protected $property;

public function method(): void
{
// assertType('InheritDocMergingVar\B', $this->property);
}
}

class Seven extends One
{

/**
* @inheritDoc
* @var B
*/
protected $property;

}
121 changes: 0 additions & 121 deletions tests/PHPStan/PhpDoc/PhpDocInheritanceResolverIntegrationTest.php

This file was deleted.

31 changes: 0 additions & 31 deletions tests/PHPStan/PhpDoc/data/inheritdoc-param.php

This file was deleted.

Loading

0 comments on commit b86f3a4

Please sign in to comment.