mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Update lib packages
This commit is contained in:
parent
238ebc0949
commit
b483115883
38 changed files with 1323 additions and 598 deletions
|
@ -10,15 +10,8 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
|||
|
||||
class PackageProxyContainer implements ContainerInterface
|
||||
{
|
||||
/**
|
||||
* @var Package
|
||||
*/
|
||||
private $package;
|
||||
|
||||
/**
|
||||
* @var ContainerInterface|null
|
||||
*/
|
||||
private $container;
|
||||
private Package $package;
|
||||
private ?ContainerInterface $container = null;
|
||||
|
||||
/**
|
||||
* @param Package $package
|
||||
|
@ -31,8 +24,6 @@ class PackageProxyContainer implements ContainerInterface
|
|||
/**
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function get(string $id)
|
||||
{
|
||||
|
@ -44,8 +35,6 @@ class PackageProxyContainer implements ContainerInterface
|
|||
/**
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function has(string $id): bool
|
||||
{
|
||||
|
@ -55,33 +44,30 @@ class PackageProxyContainer implements ContainerInterface
|
|||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
* @psalm-assert-if-true ContainerInterface $this->container
|
||||
* @phpstan-assert-if-true ContainerInterface $this->container
|
||||
* @phpstan-assert-if-false null $this->container
|
||||
*/
|
||||
private function tryContainer(): bool
|
||||
{
|
||||
if ($this->container) {
|
||||
if ($this->container !== null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** TODO: We need a better way to deal with status checking besides equality */
|
||||
if (
|
||||
$this->package->statusIs(Package::STATUS_READY)
|
||||
|| $this->package->statusIs(Package::STATUS_BOOTED)
|
||||
$this->package->hasContainer()
|
||||
|| $this->package->hasReachedStatus(Package::STATUS_INITIALIZED)
|
||||
) {
|
||||
$this->container = $this->package->container();
|
||||
}
|
||||
|
||||
return (bool)$this->container;
|
||||
return $this->container !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @psalm-assert ContainerInterface $this->container
|
||||
* @phpstan-assert ContainerInterface $this->container
|
||||
*/
|
||||
private function assertPackageBooted(string $id): void
|
||||
{
|
||||
|
@ -90,13 +76,11 @@ class PackageProxyContainer implements ContainerInterface
|
|||
}
|
||||
|
||||
$name = $this->package->name();
|
||||
$status = $this->package->statusIs(Package::STATUS_FAILED)
|
||||
? 'is errored'
|
||||
: 'is not ready yet';
|
||||
$status = $this->package->hasFailed() ? 'is errored' : 'is not ready yet';
|
||||
|
||||
throw new class ("Error retrieving service {$id} because package {$name} {$status}.")
|
||||
extends \Exception
|
||||
implements ContainerExceptionInterface {
|
||||
$error = "Error retrieving service {$id} because package {$name} {$status}.";
|
||||
throw new class (esc_html($error)) extends \Exception implements ContainerExceptionInterface
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue