_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q254600 | BaseBuilder.compileSelect | test | protected function compileSelect($select_override = false): string
{
// Write the "select" portion of the query
if ($select_override !== false)
{
$sql = $select_override;
}
else
{
$sql = ( ! $this->QBDistinct) ? 'SELECT ' : 'SELECT DISTINCT ';
if (empty($this->QBSelect))
{
$sql .= '*';
... | php | {
"resource": ""
} |
q254601 | BaseBuilder.compileWhereHaving | test | protected function compileWhereHaving(string $qb_key): string
{
if (! empty($this->$qb_key))
{
for ($i = 0, $c = count($this->$qb_key); $i < $c; $i ++)
{
// Is this condition already compiled?
if (is_string($this->{$qb_key}[$i]))
{
continue;
}
elseif ($this->{$qb_key}[$i]['escape'] =... | php | {
"resource": ""
} |
q254602 | BaseBuilder.compileGroupBy | test | protected function compileGroupBy(): string
{
if (! empty($this->QBGroupBy))
{
for ($i = 0, $c = count($this->QBGroupBy); $i < $c; $i ++)
{
// Is it already compiled?
if (is_string($this->QBGroupBy[$i]))
{
continue;
}
$this->QBGroupBy[$i] = ($this->QBGroupBy[$i]['escape'] === false ... | php | {
"resource": ""
} |
q254603 | BaseBuilder.compileOrderBy | test | protected function compileOrderBy(): string
{
if (is_array($this->QBOrderBy) && ! empty($this->QBOrderBy))
{
for ($i = 0, $c = count($this->QBOrderBy); $i < $c; $i ++)
{
if ($this->QBOrderBy[$i]['escape'] !== false && ! $this->isLiteral($this->QBOrderBy[$i]['field']))
{
$this->QBOrderBy[$i]['fie... | php | {
"resource": ""
} |
q254604 | BaseBuilder.getOperator | test | protected function getOperator(string $str, bool $list = false)
{
static $_operators;
if (empty($_operators))
{
$_les = ($this->db->likeEscapeStr !== '') ? '\s+' . preg_quote(trim(sprintf($this->db->likeEscapeStr, $this->db->likeEscapeChar)), '/') : '';
$_operators = [
'\s*(?:<|>|!)?=\s*', // =,... | php | {
"resource": ""
} |
q254605 | Toolbar.renderTimeline | test | protected function renderTimeline(array $collectors, $startTime, int $segmentCount, int $segmentDuration, array &$styles): string
{
$displayTime = $segmentCount * $segmentDuration;
$rows = $this->collectTimelineData($collectors);
$output = '';
$styleCount = 0;
foreach ($rows as $row)
{
$output .= '<tr>... | php | {
"resource": ""
} |
q254606 | Toolbar.collectTimelineData | test | protected function collectTimelineData($collectors): array
{
$data = [];
// Collect it
foreach ($collectors as $collector)
{
if (! $collector['hasTimelineData'])
{
continue;
}
$data = array_merge($data, $collector['timelineData']);
}
// Sort it
return $data;
} | php | {
"resource": ""
} |
q254607 | Toolbar.collectVarData | test | protected function collectVarData(): array
{
$data = [];
foreach ($this->collectors as $collector)
{
if (! $collector->hasVarData())
{
continue;
}
$data = array_merge($data, $collector->getVarData());
}
return $data;
} | php | {
"resource": ""
} |
q254608 | Toolbar.roundTo | test | protected function roundTo(float $number, int $increments = 5): float
{
$increments = 1 / $increments;
return (ceil($number * $increments) / $increments);
} | php | {
"resource": ""
} |
q254609 | Image.copy | test | public function copy(string $targetPath, string $targetName = null, int $perms = 0644): bool
{
$targetPath = rtrim($targetPath, '/ ') . '/';
$targetName = is_null($targetName) ? $this->getFilename() : $targetName;
if (empty($targetName))
{
throw ImageException::forInvalidFile($targetName);
}
if (! is... | php | {
"resource": ""
} |
q254610 | Image.getProperties | test | public function getProperties(bool $return = false)
{
$path = $this->getPathname();
$vals = getimagesize($path);
$types = [
1 => 'gif',
2 => 'jpeg',
3 => 'png',
];
$mime = 'image/' . ($types[$vals[2]] ?? 'jpg');
if ($return === true)
{
return [
'width' => $vals[0],
'height' ... | php | {
"resource": ""
} |
q254611 | DatabaseHandler.releaseLock | test | protected function releaseLock(): bool
{
if (! $this->lock)
{
return true;
}
if ($this->platform === 'mysql')
{
if ($this->db->query("SELECT RELEASE_LOCK('{$this->lock}') AS ci_session_lock")->getRow()->ci_session_lock)
{
$this->lock = false;
return true;
}
return $this->fail();
}
... | php | {
"resource": ""
} |
q254612 | Honeypot.attachHoneypot | test | public function attachHoneypot(ResponseInterface $response)
{
$prep_field = $this->prepareTemplate($this->config->template);
$body = $response->getBody();
$body = str_ireplace('</form>', $prep_field, $body);
$response->setBody($body);
} | php | {
"resource": ""
} |
q254613 | Honeypot.prepareTemplate | test | protected function prepareTemplate(string $template): string
{
$template = str_ireplace('{label}', $this->config->label, $template);
$template = str_ireplace('{name}', $this->config->name, $template);
if ($this->config->hidden)
{
$template = '<div style="display:none">' . $template . '</div>';
}
return... | php | {
"resource": ""
} |
q254614 | Result.fetchObject | test | protected function fetchObject(string $className = 'stdClass')
{
// No native support for fetching rows as objects
if (($row = $this->fetchAssoc()) === false)
{
return false;
}
elseif ($className === 'stdClass')
{
return (object) $row;
}
$classObj = new $className();
$classSet = \Closure::bind... | php | {
"resource": ""
} |
q254615 | Table.makeColumns | test | public function makeColumns($array = [], $columnLimit = 0)
{
if (! is_array($array) || count($array) === 0 || ! is_int($columnLimit))
{
return false;
}
// Turn off the auto-heading feature since it's doubtful we
// will want headings from a one-dimensional array
$this->autoHeading = false;
if ($colu... | php | {
"resource": ""
} |
q254616 | Table.clear | test | public function clear()
{
$this->rows = [];
$this->heading = [];
$this->footing = [];
$this->autoHeading = true;
$this->caption = null;
return $this;
} | php | {
"resource": ""
} |
q254617 | Table._setFromDBResult | test | protected function _setFromDBResult($object)
{
// First generate the headings from the table column names
if ($this->autoHeading === true && empty($this->heading))
{
$this->heading = $this->_prepArgs($object->getFieldNames());
}
foreach ($object->getResultArray() as $row)
{
$this->rows[] = $this->_p... | php | {
"resource": ""
} |
q254618 | Table._setFromArray | test | protected function _setFromArray($data)
{
if ($this->autoHeading === true && empty($this->heading))
{
$this->heading = $this->_prepArgs(array_shift($data));
}
foreach ($data as &$row)
{
$this->rows[] = $this->_prepArgs($row);
}
} | php | {
"resource": ""
} |
q254619 | UploadedFile.setPath | test | protected function setPath(string $path): string
{
if (! is_dir($path))
{
mkdir($path, 0777, true);
//create the index.html file
if (! is_file($path . 'index.html'))
{
$file = fopen($path . 'index.html', 'x+');
fclose($file);
}
}
return $path;
} | php | {
"resource": ""
} |
q254620 | UploadedFile.getErrorString | test | public function getErrorString(): string
{
$errors = [
UPLOAD_ERR_OK => lang('HTTP.uploadErrOk'),
UPLOAD_ERR_INI_SIZE => lang('HTTP.uploadErrIniSize'),
UPLOAD_ERR_FORM_SIZE => lang('HTTP.uploadErrFormSize'),
UPLOAD_ERR_PARTIAL => lang('HTTP.uploadErrPartial'),
UPLOAD_ERR_NO_FILE => la... | php | {
"resource": ""
} |
q254621 | UploadedFile.store | test | public function store(string $folderName = null, string $fileName = null): string
{
$folderName = $folderName ?? date('Ymd');
$fileName = $fileName ?? $this->getRandomName();
// Move the uploaded file to a new location.
return ($this->move(WRITEPATH . 'uploads/' . $folderName, $fileName)) ?
$folderName ... | php | {
"resource": ""
} |
q254622 | FileRules.max_size | test | public function max_size(string $blank = null, string $params, array $data): bool
{
// Grab the file name off the top of the $params
// after we split it.
$params = explode(',', $params);
$name = array_shift($params);
$file = $this->request->getFile($name);
if (is_null($file))
{
return false;
}
... | php | {
"resource": ""
} |
q254623 | FileRules.is_image | test | public function is_image(string $blank = null, string $params, array $data): bool
{
// Grab the file name off the top of the $params
// after we split it.
$params = explode(',', $params);
$name = array_shift($params);
$file = $this->request->getFile($name);
if (is_null($file))
{
return false;
}
... | php | {
"resource": ""
} |
q254624 | FileRules.mime_in | test | public function mime_in(string $blank = null, string $params, array $data): bool
{
// Grab the file name off the top of the $params
// after we split it.
$params = explode(',', $params);
$name = array_shift($params);
$file = $this->request->getFile($name);
if (is_null($file))
{
return false;
}
... | php | {
"resource": ""
} |
q254625 | FileRules.max_dims | test | public function max_dims(string $blank = null, string $params, array $data): bool
{
// Grab the file name off the top of the $params
// after we split it.
$params = explode(',', $params);
$name = array_shift($params);
$file = $this->request->getFile($name);
if (is_null($file))
{
return false;
}
... | php | {
"resource": ""
} |
q254626 | Request.fetchGlobal | test | public function fetchGlobal($method, $index = null, $filter = null, $flags = null)
{
$method = strtolower($method);
if (! isset($this->globals[$method]))
{
$this->populateGlobals($method);
}
// Null filters cause null values to return.
if (is_null($filter))
{
$filter = FILTER_DEFAULT;
}
// R... | php | {
"resource": ""
} |
q254627 | Request.populateGlobals | test | protected function populateGlobals(string $method)
{
if (! isset($this->globals[$method]))
{
$this->globals[$method] = [];
}
// Don't populate ENV as it might contain
// sensitive data that we don't want to get logged.
switch($method)
{
case 'get':
$this->globals['get'] = $_GET;
break;
... | php | {
"resource": ""
} |
q254628 | MigrateVersion.run | test | public function run(array $params = [])
{
$runner = Services::migrations();
// Get the version number
$version = array_shift($params);
if (is_null($version))
{
$version = CLI::prompt(lang('Migrations.version'));
}
if (is_null($version))
{
CLI::error(lang('Migrations.invalidVersion'));
exit(... | php | {
"resource": ""
} |
q254629 | Table.fromTable | test | public function fromTable(string $table)
{
$this->prefixedTableName = $table;
// Remove the prefix, if any, since it's
// already been added by the time we get here...
$prefix = $this->db->DBPrefix;
if (! empty($prefix))
{
if (strpos($table, $prefix) === 0)
{
$table = substr($table, strlen($pref... | php | {
"resource": ""
} |
q254630 | Table.run | test | public function run(): bool
{
$this->db->query('PRAGMA foreign_keys = OFF');
$this->db->transStart();
$this->forge->renameTable($this->tableName, "temp_{$this->tableName}");
$this->forge->reset();
$this->createTable();
$this->copyData();
$this->forge->dropTable("temp_{$this->tableName}");
$succe... | php | {
"resource": ""
} |
q254631 | Table.modifyColumn | test | public function modifyColumn(array $field)
{
$field = $field[0];
$oldName = $field['name'];
unset($field['name']);
$this->fields[$oldName] = $field;
return $this;
} | php | {
"resource": ""
} |
q254632 | Table.createTable | test | protected function createTable()
{
$this->dropIndexes();
$this->db->resetDataCache();
// Handle any modified columns.
$fields = [];
foreach ($this->fields as $name => $field)
{
if (isset($field['new_name']))
{
$fields[$field['new_name']] = $field;
continue;
}
$fields[$name] = $field;
... | php | {
"resource": ""
} |
q254633 | Table.copyData | test | protected function copyData()
{
$exFields = [];
$newFields = [];
foreach ($this->fields as $name => $details)
{
// Are we modifying the column?
if (isset($details['new_name']))
{
$newFields[] = $details['new_name'];
}
else
{
$newFields[] = $name;
}
$exFields[] = $name;
}
... | php | {
"resource": ""
} |
q254634 | Table.formatFields | test | protected function formatFields($fields)
{
if (! is_array($fields))
{
return $fields;
}
$return = [];
foreach ($fields as $field)
{
$return[$field->name] = [
'type' => $field->type,
'default' => $field->default,
'nullable' => $field->nullable,
];
if ($field->primary_key)
... | php | {
"resource": ""
} |
q254635 | Table.formatKeys | test | protected function formatKeys($keys)
{
if (! is_array($keys))
{
return $keys;
}
$return = [];
foreach ($keys as $name => $key)
{
$return[$name] = [
'fields' => $key->fields,
'type' => 'index',
];
}
return $return;
} | php | {
"resource": ""
} |
q254636 | Table.dropIndexes | test | protected function dropIndexes()
{
if (! is_array($this->keys) || ! count($this->keys))
{
return;
}
foreach ($this->keys as $name => $key)
{
if ($key['type'] === 'primary' || $key['type'] === 'unique')
{
continue;
}
$this->db->query("DROP INDEX IF EXISTS '{$name}'");
}
} | php | {
"resource": ""
} |
q254637 | Security.CSRFSetCookie | test | public function CSRFSetCookie(RequestInterface $request)
{
$expire = time() + $this->CSRFExpire;
$secure_cookie = (bool) $this->cookieSecure;
if ($secure_cookie && ! $request->isSecure())
{
return false;
}
setcookie(
$this->CSRFCookieName, $this->CSRFHash, $expire, $this->cookiePath, $this-... | php | {
"resource": ""
} |
q254638 | Security.CSRFSetHash | test | protected function CSRFSetHash(): string
{
if ($this->CSRFHash === null)
{
// If the cookie exists we will use its value.
// We don't necessarily want to regenerate it with
// each page load since a page could contain embedded
// sub-pages causing this feature to fail
if (isset($_COOKIE[$this->CSRFC... | php | {
"resource": ""
} |
q254639 | Time.now | test | public static function now($timezone = null, string $locale = null)
{
return new Time(null, $timezone, $locale);
} | php | {
"resource": ""
} |
q254640 | Time.parse | test | public static function parse(string $datetime, $timezone = null, string $locale = null)
{
return new Time($datetime, $timezone, $locale);
} | php | {
"resource": ""
} |
q254641 | Time.today | test | public static function today($timezone = null, string $locale = null)
{
return new Time(date('Y-m-d 00:00:00'), $timezone, $locale);
} | php | {
"resource": ""
} |
q254642 | Time.yesterday | test | public static function yesterday($timezone = null, string $locale = null)
{
return new Time(date('Y-m-d 00:00:00', strtotime('-1 day')), $timezone, $locale);
} | php | {
"resource": ""
} |
q254643 | Time.tomorrow | test | public static function tomorrow($timezone = null, string $locale = null)
{
return new Time(date('Y-m-d 00:00:00', strtotime('+1 day')), $timezone, $locale);
} | php | {
"resource": ""
} |
q254644 | Time.createFromDate | test | public static function createFromDate(int $year = null, int $month = null, int $day = null, $timezone = null, string $locale = null)
{
return static::create($year, $month, $day, null, null, null, $timezone, $locale);
} | php | {
"resource": ""
} |
q254645 | Time.createFromTime | test | public static function createFromTime(int $hour = null, int $minutes = null, int $seconds = null, $timezone = null, string $locale = null)
{
return static::create(null, null, null, $hour, $minutes, $seconds, $timezone, $locale);
} | php | {
"resource": ""
} |
q254646 | Time.create | test | public static function create(int $year = null, int $month = null, int $day = null, int $hour = null, int $minutes = null, int $seconds = null, $timezone = null, string $locale = null)
{
$year = is_null($year) ? date('Y') : $year;
$month = is_null($month) ? date('m') : $month;
$day = is_null($day) ? dat... | php | {
"resource": ""
} |
q254647 | Time.createFromFormat | test | public static function createFromFormat($format, $datetime, $timeZone = null)
{
$date = parent::createFromFormat($format, $datetime);
return new Time($date->format('Y-m-d H:i:s'), $timeZone);
} | php | {
"resource": ""
} |
q254648 | Time.createFromTimestamp | test | public static function createFromTimestamp(int $timestamp, $timeZone = null, string $locale = null)
{
return new Time(date('Y-m-d H:i:s', $timestamp), $timeZone, $locale);
} | php | {
"resource": ""
} |
q254649 | Time.instance | test | public static function instance(DateTime $dateTime, string $locale = null)
{
$date = $dateTime->format('Y-m-d H:i:s');
$timezone = $dateTime->getTimezone();
return new Time($date, $timezone, $locale);
} | php | {
"resource": ""
} |
q254650 | Time.toDateTime | test | public function toDateTime()
{
$dateTime = new DateTime(null, $this->getTimezone());
$dateTime->setTimestamp(parent::getTimestamp());
return $dateTime;
} | php | {
"resource": ""
} |
q254651 | Time.getAge | test | public function getAge()
{
$now = Time::now()->getTimestamp();
$time = $this->getTimestamp();
// future dates have no age
return max(0, date('Y', $now) - date('Y', $time));
} | php | {
"resource": ""
} |
q254652 | Time.getDst | test | public function getDst(): bool
{
// grab the transactions that would affect today
$start = strtotime('-1 year', $this->getTimestamp());
$end = strtotime('+2 year', $start);
$transitions = $this->timezone->getTransitions($start, $end);
$daylightSaving = false;
foreach ($transitions as $transi... | php | {
"resource": ""
} |
q254653 | Time.setMonth | test | public function setMonth($value)
{
if (is_numeric($value) && $value < 1 || $value > 12)
{
throw I18nException::forInvalidMonth($value);
}
if (is_string($value) && ! is_numeric($value))
{
$value = date('m', strtotime("{$value} 1 2017"));
}
return $this->setValue('month', $value);
} | php | {
"resource": ""
} |
q254654 | Time.setDay | test | public function setDay($value)
{
if ($value < 1 || $value > 31)
{
throw I18nException::forInvalidDay($value);
}
$date = $this->getYear() . '-' . $this->getMonth();
$lastDay = date('t', strtotime($date));
if ($value > $lastDay)
{
throw I18nException::forInvalidOverDay($lastDay, $value);
}
r... | php | {
"resource": ""
} |
q254655 | Time.setMinute | test | public function setMinute($value)
{
if ($value < 0 || $value > 59)
{
throw I18nException::forInvalidMinutes($value);
}
return $this->setValue('minute', $value);
} | php | {
"resource": ""
} |
q254656 | Time.setSecond | test | public function setSecond($value)
{
if ($value < 0 || $value > 59)
{
throw I18nException::forInvalidSeconds($value);
}
return $this->setValue('second', $value);
} | php | {
"resource": ""
} |
q254657 | Time.setValue | test | protected function setValue(string $name, $value)
{
list($year, $month, $day, $hour, $minute, $second) = explode('-', $this->format('Y-n-j-G-i-s'));
$$name = $value;
return Time::create($year, $month, $day, $hour, $minute, $second, $this->getTimezoneName(), $this->loc... | php | {
"resource": ""
} |
q254658 | Time.setTimestamp | test | public function setTimestamp($timestamp)
{
$time = date('Y-m-d H:i:s', $timestamp);
return Time::parse($time, $this->timezone, $this->locale);
} | php | {
"resource": ""
} |
q254659 | Time.equals | test | public function equals($testTime, string $timezone = null): bool
{
$testTime = $this->getUTCObject($testTime, $timezone);
$ourTime = $this->toDateTime()
->setTimezone(new DateTimeZone('UTC'))
->format('Y-m-d H:i:s');
return $testTime->format('Y-m-d H:i:s') === $ourTime;
} | php | {
"resource": ""
} |
q254660 | Time.sameAs | test | public function sameAs($testTime, string $timezone = null): bool
{
if ($testTime instanceof DateTime)
{
$testTime = $testTime->format('Y-m-d H:i:s');
}
else if (is_string($testTime))
{
$timezone = $timezone ?: $this->timezone;
$timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZ... | php | {
"resource": ""
} |
q254661 | Time.getUTCObject | test | public function getUTCObject($time, string $timezone = null)
{
if ($time instanceof Time)
{
$time = $time->toDateTime()
->setTimezone(new DateTimeZone('UTC'));
}
else if ($time instanceof DateTime)
{
$time = $time->setTimezone(new DateTimeZone('UTC'));
}
else if (is_string($time))
{
$time... | php | {
"resource": ""
} |
q254662 | Escaper.jsMatcher | test | protected function jsMatcher($matches)
{
$chr = $matches[0];
if (strlen($chr) == 1) {
return sprintf('\\x%02X', ord($chr));
}
$chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8');
$hex = strtoupper(bin2hex($chr));
if (strlen($hex) <= 4) {
r... | php | {
"resource": ""
} |
q254663 | Escaper.cssMatcher | test | protected function cssMatcher($matches)
{
$chr = $matches[0];
if (strlen($chr) == 1) {
$ord = ord($chr);
} else {
$chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8');
$ord = hexdec(bin2hex($chr));
}
return sprintf('\\%X ', $ord);
} | php | {
"resource": ""
} |
q254664 | Escaper.toUtf8 | test | protected function toUtf8($string)
{
if ($this->getEncoding() === 'utf-8') {
$result = $string;
} else {
$result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding());
}
if (! $this->isUtf8($result)) {
throw new Exception\RuntimeExcepti... | php | {
"resource": ""
} |
q254665 | Escaper.fromUtf8 | test | protected function fromUtf8($string)
{
if ($this->getEncoding() === 'utf-8') {
return $string;
}
return $this->convertEncoding($string, $this->getEncoding(), 'UTF-8');
} | php | {
"resource": ""
} |
q254666 | FileCollection.getFile | test | public function getFile(string $name)
{
$this->populateFiles();
if ($this->hasFile($name))
{
if (strpos($name, '.') !== false)
{
$name = explode('.', $name);
$uploadedFile = $this->getValueDotNotationSyntax($name, $this->files);
return ($uploadedFile instanceof UploadedFile) ?
$u... | php | {
"resource": ""
} |
q254667 | FileCollection.createFileObject | test | protected function createFileObject(array $array)
{
if (! isset($array['name']))
{
$output = [];
foreach ($array as $key => $values)
{
if (! is_array($values))
{
continue;
}
$output[$key] = $this->createFileObject($values);
}
return $output;
}
return new UploadedFile(
... | php | {
"resource": ""
} |
q254668 | FileCollection.getValueDotNotationSyntax | test | protected function getValueDotNotationSyntax(array $index, array $value)
{
if (is_array($index) && ! empty($index))
{
$current_index = array_shift($index);
}
if (is_array($index) && $index && is_array($value[$current_index]) && $value[$current_index])
{
return $this->getValueDotNotationSyntax($index, $... | php | {
"resource": ""
} |
q254669 | DownloadResponse.setBinary | test | public function setBinary(string $binary)
{
if ($this->file !== null)
{
throw DownloadException::forCannotSetBinary();
}
$this->binary = $binary;
} | php | {
"resource": ""
} |
q254670 | DownloadResponse.setFilePath | test | public function setFilePath(string $filepath)
{
if ($this->binary !== null)
{
throw DownloadException::forCannotSetFilePath($filepath);
}
$this->file = new File($filepath, true);
} | php | {
"resource": ""
} |
q254671 | DownloadResponse.getContentLength | test | public function getContentLength() : int
{
if (is_string($this->binary))
{
return strlen($this->binary);
}
elseif ($this->file instanceof File)
{
return $this->file->getSize();
}
return 0;
} | php | {
"resource": ""
} |
q254672 | DownloadResponse.setContentTypeByMimeType | test | private function setContentTypeByMimeType()
{
$mime = null;
$charset = '';
if ($this->setMime === true)
{
if (($last_dot_position = strrpos($this->filename, '.')) !== false)
{
$mime = Mimes::guessTypeFromExtension(substr($this->filename, $last_dot_position + 1));
$charset = $this->charset;... | php | {
"resource": ""
} |
q254673 | DownloadResponse.getDownloadFileName | test | private function getDownloadFileName(): string
{
$filename = $this->filename;
$x = explode('.', $this->filename);
$extension = end($x);
/* It was reported that browsers on Android 2.1 (and possibly older as well)
* need to have the filename extension upper-cased in order to be able to
* downloa... | php | {
"resource": ""
} |
q254674 | DownloadResponse.getContentDisposition | test | private function getContentDisposition() : string
{
$download_filename = $this->getDownloadFileName();
$utf8_filename = $download_filename;
if (strtoupper($this->charset) !== 'UTF-8')
{
$utf8_filename = mb_convert_encoding($download_filename, 'UTF-8', $this->charset);
}
$result = sprintf('attachment;... | php | {
"resource": ""
} |
q254675 | DownloadResponse.buildHeaders | test | public function buildHeaders()
{
if (! $this->hasHeader('Content-Type'))
{
$this->setContentTypeByMimeType();
}
$this->setHeader('Content-Disposition', $this->getContentDisposition());
$this->setHeader('Expires-Disposition', '0');
$this->setHeader('Content-Transfer-Encoding', 'binary');
$this->setHea... | php | {
"resource": ""
} |
q254676 | DownloadResponse.sendBody | test | public function sendBody()
{
if ($this->binary !== null)
{
return $this->sendBodyByBinary();
}
elseif ($this->file !== null)
{
return $this->sendBodyByFilePath();
}
throw DownloadException::forNotFoundDownloadSource();
} | php | {
"resource": ""
} |
q254677 | DownloadResponse.sendBodyByFilePath | test | private function sendBodyByFilePath()
{
$spl_file_object = $this->file->openFile('rb');
// Flush 1MB chunks of data
while (! $spl_file_object->eof() && ($data = $spl_file_object->fread(1048576)) !== false)
{
echo $data;
}
return $this;
} | php | {
"resource": ""
} |
q254678 | CommandRunner._remap | test | public function _remap($method, ...$params)
{
// The first param is usually empty, so scrap it.
if (empty($params[0]))
{
array_shift($params);
}
$this->index($params);
} | php | {
"resource": ""
} |
q254679 | CommandRunner.runCommand | test | protected function runCommand(string $command, array $params)
{
if (! isset($this->commands[$command]))
{
CLI::error(lang('CLI.commandNotFound', [$command]));
CLI::newLine();
return;
}
// The file would have already been loaded during the
// createCommandList function...
$className = $this->comma... | php | {
"resource": ""
} |
q254680 | CommandRunner.createCommandList | test | protected function createCommandList()
{
$files = Services::locator()->listFiles('Commands/');
// If no matching command files were found, bail
if (empty($files))
{
// This should never happen in unit testing.
// if it does, we have far bigger problems!
// @codeCoverageIgnoreStart
return;
// @c... | php | {
"resource": ""
} |
q254681 | Config.connect | test | public static function connect($group = null, bool $getShared = true)
{
// If a DB connection is passed in, just pass it back
if ($group instanceof BaseConnection)
{
return $group;
}
if (is_array($group))
{
$config = $group;
$group = 'custom-' . md5(json_encode($config));
}
$config = $confi... | php | {
"resource": ""
} |
q254682 | Config.seeder | test | public static function seeder(string $group = null)
{
$config = config('Database');
return new Seeder($config, static::connect($group));
} | php | {
"resource": ""
} |
q254683 | MigrateRollback.isAllNamespace | test | private function isAllNamespace(array $params): bool
{
if (array_search('-all', $params) !== false)
{
return true;
}
return ! is_null(CLI::getOption('all'));
} | php | {
"resource": ""
} |
q254684 | Iterator.add | test | public function add(string $name, \Closure $closure)
{
$name = strtolower($name);
$this->tests[$name] = $closure;
return $this;
} | php | {
"resource": ""
} |
q254685 | Iterator.run | test | public function run(int $iterations = 1000, bool $output = true)
{
foreach ($this->tests as $name => $test)
{
// clear memory before start
gc_collect_cycles();
$start = microtime(true);
$start_mem = $max_memory = memory_get_usage(true);
for ($i = 0; $i < $iterations; $i ++)
{
$result = ... | php | {
"resource": ""
} |
q254686 | Iterator.getReport | test | public function getReport(): string
{
if (empty($this->results))
{
return 'No results to display.';
}
helper('number');
// Template
$tpl = '<table>
<thead>
<tr>
<td>Test</td>
<td>Time</td>
<td>Memory</td>
</tr>
</thead>
<tbody>
{rows}
</tbody>
</table>';
$ro... | php | {
"resource": ""
} |
q254687 | Query.setQuery | test | public function setQuery(string $sql, $binds = null, bool $setEscape = true)
{
$this->originalQueryString = $sql;
if (! is_null($binds))
{
if (! is_array($binds))
{
$binds = [$binds];
}
if ($setEscape)
{
array_walk($binds, function (&$item) {
$item = [
$item,
true,
... | php | {
"resource": ""
} |
q254688 | Query.getQuery | test | public function getQuery(): string
{
if (empty($this->finalQueryString))
{
$this->finalQueryString = $this->originalQueryString;
}
$this->compileBinds();
return $this->finalQueryString;
} | php | {
"resource": ""
} |
q254689 | Query.getStartTime | test | public function getStartTime(bool $returnRaw = false, int $decimals = 6): string
{
if ($returnRaw)
{
return $this->startTime;
}
return number_format($this->startTime, $decimals);
} | php | {
"resource": ""
} |
q254690 | Query.getDuration | test | public function getDuration(int $decimals = 6): string
{
return number_format(($this->endTime - $this->startTime), $decimals);
} | php | {
"resource": ""
} |
q254691 | Query.setError | test | public function setError(int $code, string $error)
{
$this->errorCode = $code;
$this->errorString = $error;
return $this;
} | php | {
"resource": ""
} |
q254692 | Query.swapPrefix | test | public function swapPrefix(string $orig, string $swap)
{
$sql = empty($this->finalQueryString) ? $this->originalQueryString : $this->finalQueryString;
$this->finalQueryString = preg_replace('/(\W)' . $orig . '(\S+?)/', '\\1' . $swap . '\\2', $sql);
return $this;
} | php | {
"resource": ""
} |
q254693 | Query.compileBinds | test | protected function compileBinds()
{
$sql = $this->finalQueryString;
$hasNamedBinds = strpos($sql, ':') !== false;
if (empty($this->binds) || empty($this->bindMarker) ||
(strpos($sql, $this->bindMarker) === false &&
$hasNamedBinds === false)
)
{
return;
}
if (! is_array($this->binds))
{
... | php | {
"resource": ""
} |
q254694 | Controller.loadHelpers | test | protected function loadHelpers()
{
if (empty($this->helpers))
{
return;
}
foreach ($this->helpers as $helper)
{
helper($helper);
}
} | php | {
"resource": ""
} |
q254695 | Autoloader.register | test | public function register()
{
// Since the default file extensions are searched
// in order of .inc then .php, but we always use .php,
// put the .php extension first to eek out a bit
// better performance.
// http://php.net/manual/en/function.spl-autoload.php#78053
spl_autoload_extensions('.php,.inc');
... | php | {
"resource": ""
} |
q254696 | Autoloader.addNamespace | test | public function addNamespace($namespace, string $path = null)
{
if (is_array($namespace))
{
foreach ($namespace as $prefix => $path)
{
$prefix = trim($prefix, '\\');
if (is_array($path))
{
foreach ($path as $dir)
{
$this->prefixes[$prefix][] = rtrim($dir, '/') . '/';
}
... | php | {
"resource": ""
} |
q254697 | Autoloader.getNamespace | test | public function getNamespace(string $prefix = null)
{
if ($prefix === null)
{
return $this->prefixes;
}
return $this->prefixes[trim($prefix, '\\')] ?? [];
} | php | {
"resource": ""
} |
q254698 | Autoloader.requireFile | test | protected function requireFile(string $file)
{
$file = $this->sanitizeFilename($file);
if (is_file($file))
{
require_once $file;
return $file;
}
return false;
} | php | {
"resource": ""
} |
q254699 | Autoloader.sanitizeFilename | test | public function sanitizeFilename(string $filename): string
{
// Only allow characters deemed safe for POSIX portable filenames.
// Plus the forward slash for directory separators since this might
// be a path.
// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_278
// Modified t... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.