_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q245400
RedisQueue.pop
validation
function pop() { $response = $this->redis->blPop($this->key, 10); if ($response) { list($list, $serializedJob) = $response; $job = unserialize($serializedJob); return $job; } }
php
{ "resource": "" }
q245401
Client.getLoginUrl
validation
public function getLoginUrl($scope = array(), $state = null) { $scope = $this->mergeScope($scope); $state = is_string($state) ? "&state={$state}" : ''; return self::API_OAUTH_URL . '?client_id=' . $this->getApiKey() . '&redirect_uri=' . urlencode($this->getApiCallback()) . '&scope=' . implode('+', $scope) . '&response_type=code' . $state; }
php
{ "resource": "" }
q245402
Client.modifyRelationship
validation
public function modifyRelationship($action, $user) { if (true === in_array($action, $this->_actions) && isset($user)) { return $this->_makeCall('users/' . $user . '/relationship', array('action' => $action), 'POST'); } throw new InvalidParameterException('Error: modifyRelationship() - This method requires an action command and the target user id.'); }
php
{ "resource": "" }
q245403
Client.searchMedia
validation
public function searchMedia($lat, $lng, $distance = 1000, $minTimestamp = NULL, $maxTimestamp = NULL) { return $this->_makeCall('media/search', array('lat' => $lat, 'lng' => $lng, 'distance' => $distance, 'min_timestamp' => $minTimestamp, 'max_timestamp' => $maxTimestamp)); }
php
{ "resource": "" }
q245404
Client._makeCall
validation
protected function _makeCall($function, $params = null, $method = 'GET') { if (isset($params['count']) && $params['count'] < 1) { throw new InvalidParameterException('InstagramClient: you are trying to query 0 records!'); } // if the call needs an authenticated user if (true === isset($this->_accesstoken)) { $authMethod = '?access_token=' . $this->getAccessToken(); } else { throw new AuthException("Error: _makeCall() | This method requires an valid users access token."); } if (isset($params) && is_array($params)) { $paramString = '&' . http_build_query($params); } else { $paramString = null; } $apiCall = self::API_URL . $function . $authMethod . (('GET' === $method) ? $paramString : null); // we want JSON $headerData = array('Accept: application/json'); if ($this->_enforceSignedRequests) { $apiCall .= (strstr($apiCall, '?') ? '&' : '?') . 'sig=' . $this->_signHeader($function, $authMethod, $params); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $apiCall); curl_setopt($ch, CURLOPT_HTTPHEADER, $headerData); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); if ('POST' === $method) { curl_setopt($ch, CURLOPT_POST, count($params)); curl_setopt($ch, CURLOPT_POSTFIELDS, ltrim($paramString, '&')); } else if ('DELETE' === $method) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); } $jsonData = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if(403 === $httpcode) { $error = json_decode($jsonData, true); throw new CurlException('_makeCall() - ' . $error['error_type'] . ' error: ' . $error['error_message']); } if (false === $jsonData) { throw new CurlException('_makeCall() - cURL error: ' . curl_error($ch)); } curl_close($ch); return json_decode($jsonData); }
php
{ "resource": "" }
q245405
Client.setAccessToken
validation
public function setAccessToken($data) { (true === is_object($data)) ? $token = $data->access_token : $token = $data; $this->_accesstoken = $token; }
php
{ "resource": "" }
q245406
Client.mergeScope
validation
private function mergeScope(array $scope) { if (empty($scope)) return $this->_scope; $scope = array_merge($scope, $this->_defaulScope); $scope = array_unique($scope); $intersectingScope = array_intersect($scope, $this->_availableScope); if (count($intersectingScope) !== count($scope)) { throw new InvalidParameterException('Error: mergeScope() - Invalid permission scope parameter used.'); } return $intersectingScope; }
php
{ "resource": "" }
q245407
ProcessBuilder.run
validation
public function run($command) { $process = new Process( $command, null, null, null, ini_get('max_execution_time') ); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { $this->console->warn(trim($buffer)); } else { $this->console->info(trim($buffer)); } }); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } return true; }
php
{ "resource": "" }
q245408
ConfigFile.stringify
validation
protected function stringify($name) { $classes = array_unique(array_merge( $this->suffixClass($this->getFromConfig($name)), $this->suffixClass($this->$name) )); $newLine2Tabs = PHP_EOL.' '; if ($name == 'providers') { return "'$name' => [$newLine2Tabs". implode(','.$newLine2Tabs, $classes). PHP_EOL.' ],'.PHP_EOL; } $template = "'$name' => [$newLine2Tabs"; foreach ($classes as $fullClassName) { $template .= "'{$this->getClassName($fullClassName)}' => $fullClassName,$newLine2Tabs"; } $template .= PHP_EOL.' ],'.PHP_EOL; return $template; }
php
{ "resource": "" }
q245409
Add.handle
validation
public function handle() { $packageInfo = $this->tokenizePackageInfo(); $packages = $this->getPackages(); $total = $packages->count(); if (!$total) { $this->warn(' No package found. Make sure you spell it correct as specified on github or packagist.'); } if ($packages->first()['name'] !== $packageInfo['name']) { $this->warn($total.' package'.($total > 1 ? 's' : '').' found by given name.'); return $this->call('add', ['package' => $this->prettify($packages)]); } $this->downloadPackage() ->runConfiguration(); }
php
{ "resource": "" }
q245410
Add.tokenizePackageInfo
validation
public function tokenizePackageInfo() { $info = explode(':', $this->argument('package')); return [ 'name' => $info[0], 'version' => (count($info) > 1) ? last($info) : null, ]; }
php
{ "resource": "" }
q245411
Add.prettify
validation
public function prettify(Collection $packages) { $summary = []; foreach ($packages as $key => $package) { $summary[] = [ 'id' => $key + 1, 'name' => $this->prettifyPackageInfo($package), ]; } return $packages[$this->askPackageKey($summary)]['name']; }
php
{ "resource": "" }
q245412
Add.askPackageKey
validation
public function askPackageKey($summary, $message = 'Please provide an id') { $this->table(['id', 'name'], $summary); $selected = $this->ask($message); $key = collect($summary)->pluck('id')->search($selected); if ($key === false) { $this->warn('Invalid package name or id given.'); return $this->askPackageKey($summary, 'Please provide a valid id'); } return $key; }
php
{ "resource": "" }
q245413
Migration.run
validation
public function run() { if ($this->search()) { $this->registered = true; return $this->console->call('migrate'); } return false; }
php
{ "resource": "" }
q245414
Migration.hasMigrationFile
validation
public function hasMigrationFile() { $this->count = $this->fileHas('/class [A-Z]\w+ extends Migration/i') ->getClasses() ->count(); return $this->hasMigrationFile = $this->count > 0; }
php
{ "resource": "" }
q245415
Manager.build
validation
public function build() { $providers = $this->getProviders()->search(); $facades = $this->getFacades()->search(); if (!ConfigFile::instance($providers, $facades)->make()) { throw new ErrorException('Unable to register providers and facades. Please report this incident at Qafeen/Manager'); } $this->getResources()->publish($providers[0]); return $this; }
php
{ "resource": "" }
q245416
Manager.getProviders
validation
public function getProviders() { return $this->providers ?: $this->providers = new ServiceProvider(clone $this->getFiles(), $this->console); }
php
{ "resource": "" }
q245417
Manager.getFacades
validation
public function getFacades() { return $this->facades ?: $this->facades = new Facade(clone $this->getFiles(), $this->console); }
php
{ "resource": "" }
q245418
Manager.getMigration
validation
public function getMigration() { return $this->migration ?: $this->migration = new Migration(clone $this->getFiles(), $this->console); }
php
{ "resource": "" }
q245419
Manager.getFiles
validation
public function getFiles() { return $this->files ?: $this->files = Finder::create()->in(realpath($this->directory)); }
php
{ "resource": "" }
q245420
Manager.hasManagerFile
validation
public function hasManagerFile() { if (app('filesystem')->exists($this->directory.'manager.yml')) { return true; } $this->console->warn("No manager.yml file found in {$this->name} package."); return false; }
php
{ "resource": "" }
q245421
Manager.notifyUser
validation
protected function notifyUser() { $this->console->line(''); $this->console->line("{$this->isDone($this->getProviders()->isRegistered())} ". "{$this->getProviders()->count()} service provider registered."); $this->console->line("{$this->isDone($this->getFacades()->isRegistered())} ". "{$this->getFacades()->count()} facade registered."); $this->console->line("{$this->isDone($this->getMigration()->isRegistered())} ". "{$this->getMigration()->count()} migration file ran."); $this->console->line("{$this->isDone($this->getResources()->isRegistered())} ". '- '.$this->console->tokenizePackageInfo()['name']. ' file publish.'); return true; }
php
{ "resource": "" }
q245422
Manager.getResources
validation
public function getResources() { return $this->resources ?: $this->resources = Resource::instance(clone $this->getFiles(), $this->console); }
php
{ "resource": "" }
q245423
Helper.instance
validation
public static function instance() { switch (func_num_args()) { case func_num_args() == 0: return new static(); case func_num_args() == 1: return new static(func_get_arg(0)); case func_num_args() == 2: return new static(func_get_arg(0), func_get_arg(1)); case func_num_args() == 3: return new static(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case func_num_args() == 4: return new static(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case func_num_args() == 5: return new static( func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4) ); default: throw new Exception('Unable to instantiate class with given arguments'); } }
php
{ "resource": "" }
q245424
File.fileHas
validation
public function fileHas($contains) { $this->files = (new ClassIterator($this->finder->contains($contains)))->getClassMap(); $this->count = count($this->files); return $this; }
php
{ "resource": "" }
q245425
File.getFile
validation
public function getFile($class) { if (is_null($this->count)) { return $this->fileHas($class)->getFile($class); } if (isset($this->files[$class])) { return $this->files[$class]; } throw new FileException("File does not exists with given `{$class}` class."); }
php
{ "resource": "" }
q245426
ServiceProvider.search
validation
public function search() { $this->console->info('Searching directory for service providers.'); $sps = $this->getProviders(); if (!$sps->count()) { $this->console->warn('No service provider file found. Nothing to install.'); return []; } $this->console->line( " Found {$sps->count()} Service provider".($sps->count() > 1 ? 's' : '').'.' ); $sps->each(function ($sp, $index) { $currentCount = $index + 1; $this->console->line(" $currentCount. $sp"); }); if (!$this->console->confirm('Register service providers?', true)) { return []; } $this->registered = true; return $this->getProviders()->toArray(); }
php
{ "resource": "" }
q245427
Packages.search
validation
public function search() { $url = self::PACKAGIST_URL.'search.json?q='.$this->getPackageName(); $response = $this->client ->get($url) ->getBody() ->getContents(); $this->rawPackages = collect(json_decode($response, true)); return collect($this->rawPackages->get('results')); }
php
{ "resource": "" }
q245428
Resource.publish
validation
public function publish($provider) { $class = last(explode('\\', $provider)); $this->console->info("Searching {$provider} to publish vendor file."); if (!$this->finder->contains($class)->contains('/\$this->publishes/i')->count()) { $this->console->warn('Nothing to publish.'); return true; } $tag = $this->console->ask("If the \"{$this->console->tokenizePackageInfo()['name']}\" has specify vendor publish tag in installation guide then please add it here or press enter to skip adding tag.", false); $this->console->call('vendor:publish', [ '--provider' => $provider, '--tag' => $tag, ]); return $this->registered = true; }
php
{ "resource": "" }
q245429
PasswordStrengthServiceProvider.boot
validation
public function boot(Factory $validator) { $passwordStrength = app('passwordStrength'); $translator = app('passwordStrength.translationProvider')->get($validator); foreach(['letters', 'numbers', 'caseDiff', 'symbols'] as $rule) { $snakeCasedRule = snake_case($rule); $validator->extend($rule, function ($_, $value, $__) use ($passwordStrength, $rule) { $capitalizedRule = ucfirst($rule); return call_user_func([$passwordStrength, "validate{$capitalizedRule}"], $value); }, $translator->get("password-strength::validation.{$snakeCasedRule}")); } }
php
{ "resource": "" }
q245430
HtmlObject.dumpConstants
validation
protected function dumpConstants($constants) { $str = ''; if ($constants && $this->debug->output->getCfg('outputConstants')) { $str = '<dt class="constants">constants</dt>'."\n"; foreach ($constants as $k => $value) { $str .= '<dd class="constant">' .'<span class="constant-name">'.$k.'</span>' .' <span class="t_operator">=</span> ' .$this->debug->output->html->dump($value) .'</dd>'."\n"; } } return $str; }
php
{ "resource": "" }
q245431
HtmlObject.dumpMethods
validation
protected function dumpMethods($methods) { $label = \count($methods) ? 'methods' : 'no methods'; $str = '<dt class="methods">'.$label.'</dt>'."\n"; $magicMethods = \array_intersect(array('__call','__callStatic'), \array_keys($methods)); $str .= $this->magicMethodInfo($magicMethods); foreach ($methods as $methodName => $info) { if (!isset($info['phpDoc']['return'])) { $info['phpDoc']['return'] = array( 'desc' => null, 'type' => null, ); } $classes = \array_keys(\array_filter(array( 'method' => true, 'deprecated' => $info['isDeprecated'], ))); $modifiers = \array_keys(\array_filter(array( 'final' => $info['isFinal'], $info['visibility'] => true, 'static' => $info['isStatic'], ))); $str .= $this->debug->utilities->buildTag( 'dd', array( 'class' => \array_merge($classes, $modifiers), 'data-implements' => $info['implements'], ), \implode(' ', \array_map(function ($modifier) { return '<span class="t_modifier_'.$modifier.'">'.$modifier.'</span>'; }, $modifiers)) .' '.$this->debug->utilities->buildTag( 'span', array( 'class' => 't_type', 'title' => $info['phpDoc']['return']['desc'], ), $info['phpDoc']['return']['type'] ) .' '.$this->debug->utilities->buildTag( 'span', array( 'class' => 'method-name', 'title' => \trim($info['phpDoc']['summary'] .($this->debug->output->getCfg('outputMethodDescription') ? "\n\n".$info['phpDoc']['description'] : '')), ), $methodName ) .'<span class="t_punct">(</span>' .$this->dumpMethodParams($info['params']) .'<span class="t_punct">)</span>' .($methodName == '__toString' ? '<br />'.$this->debug->output->html->dump($info['returnValue']) : '') )."\n"; } $str = \str_replace(' data-implements="null"', '', $str); $str = \str_replace(' <span class="t_type"></span>', '', $str); return $str; }
php
{ "resource": "" }
q245432
HtmlObject.dumpMethodParams
validation
protected function dumpMethodParams($params) { $paramStr = ''; foreach ($params as $info) { $paramStr .= '<span class="parameter">'; if (!empty($info['type'])) { $paramStr .= '<span class="t_type">'.$info['type'].'</span> '; } $paramStr .= '<span class="t_parameter-name"' .' title="'.\htmlspecialchars($info['desc']).'"' .'>'.\htmlspecialchars($info['name']).'</span>'; if ($info['defaultValue'] !== $this->debug->abstracter->UNDEFINED) { $defaultValue = $info['defaultValue']; $paramStr .= ' <span class="t_operator">=</span> '; if ($info['constantName']) { /* only php >= 5.4.6 supports this... or via @method phpDoc show the constant name / hover for value */ $title = ''; $type = $this->debug->abstracter->getType($defaultValue); if (!\in_array($type, array('array','resource'))) { $title = $this->debug->output->text->dump($defaultValue); $title = \htmlspecialchars('value: '.$title); } $paramStr .= '<span class="t_parameter-default t_const"' .' title="'.$title.'"' .'>'.$info['constantName'].'</span>'; } else { /* The constant's value is shown */ if (\is_string($defaultValue)) { $defaultValue = \str_replace("\n", ' ', $defaultValue); } $parsed = $this->debug->utilities->parseTag($this->debug->output->html->dump($defaultValue)); $class = \trim('t_parameter-default '.$parsed['attribs']['class']); $paramStr .= '<span class="'.$class.'">'.$parsed['innerhtml'].'</span>'; } } $paramStr .= '</span>, '; // end .parameter } $paramStr = \trim($paramStr, ', '); return $paramStr; }
php
{ "resource": "" }
q245433
HtmlObject.dumpPhpDoc
validation
protected function dumpPhpDoc($phpDoc) { $str = ''; foreach ($phpDoc as $k => $values) { if (!\is_array($values)) { continue; } foreach ($values as $value) { if ($k == 'link') { $value = '<a href="'.$value['uri'].'" target="_blank">' .\htmlspecialchars($value['desc'] ?: $value['uri']) .'</a>'; } elseif ($k == 'see' && $value['uri']) { $value = '<a href="'.$value['uri'].'" target="_blank">' .\htmlspecialchars($value['desc'] ?: $value['uri']) .'</a>'; } else { $value = \htmlspecialchars(\implode(' ', $value)); } $str .= '<dd class="phpdoc phpdoc-'.$k.'">' .'<span class="phpdoc-tag">'.$k.'</span>' .'<span class="t_operator">:</span> ' .$value .'</dd>'."\n"; } } if ($str) { $str = '<dt class="phpDoc">phpDoc</dt>'."\n" .$str; } return $str; }
php
{ "resource": "" }
q245434
HtmlObject.dumpProperties
validation
protected function dumpProperties($abs) { $label = \count($abs['properties']) ? 'properties' : 'no properties'; if ($abs['viaDebugInfo']) { $label .= ' <span class="text-muted">(via __debugInfo)</span>'; } $str = '<dt class="properties">'.$label.'</dt>'."\n"; $magicMethods = \array_intersect(array('__get','__set'), \array_keys($abs['methods'])); $str .= $this->magicMethodInfo($magicMethods); foreach ($abs['properties'] as $k => $info) { $vis = (array) $info['visibility']; $isPrivateAncestor = \in_array('private', $vis) && $info['inheritedFrom']; $classes = \array_keys(\array_filter(array( 'debuginfo-value' => $info['valueFrom'] == 'debugInfo', 'excluded' => $info['isExcluded'], 'forceShow' => $info['forceShow'], 'debug-value' => $info['valueFrom'] == 'debug', 'private-ancestor' => $isPrivateAncestor, 'property' => true, \implode(' ', $vis) => $info['visibility'] !== 'debug', ))); $modifiers = $vis; if ($info['isStatic']) { $modifiers[] = 'static'; } $str .= '<dd class="'.\implode(' ', $classes).'">' .\implode(' ', \array_map(function ($modifier) { return '<span class="t_modifier_'.$modifier.'">'.$modifier.'</span>'; }, $modifiers)) .($isPrivateAncestor ? ' (<i>'.$info['inheritedFrom'].'</i>)' : '') .($info['type'] ? ' <span class="t_type">'.$info['type'].'</span>' : '') .' <span class="property-name"' .' title="'.\htmlspecialchars($info['desc']).'"' .'>'.$k.'</span>' .($info['value'] !== $this->debug->abstracter->UNDEFINED ? ' <span class="t_operator">=</span> ' .$this->debug->output->html->dump($info['value']) : '') .'</dd>'."\n"; } return $str; }
php
{ "resource": "" }
q245435
HtmlObject.magicMethodInfo
validation
private function magicMethodInfo($methods) { if (!$methods) { return ''; } foreach ($methods as $i => $method) { $methods[$i] = '<code>'.$method.'</code>'; } $methods = $i == 0 ? 'a '.$methods[0].' method' : \implode(' and ', $methods).' methods'; return '<dd class="magic info">This object has '.$methods.'</dd>'."\n"; }
php
{ "resource": "" }
q245436
AbstractObject.getAbstraction
validation
public function getAbstraction($obj, $method = null, &$hist = array()) { if (!\is_object($obj)) { return $obj; } $reflector = new \ReflectionObject($obj); $className = $reflector->getName(); $isTableTop = $method === 'table' && \count($hist) < 2; // rows (traversable) || row (traversable) $abs = new Event($obj, array( 'className' => $className, 'collectMethods' => !$isTableTop && $this->abstracter->getCfg('collectMethods') || $className == 'Closure', 'constants' => array(), 'debug' => $this->abstracter->ABSTRACTION, 'debugMethod' => $method, 'definition' => array( 'fileName' => $reflector->getFileName(), 'startLine' => $reflector->getStartLine(), 'extensionName' => $reflector->getExtensionName(), ), 'extends' => array(), 'implements' => $reflector->getInterfaceNames(), 'isExcluded' => $this->isObjExcluded($obj), 'isRecursion' => \in_array($obj, $hist, true), 'methods' => array(), // if !collectMethods, may still get ['__toString']['returnValue'] 'phpDoc' => array( 'summary' => null, 'description' => null, // additional tags ), 'properties' => array(), 'scopeClass' => $this->getScopeClass($hist), 'stringified' => null, 'type' => 'object', 'traverseValues' => array(), // populated if method is table && traversable 'viaDebugInfo' => $this->abstracter->getCfg('useDebugInfo') && $reflector->hasMethod('__debugInfo'), // these are temporary values available during abstraction 'collectPropertyValues' => true, 'hist' => $hist, 'propertyOverrideValues' => array(), 'reflector' => $reflector, )); $keysTemp = \array_flip(array('collectPropertyValues','hist','propertyOverrideValues','reflector')); if ($abs['isRecursion']) { return \array_diff_key($abs->getValues(), $keysTemp); } /* debug.objAbstractStart subscriber may set isExcluded set collectPropertyValues (boolean) set collectMethods (boolean) set propertyOverrideValues set stringified set traverseValues */ $abs = $this->abstracter->debug->internal->publishBubbleEvent('debug.objAbstractStart', $abs); if (\array_filter(array($abs['isExcluded'], $abs->isPropagationStopped()))) { return \array_diff_key($abs->getValues(), $keysTemp); } $this->getAbstractionDetails($abs); /* debug.objAbstractEnd subscriber has free reign to modify abtraction array */ $return = $this->abstracter->debug->internal->publishBubbleEvent('debug.objAbstractEnd', $abs)->getValues(); $this->sort($return['properties']); $this->sort($return['methods']); return \array_diff_key($return, $keysTemp); }
php
{ "resource": "" }
q245437
AbstractObject.getAbstractionDetails
validation
private function getAbstractionDetails(Event $abs) { $reflector = $abs['reflector']; $abs['phpDoc'] = $this->phpDoc->getParsed($reflector); $traversed = false; if ($abs['debugMethod'] === 'table' && \count($abs['hist']) < 2) { // this is either rows (traversable), or a row (traversable) $obj = $abs->getSubject(); if ($obj instanceof \Traversable && !$abs['traverseValues']) { $traversed = true; $abs['hist'][] = $obj; foreach ($obj as $k => $v) { $abs['traverseValues'][$k] = $this->abstracter->needsAbstraction($v) ? $this->abstracter->getAbstraction($v, $abs['debugMethod'], $abs['hist']) : $v; } } } if (!$traversed) { $this->addConstants($abs); while ($reflector = $reflector->getParentClass()) { $abs['extends'][] = $reflector->getName(); } $this->addProperties($abs); $this->addMethods($abs); } }
php
{ "resource": "" }
q245438
AbstractObject.onStart
validation
public function onStart(Event $event) { $obj = $event->getSubject(); if ($obj instanceof \DateTime || $obj instanceof \DateTimeImmutable) { $event['stringified'] = $obj->format(\DateTime::ISO8601); } elseif ($obj instanceof \mysqli && ($obj->connect_errno || !$obj->stat)) { // avoid "Property access is not allowed yet" $event['collectPropertyValues'] = false; } }
php
{ "resource": "" }
q245439
AbstractObject.onEnd
validation
public function onEnd(Event $event) { $obj = $event->getSubject(); if ($obj instanceof \DOMNodeList) { // for reasons unknown, DOMNodeList's properties are invisible to reflection $event['properties']['length'] = \array_merge(static::$basePropInfo, array( 'type' => 'integer', 'value' => $obj->length, )); } elseif ($obj instanceof \Exception) { if (isset($event['properties']['xdebug_message'])) { $event['properties']['xdebug_message']['isExcluded'] = true; } } elseif ($obj instanceof \mysqli && !$event['collectPropertyValues']) { $propsAlwaysAvail = array( 'client_info','client_version','connect_errno','connect_error','errno','error','stat' ); $reflectionObject = $event['reflector']; foreach ($propsAlwaysAvail as $name) { $reflectionProperty = $reflectionObject->getProperty($name); $event['properties'][$name]['value'] = $reflectionProperty->getValue($obj); } } }
php
{ "resource": "" }
q245440
AbstractObject.addConstants
validation
public function addConstants(Event $abs) { if (!$this->abstracter->getCfg('collectConstants')) { return; } $reflector = $abs['reflector']; $constants = $reflector->getConstants(); while ($reflector = $reflector->getParentClass()) { $constants = \array_merge($reflector->getConstants(), $constants); } if ($this->abstracter->getCfg('objectSort') == 'name') { \ksort($constants); } $abs['constants'] = $constants; }
php
{ "resource": "" }
q245441
AbstractObject.addMethods
validation
private function addMethods(Event $abs) { $obj = $abs->getSubject(); if (!$abs['collectMethods']) { $this->addMethodsMin($abs); return; } if ($this->abstracter->getCfg('cacheMethods') && isset(static::$methodCache[$abs['className']])) { $abs['methods'] = static::$methodCache[$abs['className']]; } else { $methodArray = array(); $methods = $abs['reflector']->getMethods(); $interfaceMethods = array( 'ArrayAccess' => array('offsetExists','offsetGet','offsetSet','offsetUnset'), 'Countable' => array('count'), 'Iterator' => array('current','key','next','rewind','void'), 'IteratorAggregate' => array('getIterator'), // 'Throwable' => array('getMessage','getCode','getFile','getLine','getTrace','getTraceAsString','getPrevious','__toString'), ); $interfacesHide = \array_intersect($abs['implements'], \array_keys($interfaceMethods)); foreach ($methods as $reflectionMethod) { $info = $this->methodInfo($obj, $reflectionMethod); $methodName = $reflectionMethod->getName(); if ($info['visibility'] === 'private' && $info['inheritedFrom']) { /* getMethods() returns parent's private methods (must be a reason... but we'll skip it) */ continue; } foreach ($interfacesHide as $interface) { if (\in_array($methodName, $interfaceMethods[$interface])) { // this method implements this interface $info['implements'] = $interface; break; } } $methodArray[$methodName] = $info; } $abs['methods'] = $methodArray; $this->addMethodsPhpDoc($abs); static::$methodCache[$abs['className']] = $abs['methods']; } if (isset($abs['methods']['__toString'])) { $abs['methods']['__toString']['returnValue'] = $obj->__toString(); } return; }
php
{ "resource": "" }
q245442
AbstractObject.addMethodsMin
validation
private function addMethodsMin(Event $abs) { $obj = $abs->getSubject(); if (\method_exists($obj, '__toString')) { $abs['methods']['__toString'] = array( 'returnValue' => \call_user_func(array($obj, '__toString')), 'visibility' => 'public', ); } if (\method_exists($obj, '__get')) { $abs['methods']['__get'] = array('visibility' => 'public'); } if (\method_exists($obj, '__set')) { $abs['methods']['__set'] = array('visibility' => 'public'); } return; }
php
{ "resource": "" }
q245443
AbstractObject.addMethodsPhpDoc
validation
private function addMethodsPhpDoc(Event $abs) { $inheritedFrom = null; if (empty($abs['phpDoc']['method'])) { // phpDoc doesn't contain any @method tags, if (\array_intersect_key($abs['methods'], \array_flip(array('__call', '__callStatic')))) { // we've got __call and/or __callStatic method: check if parent classes have @method tags $reflector = $abs['reflector']; while ($reflector = $reflector->getParentClass()) { $parsed = $this->phpDoc->getParsed($reflector); if (isset($parsed['method'])) { $inheritedFrom = $reflector->getName(); $abs['phpDoc']['method'] = $parsed['method']; break; } } } if (empty($abs['phpDoc']['method'])) { // still empty return; } } foreach ($abs['phpDoc']['method'] as $phpDocMethod) { $className = $inheritedFrom ? $inheritedFrom : $abs['className']; $abs['methods'][$phpDocMethod['name']] = array( 'implements' => null, 'inheritedFrom' => $inheritedFrom, 'isAbstract' => false, 'isDeprecated' => false, 'isFinal' => false, 'isStatic' => $phpDocMethod['static'], 'params' => \array_map(function ($param) use ($className) { $info = $this->phpDocParam($param, $className); return array( 'constantName' => $info['constantName'], 'defaultValue' => $info['defaultValue'], 'desc' => null, 'name' => $param['name'], 'optional' => false, 'type' => $param['type'], ); }, $phpDocMethod['param']), 'phpDoc' => array( 'summary' => $phpDocMethod['desc'], 'description' => null, 'return' => array( 'type' => $phpDocMethod['type'], 'desc' => null, ) ), 'visibility' => 'magic', ); } unset($abs['phpDoc']['method']); return; }
php
{ "resource": "" }
q245444
AbstractObject.addProperties
validation
private function addProperties(Event $abs) { if ($abs['debugMethod'] === 'table' && $abs['traverseValues']) { return; } $obj = $abs->getSubject(); $reflectionObject = $abs['reflector']; /* We trace our ancestory to learn where properties are inherited from */ while ($reflectionObject) { $className = $reflectionObject->getName(); $properties = $reflectionObject->getProperties(); $isDebugObj = $className == __NAMESPACE__; while ($properties) { $reflectionProperty = \array_shift($properties); $name = $reflectionProperty->getName(); if (isset($abs['properties'][$name])) { // already have info... we're in an ancestor $abs['properties'][$name]['overrides'] = $this->propOverrides( $reflectionProperty, $abs['properties'][$name], $className ); $abs['properties'][$name]['originallyDeclared'] = $className; continue; } if ($isDebugObj && $name == 'data') { $abs['properties']['data'] = \array_merge(self::$basePropInfo, array( 'value' => array('NOT INSPECTED'), 'visibility' => 'protected', )); continue; } $abs['properties'][$name] = $this->getPropInfo($abs, $reflectionProperty); } $reflectionObject = $reflectionObject->getParentClass(); } $this->addPropertiesPhpDoc($abs); // magic properties documented via phpDoc $this->addPropertiesDebug($abs); // use __debugInfo() values if useDebugInfo' && method exists $properties = $abs['properties']; $abs['hist'][] = $obj; foreach ($properties as $name => $info) { if ($this->abstracter->needsAbstraction($info['value'])) { $properties[$name]['value'] = $this->abstracter->getAbstraction($info['value'], $abs['debugMethod'], $abs['hist']); } } $abs['properties'] = $properties; return; }
php
{ "resource": "" }
q245445
AbstractObject.addPropertiesPhpDoc
validation
private function addPropertiesPhpDoc(Event $abs) { // tag => visibility $tags = array( 'property' => 'magic', 'property-read' => 'magic-read', 'property-write' => 'magic-write', ); $inheritedFrom = null; if (!\array_intersect_key($abs['phpDoc'], $tags)) { // phpDoc doesn't contain any @property tags $found = false; $obj = $abs->getSubject(); if (!\method_exists($obj, '__get')) { // don't have magic getter... don't bother searching ancestor phpDocs return; } // we've got __get method: check if parent classes have @property tags $reflector = $abs['reflector']; while ($reflector = $reflector->getParentClass()) { $parsed = $this->phpDoc->getParsed($reflector); $tagIntersect = \array_intersect_key($parsed, $tags); if (!$tagIntersect) { continue; } $found = true; $inheritedFrom = $reflector->getName(); $abs['phpDoc'] = \array_merge( $abs['phpDoc'], $tagIntersect ); break; } if (!$found) { return; } } $properties = $abs['properties']; foreach ($tags as $tag => $vis) { if (!isset($abs['phpDoc'][$tag])) { continue; } foreach ($abs['phpDoc'][$tag] as $phpDocProp) { $exists = isset($properties[ $phpDocProp['name'] ]); $properties[ $phpDocProp['name'] ] = \array_merge( $exists ? $properties[ $phpDocProp['name'] ] : self::$basePropInfo, array( 'desc' => $phpDocProp['desc'], 'type' => $phpDocProp['type'], 'inheritedFrom' => $inheritedFrom, 'visibility' => $exists ? array($properties[ $phpDocProp['name'] ]['visibility'], $vis) : $vis, ) ); if (!$exists) { $properties[ $phpDocProp['name'] ]['value'] = $this->abstracter->UNDEFINED; } } unset($abs['phpDoc'][$tag]); } $abs['properties'] = $properties; return; }
php
{ "resource": "" }
q245446
AbstractObject.getParams
validation
private function getParams(\ReflectionMethod $reflectionMethod, $phpDoc = array()) { $paramArray = array(); $params = $reflectionMethod->getParameters(); if (empty($phpDoc)) { $phpDoc = $this->phpDoc->getParsed($reflectionMethod); } foreach ($params as $i => $reflectionParameter) { $nameNoPrefix = $reflectionParameter->getName(); $name = '$'.$nameNoPrefix; if (\method_exists($reflectionParameter, 'isVariadic') && $reflectionParameter->isVariadic()) { $name = '...'.$name; } if ($reflectionParameter->isPassedByReference()) { $name = '&'.$name; } $constantName = null; $defaultValue = $this->abstracter->UNDEFINED; if ($reflectionParameter->isDefaultValueAvailable()) { $defaultValue = $reflectionParameter->getDefaultValue(); if (\version_compare(PHP_VERSION, '5.4.6', '>=') && $reflectionParameter->isDefaultValueConstant()) { /* php may return something like self::CONSTANT_NAME hhvm will return WhateverTheClassNameIs::CONSTANT_NAME */ $constantName = $reflectionParameter->getDefaultValueConstantName(); } } $paramInfo = array( 'constantName' => $constantName, 'defaultValue' => $defaultValue, 'desc' => null, 'isOptional' => $reflectionParameter->isOptional(), 'name' => $name, 'type' => $this->getParamTypeHint($reflectionParameter), ); /* Incorporate phpDoc info */ if (isset($phpDoc['param'][$i])) { $paramInfo['desc'] = $phpDoc['param'][$i]['desc']; if (!isset($paramInfo['type'])) { $paramInfo['type'] = $phpDoc['param'][$i]['type']; } } $paramArray[$nameNoPrefix] = $paramInfo; } return $paramArray; }
php
{ "resource": "" }
q245447
AbstractObject.getPropInfo
validation
private function getPropInfo(Event $abs, \ReflectionProperty $reflectionProperty) { $obj = $abs->getSubject(); $reflectionProperty->setAccessible(true); // only accessible via reflection $className = \get_class($obj); // prop->class is equiv to getDeclaringClass // get type and comment from phpdoc $commentInfo = $this->getPropCommentInfo($reflectionProperty); /* getDeclaringClass returns "LAST-declared/overriden" */ $declaringClassName = $reflectionProperty->getDeclaringClass()->getName(); $propInfo = \array_merge(static::$basePropInfo, array( 'desc' => $commentInfo['desc'], 'inheritedFrom' => $declaringClassName !== $className ? $declaringClassName : null, 'isStatic' => $reflectionProperty->isStatic(), 'type' => $commentInfo['type'], )); if ($reflectionProperty->isPrivate()) { $propInfo['visibility'] = 'private'; } elseif ($reflectionProperty->isProtected()) { $propInfo['visibility'] = 'protected'; } if ($abs['collectPropertyValues']) { $propName = $reflectionProperty->getName(); if (\array_key_exists($propName, $abs['propertyOverrideValues'])) { $propInfo['value'] = $abs['propertyOverrideValues'][$propName]; $propInfo['valueFrom'] = 'debug'; } else { $propInfo['value'] = $reflectionProperty->getValue($obj); } } return $propInfo; }
php
{ "resource": "" }
q245448
AbstractObject.getPropCommentInfo
validation
private function getPropCommentInfo(\ReflectionProperty $reflectionProperty) { $name = $reflectionProperty->name; $phpDoc = $this->phpDoc->getParsed($reflectionProperty); $info = array( 'type' => null, 'desc' => $phpDoc['summary'] ? $phpDoc['summary'] : null, ); if (isset($phpDoc['var'])) { if (\count($phpDoc['var']) == 1) { $var = $phpDoc['var'][0]; } else { /* php's getDocComment doesn't play nice with compound statements https://www.phpdoc.org/docs/latest/references/phpdoc/tags/var.html */ foreach ($phpDoc['var'] as $var) { if ($var['name'] == $name) { break; } } } $info['type'] = $var['type']; if (!$info['desc']) { $info['desc'] = $var['desc']; } elseif ($var['desc']) { $info['desc'] = $info['desc'].': '.$var['desc']; } } return $info; }
php
{ "resource": "" }
q245449
AbstractObject.isObjExcluded
validation
private function isObjExcluded($obj) { if (\in_array(\get_class($obj), $this->abstracter->getCfg('objectsExclude'))) { return true; } foreach ($this->abstracter->getCfg('objectsExclude') as $exclude) { if (\is_subclass_of($obj, $exclude)) { return true; } } return false; }
php
{ "resource": "" }
q245450
AbstractObject.methodInfo
validation
private function methodInfo($obj, \ReflectionMethod $reflectionMethod) { // getDeclaringClass() returns LAST-declared/overridden $declaringClassName = $reflectionMethod->getDeclaringClass()->getName(); $phpDoc = $this->phpDoc->getParsed($reflectionMethod); $vis = 'public'; if ($reflectionMethod->isPrivate()) { $vis = 'private'; } elseif ($reflectionMethod->isProtected()) { $vis = 'protected'; } $info = array( 'implements' => null, 'inheritedFrom' => $declaringClassName != \get_class($obj) ? $declaringClassName : null, 'isAbstract' => $reflectionMethod->isAbstract(), 'isDeprecated' => $reflectionMethod->isDeprecated() || isset($phpDoc['deprecated']), 'isFinal' => $reflectionMethod->isFinal(), 'isStatic' => $reflectionMethod->isStatic(), 'params' => $this->getParams($reflectionMethod, $phpDoc), 'phpDoc' => $phpDoc, 'visibility' => $vis, // public | private | protected | debug | magic ); unset($info['phpDoc']['param']); return $info; }
php
{ "resource": "" }
q245451
AbstractObject.phpDocParam
validation
private function phpDocParam($param, $className) { $constantName = null; $defaultValue = $this->abstracter->UNDEFINED; if (\array_key_exists('defaultValue', $param)) { $defaultValue = $param['defaultValue']; if (\in_array($defaultValue, array('true','false','null'))) { $defaultValue = \json_decode($defaultValue); } elseif (\is_numeric($defaultValue)) { // there are no quotes around value $defaultValue = $defaultValue * 1; } elseif (\preg_match('/^array\(\s*\)|\[\s*\]$/i', $defaultValue)) { // empty array... // we're not going to eval non-empty arrays... // non empty array will appear as a string $defaultValue = array(); } elseif (\preg_match('/^(self::)?([^\(\)\[\]]+)$/i', $defaultValue, $matches)) { // appears to be a constant if ($matches[1]) { // self if (\defined($className.'::'.$matches[2])) { $constantName = $matches[0]; $defaultValue = \constant($className.'::'.$matches[2]); } } elseif (\defined($defaultValue)) { $constantName = $defaultValue; $defaultValue = \constant($defaultValue); } } else { $defaultValue = \trim($defaultValue, '\'"'); } } return array( 'constantName' => $constantName, 'defaultValue' => $defaultValue, ); }
php
{ "resource": "" }
q245452
ErrorLevel.getConstants
validation
public static function getConstants($phpVer = null) { $phpVer = $phpVer ?: PHP_VERSION; /* version_compare considers 1 < 1.0 < 1.0.0 */ $phpVer = \preg_match('/^\d+\.\d+$/', $phpVer) ? $phpVer.'.0' : $phpVer; $constants = array( 'E_ERROR' => 1, 'E_WARNING' => 2, 'E_PARSE' => 4, 'E_NOTICE' => 8, 'E_CORE_ERROR' => 16, 'E_CORE_WARNING' =>32, 'E_COMPILE_ERROR' => 64, 'E_COMPILE_WARNING' => 128, 'E_USER_ERROR' => 256, 'E_USER_WARNING' => 512, 'E_USER_NOTICE' => 1024, 'E_STRICT' => \version_compare($phpVer, '5.0.0', '>=') ? 2048 : null, 'E_RECOVERABLE_ERROR' => \version_compare($phpVer, '5.2.0', '>=') ? 4096 : null, 'E_DEPRECATED' => \version_compare($phpVer, '5.3.0', '>=') ? 8192 : null, 'E_USER_DEPRECATED' => \version_compare($phpVer, '5.3.0', '>=') ? 16384 : null, 'E_ALL' => null, // calculated below ); $constants = \array_filter($constants); /* E_ALL value: >= 5.4: 32767 5.3: 30719 (doesn't include E_STRICT) 5.2: 6143 (doesn't include E_STRICT) < 5.2: 2047 (doesn't include E_STRICT) */ $constants['E_ALL'] = \array_sum($constants); if (isset($constants['E_STRICT']) && \version_compare($phpVer, '5.4.0', '<')) { // E_STRICT not included in E_ALL until 5.4 $constants['E_ALL'] -= $constants['E_STRICT']; } return $constants; }
php
{ "resource": "" }
q245453
ErrorLevel.filterConstantsByLevel
validation
private static function filterConstantsByLevel($constants, $level) { foreach ($constants as $constantName => $value) { if (!self::inBitmask($value, $level)) { unset($constants[$constantName]); } } unset($constants['E_ALL']); return $constants; }
php
{ "resource": "" }
q245454
MethodTable.colKeys
validation
public static function colKeys($rows) { if (!\is_array($rows)) { return array(); } if (Abstracter::isAbstraction($rows) && $rows['traverseValues']) { $rows = $rows['traverseValues']; } $lastKeys = array(); $newKeys = array(); $curKeys = array(); foreach ($rows as $row) { $curKeys = self::keys($row); if (empty($lastKeys)) { $lastKeys = $curKeys; } elseif ($curKeys != $lastKeys) { $newKeys = array(); $count = \count($curKeys); for ($i = 0; $i < $count; $i++) { $curKey = $curKeys[$i]; if ($lastKeys && $curKey === $lastKeys[0]) { \array_push($newKeys, $curKey); \array_shift($lastKeys); } elseif (false !== $position = \array_search($curKey, $lastKeys, true)) { $segment = \array_splice($lastKeys, 0, $position+1); \array_splice($newKeys, \count($newKeys), 0, $segment); } elseif (!\in_array($curKey, $newKeys, true)) { \array_push($newKeys, $curKey); } } // put on remaining from lastKeys \array_splice($newKeys, \count($newKeys), 0, $lastKeys); $lastKeys = \array_unique($newKeys); } } return $lastKeys; }
php
{ "resource": "" }
q245455
MethodTable.keyValues
validation
public static function keyValues($row, $keys, &$objInfo) { $objInfo = array( 'row' => false, 'cols' => array(), ); $rowIsAbstraction = Abstracter::isAbstraction($row); if ($rowIsAbstraction) { if ($row['type'] == 'object') { $objInfo['row'] = array( 'className' => $row['className'], 'phpDoc' => $row['phpDoc'], ); $row = self::objectValues($row); if (!\is_array($row)) { // ie stringified value $objInfo['row'] = false; $row = array(self::SCALAR => $row); } elseif (Abstracter::isAbstraction($row)) { // still an abstraction (ie closure) $objInfo['row'] = false; $row = array(self::SCALAR => $row); } } else { // resource & callable $row = array(self::SCALAR => $row); } } if (!\is_array($row)) { $row = array(self::SCALAR => $row); } $values = array(); foreach ($keys as $key) { if (\array_key_exists($key, $row)) { $value = $row[$key]; if ($value !== null) { // by setting to false : // indicate that the column is not populated by objs of the same type // if stringified abstraction, we'll set cols[key] below $objInfo['cols'][$key] = false; } if (Abstracter::isAbstraction($value)) { // just return the stringified / __toString value in a table if (isset($value['stringified'])) { $objInfo['cols'][$key] = $value['className']; $value = $value['stringified']; } elseif (isset($value['__toString']['returnValue'])) { $objInfo['cols'][$key] = $value['className']; $value = $value['__toString']['returnValue']; } } } else { $value = Abstracter::UNDEFINED; } $values[$key] = $value; } return $values; }
php
{ "resource": "" }
q245456
MethodTable.keys
validation
private static function keys($val) { if (Abstracter::isAbstraction($val)) { // abstraction if ($val['type'] == 'object') { if ($val['traverseValues']) { // probably Traversable $val = $val['traverseValues']; } elseif ($val['stringified']) { $val = null; } elseif (isset($val['methods']['__toString']['returnValue'])) { $val = null; } else { $val = \array_filter($val['properties'], function ($prop) { return $prop['visibility'] === 'public'; }); /* Reflection doesn't return properties in any given order so, we'll sort for consistency */ \ksort($val, SORT_NATURAL | SORT_FLAG_CASE); } } else { // ie callable or resource $val = null; } } return \is_array($val) ? \array_keys($val) : array(self::SCALAR); }
php
{ "resource": "" }
q245457
MethodClear.clearErrors
validation
private function clearErrors($flags) { $clearErrors = $flags & Debug::CLEAR_LOG_ERRORS || $flags & Debug::CLEAR_SUMMARY_ERRORS; if (!$clearErrors) { return; } $errorsNotCleared = array(); /* Clear Log Errors */ $errorsNotCleared = $this->clearErrorsHelper( $this->data['log'], $flags & Debug::CLEAR_LOG_ERRORS ); /* Clear Summary Errors */ foreach (\array_keys($this->data['logSummary']) as $priority) { $errorsNotCleared = \array_merge($this->clearErrorsHelper( $this->data['logSummary'][$priority], $flags & Debug::CLEAR_SUMMARY_ERRORS )); } $errorsNotCleared = \array_unique($errorsNotCleared); $errors = $this->debug->errorHandler->get('errors'); foreach ($errors as $error) { if (!\in_array($error['hash'], $errorsNotCleared)) { $error['inConsole'] = false; } } }
php
{ "resource": "" }
q245458
MethodClear.clearErrorsHelper
validation
private function clearErrorsHelper(&$log, $clear = true) { $errorsNotCleared = array(); foreach ($log as $k => $entry) { if (!\in_array($entry[0], array('error','warn'))) { continue; } $clear2 = $clear; if ($this->channelName) { $channel = isset($entry[2]['channel']) ? $entry[2]['channel'] : null; $clear2 = $clear && $channel === $this->channelName; } if ($clear2) { unset($log[$k]); } elseif (isset($entry[2]['errorHash'])) { $errorsNotCleared[] = $entry[2]['errorHash']; } } $log = \array_values($log); return $errorsNotCleared; }
php
{ "resource": "" }
q245459
MethodClear.clearLog
validation
private function clearLog($flags) { $return = null; $clearErrors = $flags & Debug::CLEAR_LOG_ERRORS; if ($flags & Debug::CLEAR_LOG) { $return = 'log ('.($clearErrors ? 'incl errors' : 'sans errors').')'; $curDepth = 0; foreach ($this->data['groupStacks']['main'] as $group) { $curDepth += (int) $group['collect']; } $entriesKeep = $this->debug->internal->getCurrentGroups($this->data['log'], $curDepth); $this->clearLogHelper($this->data['log'], $clearErrors, $entriesKeep); } elseif ($clearErrors) { $return = 'errors'; } return $return; }
php
{ "resource": "" }
q245460
MethodClear.clearSummary
validation
private function clearSummary($flags) { $return = null; $clearErrors = $flags & Debug::CLEAR_SUMMARY_ERRORS; if ($flags & Debug::CLEAR_SUMMARY) { $return = 'summary ('.($clearErrors ? 'incl errors' : 'sans errors').')'; $curPriority = \end($this->data['groupPriorityStack']); // false if empty foreach (\array_keys($this->data['logSummary']) as $priority) { $entriesKeep = array(); if ($priority === $curPriority) { $curDepth = 0; foreach ($this->data['groupStacks'][$priority] as $group) { $curDepth += (int) $group['collect']; } $entriesKeep = $this->debug->internal->getCurrentGroups( $this->data['logSummary'][$priority], $curDepth ); } else { $this->data['groupStacks'][$priority] = array(); } $this->clearLogHelper($this->data['logSummary'][$priority], $clearErrors, $entriesKeep); } } elseif ($clearErrors) { $return = 'summary errors'; } return $return; }
php
{ "resource": "" }
q245461
MethodClear.getLogArgs
validation
private function getLogArgs($cleared) { $cleared = \array_filter($cleared); if (!$cleared) { return array(); } $count = \count($cleared); $glue = $count == 2 ? ' and ' : ', '; if ($count > 2) { $cleared[$count-1] = 'and '.$cleared[$count-1]; } $msg = 'Cleared '.\implode($glue, $cleared); if ($this->channelName) { return array( $msg.' %c(%s)', 'background-color:#c0c0c0; padding:0 .33em;', $this->channelName, ); } return array($msg); }
php
{ "resource": "" }
q245462
AbstractArray.getAbstraction
validation
public function getAbstraction(&$array, $method = null, &$hist = array()) { if (\in_array($array, $hist, true)) { return $this->abstracter->RECURSION; } if (self::isCallable($array)) { // this appears to be a "callable" return array( 'debug' => $this->abstracter->ABSTRACTION, 'type' => 'callable', 'values' => array(\get_class($array[0]), $array[1]), ); } $return = array(); $hist[] = $array; foreach ($array as $k => $v) { if ($this->abstracter->needsAbstraction($v)) { $v = $this->abstracter->getAbstraction($array[$k], $method, $hist); } $return[$k] = $v; } return $return; }
php
{ "resource": "" }
q245463
ErrorHandler.get
validation
public function get($key = null) { if ($key == 'lastError') { return isset($this->data['lastError']) ? $this->data['lastError']->getValues() : null; } if (isset($this->data[$key])) { return $this->data[$key]; } if (isset($this->{$key})) { return $this->{$key}; } return null; }
php
{ "resource": "" }
q245464
ErrorHandler.getCfg
validation
public function getCfg($key = null) { if (!\strlen($key)) { return $this->cfg; } if (isset($this->cfg[$key])) { return $this->cfg[$key]; } return null; }
php
{ "resource": "" }
q245465
ErrorHandler.handleException
validation
public function handleException($exception) { // lets store the exception so we can use the backtrace it provides $this->uncaughtException = $exception; \http_response_code(500); $this->handleError( E_ERROR, 'Uncaught exception \''.\get_class($exception).'\' with message '.$exception->getMessage(), $exception->getFile(), $exception->getLine() ); $this->uncaughtException = null; if ($this->cfg['continueToPrevHandler'] && $this->prevExceptionHandler) { \call_user_func($this->prevErrorHandler, $exception); } }
php
{ "resource": "" }
q245466
ErrorHandler.onShutdown
validation
public function onShutdown(Event $event) { if (!$this->registered) { return; } $error = $event['error'] ?: \error_get_last(); if (!$error) { return; } if (\in_array($error['type'], $this->errCategories['fatal'])) { /* found in wild: @include(some_file_with_parse_error) which will trigger a fatal error (here we are), but error_reporting() will return 0 due to the @ operator unsupress fatal error here */ \error_reporting(E_ALL | E_STRICT); $this->handleError($error['type'], $error['message'], $error['file'], $error['line']); } /* Find the fatal error/uncaught-exception and attach to shutdown event */ foreach ($this->data['errors'] as $error) { if ($error['category'] === 'fatal') { $event['error'] = $error; break; } } return; }
php
{ "resource": "" }
q245467
ErrorHandler.register
validation
public function register() { if ($this->registered) { return; } $this->prevDisplayErrors = \ini_set('display_errors', 0); $this->prevErrorHandler = \set_error_handler(array($this, 'handleError')); $this->prevExceptionHandler = \set_exception_handler(array($this, 'handleException')); $this->registered = true; // used by this->onShutdown() return; }
php
{ "resource": "" }
q245468
ErrorHandler.unregister
validation
public function unregister() { if (!$this->registered) { return; } /* set and restore error handler to determine the current error handler */ $errHandlerCur = \set_error_handler(array($this, 'handleError')); \restore_error_handler(); if ($errHandlerCur == array($this, 'handleError')) { // we are the current error handler \restore_error_handler(); } /* set and restore exception handler to determine the current error handler */ $exHandlerCur = \set_exception_handler(array($this, 'handleException')); \restore_exception_handler(); if ($exHandlerCur == array($this, 'handleException')) { // we are the current exception handler \restore_exception_handler(); } \ini_set('display_errors', $this->prevDisplayErrors); $this->prevErrorHandler = null; $this->prevExceptionHandler = null; $this->registered = false; // used by $this->onShutdown() return; }
php
{ "resource": "" }
q245469
ErrorHandler.buildError
validation
protected function buildError($errType, $errMsg, $file, $line, $vars) { // determine $category foreach ($this->errCategories as $category => $errTypes) { if (\in_array($errType, $errTypes)) { break; } } $errorValues = array( 'type' => $errType, // int 'typeStr' => $this->errTypes[$errType], // friendly string version of 'type' 'category' => $category, 'message' => $errMsg, 'file' => $file, 'line' => $line, 'vars' => $vars, 'backtrace' => array(), // only for fatal type errors, and only if xdebug is enabled 'continueToNormal' => false, // aka, let PHP do its thing (log error) 'continueToPrevHandler' => $this->cfg['continueToPrevHandler'] && $this->prevErrorHandler, 'exception' => $this->uncaughtException, // non-null if error is uncaught-exception 'hash' => null, 'isFirstOccur' => true, 'isHtml' => \filter_var(\ini_get('html_errors'), FILTER_VALIDATE_BOOLEAN) && !\in_array($errType, $this->userErrors) && !$this->uncaughtException, 'isSuppressed' => false, ); $hash = $this->errorHash($errorValues); $isFirstOccur = !isset($this->data['errors'][$hash]); // if any instance of this error was not supprssed, reflect that if ($errorValues['isHtml']) { $errorValues['message'] = \str_replace('<a ', '<a target="phpRef" ', $errorValues['message']); } $isSuppressed = !$isFirstOccur && !$this->data['errors'][$hash]['isSuppressed'] ? false : \error_reporting() === 0; if (!empty($this->data['errorCaller'])) { $errorValues['file'] = $this->data['errorCaller']['file']; $errorValues['line'] = $this->data['errorCaller']['line']; } if (\in_array($errType, array(E_ERROR, E_USER_ERROR))) { // will return empty unless xdebug extension installed/enabled $errorValues['backtrace'] = $this->backtrace($errorValues); } $errorValues = \array_merge($errorValues, array( 'continueToNormal' => !$isSuppressed && $isFirstOccur, 'hash' => $hash, 'isFirstOccur' => $isFirstOccur, 'isSuppressed' => $isSuppressed, )); return new Event($this, $errorValues); }
php
{ "resource": "" }
q245470
ErrorHandler.errorHash
validation
protected function errorHash($errorValues) { $errMsg = $errorValues['message']; // (\(.*?)\d+(.*?\)) "(tried to allocate 16384 bytes)" -> "(tried to allocate xxx bytes)" $errMsg = \preg_replace('/(\(.*?)\d+(.*?\))/', '\1x\2', $errMsg); // "blah123" -> "blahxxx" $errMsg = \preg_replace('/\b([a-z]+\d+)+\b/', 'xxx', $errMsg); // "-123.123" -> "xxx" $errMsg = \preg_replace('/\b[\d.-]{4,}\b/', 'xxx', $errMsg); // remove "comments".. this allows throttling email, while still adding unique info to user errors $errMsg = \preg_replace('/\s*##.+$/', '', $errMsg); $hash = \md5($errorValues['file'].$errorValues['line'].$errorValues['type'].$errMsg); return $hash; }
php
{ "resource": "" }
q245471
PhpDoc.getParsed
validation
public static function getParsed($what) { $hash = null; if (\is_object($what)) { $hash = self::getHash($what); if (isset(self::$cache[$hash])) { return self::$cache[$hash]; } } $comment = self::getCommentContent($what); if (\is_array($comment)) { return $comment; } $return = array( 'summary' => null, 'description' => null, ); if (\preg_match('/^@/m', $comment, $matches, PREG_OFFSET_CAPTURE)) { // we have tags $pos = $matches[0][1]; $strTags = \substr($comment, $pos); $return = \array_merge($return, self::parseTags($strTags)); // remove tags from comment $comment = $pos > 0 ? \substr($comment, 0, $pos-1) : ''; } /* Do some string replacement */ $comment = \preg_replace('/^\\\@/m', '@', $comment); $comment = \str_replace('{@*}', '*/', $comment); /* split into summary & description summary ends with empty whiteline or "." followed by \n */ $split = \preg_split('/(\.[\r\n]+|[\r\n]{2})/', $comment, 2, PREG_SPLIT_DELIM_CAPTURE); $split = \array_replace(array('','',''), $split); // assume that summary and desc won't be "0".. remove empty value and merge $return = \array_merge($return, \array_filter(array( 'summary' => \trim($split[0].$split[1]), // split[1] is the ".\n" 'desc' => \trim($split[2]), ))); if ($hash) { // cache it self::$cache[$hash] = $return; } return $return; }
php
{ "resource": "" }
q245472
PhpDoc.findInheritedDoc
validation
public static function findInheritedDoc(\Reflector $reflector) { $name = $reflector->getName(); $reflectionClass = $reflector->getDeclaringClass(); $interfaces = $reflectionClass->getInterfaceNames(); foreach ($interfaces as $className) { $reflectionClass2 = new \ReflectionClass($className); if ($reflectionClass2->hasMethod($name)) { return self::getParsed($reflectionClass2->getMethod($name)); } } $reflectionClass = $reflectionClass->getParentClass(); if ($reflectionClass && $reflectionClass->hasMethod($name)) { return self::getParsed($reflectionClass->getMethod($name)); } }
php
{ "resource": "" }
q245473
PhpDoc.getCommentContent
validation
private static function getCommentContent($what) { $reflector = null; if (\is_object($what)) { $reflector = $what instanceof \Reflector ? $what : new \ReflectionObject($what); $docComment = $reflector->getDocComment(); } else { // assume string $docComment = $what; } // remove opening "/**" and closing "*/" $docComment = \preg_replace('#^/\*\*(.+)\*/$#s', '$1', $docComment); // remove leading "*"s $docComment = \preg_replace('#^[ \t]*\*[ ]?#m', '', $docComment); $docComment = \trim($docComment); if ($reflector) { if (\strtolower($docComment) == '{@inheritdoc}') { return self::findInheritedDoc($reflector); } else { $docComment = \preg_replace_callback( '/{@inheritdoc}/i', function () use ($reflector) { $phpDoc = self::findInheritedDoc($reflector); return $phpDoc['description']; }, $docComment ); } } return $docComment; }
php
{ "resource": "" }
q245474
PhpDoc.getHash
validation
private static function getHash($what) { $str = null; if (!($what instanceof \Reflector)) { $str = \get_class($what); } elseif ($what instanceof \ReflectionClass) { $str = $what->getName(); } elseif ($what instanceof \ReflectionMethod) { $str = $what->getDeclaringClass()->getName().'::'.$what->getName().'()'; } elseif ($what instanceof \ReflectionFunction) { $str = $what->getName().'()'; } elseif ($what instanceof \ReflectionProperty) { $str = $what->getDeclaringClass()->getName().'::'.$what->getName(); } return $str ? \md5($str) : null; }
php
{ "resource": "" }
q245475
PhpDoc.splitParams
validation
private static function splitParams($paramStr) { $depth = 0; $startPos = 0; $chars = \str_split($paramStr); $params = array(); foreach ($chars as $pos => $char) { switch ($char) { case ',': if ($depth === 0) { $params[] = \trim(\substr($paramStr, $startPos, $pos-$startPos)); $startPos = $pos + 1; } break; case '[': case '(': $depth ++; break; case ']': case ')': $depth --; break; } } $params[] = \trim(\substr($paramStr, $startPos, $pos+1-$startPos)); return $params; }
php
{ "resource": "" }
q245476
PhpDoc.trimDesc
validation
private static function trimDesc($desc) { $lines = \explode("\n", $desc); $leadingSpaces = array(); foreach ($lines as $line) { if (\strlen($line)) { $leadingSpaces[] = \strspn($line, ' '); } } \array_shift($leadingSpaces); // first line will always have zero leading spaces $trimLen = $leadingSpaces ? \min($leadingSpaces) : 0; if (!$trimLen) { return $desc; } foreach ($lines as $i => $line) { $lines[$i] = $i > 0 && \strlen($line) ? \substr($line, $trimLen) : $line; } $desc = \implode("\n", $lines); return $desc; }
php
{ "resource": "" }
q245477
Internal.emailLog
validation
public function emailLog() { /* List errors that occured */ $errorStr = $this->buildErrorList(); /* Build Subject */ $subject = 'Debug Log'; $subjectMore = ''; if (!empty($_SERVER['HTTP_HOST'])) { $subjectMore .= ' '.$_SERVER['HTTP_HOST']; } if ($errorStr) { $subjectMore .= ' '.($subjectMore ? '(Error)' : 'Error'); } $subject = \rtrim($subject.':'.$subjectMore, ':'); /* Build body */ $body = (!isset($_SERVER['REQUEST_URI']) && !empty($_SERVER['argv']) ? 'Command: '. \implode(' ', $_SERVER['argv']) : 'Request: '.$_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'] )."\n\n"; if ($errorStr) { $body .= 'Error(s):'."\n" .$errorStr."\n"; } /* "attach" serialized log to body */ $data = \array_intersect_key($this->debug->getData(), \array_flip(array( 'alerts', 'log', 'logSummary', 'requestId', 'runtime', ))); $data['rootChannel'] = $this->debug->getCfg('channel'); $body .= $this->debug->utilities->serializeLog($data); /* Now email */ $this->email($this->debug->getCfg('emailTo'), $subject, $body); return; }
php
{ "resource": "" }
q245478
Internal.getMetaVals
validation
public static function getMetaVals(&$args, $defaultMeta = array(), $defaultArgs = array(), $argsToMeta = array()) { $meta = array(); foreach ($args as $i => $v) { if (\is_array($v) && isset($v['debug']) && $v['debug'] === Debug::META) { unset($v['debug']); $meta = \array_merge($meta, $v); unset($args[$i]); } } $args = \array_values($args); if ($defaultArgs) { $args = \array_slice($args, 0, \count($defaultArgs)); $args = \array_combine( \array_keys($defaultArgs), \array_replace(\array_values($defaultArgs), $args) ); } foreach ($argsToMeta as $argk => $metak) { if (\is_int($argk)) { $argk = $metak; } $defaultMeta[$metak] = $args[$argk]; unset($args[$argk]); } $meta = \array_merge($defaultMeta, $meta); return $meta; }
php
{ "resource": "" }
q245479
Internal.hasLog
validation
public function hasLog() { $entryCountInitial = $this->debug->getData('entryCountInitial'); $entryCountCurrent = $this->debug->getData('log/__count__'); $haveLog = $entryCountCurrent > $entryCountInitial; $lastEntryMethod = $this->debug->getData('log/__end__/0'); return $haveLog && $lastEntryMethod !== 'clear'; }
php
{ "resource": "" }
q245480
Internal.onBootstrap
validation
public function onBootstrap() { if ($this->debug->parentInstance) { // only recored php/request info for root instance return; } $collectWas = $this->debug->setCfg('collect', true); $this->debug->groupSummary(); $this->debug->group('environment', $this->debug->meta(array( 'hideIfEmpty' => true, 'level' => 'info', ))); $this->logPhpInfo(); $this->logServerVals(); $this->logRequest(); // headers, cookies, post $this->debug->groupEnd(); $this->debug->groupEnd(); $this->debug->setCfg('collect', $collectWas); }
php
{ "resource": "" }
q245481
Internal.onConfig
validation
public function onConfig(Event $event) { $cfg = $event['config']; if (!isset($cfg['debug'])) { // no debug config values have changed return; } $cfg = $cfg['debug']; if (isset($cfg['file'])) { $this->debug->addPlugin($this->debug->output->file); } if (isset($cfg['onBootstrap'])) { if (!$this->debug->parentInstance) { // we're initializing $this->debug->eventManager->subscribe('debug.bootstrap', $cfg['onBootstrap']); } else { // boostrap has already occured, so go ahead and call \call_user_func($cfg['onBootstrap'], new Event($this->debug)); } } if (isset($cfg['onLog'])) { /* Replace - not append - subscriber set via setCfg */ if (isset($this->cfg['onLog'])) { $this->debug->eventManager->unsubscribe('debug.log', $this->cfg['onLog']); } $this->debug->eventManager->subscribe('debug.log', $cfg['onLog']); } if (!static::$profilingEnabled) { $cfg = $this->debug->getCfg('debug/*'); if ($cfg['enableProfiling'] && $cfg['collect']) { static::$profilingEnabled = true; $pathsExclude = array( __DIR__, ); FileStreamWrapper::register($pathsExclude); } } }
php
{ "resource": "" }
q245482
Internal.onError
validation
public function onError(Event $error) { if ($this->debug->getCfg('collect')) { /* temporarily store error so that we can easily determine error/warn a) came via error handler b) calling info */ $this->error = $error; $errInfo = $error['typeStr'].': '.$error['file'].' (line '.$error['line'].')'; $errMsg = $error['message']; if ($error['type'] & $this->debug->getCfg('errorMask')) { $this->debug->error($errInfo.': ', $errMsg); } else { $this->debug->warn($errInfo.': ', $errMsg); } $error['continueToNormal'] = false; // no need for PHP to log the error, we've captured it here $error['inConsole'] = true; // Prevent ErrorHandler\ErrorEmailer from sending email. // Since we're collecting log info, we send email on shutdown $error['email'] = false; $this->error = null; } elseif ($this->debug->getCfg('output')) { $error['email'] = false; $error['inConsole'] = false; } else { $error['inConsole'] = false; } }
php
{ "resource": "" }
q245483
Internal.onOutput
validation
public function onOutput() { if ($this->debug->parentInstance) { // only record runtime info for root instance return; } $vals = $this->runtimeVals(); $this->debug->groupSummary(1); $this->debug->info('Built In '.$vals['runtime'].' sec'); $this->debug->info( 'Peak Memory Usage' .($this->debug->getCfg('output/outputAs') == 'html' ? ' <span title="Includes debug overhead">?&#x20dd;</span>' : '') .': ' .$this->debug->utilities->getBytes($vals['memoryPeakUsage']).' / ' .$this->debug->utilities->getBytes($vals['memoryLimit']) ); $this->debug->groupEnd(); }
php
{ "resource": "" }
q245484
Internal.onShutdown
validation
public function onShutdown() { $this->runtimeVals(); if ($this->testEmailLog()) { $this->emailLog(); } if (!$this->debug->getData('outputSent')) { echo $this->debug->output(); } return; }
php
{ "resource": "" }
q245485
Internal.buildErrorList
validation
private function buildErrorList() { $errorStr = ''; $errors = $this->debug->errorHandler->get('errors'); \uasort($errors, function ($a1, $a2) { return \strcmp($a1['file'].$a1['line'], $a2['file'].$a2['line']); }); $lastFile = ''; foreach ($errors as $error) { if ($error['isSuppressed']) { continue; } if ($error['file'] !== $lastFile) { $errorStr .= $error['file'].':'."\n"; $lastFile = $error['file']; } $typeStr = $error['type'] === E_STRICT ? 'Strict' : $error['typeStr']; $errorStr .= ' Line '.$error['line'].': ('.$typeStr.') '.$error['message']."\n"; } return $errorStr; }
php
{ "resource": "" }
q245486
Internal.logPhpInfo
validation
private function logPhpInfo() { if (!$this->debug->getCfg('logEnvInfo.phpInfo')) { return; } $this->debug->log('PHP Version', PHP_VERSION); $this->debug->log('ini location', \php_ini_loaded_file()); $this->debug->log('memory_limit', $this->debug->utilities->getBytes($this->debug->utilities->memoryLimit())); $this->debug->log('session.cache_limiter', \ini_get('session.cache_limiter')); if (\session_module_name() === 'files') { $this->debug->log('session_save_path', \session_save_path() ?: \sys_get_temp_dir()); } $extensionsCheck = array('curl','mbstring'); $extensionsCheck = \array_filter($extensionsCheck, function ($extension) { return !\extension_loaded($extension); }); if ($extensionsCheck) { $this->debug->warn('These common extensions are not loaded:', $extensionsCheck); } $this->logPhpInfoEr(); }
php
{ "resource": "" }
q245487
Internal.logRequest
validation
private function logRequest() { $this->logRequestHeaders(); if ($this->debug->getCfg('logEnvInfo.cookies')) { $cookieVals = $_COOKIE; \ksort($cookieVals, SORT_NATURAL); $this->debug->log('$_COOKIE', $cookieVals); } // don't expect a request body for these methods $noBody = !isset($_SERVER['REQUEST_METHOD']) || \in_array($_SERVER['REQUEST_METHOD'], array('CONNECT','GET','HEAD','OPTIONS','TRACE')); if ($this->debug->getCfg('logEnvInfo.post') && !$noBody) { if ($_POST) { $this->debug->log('$_POST', $_POST); } else { $input = \file_get_contents('php://input'); if ($input) { $this->debug->log('php://input', $input); } elseif (isset($_SERVER['REQUEST_METHOD']) && empty($_FILES)) { $this->debug->warn($_SERVER['REQUEST_METHOD'].' request with no body'); } } if (!empty($_FILES)) { $this->debug->log('$_FILES', $_FILES); } } }
php
{ "resource": "" }
q245488
Internal.logRequestHeaders
validation
private function logRequestHeaders() { if (!$this->debug->getCfg('logEnvInfo.headers')) { return; } if (!empty($_SERVER['argv'])) { return; } $headers = $this->debug->utilities->getAllHeaders(); \ksort($headers, SORT_NATURAL); $this->debug->log('request headers', $headers); }
php
{ "resource": "" }
q245489
Firephp.onOutput
validation
public function onOutput(Event $event) { $this->outputEvent = $event; $this->channelName = $this->debug->getCfg('channel'); $this->data = $this->debug->getData(); $event['headers'][] = array('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); $event['headers'][] = array('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::FIREPHP_PROTO_VER); $event['headers'][] = array('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); $heading = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'] : '$: '. \implode(' ', $_SERVER['argv']); $this->processLogEntryWEvent('groupCollapsed', array('PHP: '.$heading)); $this->processAlerts(); $this->processSummary(); $this->processLog(); $this->processLogEntryWEvent('groupEnd'); $event['headers'][] = array('X-Wf-1-Index', $this->messageIndex); $this->data = array(); return; }
php
{ "resource": "" }
q245490
Firephp.processLogEntry
validation
public function processLogEntry($method, $args = array(), $meta = array()) { $value = null; $firePhpMeta = $this->getMeta($method, $meta); if ($method == 'alert') { list($method, $args) = $this->methodAlert($args, $meta); $value = $args[0]; } elseif (\in_array($method, array('group','groupCollapsed'))) { $firePhpMeta['Label'] = $args[0]; } elseif (\in_array($method, array('profileEnd','table'))) { $firePhpMeta['Type'] = \is_array($args[0]) ? $this->firephpMethods['table'] : $this->firephpMethods['log']; $value = $this->methodTable($args[0], $meta['columns']); if ($meta['caption']) { $firePhpMeta['Label'] = $meta['caption']; } } elseif ($method == 'trace') { $firePhpMeta['Type'] = $this->firephpMethods['table']; $value = $this->methodTable($args[0], array('function','file','line')); $firePhpMeta['Label'] = 'trace'; } elseif (\count($args)) { if (\count($args) == 1) { $value = $args[0]; // no label; } else { $firePhpMeta['Label'] = \array_shift($args); $value = \count($args) > 1 ? $args // firephp only supports label/value... we'll pass multiple values as an array : $args[0]; } } $value = $this->dump($value); if ($this->messageIndex < self::MESSAGE_LIMIT) { $this->setFirephpHeader($firePhpMeta, $value); } elseif ($this->messageIndex === self::MESSAGE_LIMIT) { $this->setFirephpHeader( array('Type'=>$this->firephpMethods['warn']), 'FirePhp\'s limit of '.\number_format(self::MESSAGE_LIMIT).' messages reached!' ); } return; }
php
{ "resource": "" }
q245491
Firephp.getMeta
validation
private function getMeta($method, $meta) { $firePhpMeta = array( 'Type' => isset($this->firephpMethods[$method]) ? $this->firephpMethods[$method] : $this->firephpMethods['log'], // Label // File // Line // Collapsed (for group) ); if (isset($meta['file'])) { $firePhpMeta['File'] = $meta['file']; $firePhpMeta['Line'] = $meta['line']; } if (\in_array($method, array('group','groupCollapsed'))) { $firePhpMeta['Collapsed'] = $method == 'groupCollapsed' // yes, strings ? 'true' : 'false'; } return $firePhpMeta; }
php
{ "resource": "" }
q245492
Firephp.methodTable
validation
protected function methodTable($array, $columns = array()) { if (!\is_array($array)) { return $this->dump($array); } $table = array(); $keys = $columns ?: $this->debug->methodTable->colKeys($array); $headerVals = $keys; foreach ($headerVals as $i => $val) { if ($val === MethodTable::SCALAR) { $headerVals[$i] = 'value'; } } \array_unshift($headerVals, ''); $table[] = $headerVals; $classNames = array(); if ($this->debug->abstracter->isAbstraction($array) && $array['traverseValues']) { $array = $array['traverseValues']; } foreach ($array as $k => $row) { $values = $this->debug->methodTable->keyValues($row, $keys, $objInfo); foreach ($values as $k2 => $val) { if ($val === $this->debug->abstracter->UNDEFINED) { $values[$k2] = null; } } $classNames[] = $objInfo['row'] ? $objInfo['row']['className'] : ''; \array_unshift($values, $k); $table[] = \array_values($values); } if (\array_filter($classNames)) { \array_unshift($table[0], ''); // first col is row key. // insert classname after key foreach ($classNames as $i => $className) { \array_splice($table[$i+1], 1, 0, $className); } } return $table; }
php
{ "resource": "" }
q245493
Script.onOutput
validation
public function onOutput(Event $event) { $this->channelName = $this->debug->getCfg('channel'); $this->data = $this->debug->getData(); $errorStats = $this->debug->internal->errorStats(); $errorStr = ''; if ($errorStats['inConsole']) { $errorStr = 'Errors: '; foreach ($errorStats['counts'] as $category => $vals) { $errorStr .= $vals['inConsole'].' '.$category.', '; } $errorStr = \substr($errorStr, 0, -2); } $str = ''; $str .= '<script type="text/javascript">'."\n"; $str .= $this->processLogEntryWEvent('groupCollapsed', array( 'PHP', (isset($_SERVER['REQUEST_METHOD']) && isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'] : ''), $errorStr, )); $str .= $this->processAlerts(); $str .= $this->processSummary(); $str .= $this->processLog(); $str .= $this->processLogEntryWEvent('groupEnd'); $str .= '</script>'."\n"; $this->data = array(); $event['return'] .= $str; }
php
{ "resource": "" }
q245494
Script.processLogEntry
validation
public function processLogEntry($method, $args = array(), $meta = array()) { if ($method == 'alert') { list($method, $args) = $this->methodAlert($args, $meta); } elseif ($method == 'assert') { \array_unshift($args, false); } elseif (\in_array($method, array('count','time'))) { $method = 'log'; } elseif (\in_array($method, array('profileEnd','table'))) { $method = 'log'; if (\is_array($args[0])) { $method = 'table'; $args = array($this->methodTable($args[0], $meta['columns'])); } elseif ($meta['caption']) { \array_unshift($args, $meta['caption']); } } elseif ($method == 'trace') { $method = 'table'; $args = array($this->methodTable($args[0], array('function','file','line'))); } elseif (\in_array($method, array('error','warn'))) { if (isset($meta['file'])) { $args[] = $meta['file'].': line '.$meta['line']; } } if (!\in_array($method, $this->consoleMethods)) { $method = 'log'; } foreach ($args as $k => $arg) { $args[$k] = \json_encode($this->dump($arg)); } $str = 'console.'.$method.'('.\implode(',', $args).');'."\n"; $str = \str_replace(\json_encode($this->debug->abstracter->UNDEFINED), 'undefined', $str); return $str; }
php
{ "resource": "" }
q245495
HtmlErrorSummary.build
validation
public function build($stats) { $this->stats = $stats; return '' .$this->buildFatal() .$this->buildInConsole() .$this->buildNotInConsole(); }
php
{ "resource": "" }
q245496
HtmlErrorSummary.buildFatal
validation
protected function buildFatal() { $haveFatal = isset($this->stats['counts']['fatal']); if (!$haveFatal) { return ''; } $lastError = $this->errorHandler->get('lastError'); $isHtml = $lastError['isHtml']; $backtrace = $lastError['backtrace']; $html = '<h3>Fatal Error</h3>'; $html .= '<ul class="list-unstyled indent">'; if (\count($backtrace) > 1) { // more than one trace frame $table = $this->outputHtml->buildTable( $backtrace, array( 'attribs' => 'trace table-bordered', 'caption' => 'trace', 'columns' => array('file','line','function'), ) ); $html .= '<li>'.$lastError['message'].'</li>'; $html .= '<li>'.$table.'</li>'; if (!$isHtml) { $html = \str_replace($lastError['message'], \htmlspecialchars($lastError['message']), $html); } } else { $keysKeep = array('typeStr','message','file','line'); $lastError = \array_intersect_key($lastError, \array_flip($keysKeep)); $html .= '<li>'.$this->outputHtml->dump($lastError).'</li>'; if ($isHtml) { $html = \str_replace(\htmlspecialchars($lastError['message']), $lastError['message'], $html); } } if (!\extension_loaded('xdebug')) { $html .= '<li>Want to see a backtrace here? Install <a target="_blank" href="https://xdebug.org/docs/install">xdebug</a> PHP extension.</li>'; } $html .= '</ul>'; return $html; }
php
{ "resource": "" }
q245497
HtmlErrorSummary.buildNotInConsole
validation
protected function buildNotInConsole() { if (!$this->stats['notInConsole']) { return ''; } $errors = $this->errorHandler->get('errors'); $lis = array(); foreach ($errors as $err) { if (\array_intersect_assoc(array( // at least one of these is true 'category' => 'fatal', 'inConsole' => true, 'isSuppressed' => true, ), $err->getValues())) { continue; } $lis[] = '<li>'.$err['typeStr'].': '.$err['file'].' (line '.$err['line'].'): ' .($err['isHtml'] ? $err['message'] : \htmlspecialchars($err['message'])) .'</li>'; } if (!$lis) { return ''; } $count = \count($lis); $header = \sprintf( '%s %s captured while not collecting debug log', $this->stats['inConsole'] || isset($this->stats['counts']['fatal']) ? 'Additionally, there' : 'There', $count === 1 ? 'was 1 error' : 'were '.$count.' errors' ); $html = '<h3>'.$header.'</h3>' .'<ul class="list-unstyled indent">'."\n" .\implode("\n", $lis)."\n" .'</ul>'; return $html; }
php
{ "resource": "" }
q245498
HtmlErrorSummary.getErrorsInCategory
validation
protected function getErrorsInCategory($category) { $errors = $this->errorHandler->get('errors'); $errorsInCat = array(); foreach ($errors as $err) { if ($err['category'] == $category && $err['inConsole']) { $errorsInCat[] = $err; } } return $errorsInCat; }
php
{ "resource": "" }
q245499
Manager.addSubscriberInterface
validation
public function addSubscriberInterface(SubscriberInterface $interface) { $subscribers = $this->getInterfaceSubscribers($interface); foreach ($subscribers as $row) { $this->subscribe($row[0], $row[1], $row[2]); } return $subscribers; }
php
{ "resource": "" }