_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q262500
Application.defaults
test
public function defaults(string $commandName, array $argumentDefaults = []): void { $command = $this->get($commandName); $commandDefinition = $command->getDefinition(); foreach ($argumentDefaults as $name => $default) { $argument = $commandDefinition->getArgument($name); $argument->setDefault($default); } }
php
{ "resource": "" }
q262501
Application.phpBinary
test
public static function phpBinary(): string { $finder = (new PhpExecutableFinder())->find(false); return \escapeshellarg($finder === false ? '' : $finder); }
php
{ "resource": "" }
q262502
Application.cerebroBinary
test
public static function cerebroBinary(): string { $constant = \defined('CEREBRO_BINARY') ? \constant('CEREBRO_BINARY') : null; return $constant !== null ? \escapeshellarg($constant) : 'cerebro'; }
php
{ "resource": "" }
q262503
Application.doRunCommand
test
protected function doRunCommand(SymfonyCommand $command, InputInterface $input, OutputInterface $output): int { $this->runningCommand = $command; foreach ($command->getHelperSet() as $helper) { if ($helper instanceof InputAwareInterface) { $helper->setInput($input); } } if ($this->eventManager === null) { return $command->run($input, $output); } // bind before the console.command event, so the listeners have access to input options/arguments try { $command->mergeApplicationDefinition(); $input->bind($command->getDefinition()); } catch (ExceptionInterface $exception) { // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition } $event = new ConsoleCommandEvent($command, $input, $output); $exception = null; try { $this->eventManager->trigger($event); if ($event->commandShouldRun()) { $exitCode = $command->run($input, $output); } else { $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED; } } catch (Throwable $exception) { $this->eventManager->trigger($event = new ConsoleErrorEvent($command, $input, $output, $exception)); $exception = $event->getError(); if (($exitCode = $event->getExitCode()) === 0) { $exception = null; } } $this->eventManager->trigger($event = new ConsoleTerminateEvent($command, $input, $output, $exitCode)); if ($exception !== null) { throw $exception; } return $event->getExitCode(); }
php
{ "resource": "" }
q262504
Application.getDefaultInputDefinition
test
protected function getDefaultInputDefinition(): InputDefinition { $definition = parent::getDefaultInputDefinition(); $definition->addOption($this->getEnvironmentOption()); return $definition; }
php
{ "resource": "" }
q262505
RouteTreeBuilder.build
test
public function build(array $routes): array { $rootRouteData = null; $nodes = []; $groupedRoutes = []; foreach ($routes as $route) { $groupedRoutes[\count($route->getSegments())][] = $route; } if (isset($groupedRoutes[0])) { $rootRouteData = new MatchedRouteDataMap(); $rootRouteData->addRoute($groupedRoutes[0][0], []); unset($groupedRoutes[0]); } foreach ($groupedRoutes as $segmentDepth => $group) { $groupNodes = []; foreach ($group as $route) { $parameterIndexNameMap = []; $segments = $route->getSegments(); $segmentMatcher = $this->getMatcher(\array_shift($segments), $parameterIndexNameMap); $firstSegmentHash = $segmentMatcher->getHash(); if (! isset($groupNodes[$firstSegmentHash])) { $groupNodes[$firstSegmentHash] = new RouteTreeNode( [0 => $segmentMatcher], $segmentDepth === 1 ? new MatchedRouteDataMap() : new ChildrenNodeCollection() ); } $this->addRouteToNode($groupNodes[$firstSegmentHash], $route, $segments, 1, $parameterIndexNameMap); } $nodes[$segmentDepth] = new ChildrenNodeCollection($groupNodes); } return [$rootRouteData, $nodes]; }
php
{ "resource": "" }
q262506
RouteTreeBuilder.addRouteToNode
test
private function addRouteToNode( RouteTreeNode $node, RouteContract $route, array $segments, int $segmentDepth, array $parameterIndexNameMap ): void { if (\count($segments) === 0) { $node->getContents()->addRoute($route, $parameterIndexNameMap); return; } $childSegmentMatcher = $this->getMatcher(\array_shift($segments), $parameterIndexNameMap); if ($node->getContents()->hasChildFor($childSegmentMatcher)) { $child = $node->getContents()->getChild($childSegmentMatcher); } else { $child = new RouteTreeNode( [$segmentDepth => $childSegmentMatcher], \count($segments) === 0 ? new MatchedRouteDataMap() : new ChildrenNodeCollection() ); $node->getContents()->addChild($child); } $this->addRouteToNode($child, $route, $segments, $segmentDepth + 1, $parameterIndexNameMap); }
php
{ "resource": "" }
q262507
RouteTreeBuilder.getMatcher
test
private function getMatcher($firstSegment, array &$parameterIndexNameMap): SegmentMatcherContract { if ($firstSegment instanceof ParameterMatcher) { return $firstSegment->getMatcher($parameterIndexNameMap); } return $firstSegment; }
php
{ "resource": "" }
q262508
FilesystemServiceProvider.createFilesystemManager
test
public static function createFilesystemManager(ContainerInterface $container): FilesystemManager { $manager = new FilesystemManager($container->get('config')); if ($container->has(CacheManagerContract::class)) { $manager->setCacheManager($container->get(CacheManagerContract::class)); } return $manager; }
php
{ "resource": "" }
q262509
FilesystemServiceProvider.createCachedFactory
test
public static function createCachedFactory(ContainerInterface $container): CachedFactory { $cache = null; if ($container->has(CacheManagerContract::class)) { $cache = $container->get(CacheManagerContract::class); } return new CachedFactory( $container->get(FilesystemManager::class), $cache ); }
php
{ "resource": "" }
q262510
TraceablePDODecorater.getAccumulatedStatementsDuration
test
public function getAccumulatedStatementsDuration(): int { return \array_reduce($this->executedStatements, static function ($v, $s) { return $v + $s->getDuration(); }); }
php
{ "resource": "" }
q262511
TraceablePDODecorater.getMemoryUsage
test
public function getMemoryUsage(): int { return \array_reduce($this->executedStatements, static function ($v, $s) { return $v + $s->getMemoryUsage(); }); }
php
{ "resource": "" }
q262512
TraceablePDODecorater.profileCall
test
protected function profileCall(string $method, string $sql, array $args) { $trace = new TracedStatement($sql); $trace->start(); $ex = null; $result = null; try { $result = $this->pdo->{$method}(...$args); } catch (PDOException $e) { $ex = $e; } if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) !== PDO::ERRMODE_EXCEPTION && $result === false) { $error = $this->pdo->errorInfo(); $ex = new PDOException($error[2], $error[0]); } $trace->end($ex); $this->addExecutedStatement($trace); if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_EXCEPTION && $ex !== null) { throw $ex; } return $result; }
php
{ "resource": "" }
q262513
Resolver.resolve
test
public function resolve(string $alias): ?string { // Check wether the alias matches the pattern if (\preg_match($this->regex, $alias, $matches) !== 1) { return null; } // Get the translation $translation = $this->translation; if (\mb_strpos($translation, '$') === false) { $class = $translation; } else { // Make sure namespace seperators are escaped $translation = \str_replace('\\', '\\\\', $translation); // Resolve the replacement $class = \preg_replace($this->regex, $translation, $alias); } // Check wether the class exists if ($class && $this->exists($class, true)) { return $class; } return null; }
php
{ "resource": "" }
q262514
Resolver.matches
test
public function matches(string $pattern, string $translation = null): bool { return $this->pattern === $pattern && (! $translation || $translation === $this->translation); }
php
{ "resource": "" }
q262515
TwigServiceProvider.createTwigEngine
test
public static function createTwigEngine(ContainerInterface $container): TwigEngine { $engine = new TwigEngine($container->get(TwigEnvironment::class), $container->get('config')); $engine->setContainer($container); return $engine; }
php
{ "resource": "" }
q262516
TwigServiceProvider.extendViewFactory
test
public static function extendViewFactory( ContainerInterface $container, ?FactoryContract $view = null ): ?FactoryContract { if ($view !== null) { // @var FactoryContract $view $view->addExtension('twig', 'twig'); } return $view; }
php
{ "resource": "" }
q262517
TwigServiceProvider.extendEngineResolver
test
public static function extendEngineResolver( ContainerInterface $container, ?EngineResolver $engines = null ): ?EngineResolver { if ($engines !== null) { // @var EngineResolver $engines $engines->register('twig', static function () use ($container) { return $container->get(TwigEngine::class); }); } return $engines; }
php
{ "resource": "" }
q262518
TwigServiceProvider.createTwigEnvironment
test
public static function createTwigEnvironment(ContainerInterface $container): TwigEnvironment { $options = self::resolveOptions($container->get('config')); $twigOptions = $options['engines']['twig']['options']; $twig = new TwigEnvironment( $container->get(LoaderInterface::class), $twigOptions ); if ($container->has(Lexer::class)) { $twig->setLexer($container->get(Lexer::class)); } return $twig; }
php
{ "resource": "" }
q262519
TwigServiceProvider.createTwigLoader
test
public static function createTwigLoader(ContainerInterface $container): LoaderInterface { $options = self::resolveOptions($container->get('config')); $loaders = []; $twigOptions = $options['engines']['twig']; $loader = new TwigLoader($container->get(FinderContract::class)); if (isset($twigOptions['file_extension'])) { $loader->setExtension($twigOptions['file_extension']); } $loaders[] = $loader; if (isset($twigOptions['templates']) && \is_array($twigOptions['templates'])) { $loaders[] = new ArrayLoader($twigOptions['templates']); } if (isset($twigOptions['loaders']) && \is_array($twigOptions['loaders'])) { $loaders = \array_merge($loaders, $twigOptions['loaders']); } return new ChainLoader($loaders); }
php
{ "resource": "" }
q262520
Validator.parseData
test
protected function parseData(array $data): array { $newData = []; foreach ($data as $key => $value) { if (\is_array($value)) { return $this->parseData($value); } $newData[$key] = $value; } return $newData; }
php
{ "resource": "" }
q262521
Validator.createRule
test
protected function createRule($rules): RespectValidator { $notRules = []; $optionalRules = []; if (\is_string($rules)) { // remove duplicate $rules = \array_unique(\explode('|', $rules)); } foreach ($rules as $key => $rule) { if (\mb_strpos($rule, '!') !== false) { $notRules[] = $rule; unset($rules[$key]); } elseif (\mb_strpos($rule, '?') !== false) { $optionalRules[] = $rule; unset($rules[$key]); } } // reset keys $rules = \array_values($rules); $validator = $this->createValidator($rules, $notRules, $optionalRules); return $this->createChainableValidators($validator, $rules); }
php
{ "resource": "" }
q262522
Validator.createNegativeOrOptionalValidator
test
protected function createNegativeOrOptionalValidator(string $filter, array $rules): RespectValidator { [$method, $parameters] = $this->parseStringRule($rules[0]); unset($rules[0]); $method = \str_replace($filter, '', $method); $validator = RespectValidator::$method(...$parameters); if ($filter === '!') { return RespectValidator::not($this->createChainableValidators($validator, $rules)); } return RespectValidator::optional($this->createChainableValidators($validator, $rules)); }
php
{ "resource": "" }
q262523
Validator.createChainableValidators
test
protected function createChainableValidators(RespectValidator $class, array $rules): RespectValidator { // reset keys $rules = \array_values($rules); if (\count($rules) !== 0) { $chain = ''; foreach ($rules as $rule) { if ($rules[0] === $rule) { $chain .= $rule; } else { $chain .= '.' . $rule; } } return \array_reduce(\explode('.', $chain), function (object $validator, string $method) { [$method, $parameters] = $this->parseStringRule($method); $method = \str_replace(['!', '?'], '', $method); return $validator->{$method}(...$parameters); }, $class); } return $class; }
php
{ "resource": "" }
q262524
Validator.parseStringRule
test
protected function parseStringRule(string $rules): array { $parameters = []; // The format for specifying validation rules and parameters follows an // easy {rule}:{parameters} formatting convention. For instance the // rule "Min:3" states that the value may only be three letters. if (\mb_strpos($rules, ':') !== false) { [$rules, $parameter] = \explode(':', $rules, 2); $parameters = $this->parseParameters($rules, $parameter); } return [\trim($rules), $parameters]; }
php
{ "resource": "" }
q262525
Validator.parseParameters
test
protected function parseParameters(string $rule, string $parameter): array { if (\mb_strtolower($rule) === 'regex') { return [$parameter]; } return \str_getcsv($parameter); }
php
{ "resource": "" }
q262526
WebServer.start
test
public static function start(WebServerConfig $config, string $pidFile = null): int { $pidFile = $pidFile ?? self::getDefaultPidFile(); if (self::isRunning($pidFile)) { throw new RuntimeException(\sprintf('A process is already listening on http://%s.', $config->getAddress())); } $pid = pcntl_fork(); if ($pid < 0) { throw new RuntimeException('Unable to start the server process.'); } if ($pid > 0) { return self::STARTED; } if (posix_setsid() < 0) { throw new RuntimeException('Unable to set the child process as session leader.'); } $process = self::createServerProcess($config); $process->disableOutput(); $process->start(); if (! $process->isRunning()) { throw new RuntimeException('Unable to start the server process.'); } \file_put_contents($pidFile, $config->getAddress()); // stop the web server when the lock file is removed while ($process->isRunning()) { if (! \file_exists($pidFile)) { $process->stop(); } \sleep(1); } return self::STOPPED; }
php
{ "resource": "" }
q262527
WebServer.stop
test
public static function stop(string $pidFile = null): void { $pidFile = $pidFile ?? self::getDefaultPidFile(); if (! \file_exists($pidFile)) { throw new RuntimeException('No web server is listening.'); } \unlink($pidFile); }
php
{ "resource": "" }
q262528
WebServer.getAddress
test
public static function getAddress(string $pidFile = null) { $pidFile = $pidFile ?? self::getDefaultPidFile(); if (! \file_exists($pidFile)) { return false; } return \file_get_contents($pidFile); }
php
{ "resource": "" }
q262529
WebServer.isRunning
test
public static function isRunning(string $pidFile = null): bool { $pidFile = $pidFile ?? self::getDefaultPidFile(); if (! \file_exists($pidFile)) { return false; } $address = \file_get_contents($pidFile); $pos = \mb_strrpos($address, ':'); $hostname = \mb_substr($address, 0, $pos); $port = \mb_substr($address, $pos + 1); if (false !== $fp = @fsockopen($hostname, (int) $port, $errno, $errstr, 1)) { fclose($fp); return true; } \unlink($pidFile); return false; }
php
{ "resource": "" }
q262530
WebServer.createServerProcess
test
private static function createServerProcess(WebServerConfig $config): Process { $finder = new PhpExecutableFinder(); if (($binary = $finder->find(false)) === false) { throw new RuntimeException('Unable to find the PHP binary.'); } $xdebugArgs = []; if ($config->hasXdebug() && \extension_loaded('xdebug')) { $xdebugArgs = ['-dxdebug.profiler_enable_trigger=1']; } $process = new Process(\array_merge([$binary], $finder->findArguments(), $xdebugArgs, ['-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()])); $process->setWorkingDirectory($config->getDocumentRoot()); $process->setTimeout(null); return $process; }
php
{ "resource": "" }
q262531
EventManager.getListeners
test
public function getListeners(string $eventName = null): array { if ($eventName === null) { foreach ($this->listeners as $name => $eventListeners) { if (! isset($this->sorted[$name])) { $this->sortListeners($name); } } return \array_filter($this->sorted); } $this->validateEventName($eventName); $this->bindPatterns($eventName); if (! isset($this->listeners[$eventName])) { return []; } if (! isset($this->sorted[$eventName])) { $this->sortListeners($eventName); } return $this->sorted[$eventName]; }
php
{ "resource": "" }
q262532
EventManager.removeListenerPattern
test
protected function removeListenerPattern(string $eventPattern, $listener): void { if (empty($this->patterns[$eventPattern])) { return; } /** @var ListenerPattern $pattern */ foreach ($this->patterns[$eventPattern] as $key => $pattern) { if ($listener === $pattern->getListener()) { $pattern->unbind($this); unset($this->patterns[$eventPattern][$key]); } } }
php
{ "resource": "" }
q262533
EventManager.hasWildcards
test
private function hasWildcards(string $subject): bool { return \mb_strpos($subject, '*') !== false || \mb_strpos($subject, '#') !== false; }
php
{ "resource": "" }
q262534
EventManager.addListenerPattern
test
private function addListenerPattern(ListenerPattern $pattern): void { $this->patterns[$pattern->getEventPattern()][] = $pattern; foreach ($this->syncedEvents as $eventName => $value) { if ($pattern->test($eventName)) { unset($this->syncedEvents[$eventName]); } } }
php
{ "resource": "" }
q262535
OptionsReader.readMandatoryOption
test
protected function readMandatoryOption(string $className, array $dimensions, array $mandatoryOptions): array { $options = []; foreach ($mandatoryOptions as $key => $mandatoryOption) { if (! \is_scalar($mandatoryOption)) { $options[$key] = $this->readMandatoryOption($className, $dimensions, $mandatoryOptions[$key]); continue; } $options[$mandatoryOption] = null; } return $options; }
php
{ "resource": "" }
q262536
OptionsReader.buildMultidimensionalArray
test
private function buildMultidimensionalArray(array $dimensions, $value): array { $config = []; $index = \array_shift($dimensions); if (! isset($dimensions[0])) { $config[$index] = $value; } else { $config[$index] = $this->buildMultidimensionalArray($dimensions, $value); } return $config; }
php
{ "resource": "" }
q262537
Handler.getPreparedResponse
test
protected function getPreparedResponse( ?ServerRequestInterface $request, Throwable $exception, Throwable $transformed ): ResponseInterface { try { $response = $this->getResponse( $request, $exception, $transformed ); } catch (Throwable $exception) { $this->report($exception); $response = $this->responseFactory->createResponse(); $response = $response->withStatus(500, HttpStatus::getReasonPhrase(500)); $response = $response->withHeader('content-type', 'text/plain'); } return $response; }
php
{ "resource": "" }
q262538
Handler.getResponse
test
protected function getResponse( ?ServerRequestInterface $request, Throwable $exception, Throwable $transformed ): ResponseInterface { $id = ExceptionIdentifier::identify($exception); $flattened = FlattenException::create($exception); $code = $flattened->getStatusCode(); $headers = $flattened->getHeaders(); return $this->getDisplayer( $request, $exception, $transformed, $code )->display($transformed, $id, $code, $headers); }
php
{ "resource": "" }
q262539
Handler.getDisplayer
test
protected function getDisplayer( ?ServerRequestInterface $request, Throwable $original, Throwable $transformed, int $code ): DisplayerContract { $sortedDisplayers = []; \ksort($this->displayers); \array_walk_recursive($this->displayers, static function ($displayers, $key) use (&$sortedDisplayers): void { $sortedDisplayers[$key] = $displayers; }); if ($request !== null) { $filtered = $this->getFiltered($sortedDisplayers, $request, $original, $transformed, $code); if (\count($filtered) !== 0) { return $this->sortedFilter($filtered, $request); } } return $sortedDisplayers[$this->resolvedOptions['http']['displayer']['default']]; }
php
{ "resource": "" }
q262540
Handler.getFiltered
test
protected function getFiltered( array $displayers, ServerRequestInterface $request, Throwable $original, Throwable $transformed, int $code ): array { /** @var \Viserio\Component\Contract\Exception\Filter[] $sortedFilters */ $sortedFilters = []; \ksort($this->filters); \array_walk_recursive($this->filters, static function ($filter, $key) use (&$sortedFilters): void { $sortedFilters[$key] = $filter; }); foreach ($sortedFilters as $filter) { $displayers = $filter->filter($displayers, $request, $original, $transformed, $code); } return \array_values($displayers); }
php
{ "resource": "" }
q262541
Handler.sortedFilter
test
private function sortedFilter(array $filtered, ServerRequestInterface $request): DisplayerContract { $accepts = self::getHeaderValuesFromString($request->getHeaderLine('Accept')); foreach ($accepts as $accept) { foreach ($filtered as $filter) { if ($filter->getContentType() === $accept) { return $filter; } } } return $filtered[0]; }
php
{ "resource": "" }
q262542
Collection.addLookups
test
protected function addLookups(RouteContract $route): void { // If the route has a name, we will add it to the name look-up table so that we // will quickly be able to find any route associate with a name and not have // to iterate through every route every time we need to perform a look-up. $action = $route->getAction(); if (isset($action['as'])) { $this->nameList[$action['as']] = $route; } // When the route is routing to a controller we will also store the action that // is used by the route. This will let us reverse route to controllers while // processing a request and easily generate URLs to the given controllers. if (isset($action['controller'])) { $this->actionList[\trim($action['controller'], '\\')] = $route; } }
php
{ "resource": "" }
q262543
Message.addAddresses
test
protected function addAddresses($address, string $name, string $type): void { if (\is_array($address)) { $set = \sprintf('set%s', $type); $this->swift->{$set}($address, $name); return; } $add = \sprintf('add%s', $type); $this->swift->{$add}($address, $name); }
php
{ "resource": "" }
q262544
ProfilerServiceProvider.createAssetsRenderer
test
public static function createAssetsRenderer(ContainerInterface $container): AssetsRenderer { $options = self::resolveOptions($container->get('config')); return new AssetsRenderer($options['jquery_is_used'], $options['path']); }
php
{ "resource": "" }
q262545
ProfilerServiceProvider.registerBaseCollectors
test
protected static function registerBaseCollectors( ContainerInterface $container, ProfilerContract $profiler, array $options ): void { if ($options['collector']['time']) { $profiler->addCollector(new TimeDataCollector( $container->get(ServerRequestInterface::class) )); } if ($options['collector']['memory']) { $profiler->addCollector(new MemoryDataCollector()); } if ($options['collector']['ajax']) { $profiler->addCollector(new AjaxRequestsDataCollector()); } if ($options['collector']['phpinfo']) { $profiler->addCollector(new PhpInfoDataCollector()); } }
php
{ "resource": "" }
q262546
ProfilerServiceProvider.registerCollectorsFromConfig
test
private static function registerCollectorsFromConfig( ContainerInterface $container, ProfilerContract $profiler, array $options ): void { if ($collectors = $options['collectors']) { foreach ($collectors as $collector) { $profiler->addCollector($container->get($collector)); } } }
php
{ "resource": "" }
q262547
SessionServiceProvider.extendEventManager
test
public static function extendEventManager( ContainerInterface $container, ?EventManagerContract $eventManager = null ): ?EventManagerContract { if ($eventManager !== null) { $eventManager->attach(TerminableContract::TERMINATE, static function (EventContract $event): void { /** @var StoreContract $driver */ $driver = $event->getTarget()->getContainer()->get(SessionManager::class)->getDriver(); if (! $driver->getHandler() instanceof CookieSessionHandler) { $driver->save(); } }); } return $eventManager; }
php
{ "resource": "" }
q262548
SessionServiceProvider.createSessionManager
test
public static function createSessionManager(ContainerInterface $container): SessionManager { $manager = new SessionManager($container->get('config')); if ($container->has(CacheManagerContract::class)) { $manager->setCacheManager($container->get(CacheManagerContract::class)); } if ($container->has(JarContract::class)) { $manager->setCookieJar($container->get(JarContract::class)); } return $manager; }
php
{ "resource": "" }
q262549
RoutingServiceProvider.createRouteDispatcher
test
public static function createRouteDispatcher( ContainerInterface $container, ?callable $getPrevious = null ): DispatcherContract { // @codeCoverageIgnoreStart if (\is_callable($getPrevious)) { $dispatcher = $getPrevious(); } elseif (\class_exists(Pipeline::class)) { $dispatcher = new MiddlewareBasedDispatcher(); } else { $dispatcher = new SimpleDispatcher(); } // @codeCoverageIgnoreStop if ($container->has(EventManagerContract::class)) { $dispatcher->setEventManager($container->get(EventManagerContract::class)); } return $dispatcher; }
php
{ "resource": "" }
q262550
RoutingServiceProvider.createRouter
test
public static function createRouter(ContainerInterface $container): RouterContract { $router = new Router($container->get(DispatcherContract::class)); $router->setContainer($container); return $router; }
php
{ "resource": "" }
q262551
RoutingServiceProvider.createUrlGenerator
test
public static function createUrlGenerator(ContainerInterface $container): ?UrlGeneratorContract { if (! $container->has(UriFactoryInterface::class)) { return null; } return new UrlGenerator( $container->get(RouterContract::class)->getRoutes(), $container->get(ServerRequestInterface::class), $container->get(UriFactoryInterface::class) ); }
php
{ "resource": "" }
q262552
EnvironmentDetector.detectConsoleEnvironment
test
protected function detectConsoleEnvironment(Closure $callback, array $args): string { // First we will check if an environment argument was passed via console arguments // and if it was that automatically overrides as the environment. Otherwise, we // will check the environment as a "web" request like a typical HTTP request. $value = $this->getEnvironmentArgument($args); if ($value !== null) { $arr = \array_slice(\explode('=', $value), 1); return \reset($arr); } return $this->detectWebEnvironment($callback); }
php
{ "resource": "" }
q262553
EnvironmentDetector.getEnvironmentArgument
test
protected function getEnvironmentArgument(array $args): ?string { $callback = static function ($v) { return self::startsWith($v, '--env'); }; foreach ($args as $key => $value) { if ($callback($value)) { return $value; } } return null; }
php
{ "resource": "" }
q262554
AssetController.js
test
public function js(): ResponseInterface { $renderer = $this->profiler->getAssetsRenderer(); $stream = $this->streamFactory->createStream( $renderer->dumpAssetsToString('js') ); $response = $this->responseFactory->createResponse(); $response = $response->withHeader('content-type', 'text/js'); return $response->withBody($stream); }
php
{ "resource": "" }
q262555
TomlDumper.fromArray
test
private function fromArray(array $data, TomlBuilder $builder, string $parent = ''): TomlBuilder { foreach ($data as $key => $value) { if (\is_array($value)) { if ($this->hasStringKeys($value)) { $key = $parent !== '' ? "${parent}.${key}" : $key; if (\mb_strpos($key, '.') !== false) { $builder->addTable($key); } $builder = $this->fromArray($value, $builder, $key); } elseif ($this->onlyArrays($value)) { $builder = $this->processArrayOfArrays($value, $key, $builder); } else { // Plain array. $builder->addValue($key, $value); } } else { // Simple key/value. $builder->addValue($key, $value); } } return $builder; }
php
{ "resource": "" }
q262556
TomlDumper.processArrayOfArrays
test
private function processArrayOfArrays(array $values, string $parent, TomlBuilder $builder): TomlBuilder { $array = []; foreach ($values as $value) { if ($this->hasStringKeys($value)) { $builder->addArrayOfTable($parent); foreach ($value as $key => $val) { if (\is_array($val)) { $builder = $this->processArrayOfArrays($val, "${parent}.${key}", $builder); } else { $builder->addValue($key, $val); } } } else { $array[] = $value; } } if (\count($array) !== 0) { $builder->addValue($parent, $array); } return $builder; }
php
{ "resource": "" }
q262557
DebugCommand.getPrettyMetadata
test
private function getPrettyMetadata(string $type, object $entity): string { if ($type === 'tests') { return ''; } try { $meta = $this->getMetadata($type, $entity); if ($meta === null) { return '(unknown?)'; } } catch (UnexpectedValueException $e) { return ' <error>' . $e->getMessage() . '</error>'; } if ($type === 'globals') { if (\is_object($meta)) { return ' = object(' . \get_class($meta) . ')'; } return ' = ' . \mb_substr(@\json_encode($meta), 0, 50); } if ($type === 'functions') { return '(' . \implode(', ', $meta) . ')'; } if ($type === 'filters') { return \is_array($meta) ? '(' . \implode(', ', $meta) . ')' : ''; } return ''; }
php
{ "resource": "" }
q262558
DebugCommand.getLoaderPaths
test
private function getLoaderPaths(Environment $twig): array { /** @var \Twig\Loader\FilesystemLoader $loader */ $loader = $twig->getLoader(); if (! $loader instanceof FilesystemLoader) { return []; } $loaderPaths = []; foreach ($loader->getNamespaces() as $namespace) { $paths = $loader->getPaths($namespace); if (FilesystemLoader::MAIN_NAMESPACE === $namespace) { $namespace = '(None)'; } else { $namespace = '@' . $namespace; } $loaderPaths[$namespace] = $paths; } return $loaderPaths; }
php
{ "resource": "" }
q262559
DebugCommand.buildTableRows
test
private function buildTableRows(array $loaderPaths): array { $rows = []; $firstNamespace = true; $prevHasSeparator = false; foreach ($loaderPaths as $namespace => $paths) { if (! $firstNamespace && ! $prevHasSeparator && \count($paths) > 1) { $rows[] = ['', '']; } $firstNamespace = false; foreach ($paths as $path) { $rows[] = [$namespace, '- ' . $path]; $namespace = ''; } if (\count($paths) > 1) { $rows[] = ['', '']; $prevHasSeparator = true; } else { $prevHasSeparator = false; } } if ($prevHasSeparator) { \array_pop($rows); } return $rows; }
php
{ "resource": "" }
q262560
AbstractWhoopsDisplayer.getWhoops
test
private function getWhoops(): Whoops { $whoops = new Whoops(); $whoops->allowQuit(false); $whoops->writeToOutput(false); $whoops->pushHandler($this->getHandler()); return $whoops; }
php
{ "resource": "" }
q262561
Router.addWhereClausesToRoute
test
protected function addWhereClausesToRoute(RouteContract $route): void { $where = $route->getAction()['where'] ?? []; $pattern = \array_merge($this->patterns, $where); foreach ($pattern as $name => $value) { $route->where($name, $value); } }
php
{ "resource": "" }
q262562
Router.mergeGroupAttributesIntoRoute
test
protected function mergeGroupAttributesIntoRoute(RouteContract $route): void { $action = $this->mergeWithLastGroup($route->getAction()); $route->setAction($action); }
php
{ "resource": "" }
q262563
Router.convertToControllerAction
test
protected function convertToControllerAction($action): array { if (\is_string($action)) { $action = ['uses' => $action]; } if ($this->hasGroupStack()) { $action['uses'] = $this->prependGroupNamespace($action['uses']); } $action['controller'] = $action['uses']; return $action; }
php
{ "resource": "" }
q262564
Router.prependGroupNamespace
test
protected function prependGroupNamespace(string $uses): string { $group = \end($this->groupStack); return isset($group['namespace']) && \strpos($uses, '\\') !== 0 ? $group['namespace'] . '\\' . $uses : $uses; }
php
{ "resource": "" }
q262565
Router.prefix
test
protected function prefix(string $uri): string { $trimmed = \trim($this->getLastGroupPrefix(), '/') . '/' . \trim($uri, '/'); if (! $trimmed) { return '/'; } if (\strpos($trimmed, '/') === 0) { return $trimmed; } return '/' . $trimmed; }
php
{ "resource": "" }
q262566
Router.updateGroupStack
test
protected function updateGroupStack(array $attributes): void { if ($this->hasGroupStack()) { $attributes = RouteGroup::merge($attributes, \end($this->groupStack)); } $this->groupStack[] = $attributes; }
php
{ "resource": "" }
q262567
SanitizerServiceProvider.createSanitizer
test
public static function createSanitizer(ContainerInterface $container): Sanitizer { $sanitizer = new Sanitizer(); $sanitizer->setContainer($container); return $sanitizer; }
php
{ "resource": "" }
q262568
BootstrapManager.addBeforeBootstrapping
test
public function addBeforeBootstrapping(string $bootstrapper, callable $callback): void { $key = 'bootstrapping: ' . \str_replace('\\', '', $bootstrapper); $this->bootstrappingCallbacks[$key][] = $callback; }
php
{ "resource": "" }
q262569
BootstrapManager.addAfterBootstrapping
test
public function addAfterBootstrapping(string $bootstrapper, callable $callback): void { $key = 'bootstrapped: ' . \str_replace('\\', '', $bootstrapper); $this->bootstrappedCallbacks[$key][] = $callback; }
php
{ "resource": "" }
q262570
BootstrapManager.bootstrapWith
test
public function bootstrapWith(array $bootstraps): void { foreach ($bootstraps as $bootstrap) { $this->callCallbacks( $this->bootstrappingCallbacks, $this->kernel, 'bootstrapping: ', $bootstrap ); $bootstrap::bootstrap($this->kernel); $this->callCallbacks( $this->bootstrappedCallbacks, $this->kernel, 'bootstrapped: ', $bootstrap ); } $this->hasBeenBootstrapped = true; }
php
{ "resource": "" }
q262571
BootstrapManager.callCallbacks
test
private function callCallbacks(array $bootCallbacks, KernelContract $kernel, string $type, string $bootstrap): void { foreach ($bootCallbacks as $name => $callbacks) { if ($type . \str_replace('\\', '', $bootstrap) === $name) { /** @var callable $callback */ foreach ($callbacks as $callback) { $callback($kernel); } } } }
php
{ "resource": "" }
q262572
Store.generateSessionId
test
protected function generateSessionId(): string { return \hash('ripemd160', \uniqid(Str::random(23), true) . Str::random(25) . \microtime(true)); }
php
{ "resource": "" }
q262573
Store.mergeNewFlashes
test
private function mergeNewFlashes(array $keys): void { $values = \array_unique(\array_merge($this->get('_flash.new', []), $keys)); $this->set('_flash.new', $values); }
php
{ "resource": "" }
q262574
Store.loadSession
test
private function loadSession(): bool { $values = $this->readFromHandler(); if (\count($values) === 0) { return false; } $metadata = $values[self::METADATA_NAMESPACE]; $this->firstTrace = $metadata['firstTrace']; $this->lastTrace = $metadata['lastTrace']; $this->regenerationTrace = $metadata['regenerationTrace']; $this->requestsCount = $metadata['requestsCount']; $this->fingerprint = $metadata['fingerprint']; $this->values = \array_merge($this->values, $values); return true; }
php
{ "resource": "" }
q262575
Store.readFromHandler
test
private function readFromHandler(): array { $data = $this->handler->read($this->id); if ($data === '') { return []; } return $this->prepareForReadFromHandler($data); }
php
{ "resource": "" }
q262576
Store.writeToHandler
test
private function writeToHandler(): void { $values = $this->values; $values[self::METADATA_NAMESPACE] = [ 'firstTrace' => $this->firstTrace, 'lastTrace' => $this->lastTrace, 'regenerationTrace' => $this->regenerationTrace, 'requestsCount' => $this->requestsCount, 'fingerprint' => $this->fingerprint, ]; $value = \json_encode($values, \JSON_PRESERVE_ZERO_FRACTION); $this->handler->write( $this->id, $this->prepareForWriteToHandler($value) ); }
php
{ "resource": "" }
q262577
AbstractPaginator.resolveCurrentPage
test
protected function resolveCurrentPage(): int { $query = $this->request->getQueryParams(); if (\array_key_exists($this->pageName, $query)) { $query = $this->secureInput($query); $page = $query[$this->pageName]; if ((int) $page >= 1 && \filter_var($page, \FILTER_VALIDATE_INT) !== false) { return (int) $page; } } return 1; }
php
{ "resource": "" }
q262578
AbstractPaginator.secureInput
test
private function secureInput(array $query): array { $secure = static function (&$v): void { if (! \is_string($v) && ! \is_numeric($v)) { $v = ''; } elseif (\mb_strpos($v, "\0") !== false) { $v = ''; } elseif (! \mb_check_encoding($v, 'UTF-8')) { $v = ''; } }; \array_walk_recursive($query, $secure); return $query; }
php
{ "resource": "" }
q262579
EventsDataCollectorServiceProvider.extendEventManager
test
public static function extendEventManager( ContainerInterface $container, ?EventManager $eventManager = null ): ?TraceableEventManager { if ($eventManager !== null) { $options = self::resolveOptions($container->get('config')); if ($options['collector']['events']) { $eventManager = new TraceableEventManager($eventManager, $container->get(Stopwatch::class)); if ($container->has(LoggerInterface::class)) { $eventManager->setLogger($container->get(LoggerInterface::class)); } } } return $eventManager; }
php
{ "resource": "" }
q262580
LintCommand.getFiles
test
protected function getFiles(array $files, array $directories): array { $foundFiles = []; /** @var \SplFileInfo $file */ foreach ($this->getFinder($directories) as $file) { if (\count($files) !== 0 && ! \in_array($file->getFilename(), $files, true)) { continue; } $foundFiles[] = $file->getRealPath(); } return $foundFiles; }
php
{ "resource": "" }
q262581
LintCommand.getFinder
test
protected function getFinder(array $paths): iterable { $foundFiles = []; $baseDir = (array) $this->argument('dir'); foreach ($baseDir as $dir) { if (\count($paths) !== 0) { foreach ($paths as $path) { $this->findTwigFiles($dir . \DIRECTORY_SEPARATOR . $path, $foundFiles); } } else { $this->findTwigFiles($dir, $foundFiles); } } return $foundFiles; }
php
{ "resource": "" }
q262582
LintCommand.validate
test
protected function validate(string $template, string $file): array { $realLoader = $this->environment->getLoader(); try { $temporaryLoader = new ArrayLoader([$file => $template]); $this->environment->setLoader($temporaryLoader); $nodeTree = $this->environment->parse($this->environment->tokenize(new Source($template, $file))); $this->environment->compile($nodeTree); $this->environment->setLoader($realLoader); } catch (Error $exception) { $this->environment->setLoader($realLoader); return [ 'template' => $template, 'file' => $file, 'valid' => false, 'exception' => $exception, ]; } return [ 'template' => $template, 'file' => $file, 'valid' => true, ]; }
php
{ "resource": "" }
q262583
LintCommand.display
test
protected function display(array $details, string $format = 'txt'): int { $verbose = $this->getOutput()->isVerbose(); switch ($format) { case 'txt': return $this->displayText($details, $verbose); case 'json': return $this->displayJson($details); default: throw new InvalidArgumentException(\sprintf('The format [%s] is not supported.', $format)); } }
php
{ "resource": "" }
q262584
LintCommand.displayText
test
protected function displayText(array $details, bool $verbose = false): int { $errors = 0; foreach ($details as $info) { if ($verbose && $info['valid']) { $file = ' in ' . $info['file']; $this->line('<info>OK</info>' . $file); } elseif (! $info['valid']) { $errors++; $this->renderException($info); } } if ($errors === 0) { $this->comment(\sprintf('All %d Twig files contain valid syntax.', \count($details))); } else { $this->warn(\sprintf('%d Twig files have valid syntax and %d contain errors.', \count($details) - $errors, $errors)); } return \min($errors, 1); }
php
{ "resource": "" }
q262585
MiddlewareNameResolver.parseMiddlewareGroup
test
protected static function parseMiddlewareGroup( string $name, array $map, array $middlewareGroups, array $disabledMiddleware ): array { $results = []; foreach ($middlewareGroups[$name] as $middleware) { $name = \is_object($middleware) ? \get_class($middleware) : $middleware; if (isset($disabledMiddleware[$name]) || \in_array($name, $disabledMiddleware, true)) { continue; } // If the middleware is another middleware group we will pull in the group and // merge its middleware into the results. This allows groups to conveniently // reference other groups without needing to repeat all their middleware. if (\is_string($middleware) && isset($middlewareGroups[$middleware])) { $results = \array_merge( $results, self::parseMiddlewareGroup($middleware, $map, $middlewareGroups, $disabledMiddleware) ); continue; } // If this middleware is actually a route middleware, we will extract the full // class name out of the middleware list now. Then we'll add the parameters // back onto this class' name so the pipeline will properly extract them. if (isset($map[$name])) { $middleware = $map[$name]; } $results[] = $middleware; } return $results; }
php
{ "resource": "" }
q262586
OptionsResolverTrait.checkMandatoryOptions
test
private static function checkMandatoryOptions( string $configClass, array $mandatoryOptions, $config, array $interfaces ): void { foreach ($mandatoryOptions as $key => $mandatoryOption) { $useRecursion = ! \is_scalar($mandatoryOption); if (! $useRecursion && \array_key_exists($mandatoryOption, (array) $config)) { continue; } if ($useRecursion && isset($config[$key])) { self::checkMandatoryOptions($configClass, $mandatoryOption, $config[$key], $interfaces); return; } throw new MandatoryOptionNotFoundException( isset($interfaces[RequiresComponentConfigContract::class]) ? $configClass::getDimensions() : [], $useRecursion ? $key : $mandatoryOption ); } }
php
{ "resource": "" }
q262587
OptionsResolverTrait.getConfigurationDimensions
test
private static function getConfigurationDimensions( array $dimensions, $config, string $configClass, array $interfaces, ?string $configId ) { foreach ($dimensions as $dimension) { if ((array) $config !== $config && ! $config instanceof ArrayAccess) { throw new UnexpectedValueException($dimensions, $dimension); } if (! isset($config[$dimension])) { if (! isset($interfaces[RequiresMandatoryOptionsContract::class]) && isset($interfaces[ProvidesDefaultOptionsContract::class]) ) { break; } throw new OptionNotFoundException($configClass, $dimension, $configId); } $config = $config[$dimension]; } return $config; }
php
{ "resource": "" }
q262588
OptionsResolverTrait.validateOptions
test
private static function validateOptions(array $validators, $config, string $configClass): void { foreach ($validators as $key => $values) { if (! \array_key_exists($key, (array) $config)) { continue; } if (\is_array($values) && isset($values[0]) && \is_string($values[0])) { $hasError = false; foreach ($values as $check) { if ($hasError === false && \array_key_exists($check, self::$defaultTypeMap)) { $fn = self::$defaultTypeMap[$check]; $hasError = $fn($config[$key]); } } if (! $hasError) { throw InvalidArgumentException::invalidType($key, $config[$key], $values, $configClass); } continue; } if (\is_callable($values)) { $values($config[$key], $key); continue; } if (! \is_array($values) && ! \is_callable($values)) { throw new InvalidValidatorException(\sprintf( 'The validator must be of type callable or string[]; [%s] given, in [%s].', \is_object($values) ? \get_class($values) : \gettype($values), $configClass )); } self::validateOptions((array) $values, $config[$key], $configClass); } }
php
{ "resource": "" }
q262589
OptionsResolverTrait.checkDeprecatedOptions
test
private static function checkDeprecatedOptions(string $configClass, array $deprecatedOptions, $config): void { foreach ($deprecatedOptions as $key => $deprecationMessage) { if (\is_array($deprecationMessage)) { self::checkDeprecatedOptions($configClass, $deprecationMessage, $config[$key]); continue; } if (\is_int($key)) { $key = $deprecationMessage; $deprecationMessage = 'The option [%s] is deprecated.'; } if (! \array_key_exists($key, (array) $config)) { throw new InvalidArgumentException(\sprintf( 'Option [%s] cant be deprecated, because it does not exist, in [%s].', $key, $configClass )); } if (! \is_string($deprecationMessage)) { throw new InvalidArgumentException(\sprintf( 'Invalid deprecation message value provided for [%s]; Expected [string], but got [%s], in [%s].', $key, (\is_object($deprecationMessage) ? \get_class($deprecationMessage) : \gettype($deprecationMessage)), $configClass )); } if (empty($deprecationMessage)) { throw new InvalidArgumentException(\sprintf( 'Deprecation message cant be empty, for option [%s], in [%s].', $key, $configClass )); } @\trigger_error(\sprintf($deprecationMessage, $key), \E_USER_DEPRECATED); } }
php
{ "resource": "" }
q262590
ResourceRegistrar.register
test
public function register(string $name, string $controller, array $options = []): void { if (isset($options['parameters']) && \count($this->parameters) === 0) { $this->parameters = (array) $options['parameters']; } // If the resource name contains a slash, we will assume the developer wishes to // register these resource routes with a prefix so we will set that up out of // the box so they don't have to mess with it. Otherwise, we will continue. if (\strpos($name, '/') !== false) { $this->prefixedResource($name, $controller, $options); return; } // We need to extract the base resource from the resource name. $baseResource = \explode('.', $name); $resource = \end($baseResource); // Wildcards for a single or nested resource may be overridden using the wildcards option. // Overrides are performed by matching the wildcards key with the resource name. If a key // matches a resource name, the value of the wildcard is used instead of the resource name. if (isset($options['wildcards'][$resource])) { $resource = $options['wildcards'][$resource]; } // Nested resources are supported in the framework, but we need to know what // name to use for a place-holder on the route wildcards, which should be // the base resources. $base = $this->getResourceWildcard($resource); $defaults = self::$resourceDefaults; foreach ($this->getResourceMethods($defaults, $options) as $m) { $this->{'addResource' . \ucfirst($m)}($name, $base, $controller, $options); } }
php
{ "resource": "" }
q262591
ResourceRegistrar.getResourceUri
test
public function getResourceUri(string $resource, array $options): string { if (\strpos($resource, '.') === false) { return $resource; } // Once we have built the base URI, we'll remove the parameter holder for this // base resource name so that the individual route adders can suffix these // paths however they need to, as some do not have any parameters at all. $segments = \explode('.', $resource); $uri = $this->getNestedResourceUri($segments, $options); $resource = \end($segments); if (isset($options['wildcards'][$resource])) { $resource = $options['wildcards'][$resource]; } return \str_replace('/{' . $this->getResourceWildcard($resource) . '}', '', $uri); }
php
{ "resource": "" }
q262592
ResourceRegistrar.getResourceWildcard
test
public function getResourceWildcard(string $value): string { if (isset($this->parameters[$value])) { $value = $this->parameters[$value]; } elseif (isset(static::$parameterMap[$value])) { $value = static::$parameterMap[$value]; } elseif (static::$singularParameters || \array_search('singular', $this->parameters, true) !== false) { $value = Str::singular($value); } return \str_replace('-', '_', $value); }
php
{ "resource": "" }
q262593
ResourceRegistrar.getResourcePrefix
test
protected function getResourcePrefix(string $name): array { $segments = \explode('/', $name); // To get the prefix, we will take all of the name segments and implode them on // a slash. This will generate a proper URI prefix for us. Then we take this // last segment, which will be considered the final resources name we use. $prefix = \implode('/', \array_slice($segments, 0, -1)); return [\end($segments), $prefix]; }
php
{ "resource": "" }
q262594
ResourceRegistrar.addResourceDestroy
test
protected function addResourceDestroy(string $name, string $base, string $controller, array $options): RouteContract { $uri = $this->getResourceUri($name, $options) . '/{' . $base . '}'; $action = $this->getResourceAction($name, $controller, 'destroy', $options); return $this->router->delete($uri, $action); }
php
{ "resource": "" }
q262595
ResourceRegistrar.getNestedResourceUri
test
protected function getNestedResourceUri(array $segments, array $options): string { // We will spin through the segments and create a place-holder for each of the // resource segments, as well as the resource itself. Then we should get an // entire string for the resource URI that contains all nested resources. return \implode('/', \array_map(function ($s) use ($options) { $wildcard = $s; //If a wildcard for a resource has been set to be overridden if (isset($options['wildcards'][$s])) { $wildcard = $options['wildcards'][$s]; } return $s . '/{' . $this->getResourceWildcard($wildcard) . '}'; }, $segments)); }
php
{ "resource": "" }
q262596
ResourceRegistrar.getResourceAction
test
protected function getResourceAction(string $resource, string $controller, string $method, array $options): array { $name = $this->getResourceRouteName($resource, $method, $options); $action = ['as' => $name, 'uses' => $controller . '@' . $method]; if (isset($options['middleware'])) { $action['middleware'] = $options['middleware']; } if (isset($options['bypass'])) { $action['bypass'] = $options['bypass']; } return $action; }
php
{ "resource": "" }
q262597
ResourceRegistrar.getResourceRouteName
test
protected function getResourceRouteName(string $resource, string $method, array $options): string { $name = $resource; // If the names array has been provided to us we will check for an entry in the // array first. We will also check for the specific method within this array // so the names may be specified on a more "granular" level using methods. if (isset($options['names'])) { if (\is_string($options['names'])) { $name = $options['names']; } elseif (isset($options['names'][$method])) { return $options['names'][$method]; } } // If a global prefix has been assigned to all names for this resource, we will // grab that so we can prepend it onto the name when we create this name for // the resource action. Otherwise we'll just use an empty string for here. $prefix = isset($options['as']) ? $options['as'] . '.' : ''; return \trim(\sprintf('%s%s.%s', $prefix, $name, $method), '.'); }
php
{ "resource": "" }
q262598
Pipeline.sliceThroughContainer
test
protected function sliceThroughContainer($traveler, $stack, string $stage) { [$name, $parameters] = $this->parseStageString($stage); $parameters = \array_merge([$traveler, $stack], $parameters); $class = null; if ($this->container->has($name)) { $class = $this->container->get($name); } elseif ($this->container instanceof FactoryContract) { $class = $this->container->resolve($name); } else { throw new RuntimeException(\sprintf('Class [%s] is not being managed by the container.', $name)); } return $this->getInvoker()->call([$class, $this->method], $parameters); }
php
{ "resource": "" }
q262599
Pipeline.getRequestHandlerMiddleware
test
private function getRequestHandlerMiddleware(callable $middleware): RequestHandlerInterface { return new class($middleware) implements RequestHandlerInterface { /** * @var callable */ private $middleware; /** * Create a new delegate callable middleware instance. * * @param callable $middleware */ public function __construct(callable $middleware) { $this->middleware = $middleware; } /** * {@inheritdoc} */ public function handle(ServerRequestInterface $request): ResponseInterface { return \call_user_func($this->middleware, $request); } }; }
php
{ "resource": "" }