-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix native static return typehint when entering class method
- Loading branch information
1 parent
ae50bb4
commit baa371e
Showing
3 changed files
with
75 additions
and
1 deletion.
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,47 @@ | ||
<?php // lint >= 8.0 | ||
|
||
namespace Bug4795; | ||
|
||
abstract class BaseDTO | ||
{ | ||
|
||
final protected static function create(): static | ||
{ | ||
$class = static::class; | ||
|
||
return new $class(); | ||
} | ||
|
||
abstract public static function parse(): static; | ||
|
||
} | ||
|
||
final class ConcreteDTO extends BaseDTO | ||
{ | ||
|
||
public string $foo; | ||
|
||
public static function parse(): static | ||
{ | ||
$instance = self::create(); | ||
|
||
$instance->foo = 'bar'; | ||
|
||
return $instance; | ||
} | ||
} | ||
|
||
class NonFinalConcreteDTO extends BaseDTO | ||
{ | ||
|
||
public string $foo; | ||
|
||
public static function parse(): static | ||
{ | ||
$instance = self::create(); | ||
|
||
$instance->foo = 'bar'; | ||
|
||
return $instance; | ||
} | ||
} |