_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q254700 | Autoloader.discoverComposerNamespaces | test | protected function discoverComposerNamespaces()
{
if (! is_file(COMPOSER_PATH))
{
return false;
}
$composer = include COMPOSER_PATH;
$paths = $composer->getPrefixesPsr4();
unset($composer);
// Get rid of CodeIgniter so we don't have duplicates
if (isset($paths['CodeIgniter\\']))
{
unset($pat... | php | {
"resource": ""
} |
q254701 | Filters.date_modify | test | public static function date_modify($value, string $adjustment): string
{
$value = static::date($value, 'Y-m-d H:i:s');
return strtotime($adjustment, strtotime($value));
} | php | {
"resource": ""
} |
q254702 | Filters.excerpt | test | public static function excerpt(string $value, string $phrase, int $radius = 100): string
{
helper('text');
return excerpt($value, $phrase, $radius);
} | php | {
"resource": ""
} |
q254703 | DotEnv.sanitizeValue | test | protected function sanitizeValue(string $value): string
{
if (! $value)
{
return $value;
}
// Does it begin with a quote?
if (strpbrk($value[0], '"\'') !== false)
{
// value starts with a quote
$quote = $value[0];
$regexPattern = sprintf(
'/^
%1$s # match a quote at t... | php | {
"resource": ""
} |
q254704 | DotEnv.resolveNestedVariables | test | protected function resolveNestedVariables(string $value): string
{
if (strpos($value, '$') !== false)
{
$loader = $this;
$value = preg_replace_callback(
'/\${([a-zA-Z0-9_]+)}/',
function ($matchedPatterns) use ($loader) {
$nestedVariable = $loader->getVariable($matchedPatterns[1]);
if (is... | php | {
"resource": ""
} |
q254705 | Connection.setDatabase | test | public function setDatabase(string $databaseName): bool
{
if ($databaseName === '')
{
$databaseName = $this->database;
}
if (empty($this->connID))
{
$this->initialize();
}
if ($this->connID->select_db($databaseName))
{
$this->database = $databaseName;
return true;
}
return false;
} | php | {
"resource": ""
} |
q254706 | Connection.execute | test | public function execute(string $sql)
{
while ($this->connID->more_results())
{
$this->connID->next_result();
if ($res = $this->connID->store_result())
{
$res->free();
}
}
return $this->connID->query($this->prepQuery($sql));
} | php | {
"resource": ""
} |
q254707 | Connection.prepQuery | test | protected function prepQuery(string $sql): string
{
// mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack
// modifies the query so that it a proper number of affected rows is returned.
if ($this->deleteHack === true && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
{
return t... | php | {
"resource": ""
} |
q254708 | Connection.error | test | public function error(): array
{
if (! empty($this->mysqli->connect_errno))
{
return [
'code' => $this->mysqli->connect_errno,
'message' => $this->mysqli->connect_error,
];
}
return [
'code' => $this->connID->errno,
'message' => $this->connID->error,
];
} | php | {
"resource": ""
} |
q254709 | Connection.execute | test | public function execute(string $sql)
{
return $this->isWriteType($sql)
? $this->connID->exec($sql)
: $this->connID->query($sql);
} | php | {
"resource": ""
} |
q254710 | Connection.getFieldNames | test | public function getFieldNames(string $table)
{
// Is there a cached result?
if (isset($this->dataCache['field_names'][$table]))
{
return $this->dataCache['field_names'][$table];
}
if (empty($this->connID))
{
$this->initialize();
}
if (false === ($sql = $this->_listColumns($table)))
{
if ($... | php | {
"resource": ""
} |
q254711 | Services.cache | test | public static function cache(Cache $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('cache', $config);
}
if (! is_object($config))
{
$config = new Cache();
}
return CacheFactory::getHandler($config);
} | php | {
"resource": ""
} |
q254712 | Services.clirequest | test | public static function clirequest(App $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('clirequest', $config);
}
if (! is_object($config))
{
$config = config(App::class);
}
return new CLIRequest($config);
} | php | {
"resource": ""
} |
q254713 | Services.curlrequest | test | public static function curlrequest(array $options = [], ResponseInterface $response = null, App $config = null, bool $getShared = true)
{
if ($getShared === true)
{
return static::getSharedInstance('curlrequest', $options, $response, $config);
}
if (! is_object($config))
{
$config = config(App::class)... | php | {
"resource": ""
} |
q254714 | Services.honeypot | test | public static function honeypot(BaseConfig $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('honeypot', $config);
}
if (is_null($config))
{
$config = new \Config\Honeypot();
}
return new Honeypot($config);
} | php | {
"resource": ""
} |
q254715 | Services.language | test | public static function language(string $locale = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('language', $locale)
->setLocale($locale);
}
$locale = ! empty($locale)
? $locale
: static::request()
->getLocale();
return new Language($locale);
} | php | {
"resource": ""
} |
q254716 | Services.logger | test | public static function logger(bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('logger');
}
return new \CodeIgniter\Log\Logger(new Logger());
} | php | {
"resource": ""
} |
q254717 | Services.negotiator | test | public static function negotiator(RequestInterface $request = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('negotiator', $request);
}
if (is_null($request))
{
$request = static::request();
}
return new Negotiate($request);
} | php | {
"resource": ""
} |
q254718 | Services.parser | test | public static function parser(string $viewPath = null, $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('parser', $viewPath, $config);
}
if (is_null($config))
{
$config = new \Config\View();
}
if (is_null($viewPath))
{
$paths = config('Paths');
... | php | {
"resource": ""
} |
q254719 | Services.request | test | public static function request(App $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('request', $config);
}
if (! is_object($config))
{
$config = config(App::class);
}
return new IncomingRequest(
$config,
new URI(),
'php://input',
new UserAge... | php | {
"resource": ""
} |
q254720 | Services.response | test | public static function response(App $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('response', $config);
}
if (! is_object($config))
{
$config = config(App::class);
}
return new Response($config);
} | php | {
"resource": ""
} |
q254721 | Services.redirectResponse | test | public static function redirectResponse(App $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('redirectResponse', $config);
}
if (! is_object($config))
{
$config = config(App::class);
}
$response = new RedirectResponse($config);
$response->setProtocolV... | php | {
"resource": ""
} |
q254722 | Services.router | test | public static function router(RouteCollectionInterface $routes = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('router', $routes);
}
if (empty($routes))
{
$routes = static::routes(true);
}
return new Router($routes);
} | php | {
"resource": ""
} |
q254723 | Services.security | test | public static function security(App $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('security', $config);
}
if (! is_object($config))
{
$config = config(App::class);
}
return new Security($config);
} | php | {
"resource": ""
} |
q254724 | Services.uri | test | public static function uri(string $uri = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('uri', $uri);
}
return new URI($uri);
} | php | {
"resource": ""
} |
q254725 | Services.validation | test | public static function validation(\Config\Validation $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('validation', $config);
}
if (is_null($config))
{
$config = config('Validation');
}
return new Validation($config, static::renderer());
} | php | {
"resource": ""
} |
q254726 | ListCommands.describeCommands | test | protected function describeCommands(array $commands = [])
{
ksort($commands);
// Sort into buckets by group
$sorted = [];
$maxTitleLength = 0;
foreach ($commands as $title => $command)
{
if (! isset($sorted[$command['group']]))
{
$sorted[$command['group']] = [];
}
$sorted[$comman... | php | {
"resource": ""
} |
q254727 | ListCommands.padTitle | test | protected function padTitle(string $item, int $max, int $extra = 2, int $indent = 0): string
{
$max += $extra + $indent;
$item = str_repeat(' ', $indent) . $item;
$item = str_pad($item, $max);
return $item;
} | php | {
"resource": ""
} |
q254728 | BaseUtils.getCSVFromResult | test | public function getCSVFromResult(ResultInterface $query, string $delim = ',', string $newline = "\n", string $enclosure = '"')
{
$out = '';
// First generate the headings from the table column names
foreach ($query->getFieldNames() as $name)
{
$out .= $enclosure . str_replace($enclosure, $enclosure . $enclo... | php | {
"resource": ""
} |
q254729 | BaseUtils.getXMLFromResult | test | public function getXMLFromResult(ResultInterface $query, array $params = []): string
{
// Set our default values
foreach (['root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t"] as $key => $val)
{
if (! isset($params[$key]))
{
$params[$key] = $val;
}
}
// Create variables f... | php | {
"resource": ""
} |
q254730 | BaseCommand.call | test | protected function call(string $command, array $params = [])
{
// The CommandRunner will grab the first element
// for the command name.
array_unshift($params, $command);
return $this->commands->index($params);
} | php | {
"resource": ""
} |
q254731 | Seeder.call | test | public function call(string $class)
{
if (empty($class))
{
throw new \InvalidArgumentException('No Seeder was specified.');
}
$path = str_replace('.php', '', $class) . '.php';
// If we have namespaced class, simply try to load it.
if (strpos($class, '\\') !== false)
{
$seeder = new $class($this->... | php | {
"resource": ""
} |
q254732 | Rules.in_list | test | public function in_list(string $value = null, string $list, array $data): bool
{
$list = explode(',', $list);
$list = array_map(function ($value) {
return trim($value);
}, $list);
return in_array($value, $list, true);
} | php | {
"resource": ""
} |
q254733 | Rules.less_than_equal_to | test | public function less_than_equal_to(string $str = null, string $max): bool
{
return is_numeric($str) ? ($str <= $max) : false;
} | php | {
"resource": ""
} |
q254734 | Rules.required_with | test | public function required_with($str = null, string $fields, array $data): bool
{
$fields = explode(',', $fields);
// If the field is present we can safely assume that
// the field is here, no matter whether the corresponding
// search field is present or not.
$present = $this->required($str ?? '');
if ($p... | php | {
"resource": ""
} |
q254735 | Rules.required_without | test | public function required_without($str = null, string $fields, array $data): bool
{
$fields = explode(',', $fields);
// If the field is present we can safely assume that
// the field is here, no matter whether the corresponding
// search field is present or not.
$present = $this->required($str ?? '');
if ... | php | {
"resource": ""
} |
q254736 | Router.validateRequest | test | protected function validateRequest(array $segments): array
{
$segments = array_filter($segments);
$segments = array_values($segments);
$c = count($segments);
$directory_override = isset($this->directory);
// Loop through our segments and return as soon as a controller
// is found or when... | php | {
"resource": ""
} |
q254737 | Router.setDirectory | test | protected function setDirectory(string $dir = null, bool $append = false)
{
$dir = ucfirst($dir);
if ($append !== true || empty($this->directory))
{
$this->directory = str_replace('.', '', trim($dir, '/')) . '/';
}
else
{
$this->directory .= str_replace('.', '', trim($dir, '/')) . '/';
}
} | php | {
"resource": ""
} |
q254738 | Router.setRequest | test | protected function setRequest(array $segments = [])
{
// If we don't have any segments - try the default controller;
if (empty($segments))
{
$this->setDefaultController();
return;
}
list($controller, $method) = array_pad(explode('::', $segments[0]), 2, null);
$this->controller = $controller;
//... | php | {
"resource": ""
} |
q254739 | Router.setDefaultController | test | protected function setDefaultController()
{
if (empty($this->controller))
{
throw RouterException::forMissingDefaultRoute();
}
// Is the method being specified?
if (sscanf($this->controller, '%[^/]/%s', $class, $this->method) !== 2)
{
$this->method = 'index';
}
if (! is_file(APPPATH . 'Controll... | php | {
"resource": ""
} |
q254740 | File.getSize | test | public function getSize(string $unit = 'b')
{
if (is_null($this->size))
{
$this->size = filesize($this->getPathname());
}
switch (strtolower($unit))
{
case 'kb':
return number_format($this->size / 1024, 3);
case 'mb':
return number_format(($this->size / 1024) / 1024, 3);
}
return (int)... | php | {
"resource": ""
} |
q254741 | File.move | test | public function move(string $targetPath, string $name = null, bool $overwrite = false)
{
$targetPath = rtrim($targetPath, '/') . '/';
$name = $name ?? $this->getBaseName();
$destination = $overwrite ? $targetPath . $name : $this->getDestination($targetPath . $name);
$oldName = empty($this->getRealPath... | php | {
"resource": ""
} |
q254742 | File.getDestination | test | public function getDestination(string $destination, string $delimiter = '_', int $i = 0): string
{
while (is_file($destination))
{
$info = pathinfo($destination);
if (strpos($info['filename'], $delimiter) !== false)
{
$parts = explode($delimiter, $info['filename']);
if (is_numeric(end($parts)))
... | php | {
"resource": ""
} |
q254743 | Database.collect | test | public static function collect(Query $query)
{
$config = config('Toolbar');
// Provide default in case it's not set
$max = $config->maxQueries ?: 100;
if (count(static::$queries) < $max)
{
static::$queries[] = $query;
}
} | php | {
"resource": ""
} |
q254744 | Database.formatTimelineData | test | protected function formatTimelineData(): array
{
$data = [];
foreach ($this->connections as $alias => $connection)
{
// Connection Time
$data[] = [
'name' => 'Connecting to Database: "' . $alias . '"',
'component' => 'Database',
'start' => $connection->getConnectStart(),
'duration... | php | {
"resource": ""
} |
q254745 | FileLocator.locateFile | test | public function locateFile(string $file, string $folder = null, string $ext = 'php')
{
$file = $this->ensureExt($file, $ext);
// Clears the folder name if it is at the beginning of the filename
if (! empty($folder) && ($pos = strpos($file, $folder)) === 0)
{
$file = substr($file, strlen($folder . '/'));
... | php | {
"resource": ""
} |
q254746 | FileLocator.getClassname | test | public function getClassname(string $file) : string
{
$php = file_get_contents($file);
$tokens = token_get_all($php);
$count = count($tokens);
$dlm = false;
$namespace = '';
$class_name = '';
for ($i = 2; $i < $count; $i++)
{
if ((isset($tokens[$i - 2][1]) && ($tokens[$i - 2... | php | {
"resource": ""
} |
q254747 | FileLocator.search | test | public function search(string $path, string $ext = 'php'): array
{
$path = $this->ensureExt($path, $ext);
$foundPaths = [];
foreach ($this->getNamespaces() as $namespace)
{
if (is_file($namespace['path'] . $path))
{
$foundPaths[] = $namespace['path'] . $path;
}
}
// Remove any duplicates
... | php | {
"resource": ""
} |
q254748 | FileLocator.ensureExt | test | protected function ensureExt(string $path, string $ext): string
{
if ($ext)
{
$ext = '.' . $ext;
if (substr($path, -strlen($ext)) !== $ext)
{
$path .= $ext;
}
}
return $path;
} | php | {
"resource": ""
} |
q254749 | FileLocator.findQualifiedNameFromPath | test | public function findQualifiedNameFromPath(string $path)
{
$path = realpath($path);
if (! $path)
{
return false;
}
foreach ($this->getNamespaces() as $namespace)
{
$namespace['path'] = realpath($namespace['path']);
if (empty($namespace['path']))
{
continue;
}
if (mb_strpos($path, $... | php | {
"resource": ""
} |
q254750 | FileLocator.legacyLocate | test | protected function legacyLocate(string $file, string $folder = null)
{
$paths = [
APPPATH,
SYSTEMPATH,
];
foreach ($paths as $path)
{
$path .= empty($folder) ? $file : $folder . '/' . $file;
if (is_file($path))
{
return $path;
}
}
return false;
} | php | {
"resource": ""
} |
q254751 | View.renderString | test | public function renderString(string $view, array $options = null, bool $saveData = null): string
{
$start = microtime(true);
if (is_null($saveData))
{
$saveData = $this->config->saveData;
}
extract($this->data);
if (! $saveData)
{
$this->data = [];
}
ob_start();
$incoming = '?>' . $view;
... | php | {
"resource": ""
} |
q254752 | View.excerpt | test | public function excerpt(string $string, int $length = 20): string
{
return (strlen($string) > $length) ? substr($string, 0, $length - 3) . '...' : $string;
} | php | {
"resource": ""
} |
q254753 | View.setData | test | public function setData(array $data = [], string $context = null): RendererInterface
{
if (! empty($context))
{
$data = \esc($data, $context);
}
$this->data = array_merge($this->data, $data);
return $this;
} | php | {
"resource": ""
} |
q254754 | View.setVar | test | public function setVar(string $name, $value = null, string $context = null): RendererInterface
{
if (! empty($context))
{
$value = \esc($value, $context);
}
$this->data[$name] = $value;
return $this;
} | php | {
"resource": ""
} |
q254755 | View.renderSection | test | public function renderSection(string $sectionName)
{
if (! isset($this->sections[$sectionName]))
{
echo '';
return;
}
foreach ($this->sections[$sectionName] as $contents)
{
echo $contents;
}
} | php | {
"resource": ""
} |
q254756 | View.include | test | public function include(string $view, array $options = null, $saveData = null): string
{
return $this->render($view, $options, $saveData);
} | php | {
"resource": ""
} |
q254757 | View.logPerformance | test | protected function logPerformance(float $start, float $end, string $view)
{
if (! $this->debug)
{
return;
}
$this->performanceData[] = [
'start' => $start,
'end' => $end,
'view' => $view,
];
} | php | {
"resource": ""
} |
q254758 | BaseHandler.withFile | test | public function withFile(string $path)
{
// Clear out the old resource so that
// it doesn't try to use a previous image
$this->resource = null;
$this->image = new Image($path, true);
$this->image->getProperties(false);
$this->width = $this->image->origWidth;
$this->height = $this->image->origHeight;
... | php | {
"resource": ""
} |
q254759 | BaseHandler.ensureResource | test | protected function ensureResource()
{
if ($this->resource === null)
{
$path = $this->image->getPathname();
// if valid image type, make corresponding image resource
switch ($this->image->imageType)
{
case IMAGETYPE_GIF:
$this->resource = imagecreatefromgif($path);
break;
case IMAGETYP... | php | {
"resource": ""
} |
q254760 | BaseHandler.resize | test | public function resize(int $width, int $height, bool $maintainRatio = false, string $masterDim = 'auto')
{
// If the target width/height match the source, then we have nothing to do here.
if ($this->image->origWidth === $width && $this->image->origHeight === $height)
{
return $this;
}
$this->width = $wi... | php | {
"resource": ""
} |
q254761 | BaseHandler.rotate | test | public function rotate(float $angle)
{
// Allowed rotation values
$degs = [
90,
180,
270,
];
if ($angle === '' || ! in_array($angle, $degs))
{
throw ImageException::forMissingAngle();
}
// cast angle as an int, for our use
$angle = (int) $angle;
// Reassign the width and height
if ($... | php | {
"resource": ""
} |
q254762 | BaseHandler.flip | test | public function flip(string $dir = 'vertical')
{
$dir = strtolower($dir);
if ($dir !== 'vertical' && $dir !== 'horizontal')
{
throw ImageException::forInvalidDirection($dir);
}
return $this->_flip($dir);
} | php | {
"resource": ""
} |
q254763 | BaseHandler.text | test | public function text(string $text, array $options = [])
{
$options = array_merge($this->textDefaults, $options);
$options['color'] = trim($options['color'], '# ');
$options['shadowColor'] = trim($options['shadowColor'], '# ');
$this->_text($text, $options);
return $this;
} | php | {
"resource": ""
} |
q254764 | BaseHandler.reorient | test | public function reorient(bool $silent = false)
{
$orientation = $this->getEXIF('Orientation', $silent);
switch ($orientation)
{
case 2:
return $this->flip('horizontal');
break;
case 3:
return $this->rotate(180);
break;
case 4:
return $this->rotate(180)
->flip('horizontal');
... | php | {
"resource": ""
} |
q254765 | BaseHandler.getEXIF | test | public function getEXIF(string $key = null, bool $silent = false)
{
if (! function_exists('exif_read_data'))
{
if ($silent)
{
return null;
}
}
$exif = exif_read_data($this->image->getPathname());
if (! is_null($key) && is_array($exif))
{
$exif = $exif[$key] ?? false;
}
return $exif;
... | php | {
"resource": ""
} |
q254766 | BaseHandler.fit | test | public function fit(int $width, int $height = null, string $position = 'center')
{
$origWidth = $this->image->origWidth;
$origHeight = $this->image->origHeight;
list($cropWidth, $cropHeight) = $this->calcAspectRatio($width, $height, $origWidth, $origHeight);
if (is_null($height))
{
$height = ceil(($wid... | php | {
"resource": ""
} |
q254767 | Serve.run | test | public function run(array $params)
{
// Valid PHP Version?
if (phpversion() < $this->minPHPVersion)
{
die('Your PHP version must be ' . $this->minPHPVersion .
' or higher to run CodeIgniter. Current version: ' . phpversion());
}
// Collect any user-supplied options and apply them.
$php = CLI::getO... | php | {
"resource": ""
} |
q254768 | Parser.renderString | test | public function renderString(string $template, array $options = null, bool $saveData = null): string
{
$start = microtime(true);
if (is_null($saveData))
{
$saveData = $this->config->saveData;
}
$output = $this->parse($template, $this->data, $options);
$this->logPerformance($start, microtime(true), $th... | php | {
"resource": ""
} |
q254769 | Parser.parsePair | test | protected function parsePair(string $variable, array $data, string $template): array
{
// Holds the replacement patterns and contents
// that will be used within a preg_replace in parse()
$replace = [];
// Find all matches of space-flexible versions of {tag}{/tag} so we
// have something to loop over.
pre... | php | {
"resource": ""
} |
q254770 | Parser.extractNoparse | test | protected function extractNoparse(string $template): string
{
$pattern = '/\{\s*noparse\s*\}(.*?)\{\s*\/noparse\s*\}/ms';
/*
* $matches[][0] is the raw match
* $matches[][1] is the contents
*/
if (preg_match_all($pattern, $template, $matches, PREG_SET_ORDER))
{
foreach ($matches as $match)
{
... | php | {
"resource": ""
} |
q254771 | Parser.insertNoparse | test | public function insertNoparse(string $template): string
{
foreach ($this->noparseBlocks as $hash => $replace)
{
$template = str_replace("noparse_{$hash}", $replace, $template);
unset($this->noparseBlocks[$hash]);
}
return $template;
} | php | {
"resource": ""
} |
q254772 | Parser.parseConditionals | test | protected function parseConditionals(string $template): string
{
$pattern = '/\{\s*(if|elseif)\s*((?:\()?(.*?)(?:\))?)\s*\}/ms';
/**
* For each match:
* [0] = raw match `{if var}`
* [1] = conditional `if`
* [2] = condition `do === true`
* [3] = same as [2]
*/
preg_match_all($pattern, $template... | php | {
"resource": ""
} |
q254773 | Parser.setDelimiters | test | public function setDelimiters($leftDelimiter = '{', $rightDelimiter = '}'): RendererInterface
{
$this->leftDelimiter = $leftDelimiter;
$this->rightDelimiter = $rightDelimiter;
return $this;
} | php | {
"resource": ""
} |
q254774 | Parser.replaceSingle | test | protected function replaceSingle($pattern, $content, $template, bool $escape = false): string
{
// Any dollar signs in the pattern will be mis-interpreted, so slash them
$pattern = addcslashes($pattern, '$');
// Replace the content in the template
$template = preg_replace_callback($pattern, function ($matches... | php | {
"resource": ""
} |
q254775 | Parser.shouldAddEscaping | test | public function shouldAddEscaping(string $key)
{
$escape = false;
$key = trim(str_replace(['{', '}'], '', $key));
// If the key has a context stored (from setData)
// we need to respect that.
if (array_key_exists($key, $this->dataContexts))
{
if ($this->dataContexts[$key] !== 'raw')
{
return $t... | php | {
"resource": ""
} |
q254776 | Parser.addPlugin | test | public function addPlugin(string $alias, callable $callback, bool $isPair = false)
{
$this->plugins[$alias] = $isPair ? [$callback] : $callback;
return $this;
} | php | {
"resource": ""
} |
q254777 | GDHandler.createImage | test | protected function createImage(string $path = '', string $imageType = '')
{
if ($this->resource !== null)
{
return $this->resource;
}
if ($path === '')
{
$path = $this->image->getPathname();
}
if ($imageType === '')
{
$imageType = $this->image->imageType;
}
switch ($imageType)
{
ca... | php | {
"resource": ""
} |
q254778 | Message.getHeader | test | public function getHeader(string $name)
{
$orig_name = $this->getHeaderName($name);
if (! isset($this->headers[$orig_name]))
{
return null;
}
return $this->headers[$orig_name];
} | php | {
"resource": ""
} |
q254779 | Message.hasHeader | test | public function hasHeader(string $name): bool
{
$orig_name = $this->getHeaderName($name);
return isset($this->headers[$orig_name]);
} | php | {
"resource": ""
} |
q254780 | Message.setHeader | test | public function setHeader(string $name, $value)
{
if (! isset($this->headers[$name]))
{
$this->headers[$name] = new Header($name, $value);
$this->headerMap[strtolower($name)] = $name;
return $this;
}
if (! is_array($this->headers[$name]))
{
$this->headers[$name] = [$this->headers[$name]];
}
... | php | {
"resource": ""
} |
q254781 | Message.removeHeader | test | public function removeHeader(string $name)
{
$orig_name = $this->getHeaderName($name);
unset($this->headers[$orig_name]);
unset($this->headerMap[strtolower($name)]);
return $this;
} | php | {
"resource": ""
} |
q254782 | Message.setProtocolVersion | test | public function setProtocolVersion(string $version)
{
if (! is_numeric($version))
{
$version = substr($version, strpos($version, '/') + 1);
}
if (! in_array($version, $this->validProtocolVersions))
{
throw HTTPException::forInvalidHTTPProtocol(implode(', ', $this->validProtocolVersions));
}
$this... | php | {
"resource": ""
} |
q254783 | Message.getHeaderName | test | protected function getHeaderName(string $name): string
{
$lower_name = strtolower($name);
return $this->headerMap[$lower_name] ?? $name;
} | php | {
"resource": ""
} |
q254784 | FileHandler.configureSessionIDRegex | test | protected function configureSessionIDRegex()
{
$bitsPerCharacter = (int)ini_get('session.sid_bits_per_character');
$SIDLength = (int)ini_get('session.sid_length');
if (($bits = $SIDLength * $bitsPerCharacter) < 160)
{
// Add as many more characters as necessary to reach at least 160 bits
$SIDLeng... | php | {
"resource": ""
} |
q254785 | Response.getReason | test | public function getReason(): string
{
if (empty($this->reason))
{
return ! empty($this->statusCode) ? static::$statusCodes[$this->statusCode] : '';
}
return $this->reason;
} | php | {
"resource": ""
} |
q254786 | Response.setLink | test | public function setLink(PagerInterface $pager)
{
$links = '';
if ($previous = $pager->getPreviousPageURI())
{
$links .= '<' . $pager->getPageURI($pager->getFirstPage()) . '>; rel="first",';
$links .= '<' . $previous . '>; rel="prev"';
}
if (($next = $pager->getNextPageURI()) && $previous)
{
$lin... | php | {
"resource": ""
} |
q254787 | Response.setContentType | test | public function setContentType(string $mime, string $charset = 'UTF-8')
{
// add charset attribute if not already there and provided as parm
if ((strpos($mime, 'charset=') < 1) && ! empty($charset))
{
$mime .= '; charset=' . $charset;
}
$this->removeHeader('Content-Type'); // replace existing content typ... | php | {
"resource": ""
} |
q254788 | Response.getJSON | test | public function getJSON()
{
$body = $this->body;
if ($this->bodyFormat !== 'json')
{
/**
* @var Format $config
*/
$config = config(Format::class);
$formatter = $config->getFormatter('application/json');
$body = $formatter->format($body);
}
return $body ?: null;
} | php | {
"resource": ""
} |
q254789 | Response.getXML | test | public function getXML()
{
$body = $this->body;
if ($this->bodyFormat !== 'xml')
{
/**
* @var Format $config
*/
$config = config(Format::class);
$formatter = $config->getFormatter('application/xml');
$body = $formatter->format($body);
}
return $body;
} | php | {
"resource": ""
} |
q254790 | Response.formatBody | test | protected function formatBody($body, string $format)
{
$mime = "application/{$format}";
$this->setContentType($mime);
$this->bodyFormat = $format;
// Nothing much to do for a string...
if (! is_string($body))
{
/**
* @var Format $config
*/
$config = config(Format::class);
$formatter = ... | php | {
"resource": ""
} |
q254791 | Response.setCache | test | public function setCache(array $options = [])
{
if (empty($options))
{
return $this;
}
$this->removeHeader('Cache-Control');
$this->removeHeader('ETag');
// ETag
if (isset($options['etag']))
{
$this->setHeader('ETag', $options['etag']);
unset($options['etag']);
}
// Last Modified
if (... | php | {
"resource": ""
} |
q254792 | Response.send | test | public function send()
{
// If we're enforcing a Content Security Policy,
// we need to give it a chance to build out it's headers.
if ($this->CSPEnabled === true)
{
$this->CSP->finalize($this);
}
else
{
$this->body = str_replace(['{csp-style-nonce}', '{csp-script-nonce}'], '', $this->body);
}
... | php | {
"resource": ""
} |
q254793 | Response.sendHeaders | test | public function sendHeaders()
{
// Have the headers already been sent?
if ($this->pretend || headers_sent())
{
return $this;
}
// Per spec, MUST be sent with each request, if possible.
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
if (! isset($this->headers['Date']))
{
$this->setDate... | php | {
"resource": ""
} |
q254794 | Response.setCookie | test | public function setCookie(
$name,
$value = '',
$expire = '',
$domain = '',
$path = '/',
$prefix = '',
$secure = false,
$httponly = false
)
{
if (is_array($name))
{
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
foreach (['value', 'expire', 'domain', 'pa... | php | {
"resource": ""
} |
q254795 | Response.hasCookie | test | public function hasCookie(string $name, string $value = null, string $prefix = ''): bool
{
if ($prefix === '' && $this->cookiePrefix !== '')
{
$prefix = $this->cookiePrefix;
}
$name = $prefix . $name;
foreach ($this->cookies as $cookie)
{
if ($cookie['name'] !== $name)
{
continue;
}
i... | php | {
"resource": ""
} |
q254796 | Response.getCookie | test | public function getCookie(string $name = null, string $prefix = '')
{
// if no name given, return them all
if (empty($name))
{
return $this->cookies;
}
if ($prefix === '' && $this->cookiePrefix !== '')
{
$prefix = $this->cookiePrefix;
}
$name = $prefix . $name;
foreach ($this->cookies as $co... | php | {
"resource": ""
} |
q254797 | Response.deleteCookie | test | public function deleteCookie(string $name = '', string $domain = '', string $path = '/', string $prefix = '')
{
if (empty($name))
{
return $this;
}
if ($prefix === '' && $this->cookiePrefix !== '')
{
$prefix = $this->cookiePrefix;
}
$name = $prefix . $name;
foreach ($this->cookies as &$cookie)... | php | {
"resource": ""
} |
q254798 | Response.sendCookies | test | protected function sendCookies()
{
if ($this->pretend)
{
return;
}
foreach ($this->cookies as $params)
{
// PHP cannot unpack array with string keys
$params = array_values($params);
setcookie(...$params);
}
} | php | {
"resource": ""
} |
q254799 | Response.download | test | public function download(string $filename = '', $data = '', bool $setMime = false)
{
if ($filename === '' || $data === '')
{
return null;
}
$filepath = '';
if ($data === null)
{
$filepath = $filename;
$filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
$filename = end($... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.