_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() {...
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) { $...
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 "' ....
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(); } ...
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 $s...
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; ...
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->getCon...
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, $memb...
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, $cont...
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, $ser...
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) { ...
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']) { ...
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...
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; ...
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 = $meth...
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($vie...
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; } $...
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), ]; ...
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($a...
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 =...
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], 'alph...
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:...
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)) . ',?]: '; $prom...
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, ...
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( ...
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( 'Unabl...
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 ?...
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], ...
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', '...
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 ($migrat...
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)); ...
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) ...
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 ...
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()) { ...
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, ...
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 ...
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('ph...
php
{ "resource": "" }