Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/uploads/flags/Contracts.tar
Назад
Service/ServiceSubscriberInterface.php 0000644 00000004306 14722060417 0014130 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Service; /** * A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method. * * The getSubscribedServices method returns an array of service types required by such instances, * optionally keyed by the service names used internally. Service types that start with an interrogation * mark "?" are optional, while the other ones are mandatory service dependencies. * * The injected service locators SHOULD NOT allow access to any other services not specified by the method. * * It is expected that ServiceSubscriber instances consume PSR-11-based service locators internally. * This interface does not dictate any injection method for these service locators, although constructor * injection is recommended. * * @author Nicolas Grekas <p@tchwork.com> */ interface ServiceSubscriberInterface { /** * Returns an array of service types required by such instances, optionally keyed by the service names used internally. * * For mandatory dependencies: * * * ['logger' => 'Psr\Log\LoggerInterface'] means the objects use the "logger" name * internally to fetch a service which must implement Psr\Log\LoggerInterface. * * ['loggers' => 'Psr\Log\LoggerInterface[]'] means the objects use the "loggers" name * internally to fetch an iterable of Psr\Log\LoggerInterface instances. * * ['Psr\Log\LoggerInterface'] is a shortcut for * * ['Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface'] * * otherwise: * * * ['logger' => '?Psr\Log\LoggerInterface'] denotes an optional dependency * * ['loggers' => '?Psr\Log\LoggerInterface[]'] denotes an optional iterable dependency * * ['?Psr\Log\LoggerInterface'] is a shortcut for * * ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface'] * * @return array The required service types, optionally keyed by service names */ public static function getSubscribedServices(); } Service/ServiceProviderInterface.php 0000644 00000002272 14722060417 0013617 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Service; use Psr\Container\ContainerInterface; /** * A ServiceProviderInterface exposes the identifiers and the types of services provided by a container. * * @author Nicolas Grekas <p@tchwork.com> * @author Mateusz Sip <mateusz.sip@gmail.com> */ interface ServiceProviderInterface extends ContainerInterface { /** * Returns an associative array of service types keyed by the identifiers provided by the current container. * * Examples: * * * ['logger' => 'Psr\Log\LoggerInterface'] means the object provides a service named "logger" that implements Psr\Log\LoggerInterface * * ['foo' => '?'] means the container provides service name "foo" of unspecified type * * ['bar' => '?Bar\Baz'] means the container provides a service "bar" of type Bar\Baz|null * * @return string[] The provided service types, keyed by service names */ public function getProvidedServices(): array; } Service/Test/ServiceLocatorTest.php 0000644 00000005517 14722060417 0013373 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Service\Test; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Symfony\Contracts\Service\ServiceLocatorTrait; abstract class ServiceLocatorTest extends TestCase { protected function getServiceLocator(array $factories) { return new class($factories) implements ContainerInterface { use ServiceLocatorTrait; }; } public function testHas() { $locator = $this->getServiceLocator([ 'foo' => function () { return 'bar'; }, 'bar' => function () { return 'baz'; }, function () { return 'dummy'; }, ]); $this->assertTrue($locator->has('foo')); $this->assertTrue($locator->has('bar')); $this->assertFalse($locator->has('dummy')); } public function testGet() { $locator = $this->getServiceLocator([ 'foo' => function () { return 'bar'; }, 'bar' => function () { return 'baz'; }, ]); $this->assertSame('bar', $locator->get('foo')); $this->assertSame('baz', $locator->get('bar')); } public function testGetDoesNotMemoize() { $i = 0; $locator = $this->getServiceLocator([ 'foo' => function () use (&$i) { ++$i; return 'bar'; }, ]); $this->assertSame('bar', $locator->get('foo')); $this->assertSame('bar', $locator->get('foo')); $this->assertSame(2, $i); } public function testThrowsOnUndefinedInternalService() { if (!$this->getExpectedException()) { $this->expectException('Psr\Container\NotFoundExceptionInterface'); $this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.'); } $locator = $this->getServiceLocator([ 'foo' => function () use (&$locator) { return $locator->get('bar'); }, ]); $locator->get('foo'); } public function testThrowsOnCircularReference() { $this->expectException('Psr\Container\ContainerExceptionInterface'); $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".'); $locator = $this->getServiceLocator([ 'foo' => function () use (&$locator) { return $locator->get('bar'); }, 'bar' => function () use (&$locator) { return $locator->get('baz'); }, 'baz' => function () use (&$locator) { return $locator->get('bar'); }, ]); $locator->get('foo'); } } Service/ResetInterface.php 0000644 00000001747 14722060417 0011574 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Service; /** * Provides a way to reset an object to its initial state. * * When calling the "reset()" method on an object, it should be put back to its * initial state. This usually means clearing any internal buffers and forwarding * the call to internal dependencies. All properties of the object should be put * back to the same state it had when it was first ready to use. * * This method could be called, for example, to recycle objects that are used as * services, so that they can be used to handle several requests in the same * process loop (note that we advise making your services stateless instead of * implementing this interface when possible.) */ interface ResetInterface { public function reset(); } Service/ServiceSubscriberTrait.php 0000644 00000003344 14722060417 0013314 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Service; use Psr\Container\ContainerInterface; /** * Implementation of ServiceSubscriberInterface that determines subscribed services from * private method return types. Service ids are available as "ClassName::methodName". * * @author Kevin Bond <kevinbond@gmail.com> */ trait ServiceSubscriberTrait { /** @var ContainerInterface */ protected $container; public static function getSubscribedServices(): array { static $services; if (null !== $services) { return $services; } $services = \is_callable(['parent', __FUNCTION__]) ? parent::getSubscribedServices() : []; foreach ((new \ReflectionClass(self::class))->getMethods() as $method) { if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) { continue; } if (self::class === $method->getDeclaringClass()->name && ($returnType = $method->getReturnType()) && !$returnType->isBuiltin()) { $services[self::class.'::'.$method->name] = '?'.$returnType->getName(); } } return $services; } /** * @required */ public function setContainer(ContainerInterface $container) { $this->container = $container; if (\is_callable(['parent', __FUNCTION__])) { return parent::setContainer($container); } return null; } } Service/ServiceLocatorTrait.php 0000644 00000006705 14722060417 0012620 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Service; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; /** * A trait to help implement ServiceProviderInterface. * * @author Robin Chalas <robin.chalas@gmail.com> * @author Nicolas Grekas <p@tchwork.com> */ trait ServiceLocatorTrait { private $factories; private $loading = []; private $providedTypes; /** * @param callable[] $factories */ public function __construct(array $factories) { $this->factories = $factories; } /** * {@inheritdoc} * * @return bool */ public function has($id) { return isset($this->factories[$id]); } /** * {@inheritdoc} */ public function get($id) { if (!isset($this->factories[$id])) { throw $this->createNotFoundException($id); } if (isset($this->loading[$id])) { $ids = array_values($this->loading); $ids = \array_slice($this->loading, array_search($id, $ids)); $ids[] = $id; throw $this->createCircularReferenceException($id, $ids); } $this->loading[$id] = $id; try { return $this->factories[$id]($this); } finally { unset($this->loading[$id]); } } /** * {@inheritdoc} */ public function getProvidedServices(): array { if (null === $this->providedTypes) { $this->providedTypes = []; foreach ($this->factories as $name => $factory) { if (!\is_callable($factory)) { $this->providedTypes[$name] = '?'; } else { $type = (new \ReflectionFunction($factory))->getReturnType(); $this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '').$type->getName() : '?'; } } } return $this->providedTypes; } private function createNotFoundException(string $id): NotFoundExceptionInterface { if (!$alternatives = array_keys($this->factories)) { $message = 'is empty...'; } else { $last = array_pop($alternatives); if ($alternatives) { $message = sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last); } else { $message = sprintf('only knows about the "%s" service.', $last); } } if ($this->loading) { $message = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message); } else { $message = sprintf('Service "%s" not found: the current service locator %s', $id, $message); } return new class($message) extends \InvalidArgumentException implements NotFoundExceptionInterface { }; } private function createCircularReferenceException(string $id, array $path): ContainerExceptionInterface { return new class(sprintf('Circular reference detected for service "%s", path: "%s".', $id, implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface { }; } } Service/autoload.php 0000644 00000002451 14722060417 0010472 0 ustar 00 <?php require_once 'Psr/Container/autoload.php'; if (stream_resolve_include_path('Symfony/Component/DependencyInjection/autoload.php')){ include_once 'Symfony/Component/DependencyInjection/autoload.php'; } // @codingStandardsIgnoreFile // @codeCoverageIgnoreStart // this is an autogenerated file - do not edit spl_autoload_register( function($class) { static $classes = null; if ($classes === null) { $classes = array( 'symfony\\contracts\\service\\resetinterface' => '/ResetInterface.php', 'symfony\\contracts\\service\\servicelocatortrait' => '/ServiceLocatorTrait.php', 'symfony\\contracts\\service\\serviceproviderinterface' => '/ServiceProviderInterface.php', 'symfony\\contracts\\service\\servicesubscriberinterface' => '/ServiceSubscriberInterface.php', 'symfony\\contracts\\service\\servicesubscribertrait' => '/ServiceSubscriberTrait.php', 'symfony\\contracts\\service\\test\\servicelocatortest' => '/Test/ServiceLocatorTest.php' ); } $cn = strtolower($class); if (isset($classes[$cn]) and file_exists(__DIR__ . $classes[$cn])) { require __DIR__ . $classes[$cn]; } }, true, false ); // @codeCoverageIgnoreEnd Cache/CallbackInterface.php 0000644 00000001453 14722060417 0011603 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Cache; use Psr\Cache\CacheItemInterface; /** * Computes and returns the cached value of an item. * * @author Nicolas Grekas <p@tchwork.com> */ interface CallbackInterface { /** * @param CacheItemInterface|ItemInterface $item The item to compute the value for * @param bool &$save Should be set to false when the value should not be saved in the pool * * @return mixed The computed value for the passed item */ public function __invoke(CacheItemInterface $item, bool &$save); } Cache/autoload.php 0000644 00000002132 14722060417 0010071 0 ustar 00 <?php require_once 'Psr/Cache/autoload.php'; if (stream_resolve_include_path('Symfony/Component/Cache/autoload.php')){ include_once 'Symfony/Component/Cache/autoload.php'; } // @codingStandardsIgnoreFile // @codeCoverageIgnoreStart // this is an autogenerated file - do not edit spl_autoload_register( function($class) { static $classes = null; if ($classes === null) { $classes = array( 'symfony\\contracts\\cache\\cacheinterface' => '/CacheInterface.php', 'symfony\\contracts\\cache\\cachetrait' => '/CacheTrait.php', 'symfony\\contracts\\cache\\callbackinterface' => '/CallbackInterface.php', 'symfony\\contracts\\cache\\iteminterface' => '/ItemInterface.php', 'symfony\\contracts\\cache\\tagawarecacheinterface' => '/TagAwareCacheInterface.php' ); } $cn = strtolower($class); if (isset($classes[$cn]) and file_exists(__DIR__ . $classes[$cn])) { require __DIR__ . $classes[$cn]; } }, true, false ); // @codeCoverageIgnoreEnd Cache/ItemInterface.php 0000644 00000003320 14722060417 0011000 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Cache; use Psr\Cache\CacheException; use Psr\Cache\CacheItemInterface; use Psr\Cache\InvalidArgumentException; /** * Augments PSR-6's CacheItemInterface with support for tags and metadata. * * @author Nicolas Grekas <p@tchwork.com> */ interface ItemInterface extends CacheItemInterface { /** * References the Unix timestamp stating when the item will expire. */ const METADATA_EXPIRY = 'expiry'; /** * References the time the item took to be created, in milliseconds. */ const METADATA_CTIME = 'ctime'; /** * References the list of tags that were assigned to the item, as string[]. */ const METADATA_TAGS = 'tags'; /** * Reserved characters that cannot be used in a key or tag. */ const RESERVED_CHARACTERS = '{}()/\@:'; /** * Adds a tag to a cache item. * * Tags are strings that follow the same validation rules as keys. * * @param string|string[] $tags A tag or array of tags * * @return $this * * @throws InvalidArgumentException When $tag is not valid * @throws CacheException When the item comes from a pool that is not tag-aware */ public function tag($tags): self; /** * Returns a list of metadata info that were saved alongside with the cached value. * * See ItemInterface::METADATA_* consts for keys potentially found in the returned array. */ public function getMetadata(): array; } Cache/CacheTrait.php 0000644 00000004627 14722060417 0010303 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Cache; use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\InvalidArgumentException; use Psr\Log\LoggerInterface; /** * An implementation of CacheInterface for PSR-6 CacheItemPoolInterface classes. * * @author Nicolas Grekas <p@tchwork.com> */ trait CacheTrait { /** * {@inheritdoc} */ public function get(string $key, callable $callback, float $beta = null, array &$metadata = null) { return $this->doGet($this, $key, $callback, $beta, $metadata); } /** * {@inheritdoc} */ public function delete(string $key): bool { return $this->deleteItem($key); } private function doGet(CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null, LoggerInterface $logger = null) { if (0 > $beta = $beta ?? 1.0) { throw new class(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', \get_class($this), $beta)) extends \InvalidArgumentException implements InvalidArgumentException { }; } $item = $pool->getItem($key); $recompute = !$item->isHit() || INF === $beta; $metadata = $item instanceof ItemInterface ? $item->getMetadata() : []; if (!$recompute && $metadata) { $expiry = $metadata[ItemInterface::METADATA_EXPIRY] ?? false; $ctime = $metadata[ItemInterface::METADATA_CTIME] ?? false; if ($recompute = $ctime && $expiry && $expiry <= ($now = microtime(true)) - $ctime / 1000 * $beta * log(random_int(1, PHP_INT_MAX) / PHP_INT_MAX)) { // force applying defaultLifetime to expiry $item->expiresAt(null); $logger && $logger->info('Item "{key}" elected for early recomputation {delta}s before its expiration', [ 'key' => $key, 'delta' => sprintf('%.1f', $expiry - $now), ]); } } if ($recompute) { $save = true; $item->set($callback($item, $save)); if ($save) { $pool->save($item); } } return $item->get(); } } Cache/TagAwareCacheInterface.php 0000644 00000001755 14722060417 0012533 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Cache; use Psr\Cache\InvalidArgumentException; /** * Allows invalidating cached items using tags. * * @author Nicolas Grekas <p@tchwork.com> */ interface TagAwareCacheInterface extends CacheInterface { /** * Invalidates cached items using tags. * * When implemented on a PSR-6 pool, invalidation should not apply * to deferred items. Instead, they should be committed as usual. * This allows replacing old tagged values by new ones without * race conditions. * * @param string[] $tags An array of tags to invalidate * * @return bool True on success * * @throws InvalidArgumentException When $tags is not valid */ public function invalidateTags(array $tags); } Cache/CacheInterface.php 0000644 00000004605 14722060417 0011114 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Contracts\Cache; use Psr\Cache\CacheItemInterface; use Psr\Cache\InvalidArgumentException; /** * Covers most simple to advanced caching needs. * * @author Nicolas Grekas <p@tchwork.com> */ interface CacheInterface { /** * Fetches a value from the pool or computes it if not found. * * On cache misses, a callback is called that should return the missing value. * This callback is given a PSR-6 CacheItemInterface instance corresponding to the * requested key, that could be used e.g. for expiration control. It could also * be an ItemInterface instance when its additional features are needed. * * @param string $key The key of the item to retrieve from the cache * @param callable|CallbackInterface $callback Should return the computed value for the given key/item * @param float|null $beta A float that, as it grows, controls the likeliness of triggering * early expiration. 0 disables it, INF forces immediate expiration. * The default (or providing null) is implementation dependent but should * typically be 1.0, which should provide optimal stampede protection. * See https://en.wikipedia.org/wiki/Cache_stampede#Probabilistic_early_expiration * @param array &$metadata The metadata of the cached item {@see ItemInterface::getMetadata()} * * @return mixed The value corresponding to the provided key * * @throws InvalidArgumentException When $key is not valid or when $beta is negative */ public function get(string $key, callable $callback, float $beta = null, array &$metadata = null); /** * Removes an item from the pool. * * @param string $key The key to delete * * @throws InvalidArgumentException When $key is not valid * * @return bool True if the item was successfully removed, false if there was any error */ public function delete(string $key): bool; }
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка