Update lib packages

This commit is contained in:
Narek Zakarian 2025-07-04 22:05:58 +04:00
parent 238ebc0949
commit b483115883
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7
38 changed files with 1323 additions and 598 deletions

View file

@ -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
{
};
}
}