_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q261100
AbstractFormatter.formatNumber
test
protected function formatNumber($float, $suffix, $precision = null) { if ($precision === null) { $precision = $this->precision; }
php
{ "resource": "" }
q261101
AbstractFormatter.normalizeBytes
test
protected function normalizeBytes($bytes) { $filteredBytes = filter_var($bytes, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); list ($bytes, $part) = explode('.', $filteredBytes . '.0');
php
{ "resource": "" }
q261102
AbstractFormatter.normalizePrecision
test
protected function normalizePrecision($precision) { $precisionFiltered
php
{ "resource": "" }
q261103
Request.withMethod
test
public function withMethod($method) { $method = strtoupper($method); $knownMethods = [ 'HEAD', 'OPTIONS', 'GET', 'POST', 'PUT', 'DELETE', 'CONNECT', 'TRACE', 'PATCH', 'PURGE' ]; if (! in_array($method, $knownMethods)) {
php
{ "resource": "" }
q261104
Request.setUri
test
protected function setUri(UriInterface $uri, $preserveHost = false) { if (! $preserveHost && $uri->getHost() !== '') { $key = $this->headerKey('Host');
php
{ "resource": "" }
q261105
Request.getTargetFromUri
test
private function getTargetFromUri() { $target = "/{$this->uri->getPath()}"; $target .= $this->uri->getQuery() !== '' ? "?{$this->uri->getQuery()}" : ''; $target .= $this->uri->getFragment() !== ''
php
{ "resource": "" }
q261106
MiddlewareStack.push
test
public function push($middleware) { if (! $middleware instanceof MiddlewareInterface && ! is_callable($middleware) ) { throw new InvalidArgumentException(
php
{ "resource": "" }
q261107
HttpCodes.reasonPhraseFor
test
public static function reasonPhraseFor($code) { $status = ''; if (array_key_exists($code,
php
{ "resource": "" }
q261108
HipChatDriver.getMessages
test
public function getMessages() { return [ new IncomingMessage($this->event->get('message')['message'],
php
{ "resource": "" }
q261109
HipChatDriver.getUser
test
public function getUser(IncomingMessage $matchingMessage) { $payload = $matchingMessage->getPayload();
php
{ "resource": "" }
q261110
file.getExtension
test
static function getExtension($filename, $toLower=true) { return preg_match('/^.*\.([^\.]*)$/s', $filename, $patt)
php
{ "resource": "" }
q261111
file.normalizeFilename
test
static function normalizeFilename($filename) { $string = htmlentities($filename, ENT_QUOTES, 'UTF-8'); if (strpos($string, '&') !== false) $filename = html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i', '$1', $string),
php
{ "resource": "" }
q261112
Stream.getContents
test
public function getContents() { if (!$this->isReadable() || ($contents = stream_get_contents($this->fp, -1, 0)) === false) { throw
php
{ "resource": "" }
q261113
MultisiteDirectoryResolver.fixSiteUrlFilter
test
public function fixSiteUrlFilter($url, $path, $scheme) { if (strpos($url, $this->wpDirectoryPath)) { return $url; } $wordpressUrl =
php
{ "resource": "" }
q261114
MultisiteDirectoryResolver.fixWpIncludeFolder
test
public function fixWpIncludeFolder($url, $path) { if (strpos($url, $this->wpDirectoryPath)) { return $url; } $wordpressUrl = ['/(wp-includes)/'];
php
{ "resource": "" }
q261115
AbstractResolver.fixNetworkAdminUrlFilter
test
public function fixNetworkAdminUrlFilter($path = '', $scheme = 'admin') { if (strpos($path, $this->wpDirectoryPath)) { return $path; } $wordpressUrl = [ '/(wp-admin)/', '/(wp-login\.php)/',
php
{ "resource": "" }
q261116
AbstractResolver.fixWpDoubleSlashFilter
test
public function fixWpDoubleSlashFilter($urls) { foreach ($urls as &$url) {
php
{ "resource": "" }
q261117
AbstractResolver.init
test
public function init() { $this->getWpBridge()->addFilter('network_admin_url', [$this, 'fixNetworkAdminUrlFilter'], 10, 2); $this->getWpBridge()->addFilter('script_loader_src', [$this, 'fixStyleScriptPathFilter'], 10, 2); $this->getWpBridge()->addFilter('style_loader_src', [$this, 'fixStyleS...
php
{ "resource": "" }
q261118
AbstractResolver.setWpFolderName
test
protected function setWpFolderName() { $dirs = explode('/', $this->wpDirectoryPath);
php
{ "resource": "" }
q261119
path.url2fullPath
test
static function url2fullPath($url) { $url = self::normalize($url); $uri = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : false); $uri = self::normalize($uri); if (substr($url, 0, 1) !...
php
{ "resource": "" }
q261120
path.urlPathEncode
test
static function urlPathEncode($path) { $path = self::normalize($path); $encoded = ""; foreach (explode("/", $path) as $dir)
php
{ "resource": "" }
q261121
path.urlPathDecode
test
static function urlPathDecode($path) { $path = self::normalize($path); $decoded = ""; foreach (explode("/", $path) as $dir)
php
{ "resource": "" }
q261122
dir.content
test
static function content($dir, array $options=null) { $defaultOptions = array( 'types' => "all", // Allowed: "all" or possible return values // of filetype(), or an array with them 'addPath' => true, // Whether to add directory path to filenames ...
php
{ "resource": "" }
q261123
Console.database
test
public function database($data, $time_start, $memory_start = null) { if (!array_key_exists('Database', $this->Profiler->log_sections)) { return ; } if (!is_string($data)) { return ; } if (!is_float($time_start)) { $time_start = $this->Pro...
php
{ "resource": "" }
q261124
Console.log
test
public function log($logtype, $data, $file = '', $line = '') { $data = [
php
{ "resource": "" }
q261125
Console.memoryUsage
test
public function memoryUsage($data, $file = '', $line = '', $matchKey =
php
{ "resource": "" }
q261126
Console.timeload
test
public function timeload($data, $file = '', $line = '', $matchKey =
php
{ "resource": "" }
q261127
Console.writeLogSections
test
public function writeLogSections($section, $data, $file = '', $line = '', $matchKey = null) { if (!is_array($this->Profiler->log_sections)) { $this->Profiler->log_sections = []; } if (!array_key_exists($section, $this->Profiler->log_sections)) { // if section is not ...
php
{ "resource": "" }
q261128
UploadedFile.filesFlip
test
public static function filesFlip(&$result, $keys, $value) { if (is_array($value)) { foreach ($value as $k => $v) { $newKeys = $keys; array_push($newKeys, $k); self::filesFlip($result, $newKeys, $v); } } else { $res =...
php
{ "resource": "" }
q261129
UploadedFile.setStream
test
public function setStream(StreamInterface $stream): UploadedFile { if ($this->hasMoved()) { throw new \RuntimeException(sprintf('Uploaded file "%s"
php
{ "resource": "" }
q261130
UploadedFile.getHash
test
public function getHash($algo = 'sha1') { if ($this->hasMoved()) { throw new \RuntimeException(sprintf('Uploaded file "%s" has
php
{ "resource": "" }
q261131
UploadedFile.getMediaType
test
public function getMediaType() { if ($this->hasMoved()) { throw new \RuntimeException(sprintf('Uploaded file "%s" has already moved', $this->file)); } if (extension_loaded('fileinfo')) { $finfo = finfo_open(FILEINFO_MIME); $mime = finfo_file($finfo, $this...
php
{ "resource": "" }
q261132
ServerRequest.getQueryParams
test
public function getQueryParams() { if (!is_null($this->queryParams)) { return $this->queryParams; } else { if (!is_null($this->getUri())) {
php
{ "resource": "" }
q261133
ServerRequest.isAjaxRequest
test
public function isAjaxRequest() { // Check if ajax request { $ajaxRequest = $this->hasHeader('AjaxRequest'); $serverParams = $this->getServerParams();
php
{ "resource": "" }
q261134
Handler.toDocument
test
public function toDocument($json) { $data = json_decode($json, true); $document = new Document(); if (isset($data['class']) && is_array($data['class'])) { $document->setClass($data['class']); } if (isset($data['properties']) && is_array($data['properties'])) { ...
php
{ "resource": "" }
q261135
Handler.getEntitiesFromDataArray
test
protected function getEntitiesFromDataArray(array $entitiesArray) { $entities = array(); foreach ($entitiesArray as $entityArray) { $entity = new Entity(); if (isset($entityArray['class']) && is_array($entityArray['class'])) { $entity->setClass($entityArray['...
php
{ "resource": "" }
q261136
Handler.getActionsFromDataArray
test
protected function getActionsFromDataArray(array $actionsArray) { $actions = array(); foreach ($actionsArray as $actionArray) { $action = new Action(); if (isset($actionArray['name']) && is_string($actionArray['name'])) { $action->setName($actionArray['name']...
php
{ "resource": "" }
q261137
Handler.getFieldsFromDataArray
test
protected function getFieldsFromDataArray(array $fieldsArray) { $fields = array(); foreach ($fieldsArray as $fieldArray) { $field = new Field(); if (isset($fieldArray['name']) && is_string($fieldArray['name'])) { $field->setName($fieldArray['name']); ...
php
{ "resource": "" }
q261138
Handler.getLinksFromDataArray
test
protected function getLinksFromDataArray(array $linksArray) { $links = array(); foreach ($linksArray as $linkArray) { $link = new Link(); if (isset($linkArray['rel']) && is_array($linkArray['rel'])) { $link->setRel($linkArray['rel']); }
php
{ "resource": "" }
q261139
CurlHttpClient.send
test
public function send(RequestInterface $request) { $deferred = new Deferred(); try { $response = $this->call($request); $deferred->resolve($response);
php
{ "resource": "" }
q261140
CurlHttpClient.call
test
private function call(RequestInterface $request) { $this->prepare($request); $result = curl_exec($this->handler); if (curl_errno($this->handler) !== 0) { throw new RuntimeException( "Error connecting to server: ".curl_error($this->handler) );
php
{ "resource": "" }
q261141
CurlHttpClient.prepare
test
private function prepare(RequestInterface $request) { $this->reset($this->handler); $this->setUrl($request); $this->options[CURLOPT_CUSTOMREQUEST] = $request->getMethod(); $this->setHeaders($request); $this->options[CURLOPT_POSTFIELDS] = (string)
php
{ "resource": "" }
q261142
CurlHttpClient.setUrl
test
private function setUrl(RequestInterface $request) { $target = $request->getRequestTarget(); $parts = parse_url($target); $uri = $this->url instanceof Uri ? $this->url : $request->getUri(); $uri =
php
{ "resource": "" }
q261143
CurlHttpClient.setHeaders
test
private function setHeaders(RequestInterface $request) { $headers = []; foreach ($request->getHeaders() as $header => $values) { $headers[]
php
{ "resource": "" }
q261144
CurlHttpClient.createResponse
test
private function createResponse($result) { $status = curl_getinfo($this->handler, CURLINFO_HTTP_CODE); list($header, $body) = $this->splitHeaderFromBody($result);
php
{ "resource": "" }
q261145
CurlHttpClient.splitHeaderFromBody
test
private function splitHeaderFromBody($result) { $header_size = curl_getinfo($this->handler, CURLINFO_HEADER_SIZE); $header = substr($result, 0, $header_size);
php
{ "resource": "" }
q261146
CurlHttpClient.parseHeaders
test
private function parseHeaders($header) { $lines = explode("\n", $header); $headers = []; foreach ($lines as $line) { if (strpos($line, ':') === false) { continue;
php
{ "resource": "" }
q261147
Profiler.countTotalLogType
test
public function countTotalLogType($logtype) { $count = 0; if (isset($this->log_sections['Logs']) && is_array($this->log_sections['Logs'])) { foreach ($this->log_sections['Logs'] as $item) { if (isset($item['logtype']) && $item['logtype'] == $logtype) {
php
{ "resource": "" }
q261148
Profiler.display
test
public function display($dbh = '', $display_db_function = '') { $this->gatherAll(); global $rundizProfilerBeautifulIndent; $rundizProfilerBeautifulIndent = $this->beautifulIndent;
php
{ "resource": "" }
q261149
Profiler.gatherFiles
test
private function gatherFiles() { if (!array_key_exists('Files', $this->log_sections)) { return ; } $files = get_included_files(); $section_data_array = []; $total_size = 0; $largest_size = 0; if (is_array($files)) { foreach ($files as...
php
{ "resource": "" }
q261150
Profiler.gatherInputGet
test
private function gatherInputGet() { if (!array_key_exists('Get', $this->log_sections)) { return ; } $section_data_array = []; if (isset($_GET) && is_array($_GET)) { foreach ($_GET as $name => $value) { $section_data_array[] = [ ...
php
{ "resource": "" }
q261151
Profiler.gatherInputPost
test
private function gatherInputPost() { if (!array_key_exists('Post', $this->log_sections)) { return ; } $section_data_array = []; if (isset($_POST) && is_array($_POST)) { foreach ($_POST as $name => $value) { $section_data_array[] = [ ...
php
{ "resource": "" }
q261152
Profiler.gatherInputSession
test
private function gatherInputSession() { if (!array_key_exists('Session', $this->log_sections)) { return ; } $section_data_array = []; if (isset($_SESSION) && is_array($_SESSION)) { foreach ($_SESSION as $name => $value) { $section_data_array[...
php
{ "resource": "" }
q261153
Profiler.getMicrotime
test
public function getMicrotime($at_start = false) { if ($at_start === true && is_array($_SERVER) && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER))
php
{ "resource": "" }
q261154
Profiler.summaryMatchKey
test
public function summaryMatchKey($section, $matchKey, $sectionKey) { if (!is_string($section)) { $section = null; } if (!is_string($matchKey)) { $matchKey = null; } if (!is_numeric($sectionKey)) { $sectionKey = 0; } $outpu...
php
{ "resource": "" }
q261155
UploadedFilesFactory.createFiles
test
public static function createFiles() { $fixer = new static(); $files = $fixer->saneFilesArray($_FILES); $fixed = []; foreach ($files as $key => $data) {
php
{ "resource": "" }
q261156
UploadedFilesFactory.createUploadedFile
test
private function createUploadedFile($data) { if (array_key_exists('tmp_name', $data)) { return UploadedFile::create($data); } $result = []; foreach ($data as $key => $datum) {
php
{ "resource": "" }
q261157
UploadedFilesFactory.filesFlip
test
private function filesFlip(&$result, $keys, $value) { if (is_array($value)) { foreach ($value as $k => $v) { $newKeys = $keys; array_push($newKeys, $k); $this->filesFlip($result, $newKeys, $v); } return; } $...
php
{ "resource": "" }
q261158
UploadedFilesFactory.arrayMergeRecursive
test
private function arrayMergeRecursive($array1, $array2) { if (!is_array($array1) or !is_array($array2)) { return $array2; } foreach ($array2 as $sKey2 => $sValue2) {
php
{ "resource": "" }
q261159
SessionMiddleware.process
test
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
php
{ "resource": "" }
q261160
AdminCrudController.add
test
public function add() { // Are we creating this object from the menu add wizard? // Toss the menu_id URL variable into the session instead if (Input::get('menu_id')) { return Redirect::to($this->uri('add'))->with('menu_id', Input::get('menu_id'));
php
{ "resource": "" }
q261161
AdminCrudController.edit
test
public function edit($id) { $Model = App::make($this->Model); $this->data[$this->singular] = $Model::withTrashed()->findOrFail($id); $this->data['action']
php
{ "resource": "" }
q261162
AdminCrudController.attempt_edit
test
public function attempt_edit($id) { $Model = App::make($this->Model); $object = $Model::withTrashed()->findOrFail($id); $errors = $object->validate(); if (count($errors)) {
php
{ "resource": "" }
q261163
AdminCrudController.edit_redirect
test
public function edit_redirect($object) { return Redirect::to($this->uri('edit/' . $object->id))->with('success', ' <p>' . $this->Model . '
php
{ "resource": "" }
q261164
AdminCrudController.order
test
public function order() { $Model = App::make($this->Model); $orders = Input::get('orders'); $objects = $Model::whereIn('id', array_keys($orders))->get(); foreach ($objects as $object)
php
{ "resource": "" }
q261165
AdminCrudController.delete
test
public function delete($id, $ajax = false) { $Model = App::make($this->Model); $object = $Model::findOrFail($id); $object->delete();
php
{ "resource": "" }
q261166
Request.getUploadedFiles
test
public function getUploadedFiles() { if (null === $this->uploadedFiles) {
php
{ "resource": "" }
q261167
Request.withUploadedFiles
test
public function withUploadedFiles(array $uploadedFiles) { if (! $this->checkUploadedFiles($uploadedFiles)) { throw new InvalidArgumentException( "The uploaded files array given has at least one leaf that is not ".
php
{ "resource": "" }
q261168
Request.checkUploadedFiles
test
private function checkUploadedFiles(array $files) { $valid = true; foreach ($files as $file) { if (is_array($file)) { $valid = $this->checkUploadedFiles($files); break; }
php
{ "resource": "" }
q261169
Request.loadHeaders
test
private function loadHeaders() { foreach ($_SERVER as $key => $value) { $subset = substr($key, 0, 5); if ($subset <> 'HTTP_' && $subset <> 'CONTE') { continue; } $header = str_replace( ' ', '-',
php
{ "resource": "" }
q261170
Request.withAttribute
test
public function withAttribute($name, $value) { $request = clone $this;
php
{ "resource": "" }
q261171
Request.withoutAttribute
test
public function withoutAttribute($name) { $request = clone $this; if (array_key_exists($name, $request->attributes)) {
php
{ "resource": "" }
q261172
httpCache.checkMTime
test
static function checkMTime($mtime, $sendHeaders=null) { header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT"); $headers = function_exists("getallheaders") ? getallheaders() : (function_exists("apache_request_headers") ? apache_request_headers() ...
php
{ "resource": "" }
q261173
Message.getHeader
test
public function getHeader($name) { $key = $this->headerKey($name); if (array_key_exists($key, $this->headers)) {
php
{ "resource": "" }
q261174
Response.setStatus
test
private function setStatus($status, $reasonPhrase = '') { HttpCodes::check($status); $this->status = intval($status, 10); if ($reasonPhrase === '') {
php
{ "resource": "" }
q261175
CallableMiddleware.process
test
public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { $response = self::execute($this->callable, [$request, $handler]); if (!$response instanceof ResponseInterface) { throw new UnexpectedValueException(
php
{ "resource": "" }
q261176
ToolBelt.mysql_version
test
static function mysql_version() { $version = DB::select('SELECT VERSION()
php
{ "resource": "" }
q261177
UserManager.authenticate
test
public function authenticate(array $credentials) { list($username, $password) = $credentials; $user = $this->repository->getActiveUser($username); if (!$user) { throw new Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND); } elseif (!Passwords::verify($password, $use...
php
{ "resource": "" }
q261178
UserManager.findAll
test
public function findAll() { if ($this->user && $this->user->isInRole('root')) { return $this->repository->findAllActive(); } else {
php
{ "resource": "" }
q261179
UserManager.findAllDeactivated
test
public function findAllDeactivated() { if ($this->user && $this->user->isInRole('root')) { return $this->repository->findAll() ->where('active', '0'); } else {
php
{ "resource": "" }
q261180
UserManager.add
test
public function add($data = []) { if (isset($data['email']) && isset($data['password'])) { if ((isset($data['username']) && $data['username'] === '') or !$this->useUsernames ){ $data['username'] = $data['email']; } if (!Validators::isEmail($data['email'])){ throw new \InvalidArgumentExceptio...
php
{ "resource": "" }
q261181
Metric.getOption
test
public function getOption($value) { if(!in_array($value, $this->allowedValues, true)) { throw new InvalidOptionValueException('Invalid $metricOption argument "' . $value . '", allowed values: '
php
{ "resource": "" }
q261182
Post.set_current_lang_from_post_id
test
private static function set_current_lang_from_post_id($postId) { if (WpCxense::instance()->settings->languagesIsEnabled()) {
php
{ "resource": "" }
q261183
StringCheckerTrait.isEncryptedContainer
test
public function isEncryptedContainer($encrypted, $key) { try { $data = JWT::decode($encrypted, $key); } catch(Exception $e) {
php
{ "resource": "" }
q261184
StringCheckerTrait.isEncryptedString
test
public function isEncryptedString($encrypted, $key) { try { $data = JWT::decode($encrypted, $key);
php
{ "resource": "" }
q261185
Dumper.dump
test
public function dump() { return $this->startFile(). $this->addNamespace(). $this->startClass().
php
{ "resource": "" }
q261186
Dumper.exportArray
test
static public function exportArray(array $array, $indent) { $code = array(); foreach ($array as $key => $value) { if (is_array($value)) { $value = self::exportArray($value, $indent + 4); } else { $value = null === $value ? 'null' : var_export($...
php
{ "resource": "" }
q261187
Extension.preGlobalProcess
test
public function preGlobalProcess(\ArrayObject $configClasses, Container $container) { $this->configClasses = $configClasses; $this->definitions = $container;
php
{ "resource": "" }
q261188
Extension.postGlobalProcess
test
public function postGlobalProcess(\ArrayObject $configClasses, Container $container) { $this->configClasses = $configClasses; $this->definitions = $container;
php
{ "resource": "" }
q261189
ParseException.noTokenForTokenTypes
test
public static function noTokenForTokenTypes($tokenTypes) : ParseException { $message = "No token could be found for any of types "; $message
php
{ "resource": "" }
q261190
ContainerFactory.make
test
public function make($from, $type) { $type = $type ?: static::SIMPLE; switch ($type) { case static::SIMPLE: return new Container($from); case static::REVERTABLE:
php
{ "resource": "" }
q261191
TSoftDelete.recover
test
public function recover($id, $user = TRUE) { $recover = array( 'deleted_at' => NULL, ); if ($user) { $recover['deleted_by'] = NULL; }
php
{ "resource": "" }
q261192
ClassExtension.newClassExtensionsProcess
test
public function newClassExtensionsProcess($class, \ArrayObject $configClasses, \ArrayObject $newClassExtensions) { $this->class = $class; $this->configClasses = $configClasses; $this->configClass = $configClasses[$class]; $this->newClassExtensions = $newClassExtensions;
php
{ "resource": "" }
q261193
ClassExtension.newConfigClassesProcess
test
public function newConfigClassesProcess($class, \ArrayObject $configClasses, \ArrayObject $newConfigClasses) { $this->class = $class; $this->configClasses = $configClasses; $this->configClass = $configClasses[$class]; $this->newConfigClasses = $newConfigClasses;
php
{ "resource": "" }
q261194
ClassExtension.configClassProcess
test
public function configClassProcess($class, \ArrayObject $configClasses) { $this->class = $class; $this->configClasses = $configClasses; $this->configClass = $configClasses[$class];
php
{ "resource": "" }
q261195
ClassExtension.classProcess
test
public function classProcess($class, \ArrayObject $configClasses, Container $container) { $this->class = $class; $this->configClasses = $configClasses; $this->configClass = $configClasses[$class]; $this->definitions = $container; $this->doClassProcess();
php
{ "resource": "" }
q261196
Container.setDefinitions
test
public function setDefinitions(array $definitions) { $this->definitions = array(); foreach ($definitions as $name => $definition) {
php
{ "resource": "" }
q261197
Container.getDefinition
test
public function getDefinition($name) { if (!$this->hasDefinition($name)) { throw new \InvalidArgumentException(sprintf('The definition "%s"
php
{ "resource": "" }
q261198
Container.removeDefinition
test
public function removeDefinition($name) { if (!$this->hasDefinition($name)) {
php
{ "resource": "" }
q261199
Mondator.setConfigClasses
test
public function setConfigClasses(array $configClasses) { $this->configClasses = array();
php
{ "resource": "" }