-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResolvedPhpDocBlock: fix parent return tag merging #2803
Merged
+274
−4
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
26a152a
ResolvedPhpDocBlock: fix parent return tag merging
janedbal fad17e0
Add regression test for issue 10208
janedbal 49c1c97
Move bug10208 fix to standalone testcase
janedbal 59b58e9
Fix typo
janedbal 45bb59d
Add all regression tests
janedbal 4cdfde9
Split analyse call per each file
janedbal 53f60d8
Split testcases
janedbal File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug6462; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class Base | ||
{ | ||
/** | ||
* @return $this | ||
*/ | ||
public function getThis(): self | ||
{ | ||
return $this; | ||
} | ||
} | ||
|
||
class Child extends Base | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getThis(): self | ||
{ | ||
return $this; | ||
} | ||
} | ||
|
||
class FixedChild extends Base | ||
{ | ||
/** | ||
* @return $this | ||
*/ | ||
public function getThis(): self | ||
{ | ||
return $this; | ||
} | ||
} | ||
|
||
$base = new Base(); | ||
$child = new Child(); | ||
$fixedChild = new FixedChild(); | ||
|
||
assertType('Bug6462\Base', $base->getThis()); | ||
assertType('Bug6462\Child', $child->getThis()); | ||
|
||
if ($base instanceof \Traversable) { | ||
assertType('Bug6462\Base&Traversable', $base->getThis()); | ||
} | ||
|
||
if ($child instanceof \Traversable) { | ||
assertType('Bug6462\Child&Traversable', $child->getThis()); | ||
} | ||
|
||
if ($fixedChild instanceof \Traversable) { | ||
assertType('Bug6462\FixedChild&Traversable', $fixedChild->getThis()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug10208; | ||
|
||
abstract class AbstractScope | ||
{ | ||
/** | ||
* @return $this | ||
*/ | ||
abstract public function clear(): self; | ||
} | ||
|
||
class Condition extends AbstractScope | ||
{ | ||
/** @var string|null */ | ||
public $key; | ||
|
||
public function clear(): self | ||
{ | ||
$this->key = null; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug3580; | ||
|
||
interface TheBaseFoo { | ||
/** | ||
* @return static | ||
*/ | ||
public function getClone(): self; | ||
} | ||
|
||
interface TheFoo extends TheBaseFoo { | ||
} | ||
|
||
abstract class BaseFoo implements TheBaseFoo { | ||
public function getClone(): self { | ||
return clone $this; | ||
} | ||
} | ||
|
||
final class Foo extends BaseFoo implements TheFoo { | ||
} | ||
|
||
final class TheFooMaker { | ||
public Foo $foo; | ||
|
||
public function make(): TheFoo { | ||
return $this->foo->getClone(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bug4396; | ||
|
||
interface TheInterface | ||
{ | ||
/** @return static */ | ||
public static function fromString(string $value); | ||
} | ||
|
||
abstract class ClassC implements TheInterface | ||
{ | ||
private string $value; | ||
|
||
final private function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
final public static function fromString(string $value): self | ||
{ | ||
return new static($value); | ||
} | ||
} | ||
|
||
final class ClassB extends ClassC | ||
{ | ||
} | ||
|
||
final class ClassA | ||
{ | ||
public function classB(): ClassB | ||
{ | ||
return ClassB::fromString("any"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug6462; | ||
|
||
interface ThisInterface { | ||
/** | ||
* @return $this | ||
*/ | ||
public function t() : self; | ||
} | ||
|
||
class ThisImplementer implements ThisInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function t() : self { | ||
return $this; | ||
} | ||
} | ||
|
||
|
||
interface NonThisInterface { | ||
public function t() : self; | ||
} | ||
|
||
class NonThisImplementer implements NonThisInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function t() : self { | ||
return $this; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I'd fix this the same way so 👍
I just hate adding new properties to this class but I didn't figure out a better solution. yet. Merging this.