-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IllegalConstructorStaticCallRule - fix for renamed trait constructor
- Loading branch information
1 parent
eafba2e
commit 65330d3
Showing
3 changed files
with
83 additions
and
5 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,40 @@ | ||
<?php // lint >= 8.1 | ||
|
||
namespace Bug9577IllegalConstructorStaticCall; | ||
|
||
trait StringableMessageTrait | ||
{ | ||
public function __construct( | ||
private readonly \Stringable $StringableMessage, | ||
int $code = 0, | ||
?\Throwable $previous = null, | ||
) { | ||
parent::__construct((string) $StringableMessage, $code, $previous); | ||
} | ||
|
||
public function getStringableMessage(): \Stringable | ||
{ | ||
return $this->StringableMessage; | ||
} | ||
} | ||
|
||
class SpecializedException extends \RuntimeException | ||
{ | ||
use StringableMessageTrait { | ||
StringableMessageTrait::__construct as __traitConstruct; | ||
} | ||
|
||
public function __construct( | ||
private readonly object $aService, | ||
\Stringable $StringableMessage, | ||
int $code = 0, | ||
?\Throwable $previous = null, | ||
) { | ||
$this->__traitConstruct($StringableMessage, $code, $previous); | ||
} | ||
|
||
public function getService(): object | ||
{ | ||
return $this->aService; | ||
} | ||
} |