_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q268100
RequestApplication.handleRequest
test
public function handleRequest() { //Wait for static application initialization $staticInitPromise = !Reaction::$app->initialized ? Reaction::$app->initPromise : Reaction\Promise\resolve(true); return $staticInitPromise //Load Request app components ->then(function() { return $this->loadComponents(); //Try to resolve request action })->then(function() { return $this->resolveAction(); //Handle exceptions })->otherwise(function($exception) { if (Reaction::isConsoleApp() && $exception instanceof Reaction\Exceptions\Http\NotFoundException) {
php
{ "resource": "" }
q268101
RequestApplication.resolveAction
test
public function resolveAction($routePath = null, $method = null, $params = null)
php
{ "resource": "" }
q268102
RequestApplication.getHomeUrl
test
public function getHomeUrl() { return isset($this->homeUrl)
php
{ "resource": "" }
q268103
RequestApplication.set
test
public function set($id, $definition) { unset($this->_components[$id]); if ($definition === null) { unset($this->_definitions[$id]); return; } //Extract definition from DI Definition if ($definition instanceof \Reaction\DI\Definition) { $definition = $definition->dumpArrayDefinition(); } if (is_string($definition)) { $config = ['class' => $definition]; } elseif (ArrayHelper::isIndexed($definition) && count($definition) === 2) { $config = $definition[0]; $params = $definition[1]; } else { $config = $definition; } if (is_array($config)) { $config = ArrayHelper::merge(['app' => $this], $config); $definition = isset($params) ? [$config, $params] : $config; } if (is_object($definition) || is_callable($definition, true)) { // an object, a class name, or a PHP callable $this->_definitions[$id] = $definition;
php
{ "resource": "" }
q268104
ParamUsersRepository.restaureUtilisateur
test
public function restaureUtilisateur($idUser) { $oQb = $this->createQueryBuilder('U'); $oQb->update() ->set('U.dateSuppression', 'NULL') ->where($oQb->expr()->eq('U.id',
php
{ "resource": "" }
q268105
ParamUsersRepository.getUserById
test
public function getUserById($id) { $oQB = $this->createQueryBuilder('U'); $oQB->select() ->where($oQB->expr()->eq('U.id', ':id')) ->setParameter(':id', $id);
php
{ "resource": "" }
q268106
ParamUsersRepository.getActive
test
public function getActive() { $oDelay = new \DateTime('now'); $oDelay->setTimestamp(strtotime('2 minutes ago')); $oQb = $this->createQueryBuilder('U');
php
{ "resource": "" }
q268107
GettextMoFile.save
test
public function save($messages, $filePath = null) { if (false === ($fileHandle = @fopen($filePath, 'wb'))) { throw new Exception('Unable to write file "' . $filePath . '".'); } if (false === @flock($fileHandle, LOCK_EX)) { throw new Exception('Unable to lock file "' . $filePath . '" for reading.'); } // magic if ($this->useBigEndian) { $this->writeBytes($fileHandle, pack('c*', 0x95, 0x04, 0x12, 0xde)); // -107 } else { $this->writeBytes($fileHandle, pack('c*', 0xde, 0x12, 0x04, 0x95)); // -34 } // revision $this->writeInteger($fileHandle, 0); // message count $messageCount = count($messages); $this->writeInteger($fileHandle, $messageCount); // offset of source message table $offset = 28; $this->writeInteger($fileHandle, $offset); $offset += $messageCount * 8; $this->writeInteger($fileHandle, $offset); // hashtable size, omitted $this->writeInteger($fileHandle, 0); $offset += $messageCount * 8; $this->writeInteger($fileHandle, $offset); // length and offsets for source messages foreach (array_keys($messages) as $id) { $length = strlen($id);
php
{ "resource": "" }
q268108
ListTools.find
test
public static function find($list, $value, $delimiter = ',')
php
{ "resource": "" }
q268109
ActiveQueryTrait.findWith
test
public function findWith($with, &$models) { $primaryModel = reset($models); if (!$primaryModel instanceof ActiveRecordInterface) { /* @var $modelClass ActiveRecordInterface */ $modelClass = $this->modelClass; $primaryModel = $modelClass::instance(); } $relations = $this->normalizeRelations($primaryModel, $with); /* @var $relation ActiveQuery */ $promises = []; foreach ($relations as $name => $relation) { if ($relation->asArray === null) {
php
{ "resource": "" }
q268110
DataReader.read
test
public function read() { $this->next(); if (!$this->valid()) { return false; } /** @var array|false $fetched */
php
{ "resource": "" }
q268111
DataReader.readColumn
test
public function readColumn($columnIndex) { $this->next(); if (!$this->valid()) { return false; }
php
{ "resource": "" }
q268112
DataReader.readObject
test
public function readObject($className = 'stdClass', $fields = []) { $this->next(); if (!$this->valid()) { return false; } $obj = new $className($fields);
php
{ "resource": "" }
q268113
DataReader.readAll
test
public function readAll() { /** @var array $fetched */ $fetched =
php
{ "resource": "" }
q268114
DataReader.getColumnCount
test
public function getColumnCount() { if (empty($this->_results)) { return 0; }
php
{ "resource": "" }
q268115
Schema.findConstraints
test
protected function findConstraints(&$table) { $tableName = $this->quoteValue($table->name); $tableSchema = $this->quoteValue($table->schemaName); //We need to extract the constraints de hard way since: //http://www.postgresql.org/message-id/26677.1086673982@sss.pgh.pa.us $sql = <<<SQL select ct.conname as constraint_name, a.attname as column_name, fc.relname as foreign_table_name, fns.nspname as foreign_table_schema, fa.attname as foreign_column_name from (SELECT ct.conname, ct.conrelid, ct.confrelid, ct.conkey, ct.contype, ct.confkey, generate_subscripts(ct.conkey, 1) AS s FROM pg_constraint ct ) AS ct inner join pg_class c on c.oid=ct.conrelid inner join pg_namespace ns on c.relnamespace=ns.oid inner join pg_attribute a on a.attrelid=ct.conrelid and a.attnum = ct.conkey[ct.s] left join pg_class fc on fc.oid=ct.confrelid left join pg_namespace fns on fc.relnamespace=fns.oid left join pg_attribute fa on fa.attrelid=ct.confrelid and fa.attnum = ct.confkey[ct.s] where ct.contype='f' and c.relname={$tableName} and ns.nspname={$tableSchema} order by fns.nspname, fc.relname, a.attnum SQL; return $this->db->createCommand($sql)->queryAll()->then( function($_constraints) use (&$table) { $constraints = []; foreach ($_constraints as $constraint) { if ($constraint['foreign_table_schema'] !== $this->defaultSchema) {
php
{ "resource": "" }
q268116
Schema.getServerVersionPromised
test
protected function getServerVersionPromised() { $sql = "SELECT VERSION()"; return $this->db->createCommand($sql)->queryScalar()->then( function($result) {
php
{ "resource": "" }
q268117
Router.publishRoutes
test
protected function publishRoutes() { $routes = $this->routes; $this->parseRoutesData(); $this->dispatcher = $this->createDispatcher(function(\FastRoute\RouteCollector $r) use
php
{ "resource": "" }
q268118
Router.parseRoutesData
test
protected function parseRoutesData() { $routes = $this->routes; foreach ($routes as $routeData) { $path = $routeData['route']; $this->buildPathExpressions($path, true); } foreach ($this->_routePaths as &$routePaths) { $prevCnt
php
{ "resource": "" }
q268119
Router.buildPathExpressions
test
protected function buildPathExpressions($path, $store = false) { $segments = $this->routeParser->parse($path); $expressions = []; foreach ($segments as $segmentGroup) { $expression = ''; $params = []; $staticPart = '/'; $staticPartEnded = false; foreach ($segmentGroup as $segment) { if (is_string($segment)) { $expression .= $segment; if (!$staticPartEnded) { $staticPart .= $segment; } } elseif (is_array($segment)) { $staticPartEnded = true; $expression .= '{' . $segment[0] . '}'; $params[] = $segment[0]; } } $staticPart = '/' . trim($staticPart, '/'); if ($store && !empty($params))
php
{ "resource": "" }
q268120
NativeContainer.alias
test
public function alias(string $alias, string $serviceId): void {
php
{ "resource": "" }
q268121
NativeContainer.bind
test
public function bind(Service $service, bool $verify = true): void { // If there is no id if (null === $service->getId()) { // Throw a new exception throw new InvalidServiceIdException('Invalid service id provided.'); } // If we should verify the dispatch
php
{ "resource": "" }
q268122
NativeContainer.context
test
public function context(ServiceContext $serviceContext): void { $context = $serviceContext->getClass() ?? $serviceContext->getFunction(); $member = $serviceContext->getMethod() ?? $serviceContext->getProperty(); $contextContext = $serviceContext->getContextClass() ?? $serviceContext->getContextFunction(); // If the context index is null then there's no context if (null === $context || null === $serviceContext->getId()) { throw new InvalidContextException('Invalid context.'); } // If the context is the same as the end service dispatch and the // dispatch isn't static throw an error to disallow this
php
{ "resource": "" }
q268123
NativeContainer.getServiceFromContext
test
protected function getServiceFromContext( ServiceContext $serviceContext, string $context = null, string $member = null ): Service { $service = new Service(); $serviceId = $this->contextServiceId( $serviceContext->getId(), $context, $member ); $service ->setId($serviceId) ->setSingleton($serviceContext->isSingleton()) ->setDefaults($serviceContext->getDefaults()) ->setName($serviceContext->getName()) ->setClass($serviceContext->getContextClass()) ->setProperty($serviceContext->getContextProperty()) ->setMethod($serviceContext->getContextMethod())
php
{ "resource": "" }
q268124
NativeContainer.has
test
public function has(string $serviceId): bool {
php
{ "resource": "" }
q268125
NativeContainer.hasContext
test
public function hasContext(string $serviceId, string $context, string $member = null): bool {
php
{ "resource": "" }
q268126
NativeContainer.get
test
public function get(string $serviceId, array $arguments = null, string $context = null, string $member = null) { // If there is a context set for this context and member combination if ( null !== $context && $this->hasContext( $serviceId, $context, $member ) ) { // Return that context return $this->get( $this->contextServiceId($serviceId, $context, $member), $arguments ); } // If there is a context set for this context only if (null !== $context && $this->hasContext($serviceId, $context)) { // Return that context return $this->get( $this->contextServiceId($serviceId, $context), $arguments
php
{ "resource": "" }
q268127
NativeContainer.make
test
public function make(string $serviceId, array $arguments = null) { $service = self::$services[$serviceId]; $arguments = $service->getDefaults() ?? $arguments; // Dispatch before make event $this->app->events()->trigger( ServiceMake::class, [$serviceId, $service, $arguments] ); // Make the object by dispatching the service $made = $this->app->dispatcher()->dispatchCallable($service, $arguments); // Dispatch after make event $this->app->events()->trigger(ServiceMade::class, [$serviceId, $made]); // If the service is a singleton
php
{ "resource": "" }
q268128
NativeContainer.getSingleton
test
public function getSingleton(string $serviceId) { // If the service isn't a singleton but is provided if (! $this->isSingleton($serviceId) && $this->isProvided($serviceId)) { // Initialize the
php
{ "resource": "" }
q268129
NativeContainer.getProvided
test
public function getProvided( string $serviceId, array $arguments = null, string $context = null, string $member = null
php
{ "resource": "" }
q268130
NativeContainer.contextServiceId
test
public function contextServiceId(string $serviceId, string $context = null, string $member = null): string { $index = $serviceId . '@' . ($context ?? ''); // If there is a method if (null !== $member) { // If there is a class if (null !== $context) { // Add the double colon to separate the method name and class $index .= '::';
php
{ "resource": "" }
q268131
NativeContainer.setup
test
public function setup(bool $force = false, bool $useCache = true): void { if (self::$setup && ! $force) { return; } self::$setup = true; // If the application should use the container cache files if ($useCache && $this->app->config()['container']['useCache']) { $this->setupFromCache(); // Then return out of setup return; } self::$registered = []; self::$services = []; self::$provided = []; $useAnnotations = $this->app->config( 'container.useAnnotations', false ); $annotationsEnabled = $this->app->config( 'annotations.enabled', false ); $onlyAnnotations = $this->app->config( 'container.useAnnotationsExclusively', false ); // Setup service providers $this->setupServiceProviders(); // If annotations are enabled and the container should use annotations if ($useAnnotations && $annotationsEnabled) {
php
{ "resource": "" }
q268132
NativeContainer.setupFromCache
test
protected function setupFromCache(): void { // Set the application container with said file $cache = $this->app->config()['cache']['container'] ?? require $this->app->config()['container']['cacheFilePath'];
php
{ "resource": "" }
q268133
NativeContainer.setupServiceProviders
test
protected function setupServiceProviders(): void { /** @var array $providers */ $providers = $this->app->config()['container']['providers']; // Iterate through all the providers foreach ($providers as $provider) { $this->register($provider); } // If this is not a dev environment if (! $this->app->debug()) { return; } /** @var array $devProviders
php
{ "resource": "" }
q268134
NativeContainer.getCacheable
test
public function getCacheable(): array { $this->setup(true, false); return [
php
{ "resource": "" }
q268135
Address.getAddressLines
test
public function getAddressLines() { return array_filter([ $this->getComplex(), implode(' ',
php
{ "resource": "" }
q268136
Zend_Filter_Compress_Gz.setLevel
test
public function setLevel($level) { if (($level < 0) || ($level > 9)) { throw new Zend_Filter_Exception('Level must be between 0 and 9'); }
php
{ "resource": "" }
q268137
Controller.getUniqueId
test
public function getUniqueId() { $group = $this->group(); if ($group !== "") { return $group;
php
{ "resource": "" }
q268138
Controller.registerInRouter
test
public function registerInRouter(Router $router) { $routes = $this->routes(); $group = $this->group(); if (empty($routes)) { return; } foreach ($routes as $row) { $method =
php
{ "resource": "" }
q268139
Controller.resolveAction
test
public function resolveAction(RequestApplicationInterface $app, string $action, ...$params) { $action = $this->normalizeActionName($action); $actionId = static::getActionId($action); if (!in_array($app, $params)) { array_unshift($params, $app); } $self = $this; return $this->validateAction($action, $app)->then( function() use (&$app, &$self, $action, $actionId, $params) { if ($this->beforeAction($actionId)) { $app->view->context = $self; return Reaction::$di->invoke([$self, $action], $params); } else { throw new Exception("Before action error"); } }, function($error) {
php
{ "resource": "" }
q268140
Controller.beforeAction
test
public function beforeAction($actionId) { $isValid = true;
php
{ "resource": "" }
q268141
Controller.afterAction
test
public function afterAction($actionId, $result = null) {
php
{ "resource": "" }
q268142
Controller.renderPartial
test
public function renderPartial(RequestApplicationInterface $app, $viewName, $params = [], $asResponse = false) {
php
{ "resource": "" }
q268143
Controller.renderAjax
test
public function renderAjax(RequestApplicationInterface $app, $viewName, $params = [], $asResponse = false) { return
php
{ "resource": "" }
q268144
Controller.actions
test
public function actions() { if (!isset($this->_actions)) { $reflection = ReflectionHelper::getClassReflection($this); $methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC); $actions = []; foreach ($methods as $method) { $name = $method->getName();
php
{ "resource": "" }
q268145
Controller.renderInLayout
test
protected function renderInLayout(RequestApplicationInterface $app, $viewName, $params = [], $asResponse = false) { $view = $app->view; if (isset($this->layout)) { $layoutFile = $view->findViewFile($this->layout, $this); } else { $layoutFile = $view->findViewFile($view->layout, $this); } $content =
php
{ "resource": "" }
q268146
Controller.renderInternal
test
protected function renderInternal(RequestApplicationInterface $app, $viewName, $params = [], $ajax = false, $asResponse = false) { $view = $app->view; $rendered = $ajax ? $view->renderAjax($viewName, $params, $this) : $view->render($viewName, $params, $this);
php
{ "resource": "" }
q268147
Controller.normalizeActionName
test
protected function normalizeActionName($actionMethod, $throwException = true) { if (!StringHelper::startsWith($actionMethod, 'action')) { $actionMethod = static::getActionMethod($actionMethod); } if (!method_exists($this, $actionMethod)) { if ($throwException)
php
{ "resource": "" }
q268148
Controller.resolveErrorAsHtml
test
protected function resolveErrorAsHtml(RequestApplicationInterface $app, \Throwable $exception) { $actions = ['actionError']; if ($exception instanceof HttpException) { $actions[] = 'actionErrorHttp'; $actions[] = 'actionErrorHttp' . $exception->statusCode; } $action = null; foreach ($actions as $possibleAction) { $action = $this->normalizeActionName($possibleAction, false); if (isset($action)) {
php
{ "resource": "" }
q268149
Controller.resolveErrorAsArray
test
protected function resolveErrorAsArray(RequestApplicationInterface $app, \Throwable $exception) { $data = $this->getErrorData($exception); $responseData = ['error' => $data];
php
{ "resource": "" }
q268150
Controller.getErrorData
test
protected function getErrorData(\Throwable $exception) { $data = [ 'message' => $exception->getMessage(), 'code' => $exception instanceof HttpExceptionInterface ? $exception->statusCode : $exception->getCode(), 'name' => $this->getExceptionName($exception), ]; if (Reaction::isDebug() || Reaction::isDev())
php
{ "resource": "" }
q268151
Controller.getExceptionName
test
protected function getExceptionName($exception) { if ($exception instanceof Exception) { return $exception->getName(); } else {
php
{ "resource": "" }
q268152
Controller.validateAction
test
protected function validateAction($action, RequestApplicationInterface $app) { $annotationsCtrl = Reaction::$annotations->getClass($this); $annotationsAction = Reaction::$annotations->getMethod($action, $this); $annotations = ArrayHelper::merge(array_values($annotationsCtrl), array_values($annotationsAction)); $promises = []; if (!empty($annotations)) { foreach ($annotations as $annotation) { if (!$annotation instanceof CtrlActionValidatorInterface) {
php
{ "resource": "" }
q268153
Controller.getActionId
test
public static function getActionId($actionMethod) { if (strpos($actionMethod, 'action') === 0) { $actionMethod = substr($actionMethod,
php
{ "resource": "" }
q268154
Controller.getActionMethod
test
public static function getActionMethod($actionId = '') { if ($actionId === '') { $actionId = static::$_defaultAction; }
php
{ "resource": "" }
q268155
ColorTools.toHex
test
public static function toHex($color) { // Check it it's a RGB color if (is_array($color)) { if ((count($color) == 3 && array_keys($color) === range(0, 2)) || (count($color) == 4 && array_keys($color) === range(0, 3))) { $red = $color[0]; $green = $color[1]; $blue = $color[2]; } else { $red = isset($color['red']) ?: (isset($color['r']) ?: 0); $red = isset($color['red']) ? $color['red'] : (isset($color['r']) ? $color['r'] : 0); $green = isset($color['green']) ? $color['green']
php
{ "resource": "" }
q268156
ColorTools.toRGBA
test
public static function toRGBA($color) { // Check it it's already a RGB color if (is_array($color)) { if (count($color) == 3 && array_keys($color) === range(0, 2)) { return array( 'red' => $color[0], 'green' => $color[1], 'blue' => $color[2], 'alpha' => 1 ); } if (count($color) == 4 && array_keys($color) === range(0, 3)) { return array( 'red' => $color[0], 'green' => $color[1], 'blue' => $color[2], 'alpha' => $color[3] ); } return array( 'red' => isset($color['red']) ? $color['red'] : (isset($color['r']) ? $color['r'] : 0), 'green' => isset($color['green']) ? $color['green'] : (isset($color['g']) ? $color['g'] : 0), 'blue' => isset($color['blue']) ? $color['blue'] : (isset($color['b']) ? $color['b'] : 0), 'alpha' => isset($color['alpha']) ? $color['alpha'] : 1 ); } if (is_string($color)) { $color = strtolower($color); // Check if it's a X11 color
php
{ "resource": "" }
q268157
ColorTools.imageDominant
test
public static function imageDominant($src, $granularity = 1) { $granularity = max(1, abs((int)$granularity)); $channels = array( 'red' => 0, 'green' => 0, 'blue' => 0 ); $size = @getimagesize($src); if ($size === false) { user_error("Unable to get image size data: ".$src); return false; } $img = @imagecreatefromstring(@file_get_contents($src)); if (!$img) { user_error("Unable to open image file: ".$src); return false; } for($x = 0; $x < $size[0]; $x += $granularity) { for($y = 0; $y < $size[1]; $y += $granularity) { $thisColor = imagecolorat($img, $x, $y); $rgb = imagecolorsforindex($img, $thisColor);
php
{ "resource": "" }
q268158
Console.stdin
test
public static function stdin($raw = false) { $promise = new Promise(function($r, $c) use ($raw) { static::getStdInStream()->once('data', function($chunk) use ($r, $raw) { if (!$raw) {
php
{ "resource": "" }
q268159
Console.select
test
public static function select($prompt, $options = []) { $helpText = ''; foreach ($options as $key => $value) { $helpText .= " $key - $value\n"; } $helpText .= ' ? - Show help'; $promptText = "$prompt [" . implode(',', array_keys($options)) . ',?]: '; $promptOptions = [ 'required' => true,
php
{ "resource": "" }
q268160
FileAppenderTrait._appendFileToPaths
test
protected function _appendFileToPaths(array $paths, $file) { if (!$this->_isAtom($file)) { return [$file]; } $appendFile = function($path) use($file) { return
php
{ "resource": "" }
q268161
Database.getPgClient
test
protected function getPgClient() { if (!isset($this->_pgClient)) { $config = [ 'dbCredentials' => [ 'host' => $this->host, 'port' => $this->port, 'user' => $this->username, 'password' => $this->password, 'database' => $this->database, ],
php
{ "resource": "" }
q268162
Database.executeSql
test
public function executeSql($sql, $params = [], $lazy = true) { list($sql, $params) = $this->convertSqlToIndexed($sql, $params); $promiseResolver = function($r, $c) use ($sql, $params) { $result = []; $this->getPgClient()->executeStatement($sql, $params)->subscribe( function($row) use (&$result) { $result[] = $row; }, function($error = null) use (&$c) { $c($error); }, function() use (&$r, &$result) { $r($result);
php
{ "resource": "" }
q268163
NativeUploadedFile.writeStream
test
protected function writeStream(string $path): void { // Attempt to open the path specified $handle = fopen($path, 'wb+'); // If the handler failed to open if (false === $handle) { // Throw a runtime exception throw new RuntimeException( 'Unable to write to designated path' ); } // Get the stream $stream = $this->getStream(); // Rewind the stream
php
{ "resource": "" }
q268164
ServerRequestFactory.fromGlobals
test
public static function fromGlobals( array $server = null, array $query = null, array $body = null, array $cookies = null, array $files = null ): ServerRequest { $server = static::normalizeServer($server ?: $_SERVER); $files = static::normalizeFiles($files ?: $_FILES); $headers = static::marshalHeaders($server); if (null ===
php
{ "resource": "" }
q268165
ServerRequestFactory.getHeader
test
public static function getHeader(string $header, array $headers, $default = null): string { $header = strtolower($header); $headers = array_change_key_case($headers, CASE_LOWER); if (array_key_exists($header, $headers)) {
php
{ "resource": "" }
q268166
ServerRequestFactory.stripQueryString
test
public static function stripQueryString(string $path): string { if (($queryPos = strpos($path, '?')) !== false) {
php
{ "resource": "" }
q268167
ServerRequestFactory.marshalHostAndPortFromHeader
test
private static function marshalHostAndPortFromHeader(stdClass $accumulator, $host): void { if (\is_array($host)) { $host = implode(', ', $host); } $accumulator->host = $host; $accumulator->port = null; // Works for regname, IPv4 & IPv6 if
php
{ "resource": "" }
q268168
ServerRequestFactory.normalizeNestedFileSpec
test
private static function normalizeNestedFileSpec(array $files = []): array { $normalizedFiles = []; foreach (array_keys($files['tmp_name']) as $key) { $spec = [ 'tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key], 'error' => $files['error'][$key], 'name' => $files['name'][$key],
php
{ "resource": "" }
q268169
Str.endsWith
test
public static function endsWith($needle, $str) {
php
{ "resource": "" }
q268170
Str.random
test
public static function random($charsAmount, $chars = array()) { if (!$chars) { $chars = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
php
{ "resource": "" }
q268171
VersionPathSearch.createEdges
test
private function createEdges(Graph $graph, $className) { $migrationsAnnotations = $this->reader->getClassMigrationMethodInfo($className); $parentVertex = $graph->hasVertex($className) ? $graph->getVertex($className) : $graph->createVertex( $className ); foreach ($migrationsAnnotations as $migrationsAnnotation) { if ($migrationsAnnotation->annotation->from) { $fromClass = $migrationsAnnotation->annotation->from; $fromVertex = $graph->hasVertex($fromClass) ? $graph->getVertex($fromClass) : $graph->createVertex( $fromClass ); if (!$parentVertex->hasEdgeTo($fromVertex)) { $edge = $fromVertex->createEdgeTo($parentVertex); $this->annotations[$this->getEdgeId($edge)] = $migrationsAnnotation; $this->createEdges($graph, $fromClass); } }
php
{ "resource": "" }
q268172
VersionPathSearch.find
test
public function find($fromClassName, $toClassName) { $annotations = array(); $graph = new Graph(); $this->createEdges($graph, $fromClassName); $this->createEdges($graph, $toClassName); try { $breadFirst = new BreadthFirst($graph->getVertex($fromClassName)); $edges = $breadFirst->getEdgesTo($graph->getVertex($toClassName)); /** @var Directed $edge */
php
{ "resource": "" }
q268173
EntityRepositoryResource.create
test
public function create($data) { $data = $this->sanitizeData((array)$data); return
php
{ "resource": "" }
q268174
EntityRepositoryResource.fetchAll
test
public function fetchAll($params = array()) { $criteria = $params->get('query', []); $orderBy = $params->get('order_by', []);
php
{ "resource": "" }
q268175
EntityRepositoryResource.update
test
public function update($id, $data) { $data = $this->sanitizeData((array)$data); return
php
{ "resource": "" }
q268176
NativeResponse.setStatusCode
test
public function setStatusCode(int $code, string $text = null): Response { $this->statusCode = $code; // Check if the status code is valid if ($this->isInvalid()) { throw new InvalidStatusCodeException( sprintf('The HTTP status code "%s" is not valid.', $code) ); } // If no text was supplied if (null === $text) { // Set the
php
{ "resource": "" }
q268177
NativeResponse.setHeaders
test
public function setHeaders(array $headers = []): Response { // If the headers have no been set yet if (null === $this->headers) { // Set them to a new Headers collection $this->headers = new Headers(); } // Set all the headers with the array provided $this->headers->setAll($headers);
php
{ "resource": "" }
q268178
NativeResponse.getDateHeader
test
public function getDateHeader(): DateTime { if (! $this->headers->has('Date')) {
php
{ "resource": "" }
q268179
NativeResponse.setDateHeader
test
public function setDateHeader(DateTime $date): Response { $date->setTimezone(new DateTimeZone('UTC'));
php
{ "resource": "" }
q268180
NativeResponse.addCacheControl
test
public function addCacheControl(string $name, string $value = null): Response {
php
{ "resource": "" }
q268181
NativeResponse.getCacheControl
test
public function getCacheControl(string $name): string { return $this->hasCacheControl($name)
php
{ "resource": "" }
q268182
NativeResponse.removeCacheControl
test
public function removeCacheControl(string $name): Response { if (! $this->hasCacheControl($name)) {
php
{ "resource": "" }
q268183
NativeResponse.isCacheable
test
public function isCacheable(): bool { if (! \in_array( $this->statusCode, [ StatusCode::OK, StatusCode::NON_AUTHORITATIVE_INFORMATION, StatusCode::MULTIPLE_CHOICES, StatusCode::MOVED_PERMANENTLY,
php
{ "resource": "" }
q268184
NativeResponse.getAge
test
public function getAge(): int { if (null !== $age = $this->headers->get('Age')) { return $age; } return max(
php
{ "resource": "" }
q268185
NativeResponse.expire
test
public function expire(): Response { if ($this->isFresh()) {
php
{ "resource": "" }
q268186
NativeResponse.getExpires
test
public function getExpires(): DateTime { try { return $this->headers->get('Expires'); } catch (\RuntimeException $e) { // according to RFC 2616 invalid date formats (e.g. "0" and "-1") // must be treated as in the past
php
{ "resource": "" }
q268187
NativeResponse.getMaxAge
test
public function getMaxAge(): int { if ($this->hasCacheControl('s-maxage')) { return $this->getCacheControl('s-maxage'); } if ($this->hasCacheControl('max-age')) { return $this->getCacheControl('max-age'); } if (null !== $this->getExpires()) { return
php
{ "resource": "" }
q268188
NativeResponse.setSharedMaxAge
test
public function setSharedMaxAge(int $value): Response { $this->setPublic();
php
{ "resource": "" }
q268189
NativeResponse.setTtl
test
public function setTtl(int $seconds): Response {
php
{ "resource": "" }
q268190
NativeResponse.setNotModified
test
public function setNotModified(): Response { $this->setStatusCode(StatusCode::NOT_MODIFIED); $this->setContent(null); $this->headers ->remove('Allow') ->remove('Content-Encoding') ->remove('Content-Language')
php
{ "resource": "" }
q268191
NativeResponse.isInvalid
test
public function isInvalid(): bool { return $this->statusCode <
php
{ "resource": "" }
q268192
NativeResponse.isInformational
test
public function isInformational(): bool { return $this->statusCode >= StatusCode::CONTINUE
php
{ "resource": "" }
q268193
NativeResponse.isSuccessful
test
public function isSuccessful(): bool { return $this->statusCode >=
php
{ "resource": "" }
q268194
NativeResponse.isRedirection
test
public function isRedirection(): bool { return $this->statusCode >= StatusCode::MULTIPLE_CHOICES
php
{ "resource": "" }
q268195
NativeResponse.isClientError
test
public function isClientError(): bool { return $this->statusCode >=
php
{ "resource": "" }
q268196
NativeResponse.isRedirect
test
public function isRedirect(string $location = null): bool { return \in_array( $this->statusCode, [ StatusCode::CREATED, StatusCode::MOVED_PERMANENTLY, StatusCode::FOUND, StatusCode::SEE_OTHER, StatusCode::TEMPORARY_REDIRECT,
php
{ "resource": "" }
q268197
NativeResponse.isEmpty
test
public function isEmpty(): bool { return \in_array( $this->statusCode, [ StatusCode::NO_CONTENT,
php
{ "resource": "" }
q268198
NativeResponse.closeOutputBuffers
test
public static function closeOutputBuffers(int $targetLevel, bool $flush): void { $status = ob_get_status(true); $level = \count($status); // PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3 $flags = \defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; while (
php
{ "resource": "" }
q268199
RequestTrait.initialize
test
protected function initialize( Uri $uri = null, string $method = null, Stream $body = null, array $headers = null ): void { $this->uri = $uri ?? new NativeUri(); $this->method = $method ?? RequestMethod::GET; $this->body = $body ?? new NativeStream('php://input'); $this->headers = $headers ?? []; $this->setHeaders($headers); $this->validateMethod($this->method);
php
{ "resource": "" }