_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q252100
Container.cacheMarkers
validation
protected function cacheMarkers(string $marker): void { $this->marked[$marker] = []; foreach ($this->definitions as $definition) { foreach ((array) $definition->markers as $m) { if ($m instanceof $marker) { $this->marked[$marker][] = [ ...
php
{ "resource": "" }
q252101
Container.createObject
validation
protected function createObject(string $typeName, ?bool $nullable = false, ?bool $checkCycles = true, ?bool $treatAsNotFound = true): ?object { if ($checkCycles) { $this->underConstruction[$typeName] = true; } try { if (!isset($this->typeCache[$typeName])) { ...
php
{ "resource": "" }
q252102
Container.createObjectUsingFactory
validation
protected function createObjectUsingFactory(string $typeName, Factory $factory, ?bool $nullable = false): ?object { $this->underConstruction[$typeName] = true; try { // Assemble arguments and scope config objects to the bound type: $object = ($factory->callback)(...$...
php
{ "resource": "" }
q252103
Hasher.getHashes
validation
public function getHashes() { if (empty($this->hashes)) { $this->generateHashes(); } return json_encode($this->hashes, \sndsgd\Json::HUMAN); }
php
{ "resource": "" }
q252104
Hasher.createIterator
validation
protected function createIterator() { $options = \RecursiveDirectoryIterator::SKIP_DOTS; $iterator = new \RecursiveDirectoryIterator($this->dir, $options); $options = \RecursiveIteratorIterator::SELF_FIRST; return new \RecursiveIteratorIterator($iterator, $options); }
php
{ "resource": "" }
q252105
Hasher.generateHashes
validation
protected function generateHashes(): array { $dirLength = strlen($this->dir); foreach ($this->createIterator() as $file) { if (!$file->isFile()) { continue; } $realpath = $file->getRealPath(); $path = $file->getPath().DIRECTORY_SEPARATO...
php
{ "resource": "" }
q252106
BaseInstanceWrapperComponent.setInstProperty
validation
protected function setInstProperty($inst, $propertyName, $mappingDefinition, $propertyValue = null) { if ($mappingDefinition === false) { return false; // Do not even attempt to set this property } if (func_num_args() <= 3) { $propertyValue = $this->$propertyName; ...
php
{ "resource": "" }
q252107
BaseInstanceWrapperComponent.createNewInst
validation
protected function createNewInst() { $classReflection = new \ReflectionClass($this->instClass); if ($this->constructorArgs === null) { return $classReflection->newInstance(); } else { return $classReflection->newInstanceArgs($this->concstructorArgs); } }
php
{ "resource": "" }
q252108
IdentityModel.getList
validation
public function getList(): IDataSource { $columns = array_map(function ($item) { return $this->tableName[0] . '.' . $item; }, $this->columns); return $this->connection->select($columns)->from($this->tableIdentity)->as($this->tableName[0]); }
php
{ "resource": "" }
q252109
IdentityModel.getById
validation
public function getById(int $id) { /** @noinspection PhpUndefinedMethodInspection */ return $this->getList() ->where([$this->tableName[0] . '.' . self::COLUMN_ID => $id]) ->fetch(); }
php
{ "resource": "" }
q252110
IdentityModel.getByEmail
validation
public function getByEmail(string $email) { // get by id and active must by true /** @noinspection PhpUndefinedMethodInspection */ return $this->getList() ->where([$this->tableName[0] . '.email' => $email, $this->tableName[0] . '.active' => true]) ->fetch(); }
php
{ "resource": "" }
q252111
IdentityModel.verifyHash
validation
public function verifyHash(string $password, string $hash): bool { return Passwords::verify($password, $hash); }
php
{ "resource": "" }
q252112
IdentityModel.existLogin
validation
public function existLogin(string $login): int { return (int) $this->connection->select(self::COLUMN_ID) ->from($this->tableIdentity) ->where(['login' => $login]) ->fetchSingle(); }
php
{ "resource": "" }
q252113
IdentityModel.existEmail
validation
public function existEmail(string $email): int { return (int) $this->connection->select(self::COLUMN_ID) ->from($this->tableIdentity) ->where(['email' => $email]) ->fetchSingle(); }
php
{ "resource": "" }
q252114
IdentityModel.cleanUser
validation
public function cleanUser(string $validate = null): int { $result = 0; if ($validate) { $validateTo = new DateTime; $validateTo->modify($validate); /** @noinspection PhpUndefinedMethodInspection */ $list = $this->getList() ->where([ ...
php
{ "resource": "" }
q252115
IdentityModel.getEncodeHash
validation
public function getEncodeHash(int $id, string $slug, string $linkValidate = null): string { return base64_encode(uniqid(($linkValidate ? strtotime($linkValidate) : self::NO_TIME) . self::TIME_SEPARATOR, true) . self::PART_SEPARATOR . $this->getHash($id . $slug) . self::ID_SEPARATOR . $id); }
php
{ "resource": "" }
q252116
IdentityModel.getDecodeHash
validation
public function getDecodeHash(string $hash): array { $decode = base64_decode($hash); list($part1, $part2) = explode(self::PART_SEPARATOR, $decode); $p1 = explode(self::TIME_SEPARATOR, $part1); list($linkValidate,) = $p1; // get validate int $id = null; $verifyHash =...
php
{ "resource": "" }
q252117
IdentityModel.processApprove
validation
public function processApprove(string $hash): bool { $decode = $this->getDecodeHash($hash); $id = (int) $decode['id']; $verifyHash = $decode['verifyHash']; $item = $this->getById($id); // load row from db if ($item && $id == $item['id']) { // not null result if...
php
{ "resource": "" }
q252118
IdentityModel.isValidForgotten
validation
public function isValidForgotten(string $hash): bool { $decode = $this->getDecodeHash($hash); $id = (int) $decode['id']; $verifyHash = $decode['verifyHash']; $item = $this->getById($id); // load row from db if ($item && $id == $item['id']) { // not null result ...
php
{ "resource": "" }
q252119
IdentityModel.processForgotten
validation
public function processForgotten(string $hash, string $password): bool { $decode = $this->getDecodeHash($hash); $id = (int) $decode['id']; $verifyHash = $decode['verifyHash']; $item = $this->getById($id); // load row from db if ($item && $id == $item['id']) { // not null r...
php
{ "resource": "" }
q252120
ErrorHandler.convertExceptionToArray
validation
protected function convertExceptionToArray($exception) { if (!YII_DEBUG && !$exception instanceof UserException && !$exception instanceof HttpException) { $exception = new HttpException(500, 'There was an error at the server.'); } $array = [ 'name' => ($exception ins...
php
{ "resource": "" }
q252121
ErrorHandler.renderPreviousExceptions
validation
public function renderPreviousExceptions($exception) { if (($previous = $exception->getPrevious()) !== null) { return $this->renderFile($this->previousExceptionView, ['exception' => $previous]); } else { return ''; } }
php
{ "resource": "" }
q252122
PathConfig.checkPaths
validation
public function checkPaths() { if ($this->path_checked) return true; foreach (array('root', 'webroot') as $type) { $path = $this->$type; if (!file_exists($path) || !is_dir($path)) throw new IOException("Path '$type' does not exist: " . $pa...
php
{ "resource": "" }
q252123
EventDispatcherCollection.aggregateTernaryValues
validation
protected function aggregateTernaryValues(array $values) { if (in_array(false, $values, true)) { return false; } elseif (in_array(true, $values, true)) { return true; } else { return null; } }
php
{ "resource": "" }
q252124
ErrorStreamClient.reportException
validation
public function reportException(\Exception $ex) { $report = new ErrorStreamReport(); $report->error_group = $ex->getMessage().':'.$ex->getLine(); $report->line_number = $ex->getLine(); $report->file_name = $ex->getFile(); $report->message = $ex->getMessage(); $report-...
php
{ "resource": "" }
q252125
ErrorStreamClient.report
validation
public function report(ErrorStreamReport $report) { $report->tags = $this->tags; $report->context = $this->context; return $this->makeRequest($report); }
php
{ "resource": "" }
q252126
ErrorStreamClient.makeRequest
validation
protected function makeRequest($data) { $url = 'https://www.errorstream.com/api/1.0/errors/create?'.http_build_query(['api_token' => $this->api_token, 'project_token' => $this->project_token]); try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_s...
php
{ "resource": "" }
q252127
AuthSession.startSession
validation
protected function startSession(Request $request, $sessionId) { return tap($this->getSession($sessionId), function ($session) use ($request) { $session->setRequestOnHandler($request); $session->start(); }); }
php
{ "resource": "" }
q252128
AuthSession.getSession
validation
public function getSession($sessionId) { return tap($this->manager->driver(), function ($session) use ($sessionId) { $session->setId($sessionId); }); }
php
{ "resource": "" }
q252129
CLI.addOption
validation
public function addOption($short, $long, $arg, $description) { $this->parameters[] = array( $short, $long, $arg, $description ); return $this; }
php
{ "resource": "" }
q252130
CLI.parse
validation
public function parse() { list($opt_str, $long_opts, $mapping) = $this->getOptString(); $opts = \getopt($opt_str, $long_opts); $options = $this->mapOptions($opts, $mapping); return new Dictionary($options); }
php
{ "resource": "" }
q252131
CLI.input
validation
public static function input($prompt, $default = null) { $ret = false; while (!$ret) { if ($prompt) { echo $prompt; if ($default) echo " (" . $default . ")"; echo ": "; }...
php
{ "resource": "" }
q252132
CLI.syntax
validation
public function syntax($error = "Please specify valid options") { $ostr = (!$error) ? STDOUT : STDERR; if (is_string($error)) fprintf($ostr, "Error: %s\n", $error); fprintf($ostr, "Syntax: php " . $_SERVER['argv'][0] . " <options> <action>\n\n"); fprintf($ostr, "Options: ...
php
{ "resource": "" }
q252133
IntType.isPrime
validation
public function isPrime() { if ($this->value < 2) { return false; } if ($this->value === 2) { return true; } if ($this->isEven()) { return false; } for ($i = 3; $i <= ceil(sqrt($this->value)); $i = $i + 2) { i...
php
{ "resource": "" }
q252134
UriCollection.add
validation
public function add($name, UriInterface $uri) { unset($this->uris[$name]); $this->uris[$name] = $uri; }
php
{ "resource": "" }
q252135
UriCollection.get
validation
public function get($name) { return isset($this->uris[$name]) ? $this->uris[$name] : null; }
php
{ "resource": "" }
q252136
UriCollection.addCollection
validation
public function addCollection(UriCollection $collection) { // we need to remove all uris with the same names first because just replacing them // would not place the new uri at the end of the merged array foreach ($collection->all() as $name => $uri) { unset($this->uris[$name]); ...
php
{ "resource": "" }
q252137
UriCollection.setHost
validation
public function setHost($host) { foreach ($this->uris as $name => $uri) { $this->add($name, $uri->withHost($host)); } }
php
{ "resource": "" }
q252138
UriCollection.setScheme
validation
public function setScheme($scheme) { foreach ($this->uris as $name => $uri) { $this->add($name, $uri->withScheme($scheme)); } }
php
{ "resource": "" }
q252139
Entity.getScheme
validation
public function getScheme(): array { if (null === $this->scheme) { $raw = $this->medoo->query('DESCRIBE '.$this->getTable())->fetchAll(); $this->scheme = []; foreach ($raw as $field) { $this->scheme[$field['Field']] = $field; } } ...
php
{ "resource": "" }
q252140
Entity.save
validation
public function save(bool $validate = true): self { if ($validate && $this->validate()) { throw new Exception('Entity '.$this->__getEntityName().' data is not valid'); } /** * Remove fields that not exists in DB table scheme, * to avoid thrown exceptions on sav...
php
{ "resource": "" }
q252141
Entity.validate
validation
public function validate(string $method = 'save'): array { $errors = []; foreach ($this->getValidators()[$method] ?? [] as $field => $validator) { try { $validator->setName($field)->assert($this->get($field)); } catch (NestedValidationException $e) { ...
php
{ "resource": "" }
q252142
Entity.loadAll
validation
public function loadAll(array $where = [], bool $assoc = false, array $fields = null): Collection { $allData = $this->medoo->select($this->getTable(), $fields ? $fields : '*', $where); $this->sentry->breadcrumbs->record([ 'message' => 'Entity '.$this->__getEntityName().'::loadAll('.\prin...
php
{ "resource": "" }
q252143
Entity.loadRelation
validation
public function loadRelation(string $name) { if (!isset($this->relationObjects[$name]) || empty($this->relationObjects[$name])) { $relation = $this->getRelations()[$name]; if (!$relation || !$relation['entity'] || !$this->get($relation['key'] ?? 'id')) { return null; ...
php
{ "resource": "" }
q252144
Entity.delete
validation
public function delete(): bool { return (bool) $this->medoo->delete($this->getTable(), ['id' => $this->getId()]); }
php
{ "resource": "" }
q252145
DirEntity.isEmpty
validation
public function isEmpty() { if ($this->test(\sndsgd\Fs::EXISTS | \sndsgd\Fs::READABLE) === false) { throw new \RuntimeException( "failed to determine if a directory is empty; ".$this->getError() ); } return count(scandir($this->path)) === 2; }
php
{ "resource": "" }
q252146
DirEntity.getList
validation
public function getList($asStrings = false) { $list = scandir($this->path); if ($asStrings === true) { return array_diff($list, [".", ".."]); } $ret = []; foreach ($list as $name) { if ($name === "." || $name === "..") { continue; ...
php
{ "resource": "" }
q252147
DirEntity.remove
validation
public function remove(): bool { if ($this->test(\sndsgd\Fs::EXISTS | \sndsgd\Fs::READABLE | \sndsgd\Fs::WRITABLE) === false) { $this->error = "failed to remove directory; {$this->error}"; return false; } foreach ($this->getList() as $entity) { if ($entit...
php
{ "resource": "" }
q252148
QueryParams.get
validation
public static function get(array $server): array { $params = []; if (isset($server['QUERY_STRING'])) { $query = ltrim($server['QUERY_STRING'], '?'); foreach (explode('&', $query) as $pair) { if ($pair) { list($name, $value) = self::normaliz...
php
{ "resource": "" }
q252149
Binding.instance
validation
public function instance(object $object): Binding { if (!$object instanceof $this->definition->typeName) { throw new \InvalidArgumentException(\sprintf('%s is not an instance of %s', \get_class($object), $this->definition->typeName)); } $this->definition->instantiator = ...
php
{ "resource": "" }
q252150
Binding.inject
validation
public function inject(string ...$methods): Binding { if ($this->definition->injects === null) { $this->definition->injects = \array_fill_keys($methods, true); } else { foreach ($methods as $f) { $this->definition->injects[$f] = true; } } ...
php
{ "resource": "" }
q252151
Binding.decorate
validation
public function decorate(callable $decorator): Binding { if (empty($this->definition->decorators)) { $this->definition->decorators = []; } $this->definition->decorators[] = new Decorator($decorator); return $this; }
php
{ "resource": "" }
q252152
Binding.marked
validation
public function marked(Marker ...$markers): Binding { if (empty($this->definition->markers)) { $this->definition->markers = []; } foreach ($markers as $marker) { $types = $marker->getAllowedTyes(); if (empty($types)) { ...
php
{ "resource": "" }
q252153
InputOutputTiming.convertDateTimeToUtcTimeZone
validation
public function convertDateTimeToUtcTimeZone($inStrictIso8601DtTm) { $tmpDateTimeIn = $this->convertTimeFromFormatSafely($inStrictIso8601DtTm); $tmpDateTimeIn->setTimezone(new \DateTimeZone('UTC')); return $tmpDateTimeIn->format('Y-m-d H:i:s'); }
php
{ "resource": "" }
q252154
AppRunner.setVariable
validation
public function setVariable(string $name, $value, bool $as_instance = true) { $this->variables[$name] = $value; if (is_object($value)) $this->instances[get_class($value)] = $value; return $this; }
php
{ "resource": "" }
q252155
AppRunner.execute
validation
public function execute() { try { // No output should be produced by apps directly, so buffer // everything, and log afterwards $this->output_buffer_level = ob_get_level(); ob_start(); $response = $this->doExecute(); if ( ...
php
{ "resource": "" }
q252156
AppRunner.findController
validation
protected function findController($object) { // Get the next URL argument $urlargs = $this->arguments; $arg = $urlargs->shift(); // Store it as controller name $controller = $arg; // Strip any suffix if (($pos = strpos($controller, '.')) !== false) ...
php
{ "resource": "" }
q252157
AppRunner.logScriptOutput
validation
private function logScriptOutput() { $output_buffers = array(); $ob_cnt = 0; while (ob_get_level() > $this->output_buffer_level) { $output = trim(ob_get_contents()); ++$ob_cnt; ob_end_clean(); if (!empty($output)) { ...
php
{ "resource": "" }
q252158
MelisCmsPageHistoricRecentUserActivityPlugin.isCmsActive
validation
private function isCmsActive() { $melisCms = 'MelisCms'; $moduleSvc = $this->getServiceLocator()->get('ModulesService'); $modules = $moduleSvc->getActiveModules(); if(in_array($melisCms, $modules)) { return true; } return false; }
php
{ "resource": "" }
q252159
Db.getUserEntity
validation
public function getUserEntity($identity, $credential) { $credential = $this->preProcessCredential($credential); $userObject = NULL; // Cycle through the configured identity sources and test each $fields = $this->getOptions()->getAuthIdentityFields(); while ( !is_object($userObject) && count($fields) > 0 ...
php
{ "resource": "" }
q252160
StopWords.getArray
validation
public static function getArray($language) { $fileName = __DIR__ . '/stop-words/' . $language . '.txt'; if (file_exists($fileName)) { return array_map('trim', file($fileName)); } return []; }
php
{ "resource": "" }
q252161
StopWords.getString
validation
public static function getString($language, $separator = ',') { $fileName = __DIR__ . '/stop-words/' . $language . '.txt'; if (file_exists($fileName)) { return implode($separator, array_map('trim', file($fileName))); } return ''; }
php
{ "resource": "" }
q252162
Table.setHeaders
validation
public function setHeaders(array $headers) { $columnNumber = 0; foreach ($headers as $header) { $this->updateWidth($columnNumber, $this->length($header)); if (!in_array($header, $this->headers)) { $this->headers[] = $header; } $columnNu...
php
{ "resource": "" }
q252163
Table.setRows
validation
public function setRows(array $rows) { foreach ($rows as $row) { $columnNumber = 0; if (!is_array($row)) { $row = [$row]; } foreach ($row as $column => $value) { $this->updateWidth($columnNumber, $this->length($column)); ...
php
{ "resource": "" }
q252164
Table.render
validation
public function render() { $output = []; // Top. if (count($this->rows) > 0) { $output[] = $this->renderLine(); } // Headers. if (count($this->columns) > 0) { $line = []; $line[] = $this->charVertical; $columnNumber = ...
php
{ "resource": "" }
q252165
Table.renderLine
validation
private function renderLine() { $output = []; $output[] = $this->charCross; if (count($this->columns) > 0) { for ($columnNumber = 0; $columnNumber < count($this->columns); $columnNumber++) { $output[] = $this->renderCell($columnNumber, $this->charHorizontal, $this...
php
{ "resource": "" }
q252166
Table.renderRow
validation
private function renderRow(array $row) { $output = []; $output[] = $this->charVertical; $columnNumber = 0; foreach ($row as $column => $value) { $output[] = $this->renderCell($columnNumber, $value, ' '); $output[] = $this->charVertical; $columnNumb...
php
{ "resource": "" }
q252167
Table.renderCell
validation
private function renderCell($columnNumber, $value, $filler, $style = '') { $output = []; $width = $this->getWidth($columnNumber); $output[] = $filler; while ($this->length($value) < $width) { $value .= $filler; } $output[] = Style::applyStyle($value, $styl...
php
{ "resource": "" }
q252168
Table.updateWidth
validation
private function updateWidth($columnNumber, $width) { if ($width > $this->getWidth($columnNumber)) { $this->widths[$columnNumber] = $width; } }
php
{ "resource": "" }
q252169
DAL.executeInstruction
validation
public function executeInstruction(string $strSQL, ?array $parans = null) : bool { $this->dbPreparedStatment = $this->dbConnection->prepare($strSQL); $this->pdoLastError = null; if($parans !== null) { foreach($parans as $key => $value) { $val = $value; ...
php
{ "resource": "" }
q252170
DAL.getCountOf
validation
public function getCountOf(string $strSQL, ?array $parans = null) : int { $r = $this->getDataColumn($strSQL, $parans, "int"); return (($r === null) ? 0 : $r); }
php
{ "resource": "" }
q252171
DAL.countRowsFrom
validation
public function countRowsFrom(string $tableName, string $pkName) : int { $strSQL = "SELECT COUNT($pkName) as count FROM $tableName;"; return $this->getCountOf($strSQL); }
php
{ "resource": "" }
q252172
DAL.countRowsWith
validation
function countRowsWith(string $tablename, string $colName, $colValue) : int { $strSQL = "SELECT COUNT($colName) as count FROM $tablename WHERE $colName=:$colName;"; return $this->getCountOf($strSQL, ["$colName" => $colValue]); }
php
{ "resource": "" }
q252173
DAL.hasRowsWith
validation
public function hasRowsWith(string $tablename, string $colName, $colValue) : bool { return ($this->countRowsWith($tablename, $colName, $colValue) > 0); }
php
{ "resource": "" }
q252174
UriGenerator.resolveParams
validation
protected function resolveParams(UriInfo $info, array $params) { $uri = $info->getUri(); if(false === strpos($uri, '{')) { return $info; } $ctx = NULL; $result = ''; foreach(preg_split("'(\\{[^\\}]+\\})'", $uri, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $part) { if('{' != sub...
php
{ "resource": "" }
q252175
AuthDataDriver.is_php
validation
protected function is_php($version) { static $_is_php; $version = (string)$version; if (!isset($_is_php[$version])) { $_is_php[$version] = version_compare(PHP_VERSION, $version, '>='); } return $_is_php[$version]; }
php
{ "resource": "" }
q252176
ResettingController.checkEmailAction
validation
public function checkEmailAction() { $session = $this->get('session'); $email = $session->get(static::SESSION_EMAIL); $session->remove(static::SESSION_EMAIL); if (empty($email)) { return new RedirectResponse($this->get('router')->generate('miky_app_customer_resetting_req...
php
{ "resource": "" }
q252177
ResettingController.authenticateUser
validation
protected function authenticateUser(CustomerInterface $user, Response $response) { try { $this->get('fos_user.security.login_manager')->loginUser( $this->getParameter('fos_user.firewall_name'), $user, $response); } catch (AccountStatusExcep...
php
{ "resource": "" }
q252178
ResettingController.getObfuscatedEmail
validation
protected function getObfuscatedEmail(CustomerInterface $user) { $email = $user->getEmail(); if (false !== $pos = strpos($email, '@')) { $email = '...' . substr($email, $pos); } return $email; }
php
{ "resource": "" }
q252179
LogParser.populateEntries
validation
private static function populateEntries($heading, $data, $key) { foreach (LogLevels::all() as $level) { if (self::hasLogLevel($heading[$key], $level)) { self::$parsed[] = [ 'level' => $level, 'header' => $heading[$key], ...
php
{ "resource": "" }
q252180
Keeper.get
validation
public function get($key) { if (!($time = $this->driver->get($key))) { if ($key == self::LAST_UPDATE_KEY) { $time = $this->reset(); } else { $time = $this->get(self::LAST_UPDATE_KEY); } } return $time; }
php
{ "resource": "" }
q252181
Keeper.getResponse
validation
public function getResponse($params = [], $lifetime = -1, Response $response = null) { if (!$response) { $response = new Response(); } if (!$this->enable) { return $response; } return $this->configurator->configure($response, $this->getMax($params), ...
php
{ "resource": "" }
q252182
Keeper.getModifiedResponse
validation
public function getModifiedResponse(Request $request, $params = [], $lifetime = -1, Response $response = null) { $response = $this->getResponse($params, $lifetime, $response); if ($response->isNotModified($request)) { throw new NotModifiedException($response); } return ...
php
{ "resource": "" }
q252183
Keeper.reset
validation
private function reset() { $time = new \DateTime(); $this->driver->set(self::LAST_UPDATE_KEY, $time); return $time; }
php
{ "resource": "" }
q252184
FixedBitNotation.encode
validation
public function encode($rawString) { // Unpack string into an array of bytes $bytes = unpack('C*', $rawString); $byteCount = count($bytes); $encodedString = ''; $byte = array_shift($bytes); $bitsRead = 0; $chars = $this->chars; $bitsPerCharacter = $t...
php
{ "resource": "" }
q252185
PrerenderListener.onPrerenderPre
validation
public function onPrerenderPre(PrerenderEvent $events) { $cache = $this->getServiceLocator()->get($this->moduleOptions->getCacheKey()); return $cache->getItem($this->getCacheEntryKey($events->getRequest())); }
php
{ "resource": "" }
q252186
PrerenderListener.onPrerenderPost
validation
public function onPrerenderPost(PrerenderEvent $events) { $cache = $this->getServiceLocator()->get($this->moduleOptions->getCacheKey()); $response = $events->getResponse(); $key = $this->getCacheEntryKey($events->getRequest()); $cache->setItem($key, $events->getResponse()); ...
php
{ "resource": "" }
q252187
Request.post
validation
public function post($name = null, $defaultValue = null) { if ($name === null) { return $this->getBodyParams(); } else { return $this->getBodyParam($name, $defaultValue); } }
php
{ "resource": "" }
q252188
Request.getAcceptableContentTypes
validation
public function getAcceptableContentTypes() { if ($this->_contentTypes === null) { if (isset($_SERVER['HTTP_ACCEPT'])) { $this->_contentTypes = $this->parseAcceptHeader($_SERVER['HTTP_ACCEPT']); } else { $this->_contentTypes = []; } ...
php
{ "resource": "" }
q252189
Request.getCsrfToken
validation
public function getCsrfToken($regenerate = false) { if ($this->_csrfToken === null || $regenerate) { if ($regenerate || ($token = $this->loadCsrfToken()) === null) { $token = $this->generateCsrfToken(); } // the mask doesn't need to be very random ...
php
{ "resource": "" }
q252190
Request.loadCsrfToken
validation
protected function loadCsrfToken() { if ($this->enableCsrfCookie) { return $this->getCookies()->getValue($this->csrfParam); } else { return Yii::$app->getSession()->get($this->csrfParam); } }
php
{ "resource": "" }
q252191
Request.xorTokens
validation
private function xorTokens($token1, $token2) { $n1 = StringHelper::byteLength($token1); $n2 = StringHelper::byteLength($token2); if ($n1 > $n2) { $token2 = str_pad($token2, $n1, $token2); } elseif ($n1 < $n2) { $token1 = str_pad($token1, $n2, $n1 === 0 ? ' ' :...
php
{ "resource": "" }
q252192
Request.validateCsrfTokenInternal
validation
private function validateCsrfTokenInternal($token, $trueToken) { $token = base64_decode(str_replace('.', '+', $token)); $n = StringHelper::byteLength($token); if ($n <= static::CSRF_MASK_LENGTH) { return false; } $mask = StringHelper::byteSubstr($token, 0, static:...
php
{ "resource": "" }
q252193
MessageHelper.write
validation
protected function write(Response $response, $body): Response { $response->getBody()->write((string) $body); return $response; }
php
{ "resource": "" }
q252194
MessageHelper.ifModSince
validation
protected function ifModSince(Request $request, Response $response, int $timestamp): Response { $ifModSince = $request->getHeaderLine('If-Modified-Since'); if ($ifModSince && $timestamp <= strtotime($ifModSince)) { return $response->withStatus(304, "Not Modified"); } retu...
php
{ "resource": "" }
q252195
MessageHelper.ifNoneMatch
validation
protected function ifNoneMatch(Request $request, Response $response, string $etag): Response { $ifNoneMatch = $request->getHeaderLine('If-None-Match'); if ($ifNoneMatch && $etag === $ifNoneMatch) { return $response->withStatus(304, "Not Modified"); } return $response; ...
php
{ "resource": "" }
q252196
MessageHelper.redirect
validation
protected function redirect(Response $response, int $code, string $url): Response { return $response->withStatus($code)->withHeader('Location', $url); }
php
{ "resource": "" }
q252197
BeforeAfterTrait.dealWithParam
validation
protected function dealWithParam( /*# string */ $clause, array $values )/*# : string */ { array_shift($values); array_shift($values); // replacement $pat = $rep = []; foreach ($values as $val) { $pat[] = '/\?/'; $rep[] = $this->getBuil...
php
{ "resource": "" }
q252198
Mover.iLikeToMoveItMoveItBack
validation
public function iLikeToMoveItMoveItBack() { $moveCommand = $this->popCommandFromList(); $moveCommand->reverseFromToDirs(); $this->direction = self::DIRECTION_BACK; $this->init($moveCommand); $this->processFiles(); }
php
{ "resource": "" }
q252199
Mover.processFiles
validation
private function processFiles() { foreach ($this->currentCommand->getFilesToMove() as $fileToMove) { if ($fileToMove instanceof \SplFileInfo) { $this->processSplFileInfo($fileToMove); } else { $this->processArray($fileToMove); } } ...
php
{ "resource": "" }