-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed intersecting and removal from TemplateUnionType
- Loading branch information
1 parent
ccffbc3
commit 0d28835
Showing
7 changed files
with
111 additions
and
6 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Bug6566Types; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class A { | ||
public string $name; | ||
} | ||
|
||
class B { | ||
public string $name; | ||
} | ||
|
||
class C { | ||
|
||
} | ||
|
||
/** | ||
* @template T of A|B|C | ||
*/ | ||
abstract class HelloWorld | ||
{ | ||
public function sayHelloBug(): void | ||
{ | ||
$object = $this->getObject(); | ||
assertType('T of Bug6566Types\A|Bug6566Types\B|Bug6566Types\C (class Bug6566Types\HelloWorld, argument)', $object); | ||
if ($object instanceof C) { | ||
assertType('T of Bug6566Types\C (class Bug6566Types\HelloWorld, argument)', $object); | ||
return; | ||
} | ||
assertType('T of Bug6566Types\A|Bug6566Types\B (class Bug6566Types\HelloWorld, argument)', $object); | ||
if ($object instanceof B) { | ||
assertType('T of Bug6566Types\B (class Bug6566Types\HelloWorld, argument)', $object); | ||
return; | ||
} | ||
assertType('T of Bug6566Types\A (class Bug6566Types\HelloWorld, argument)', $object); | ||
if ($object instanceof A) { | ||
assertType('T of Bug6566Types\A (class Bug6566Types\HelloWorld, argument)', $object); | ||
return; | ||
} | ||
assertType('*NEVER*', $object); | ||
} | ||
|
||
/** | ||
* @return T | ||
*/ | ||
abstract protected function getObject(): A|B|C; | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Bug6566; | ||
|
||
class A { | ||
public string $name; | ||
} | ||
|
||
class B { | ||
public string $name; | ||
} | ||
|
||
class C { | ||
|
||
} | ||
|
||
/** | ||
* @template T of A|B|C | ||
*/ | ||
abstract class HelloWorld | ||
{ | ||
public function sayHelloBug(): void | ||
{ | ||
$object = $this->getObject(); | ||
if (!$object instanceof C) { | ||
echo $object->name; | ||
} | ||
} | ||
|
||
/** | ||
* @return T | ||
*/ | ||
abstract protected function getObject(): A|B|C; | ||
} |
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