_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q238900
Gdn_ApplicationManager.AvailableApplications
train
public function AvailableApplications() { if (!is_array($this->_AvailableApplications)) { $ApplicationInfo = array(); $AppFolders = Gdn_FileSystem::Folders(PATH_APPLICATIONS); // Get an array of all application folders $ApplicationAboutFiles = Gdn_FileSystem::FindAll(PATH_APPL...
php
{ "resource": "" }
q238901
Gdn_ApplicationManager.EnabledApplications
train
public function EnabledApplications() { if (!is_array($this->_EnabledApplications)) { $EnabledApplications = Gdn::Config('EnabledApplications', array('Dashboard' => 'dashboard')); // Add some information about the applications to the array. foreach($EnabledApplications as $Name => $Fold...
php
{ "resource": "" }
q238902
GhostService.prepareService
train
private function prepareService() { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!($bound = $this->app->bound(ServiceShortCuts::CORE_INITIALIZED))) { $this->services(['LaravelCommode\Common\Co...
php
{ "resource": "" }
q238903
Generator.generateGrid
train
protected function generateGrid($tiles, $columns) { [$distribution, $grid] = Distributor::distribute( $tiles, $columns, $this->settings['tallRate'], $this->settings['wideRate'] ); RandomFiller::fill($grid, $distribution, $this->settings['maxFil...
php
{ "resource": "" }
q238904
Extension.load
train
public function load(ServiceContainer $container, array $params) { $container->define( 'ecomdev.matcher.file', function () { return $this->createFileMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher...
php
{ "resource": "" }
q238905
Extension.createCheckMatcher
train
private function createCheckMatcher($verbs, $nouns, ...$matcherArguments) { return new CheckMatcher( $this->createLexer($verbs, $nouns), ...$matcherArguments ); }
php
{ "resource": "" }
q238906
BaseRequestHelper.instantiate
train
static public function instantiate(RequestHelper $requestHelper) { $objectHash = spl_object_hash($requestHelper); if(static::isSingleInstance()) { if(isset(static::$instances[$objectHash][static::getName()])) { return static::$instances[$objectHash][static::getName()]; ...
php
{ "resource": "" }
q238907
AbstractAclHandler.deleteAcl
train
public function deleteAcl($object) { try { if ($objectIdentity = $this->getObjectIdentity($object)) { $this->aclProvider->deleteAcl($objectIdentity); } } catch (\Exception $e) { // nothing to do } }
php
{ "resource": "" }
q238908
Filesystem.files
train
public function files($directory, $recursive = false) { $result = []; $recursive = boolval($recursive); if ( ! $this->isDirectory($directory)) return []; $items = new FilesystemIterator($directory); foreach ($items as $item) { if ($item->isFile()) { ...
php
{ "resource": "" }
q238909
Groupie.buildGroups
train
public function buildGroups($entities, $level = 0) { if(!count($this->groupDefinitions)) { throw new \RuntimeException('There are no groups defined.'); } // Building groups /** @var Group[] $groups */ $groups = []; if(!isset($this->groupDefinitions[$level])) { return []; } $groupDefinition = $thi...
php
{ "resource": "" }
q238910
Groupie.addGlobalColumn
train
public function addGlobalColumn(ColumnDefinition $columnDefinition, callable $columnDataFactory) { $this->addColumn($columnDefinition); foreach($this->groupDefinitions as $groupDefinition) { $groupDefinition->addColumn($columnDefinition, $columnDataFactory); } return $this; }
php
{ "resource": "" }
q238911
Repository.addBuild
train
public function addBuild(Build $build) { $this->getBuilds(); $build->setRepositoryId($this->getId()); $this->builds[$build->getId()] = $build; }
php
{ "resource": "" }
q238912
Repository.removeBuild
train
public function removeBuild(Build $build) { if (isset($this->builds[$build->getId()])) { unset($this->builds[$build->getId()]); } }
php
{ "resource": "" }
q238913
DocumentSerialization.jsonDeserialize
train
public static function jsonDeserialize(array $json): DocumentSerializationInterface { $managerClass = $json['document_serialization']['manager_class']; $data = (array) $json['document_serialization']['data']; return new self($managerClass, $data); }
php
{ "resource": "" }
q238914
JsonToList.invoke
train
public static function invoke($jsonString, $returnNode = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); $jsonString = mb_convert_encoding($jsonString, 'UTF-8', mb_detect_encoding($jsonString)); $jsonDecode = json_decode($jsonString, false); $lastError = json_last_error(); ...
php
{ "resource": "" }
q238915
JsonToList.objectOutput
train
protected static function objectOutput(\stdClass $object, \DOMDocument $dom, \DOMElement $parentUL) { foreach($object as $k=>$v) { $li = $dom->createElement('li'); $parentUL->appendChild($li); $strong = $dom->createElement('strong', $k); $li->appendChi...
php
{ "resource": "" }
q238916
FilteringRepositoryTrait.applyFilters
train
public function applyFilters(QueryBuilder $queryBuilder, $alias, FilterBagInterface $filterBag = null) { if (is_null($filterBag)) { return $queryBuilder; } foreach ($filterBag->all() as $filter) { if ($filter instanceof FilterNode) { $this->applyFilte...
php
{ "resource": "" }
q238917
FilteringRepositoryTrait.applyFilter
train
protected function applyFilter(QueryBuilder $queryBuilder, $alias, FilterNode $filter) { $queryBuilderPatcher = new QueryBuilderPatcher(new QueryExpressionBuilder()); return $queryBuilderPatcher->patch($queryBuilder, $filter, new QueryContext($alias)); }
php
{ "resource": "" }
q238918
AbstractApi.addErrorMessage
train
public function addErrorMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'error', 'bootstrapType' => 'danger', 'message' => $message ); static::$success = false; }
php
{ "resource": "" }
q238919
AbstractApi.addSuccessMessage
train
public function addSuccessMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[$message] = array( 'type' => 'success', 'bootstrapType' => 'success', 'message' => $message ); }
php
{ "resource": "" }
q238920
AbstractApi.addInfoMessage
train
public function addInfoMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'info', 'bootstrapType' => 'info', 'message' => $message ); }
php
{ "resource": "" }
q238921
AbstractApi.addWarningMessage
train
public function addWarningMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'warning', 'bootstrapType' => 'warning', 'message' => $message ); }
php
{ "resource": "" }
q238922
DisplayNoAccessMessage.execute
train
public function execute(Framework $framework, WebRequest $request, Response $response) { $renderedOutput = $this->render('\\Zepi\\Web\\AccessControl\\Templates\\NoAccessMessage'); $response->setOutput($renderedOutput); }
php
{ "resource": "" }
q238923
PropertyHandler.getPropertyAnnotation
train
public function getPropertyAnnotation(\ReflectionProperty $property) { $annot = $this->reader->getPropertyAnnotation($property, '\Represent\Annotations\Property'); if (!$annot) { return false; } return $annot; }
php
{ "resource": "" }
q238924
PropertyHandler.getSerializedName
train
public function getSerializedName(\ReflectionProperty $property, Property $annot = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getName(); } return $property->getName(); }
php
{ "resource": "" }
q238925
PropertyHandler.propertyTypeOverride
train
public function propertyTypeOverride(Property $annot = null, \ReflectionProperty $property = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getType(); } return null; }
php
{ "resource": "" }
q238926
PropertyHandler.getConvertedValue
train
public function getConvertedValue(\ReflectionProperty $property, $original, Property $annot = null) { return $this->handleTypeConversion($this->propertyTypeOverride($annot, $property), $property->getValue($original)); }
php
{ "resource": "" }
q238927
JavascriptFormatter.formatAttributeValue
train
protected function formatAttributeValue(Attribute $attribute) { $value = $attribute->getValue(); if ($attribute->getType() === Attribute::TYPE_FUNCTION && strlen($value)) { return new Expr($value); } return $value; }
php
{ "resource": "" }
q238928
User.getAvatarAttribute
train
public function getAvatarAttribute() { $hash = ! empty($this->email) ? md5(strtolower(trim($this->email))) : ''; return sprintf('//secure.gravatar.com/avatar/%s?d=mm', $hash); }
php
{ "resource": "" }
q238929
Client.prepareParametersUrl
train
private function prepareParametersUrl(array $params, array $allowedParams) { $allowedParams = array_flip($allowedParams); $params = array_intersect_key($params, $allowedParams); $paramsUrlItems = []; foreach ($params as $key => $param) { $paramsUrlItems[] = $key . '=' . ...
php
{ "resource": "" }
q238930
EventEmitter.on
train
public final function on( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected ...
php
{ "resource": "" }
q238931
EventEmitter.once
train
public final function once( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected n...
php
{ "resource": "" }
q238932
EventEmitter.callbackEquals
train
private static function callbackEquals( $callback1, $callback2 ) { if ( is_array( $callback1 ) && is_array( $callback2 ) ) { if ( count( $callback1 ) == count( $callback2 ) ) { for ( $i=0, $len = count( $callback1 ); $i<$len; $i++ ) { if ( $callback1[$i] != $callback2[$i] ) { return ...
php
{ "resource": "" }
q238933
EventEmitter.off
train
public final function off( $eventName, $eventCallback = null ) { if ( is_string( $eventName ) ) { if ( strlen( $eventName ) > 0 ) { if ( isset( $this->events[ $eventName ] ) ) { if ( $eventCallback === null ) { unset( $this->events[ $eventName ] ); } else { for ( $i = ...
php
{ "resource": "" }
q238934
EventEmitter.fire
train
public final function fire( $eventName /* ... $eventArgs: any[] */ ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected' ); } else if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string ...
php
{ "resource": "" }
q238935
CategoryRepository.findNextSubcategory
train
public function findNextSubcategory($subcategory) { $qb = $this->getQueryBuilder() ->select('c') ->where('c.id > :id') ->andWhere('c.parentCategory = :parentCategory') ->orderBy('c.id', 'asc') ->setMaxResults(1) ->setParameter('id', $su...
php
{ "resource": "" }
q238936
CategoryRepository.getBrands
train
public function getBrands($category, $limit = null) { $qb = $this->getQueryBuilder() ->select('DISTINCT b.id, b.name') ->innerJoin('c.products', 'p') ->innerJoin('p.brand', 'b') ->where('p.active = TRUE') ->andWhere('b.available = TRUE'); ...
php
{ "resource": "" }
q238937
Finder.find
train
public function find($paths = null) { if ($paths === null) $paths = $this->paths; // iterator $iterator = $this->getIterator(); // search in target paths foreach ((array)$paths as $path) { $this->searchInPath($iterator, $path); } // clear ...
php
{ "resource": "" }
q238938
Finder.searchInPath
train
private function searchInPath(FileSystem\Iterator\IteratorAggregate $iterator, $path, FileSystem\Directory $parent = null, $depth = 0) { // when exists. if (file_exists($path)) { if(is_dir($path)) { $dir = new FileSystem\Directory($path); if ($parent) $dir...
php
{ "resource": "" }
q238939
Finder.validate
train
private function validate(FileSystem\File $file) { $filters = $this->buildFilters(); foreach ($filters as $filter) { if (! $filter->validate($file)) return false; } return true; }
php
{ "resource": "" }
q238940
Finder.buildFilters
train
private function buildFilters() { $filters = array(); // file only ? or direcotry only ? if ($this->file_only) $filters[] = new Filter\FileOnlyFilter(); if ($this->directory_only) $filters[] = new Filter\DirectoryOnlyFilter(); // name match ? foreach ($this->names a...
php
{ "resource": "" }
q238941
Finder.fileOnly
train
public function fileOnly($flag = true) { $this->file_only = $flag; if ($this->file_only) $this->directory_only = false; return $this; }
php
{ "resource": "" }
q238942
Finder.directoryOnly
train
public function directoryOnly($flag = true) { $this->directory_only = $flag; if ($this->directory_only) $this->file_only = false; return $this; }
php
{ "resource": "" }
q238943
Robot.removeListener
train
public function removeListener(Listener $listener) { foreach ($this->listeners as $id => $listening) { if ($listener == $listening) { unset($this->listeners[$id]); break; } } }
php
{ "resource": "" }
q238944
Robot.login
train
public function login($nick, $password = null) { if ($password) { if (!$this->connection->send("PASS {$password}")) { throw new \RuntimeException( "failed to send password to {$this->server}"); } } else { if (!$this->connection->send("PASS NOPASS")) { throw new \RuntimeException( "failed ...
php
{ "resource": "" }
q238945
Robot.loop
train
public function loop($main = true) { if ($main && $this->manager) { $this->manager->onStartup($this); } while (($line = $this->connection->recv())) { if (preg_match("~^ping :(.*)?~i", $line, $pong)) { if (!$this->connection->send("PONG {$pong[1]}")) { throw new \RuntimeException( "failed t...
php
{ "resource": "" }
q238946
ServiceFactory.createServiceFactory
train
protected function createServiceFactory( $requestedName, ReflectionClass $reflection, ContainerInterface $container ) { /** @var array $mappings */ $mappings = $this->getServiceMapping($container, $requestedName); if ($reflection->implementsInterface(Factory\FactoryInterface::class)...
php
{ "resource": "" }
q238947
File.iterateFileName
train
protected static function iterateFileName(string $fileName) { //First remove Extension $arrFileParts = explode(".", $fileName); $extension = array_pop($arrFileParts); $tempFileName = implode(".", $arrFileParts); $arrFileName = explode("_", $tempFileName); if (is_numer...
php
{ "resource": "" }
q238948
BasicAuthentication.authenticate
train
public function authenticate($params, $method, $headers) { $email = \Phramework\Validate\EmailValidator::parseStatic($params['email']); $password = $params['password']; $user = call_user_func(Manager::getUserGetByEmailMethod(), $email); if (!$user) { return false; ...
php
{ "resource": "" }
q238949
ContextTrait.set
train
public function set($prop, $value) { $class = get_class($this); if(property_exists($class, $prop)) { // Use reflection to set private property $reflection = new \ReflectionProperty($class, $prop); $reflection->setAccessible(true); $reflection->setValue($th...
php
{ "resource": "" }
q238950
WhereStatement.addCondition
train
public function addCondition($field, $value = false, $operator = '=') { if (is_array($field) && !$value) { foreach ($field as $key => $value) { // handles #6 if (is_array($value)) { call_user_func_array([$this, 'addCondition'], $value); ...
php
{ "resource": "" }
q238951
WhereStatement.addBetweenCondition
train
public function addBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, true]; return $this; }
php
{ "resource": "" }
q238952
WhereStatement.addNotBetweenCondition
train
public function addNotBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, false]; return $this; }
php
{ "resource": "" }
q238953
WhereStatement.buildClause
train
protected function buildClause(array $cond) { // handle SQL fragments if (count($cond) == 1 && (is_string($cond[0]) || !is_callable($cond[0]))) { return $cond[0]; } // handle EXISTS conditions if ($cond[0] === 'EXISTS') { return $this->buildExists($co...
php
{ "resource": "" }
q238954
WhereStatement.buildSubquery
train
protected function buildSubquery(callable $f) { $query = new SelectQuery(); $query->getSelect()->clearFields(); $f($query); $sql = $query->build(); $this->values = array_merge($this->values, $query->getValues()); return '('.$sql.')'; }
php
{ "resource": "" }
q238955
WhereStatement.buildBetween
train
protected function buildBetween($field, $value1, $value2, $isBetween) { $operator = $isBetween ? 'BETWEEN' : 'NOT BETWEEN'; return $this->escapeIdentifier($field).' '.$operator.' '.$this->parameterize($value1).' AND '.$this->parameterize($value2); }
php
{ "resource": "" }
q238956
WhereStatement.buildIn
train
protected function buildIn($field, array $values, $isIn) { $operator = $isIn ? ' IN ' : ' NOT IN '; return $field.$operator.$this->parameterizeValues($values); }
php
{ "resource": "" }
q238957
WhereStatement.implodeClauses
train
protected function implodeClauses(array $clauses) { $str = ''; $op = false; foreach ($clauses as $clause) { // an 'OR' token will change the operator used // when concatenating the next clause if ($clause == 'OR') { $op = ' OR '; ...
php
{ "resource": "" }
q238958
JinitializeCommand.export
train
protected function export(string $key, $value) { $container = JinitializeContainer::getInstance(); $container->getPlugin($this->getPluginName())->getContainer()->set($key, $value); }
php
{ "resource": "" }
q238959
JinitializeCommand.import
train
protected function import(string $key) { $container = JinitializeContainer::getInstance(); return $container->getPlugin($this->getPluginName())->getContainer()->get($key); }
php
{ "resource": "" }
q238960
Curl.getImageInfo
train
public static function getImageInfo($image, array $config = null) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $img = new static($image['value'], $finfo, $config); $curl = $img->getConnection(); curl_exec($curl); curl_close($curl); $info = $img->getInfo(); fi...
php
{ "resource": "" }
q238961
Curl.writeCallback
train
public function writeCallback($connection, $string) { $this->content .= $string; if (!$this->mime) { $this->mime = finfo_buffer($this->finfo, $this->content); if (!in_array($this->mime, static::$mimetypes, true)) { $this->mime = null; return...
php
{ "resource": "" }
q238962
File.delete
train
public function delete() { if (!$this->exists()) { return false; } if ($this->isDir()) { return rmdir($this->absoluteFileName); } return unlink($this->absoluteFileName); }
php
{ "resource": "" }
q238963
File.createDir
train
public function createDir($mode = 0777) { return is_dir($this->absoluteFileName) || mkdir($this->absoluteFileName, $mode, true); }
php
{ "resource": "" }
q238964
File.scanDir
train
public function scanDir() { // only possible in directories if (!$this->isDir() || !$this->exists()) { return null; } $fileList = []; $fileNameList = scandir($this->absoluteFileName); foreach ($fileNameList as $fileName) { // do not add . and ...
php
{ "resource": "" }
q238965
File.findFirstOccurenceOfFile
train
public function findFirstOccurenceOfFile(string $fileName) { if (!$this->isDir() || !$this->exists()) { return null; } foreach ($this->scanDir() as $file) { if ($file->getFileName() === $fileName) { return $file; } if ($file->...
php
{ "resource": "" }
q238966
File.loadAsXSLTProcessor
train
public function loadAsXSLTProcessor() { $this->checkFileExists(); $xsl = new \XSLTProcessor(); $xsl->importStylesheet($this->loadAsXML()); return $xsl; }
php
{ "resource": "" }
q238967
File.loadAsXML
train
public function loadAsXML() { $this->checkFileExists(); $xml = new \DomDocument (); libxml_use_internal_errors(true); $result = $xml->load($this->absoluteFileName); if ($result) { return $xml; } $messageObject = ArrayUtil::getFromArray(libxml_get_e...
php
{ "resource": "" }
q238968
FeatureContext.elementShouldBeVisible
train
public function elementShouldBeVisible($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUni...
php
{ "resource": "" }
q238969
FeatureContext.elementShouldBeHidden
train
public function elementShouldBeHidden($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit...
php
{ "resource": "" }
q238970
FeatureContext.elementShouldHaveClass
train
public function elementShouldHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } ...
php
{ "resource": "" }
q238971
FeatureContext.elementShouldNotHaveClass
train
public function elementShouldNotHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } ...
php
{ "resource": "" }
q238972
SocietyJavascriptPipeline.addJs
train
public function addJs($js) { if (is_array($js)) { foreach ($js as $script) { $this->addJs($script); } return $this; } $this->js->push($js); return $this; }
php
{ "resource": "" }
q238973
ClassLoaderLocator.getClassLoaders
train
public function getClassLoaders() { if (null !== static::$classLoaders) { return static::$classLoaders; } static::$classLoaders = array(); foreach (spl_autoload_functions() as $function) { if (is_array($function) && count($function[0]) > 0 && is_object($func...
php
{ "resource": "" }
q238974
DbTaskList.migrateTask
train
public function migrateTask(Option $option) { $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->migrate($this->application->getEnv(), $option->...
php
{ "resource": "" }
q238975
DbTaskList.seedTask
train
public function seedTask(Option $option) { $name = $option->getArg(0); $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { foreach ($this->migrationHelper->getSeeders($alias, $name) as $seeder) { ...
php
{ "resource": "" }
q238976
DbTaskList.statusTask
train
public function statusTask(Option $option) { $databases = $this->getDatabases($option); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->printStatus($this->application->getEnv(), $option->get('format')); } }
php
{ "resource": "" }
q238977
InsertModel.setModel
train
public function setModel($model) { $model->setSerializeNull($this->isSerializeNull()); $this->setJson($model->toJson()); return $this; }
php
{ "resource": "" }
q238978
ExceptionListener.onKernelException
train
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = null; switch (true) { case ($exception instanceof NotFoundHttpException): $response = $this->createNotFoundResponse($event->getRequest(), $e...
php
{ "resource": "" }
q238979
ExceptionListener.createNotFoundResponse
train
private function createNotFoundResponse($request, $exception) { $message = $exception->getMessage(); if (empty($message)) { $message = 'Uri ' . $request->getRequestUri() . ' could not be found'; } return new JsonResponse( [ 'status' => 'ERROR...
php
{ "resource": "" }
q238980
ExceptionListener.createHttpExceptionResponse
train
private function createHttpExceptionResponse(HttpException $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'message' => $exception->getMessage() ], $exception->getStatusCode(), $exception->getHeaders() ); ...
php
{ "resource": "" }
q238981
ExceptionListener.createInternalServerError
train
private function createInternalServerError(\Exception $exception) { $message = sprintf( '%s: %s (uncaught exception) at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine() ); $...
php
{ "resource": "" }
q238982
ExceptionListener.formatStackFrame
train
private function formatStackFrame($frame) { return [ 'file' => isset($frame['file']) ? $frame['file'] : 'unknown', 'line' => isset($frame['line']) ? $frame['line'] : 'unknown', 'function' => (isset($frame['class']) ? $frame['class'] . $frame['type'] : '') . $fr...
php
{ "resource": "" }
q238983
ExceptionListener.formatArguments
train
private function formatArguments($arguments) { $result = []; foreach ($arguments as $key => $argument) { if (is_object($argument)) { $result[$key] = get_class($argument); continue; } if (is_array($argument)) { $resu...
php
{ "resource": "" }
q238984
Core._init
train
public static function _init(): Core { static::$framework = new Core(); static::$framework->createDIContainer(); try { static::$framework->fireEvent('initialized'); } catch (\Exception $e) { echo('Unable to fire initialization.'); exit(); }...
php
{ "resource": "" }
q238985
Core.registerServiceManager
train
public function registerServiceManager(string $name, ServiceManager $service_manager): Core { $this->service_managers->register($name, $service_manager); return $this; }
php
{ "resource": "" }
q238986
Core.on
train
public function on(string $event, $class_or_obj, string $method, array $arguments = []): Core { $this->registerEventHandler(new EventHandler($event, $class_or_obj, $method, $arguments)); return $this; }
php
{ "resource": "" }
q238987
Core.fireEvent
train
public function fireEvent(string $event): void { $this->log->debug('Event {event} has been fired.', ['event' => $event]); foreach ($this->event_handlers as $handler) { /** @var EventHandler $handler */ if ($event === $handler->getEvent()) { $handler->execute()...
php
{ "resource": "" }
q238988
Core.getRemoteIP
train
public function getRemoteIP(): string { if (null === $this->remote_ip) { $ip = $_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; $ip = explode(',', $ip); $ip = trim($ip[0]);...
php
{ "resource": "" }
q238989
Access.check
train
public static function check($name, $user, $request, $options = []) { if (($config = static::_config($name)) === null) { throw new ConfigException("Configuration `{$name}` has not been defined."); } $filter = function($self, $params) use ($name) { $user = $params['user']; $request = $params['request']; ...
php
{ "resource": "" }
q238990
Caller.call
train
protected function call(array $params) { $defaultParams = [ 'key' => $this->apiKey, 'format' => 'json', 'apiVersion' => self::VERSION, ]; $params = array_merge($defaultParams, $params); $url = sprintf('%s?%s', self::ENDPOINT, http_buil...
php
{ "resource": "" }
q238991
Config._parseLang
train
protected function _parseLang($src = null, $lang) { if ($src == null) { $file = APP_RESOURCE_LANG_PATH . $lang . '.xml'; $src = 'app'; } else { $file = SRC_PATH . $src . '/' . SRC_RESOURCE_LANG_PATH . $lang . '.xml'; } $this->config['lang'][''...
php
{ "resource": "" }
q238992
Config._parseParent
train
protected function _parseParent($child, $data, $attributes) { $parent = $child->xpath("parent::*"); if (is_object($parent[0]['name'])) { foreach ($attributes as $attribute) { $name = $attribute['name']; if (is_object($parent[0][$name])) { ...
php
{ "resource": "" }
q238993
AjaxValidationTrait.performAjaxValidation
train
protected function performAjaxValidation($model) { $result = ($model instanceof Model) ? ActiveForm::validate($model) : ActiveForm::validateMultiple($model); $response = Yii::$app->getResponse(); if (!empty($result) && $ajaxRedirect = Yii::$app->getSession()->get('s...
php
{ "resource": "" }
q238994
OsfCache.start
train
public function start(string $key) { $filteredKey = $this->filterKey($key); $value = $this->get($filteredKey); if ($value === null) { $this->lastKey = $filteredKey; ob_start(); } else { $this->lastKey = null; trigger_error('Cache start ...
php
{ "resource": "" }
q238995
OsfCache.stop
train
public function stop(float $timeout = 0.0): self { if ($this->lastKey !== null) { $this->set($this->lastKey, ob_get_clean(), $timeout); } $this->lastKey = null; return $this; }
php
{ "resource": "" }
q238996
OsfCache.cleanAll
train
public function cleanAll(): int { $cpt = 0; $keys = $this->getRedis()->keys($this->namespace . ':*'); if ($keys) { foreach ($keys as $key) { $this->getRedis()->del($key); $cpt++; } } return $cpt; }
php
{ "resource": "" }
q238997
OsfCache.getZendStorage
train
public function getZendStorage(string $namespace = 'default') { static $storages = []; if (!isset($storages[$namespace])) { $rrm = new RedisResourceManager(); $rrm->setResource('default', $this->getRedis()); $rrm->setLibOption('default', Redis::OPT_SERIAL...
php
{ "resource": "" }
q238998
OsfCache.filterTtl
train
protected function filterTtl(&$ttl): void { if ($ttl !== null) { if ($ttl instanceof \DateInterval) { $ttl = (int) $ttl->format('%s'); } $ttl = (int) $ttl; } }
php
{ "resource": "" }
q238999
ServiceContainer.register
train
public function register($serviceClass): void { try { $class = new ReflectionClass($serviceClass); } catch(ReflectionException $e) { throw new RuntimeException('Service class not found', 0, $e); } if(!$class->implementsInterface(ServiceProvider::class)) { throw new InvalidArgumentExce...
php
{ "resource": "" }