-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dispatcher-scopes
# Conflicts: # src/Core/src/Container.php # src/Core/tests/Scope/UseCaseTest.php
- Loading branch information
Showing
32 changed files
with
913 additions
and
108 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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spiral\Core\Config; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class DeprecationProxy extends Proxy | ||
{ | ||
/** | ||
* @param class-string $interface | ||
*/ | ||
public function __construct( | ||
string $interface, | ||
bool $singleton = false, | ||
private readonly string|\BackedEnum|null $scope = null, | ||
private readonly ?string $version = null, | ||
private readonly ?string $message = null, | ||
) { | ||
if (($scope === null || $version === null) && $message === null) { | ||
throw new \InvalidArgumentException('Scope and version or custom message must be provided.'); | ||
} | ||
|
||
parent::__construct($interface, $singleton); | ||
} | ||
|
||
/** | ||
* @return class-string | ||
*/ | ||
public function getInterface(): string | ||
{ | ||
$message = $this->message ?? \sprintf( | ||
'Using `%s` outside of the `%s` scope is deprecated and will be impossible in version %s.', | ||
$this->interface, | ||
$this->scope, | ||
$this->version | ||
); | ||
|
||
@trigger_error($message, \E_USER_DEPRECATED); | ||
|
||
return parent::getInterface(); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spiral\Core\Config; | ||
|
||
class Proxy extends Binding | ||
{ | ||
/** | ||
* @param class-string $interface | ||
*/ | ||
public function __construct( | ||
protected readonly string $interface, | ||
public readonly bool $singleton = false, | ||
) { | ||
if (!\interface_exists($interface)) { | ||
throw new \InvalidArgumentException(\sprintf('Interface `%s` does not exist.', $interface)); | ||
} | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return \sprintf('Proxy to `%s`', $this->interface); | ||
} | ||
|
||
/** | ||
* @return class-string | ||
*/ | ||
public function getInterface(): string | ||
{ | ||
return $this->interface; | ||
} | ||
} |
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
Oops, something went wrong.