_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q267700
Reflection.setPropertyValue
test
public static function setPropertyValue($object, $property, $value) { $ref = self::loadClassReflection($object); $refProperty = $ref->getProperty($property); if (!$refProperty->isPublic()) { $refProperty->setAccessible(true); } if ($refProperty->isStatic()) { ...
php
{ "resource": "" }
q267701
Reflection.setPropertiesValue
test
public static function setPropertiesValue($object, array $properties) { foreach ($properties as $name => $value) { self::setPropertyValue($object, $name, $value); } }
php
{ "resource": "" }
q267702
Reflection.loadClassAnnotations
test
public static function loadClassAnnotations(Reader $reader, $class, $inParents = false) { $reflection = self::loadClassReflection($class); if (!$inParents) { return $reader->getClassAnnotations($reflection); } $annotations = []; do { $classAnnotatio...
php
{ "resource": "" }
q267703
Reflection.clear
test
public static function clear($mode = null) { if (is_numeric($mode)) { $mode = self::TYPE_CLASS | self::TYPE_OBJECT; } if ($mode & self::TYPE_CLASS) { self::$classReflections = array(); } if ($mode & self::TYPE_OBJECT) { self::$objectRefle...
php
{ "resource": "" }
q267704
ReflectionHelper.isInstantiable
test
public static function isInstantiable($className) { $reflection = static::getClassReflection($className); if ($reflection === null) { return false; } return $reflection->isInstantiable(); }
php
{ "resource": "" }
q267705
ReflectionHelper.getMethodReflection
test
public static function getMethodReflection($objectOrName, $methodName) { $cached = static::getReflectionFromCache(static::REFLECTION_METHOD, $objectOrName, $methodName); if ($cached !== null) { return $cached; } try { $reflection = new \ReflectionMethod($objec...
php
{ "resource": "" }
q267706
ReflectionHelper.getClassReflection
test
public static function getClassReflection($objectOrName) { $cached = static::getReflectionFromCache(static::REFLECTION_CLASS, $objectOrName); if ($cached !== null) { return $cached; } try { $reflection = new \ReflectionClass($objectOrName); return ...
php
{ "resource": "" }
q267707
ReflectionHelper.checkMethodArguments
test
public static function checkMethodArguments($arguments = [], $method, $objectOrName = null, $returnType = self::ARG_CHECK_RETURN_DATA) { if ($method instanceof \ReflectionMethod) { $reflection = $method; } elseif ($objectOrName !== null) { $reflection = static::getMethodRefle...
php
{ "resource": "" }
q267708
ReflectionHelper.getReflectionFromCache
test
protected static function getReflectionFromCache($type = self::REFLECTION_CLASS, $objectOrName, ...$params) { $cache = &static::$_reflections[$type]; $key = static::getCacheKey($type, $objectOrName, ...$params); return isset($cache[$key]) ? $cache[$key] : null; }
php
{ "resource": "" }
q267709
ReflectionHelper.setReflectionToCache
test
protected static function setReflectionToCache($reflection, $type = self::REFLECTION_CLASS, $objectOrName = null, ...$params) { if (null === $reflection || null === $objectOrName) { return null; } $key = static::getCacheKey($type, $objectOrName, ...$params); static::$_ref...
php
{ "resource": "" }
q267710
ReflectionHelper.getCacheKey
test
protected static function getCacheKey($type = self::REFLECTION_CLASS, $objectOrName, ...$params) { if (is_object($objectOrName)) { $className = static::getObjectClassName($objectOrName); } else { $className = $objectOrName; } $key = $className; switch ...
php
{ "resource": "" }
q267711
ReflectionHelper.getObjectClassName
test
protected static function getObjectClassName($object) { $nameGetters = [ \ReflectionClass::class => 'getName()', \ReflectionMethod::class => 'class', \ReflectionProperty::class => 'class', ]; foreach ($nameGetters as $class => $getter) { if ($o...
php
{ "resource": "" }
q267712
ReflectionHelper.parseDocCommentSummary
test
protected static function parseDocCommentSummary($reflection) { $docLines = preg_split('~\R~u', $reflection->getDocComment()); if (isset($docLines[1])) { return trim($docLines[1], "\t *"); } return ''; }
php
{ "resource": "" }
q267713
ReflectionHelper.getClassDoc
test
protected static function getClassDoc($object, $parseMethod = 'parseDocCommentSummary') { try { $reflection = new \ReflectionClass($object); $docData = static::$parseMethod($reflection); } catch (\ReflectionException $exception) { $docData = null; } ...
php
{ "resource": "" }
q267714
ReflectionHelper.getMethodPropertyDoc
test
protected static function getMethodPropertyDoc($method, $object = null, $type = self::REFLECTION_METHOD, $parseMethod = self::DOC_COMMENT_SHORT) { try { //Method is already a \ReflectionMethod|\ReflectionProperty if ($method instanceof \ReflectionMethod || $method instanceof \Reflect...
php
{ "resource": "" }
q267715
Db.initByConfig
test
public function initByConfig($key, $config) { if(empty($config)) { throw new Exception('db config is empty'); } $driver = 'Li\\'.ucfirst($config['driver']); if(!(isset($this->$key) && $this->$key instanceof $driver)) { $this->$key = new $driv...
php
{ "resource": "" }
q267716
FlashMessages._mapNameSpace
test
private function _mapNameSpace($foundationClass) { if (isset($this->_nsMap[$foundationClass])) { return $this->_nsMap[$foundationClass]; } return reset($this->_nsMap); }
php
{ "resource": "" }
q267717
PEAR_PackageFile_Parser_v2._unIndent
test
function _unIndent($str) { // remove leading newlines $str = preg_replace('/^[\r\n]+/', '', $str); // find whitespace at the beginning of the first line $indent_len = strspn($str, " \t"); $indent = substr($str, 0, $indent_len); $data = ''; // remove the same a...
php
{ "resource": "" }
q267718
PEAR_PackageFile_Parser_v2.postProcess
test
function postProcess($data, $element) { if ($element == 'notes') { return trim($this->_unIndent($data)); } return trim($data); }
php
{ "resource": "" }
q267719
Photo.extractPhotoArray
test
private function extractPhotoArray($source) { if ($source->stat == 'fail') { return; } $data = &$source->photo; $photo = []; $photo['id'] = $data->id; $photo['title'] = $data->title->_content; $photo[...
php
{ "resource": "" }
q267720
Photo.fetchImages
test
private function fetchImages($photoId) { $query = array_merge( $this->defaultQuery, [ 'method' => 'flickr.photos.getSizes', 'photo_id' => $photoId, ] ); $body = $this->newRequest() ->setQuery($query) ...
php
{ "resource": "" }
q267721
Photo.extractImagesArray
test
private function extractImagesArray($source) { $sizes = array_get($source, 'sizes.size'); $images = array_where($sizes, function ($key, $value) { return in_array($value['label'], ['Original', 'Small 320']); }); return array_fetch($images, 'source'); }
php
{ "resource": "" }
q267722
UrlManager.findPlaceholderStartPos
test
protected function findPlaceholderStartPos($path) { $brFgPos = strpos($path, '{'); $brSqPos = strpos($path, '['); if ($brFgPos === false && $brSqPos === false) { return false; } $len = strlen($path); $positions = [ $brFgPos !== false ? $brFgPos : $...
php
{ "resource": "" }
q267723
UrlManager.buildRoutePath
test
protected function buildRoutePath($path, &$params) { $path = $this->replacePlaceholders($path, $params); $path = $this->searchInRouter($path, $params); return $path; }
php
{ "resource": "" }
q267724
UrlManager.searchInRouter
test
protected function searchInRouter($path, &$params) { if (isset(\Reaction::$app->router->routePaths[$path])) { $paramsKeys = array_keys($params); $routes = \Reaction::$app->router->routePaths[$path]; foreach ($routes as $routeData) { $intersect = array_intersec...
php
{ "resource": "" }
q267725
UrlManager.replacePlaceholders
test
protected function replacePlaceholders($path, &$params) { if (strpos($path, '{') === false) { return $path; } $path = preg_replace_callback('/(\{([a-zA-Z0-9]+)\})/i', function($matches) use (&$params) { $match = $matches[1]; $key = $matches[2]; if ...
php
{ "resource": "" }
q267726
MessageSource.init
test
public function init() { parent::init(); if ($this->sourceLanguage === null) { $this->sourceLanguage = Reaction::$app->sourceLanguage; } }
php
{ "resource": "" }
q267727
MessageSource.preloadMessages
test
public function preloadMessages($category, $languages = []) { if ($category === '*') { $categoriesFind = $this->findAllCategories(); } else { $categoriesFind = strpos($category, '*') > 0 ? $this->findCategoriesByPattern($category) : resolve([$category]); } ret...
php
{ "resource": "" }
q267728
MessageSource.findCategoriesByPattern
test
protected function findCategoriesByPattern($pattern) { return $this->findAllCategories() ->then(function($categories) use ($pattern) { $matches = []; foreach ($categories as $category) { if (Reaction\Helpers\StringHelper::matchWildcard($pattern...
php
{ "resource": "" }
q267729
Model.__isset
test
public function __isset(string $name): bool { $methodName = str_replace('_', '', ucwords($name, '_')); $methodName = 'isset' . $methodName; if (method_exists($this, $methodName)) { return $this->$methodName(); } return property_exists($this, $name); }
php
{ "resource": "" }
q267730
ExceptionHandler.sendExceptionResponse
test
public function sendExceptionResponse($exception): void { if (! headers_sent()) { if ($exception instanceof HttpException) { header(sprintf('HTTP/1.0 %s', $exception->getStatusCode())); foreach ($exception->getHeaders() as $name => $value) { h...
php
{ "resource": "" }
q267731
ExceptionHandler.getContent
test
public function getContent(Throwable $exception): string { $title = 'Whoops, looks like something went wrong.'; if ( $exception instanceof HttpException && $exception->getStatusCode() === 404 ) { $title = 'Sorry, the page you are looking for could not be ...
php
{ "resource": "" }
q267732
ExceptionHandler.formatPath
test
protected function formatPath(string $path, int $line): string { $path = $this->escapeHtml($path); $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path; if ($linkFormat = $this->fileLinkFormat) { $link = strtr( $this->escape...
php
{ "resource": "" }
q267733
ExceptionHandler.formatArgs
test
protected function formatArgs(array $args): string { $result = []; foreach ($args as $key => $item) { if (\is_object($item)) { $formattedValue = sprintf( '<em>object</em>(%s)', $this->formatClass(\get_class($item)) ...
php
{ "resource": "" }
q267734
ExceptionHandler.escapeHtml
test
protected function escapeHtml(string $str): string { return htmlspecialchars( $str, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset ); }
php
{ "resource": "" }
q267735
LaravelValidationService.with
test
public function with(array $data, array $rules) { $this->validator = $this->factory->make($data, $rules); }
php
{ "resource": "" }
q267736
InputParser.transforms
test
public function transforms($string) { if (!is_string($string)) { throw new InvalidArgumentException('A string is required'); } if (false == preg_match('#^[a-zA-Z0-9]+$#', $string)) { throw new InvalidArgumentException('A valid string is required'); } $...
php
{ "resource": "" }
q267737
Plugin.handleDisconnect
test
public function handleDisconnect(ConnectionInterface $connection, LoggerInterface $logger) { $timers = $this->getTimers(); if ($timers->contains($connection)) { $this->getLogger()->debug('Detaching activity listener for disconnected connection'); $timers->offsetGet($connectio...
php
{ "resource": "" }
q267738
Plugin.handleReceived
test
public function handleReceived(Event $event, Queue $queue) { $connection = $event->getConnection(); $timers = $this->getTimers(); if ($timers->contains($connection)) { $timers->offsetGet($connection)->cancel(); } else { $this->getLogger()->debug('Attaching act...
php
{ "resource": "" }
q267739
Plugin.callbackPhoneHome
test
public function callbackPhoneHome(TimerInterface $caller) { $connection = $caller->getData(); $this->getLogger()->debug('Inactivity period reached, sending CTCP PING'); $this->getEventQueueFactory()->getEventQueue($connection)->ctcpPing($connection->getNickname(), time()); $timer =...
php
{ "resource": "" }
q267740
Plugin.callbackGrimReaper
test
public function callbackGrimReaper(TimerInterface $caller) { $connection = $caller->getData(); $this->getLogger()->debug('CTCP PING timeout reached, closing connection'); $this->getEventQueueFactory()->getEventQueue($connection)->ircQuit(); }
php
{ "resource": "" }
q267741
CommandDispatcherFactory.getProxyCommandHandler
test
protected function getProxyCommandHandler(ServiceLocatorInterface $serviceLocator, string $key): object { $eventStore = $serviceLocator->getService(EventStoreInterface::class); $eventPublisher = $serviceLocator->getService(EventPublisherInterface::class); $aggregate = $serviceLocator->getSer...
php
{ "resource": "" }
q267742
Dev.cb_configAction
test
public function cb_configAction() { $config = $this->getContainer()->get('config')->dump(); $reflection_cb = new \ReflectionClass('\CarteBlanche\App\Kernel'); $constants = $reflection_cb->getConstants(); $mode_data = \CarteBlanche\CarteBlanche::getKernelMode(true); return ar...
php
{ "resource": "" }
q267743
ConfigLoader.loadBundles
test
final public function loadBundles() { $projectBundleConfig = []; if (is_readable($this->getConfigDir() . '/bundles.yml')) { $projectBundleConfig = Yaml::parse( file_get_contents($this->getConfigDir() . '/bundles.yml') ); return $projectBundleConfi...
php
{ "resource": "" }
q267744
JsonCache.loadMessages
test
protected function loadMessages() { if ( $this->messages === null ) { $this->messages = array(); foreach ( glob( "{$this->messageDirectory}/*.json" ) as $file ) { $lang = strtolower( substr( basename( $file ), 0, -5 ) ); if ( $lang === 'qqq' ) { // Ignore message documentation continue; } ...
php
{ "resource": "" }
q267745
Requester.setHttpHeaders
test
public function setHttpHeaders(array $inHttpHeaders, $inMerge=false) { if ($inMerge) { $this->__httpHeaders = array_merge($this->__httpHeaders, $inHttpHeaders); } else { $this->__httpHeaders = $inHttpHeaders; } return $this; }
php
{ "resource": "" }
q267746
Requester.setServerCgiEnvironmentVariables
test
public function setServerCgiEnvironmentVariables(array $inServerCgiEnvironmentVariables, $inMerge=false) { if ($inMerge) { $this->__serverCgiEnvironmentVariables = array_merge($this->__serverCgiEnvironmentVariables, $inServerCgiEnvironmentVariables); } else { $this->__serverCgiEn...
php
{ "resource": "" }
q267747
Requester.post
test
public function post($inRequestUri, $inPostParameters=[]) { // Prepare the content of the request's body. $bodyContent = []; foreach ($inPostParameters as $_name => $_value) { $bodyContent[] = $_name . '=' . urlencode($_value); } $bodyContent = implode('&', $bodyCont...
php
{ "resource": "" }
q267748
Requester.jsonRpc
test
public function jsonRpc($inRequestUri, $inParameters=[]) { $bodyContent = json_encode($inParameters); // Prepare the request's headers. if (! array_key_exists('Content-Type', $this->__httpHeaders)) { $this->__httpHeaders['Content-Type'] = 'application/jsonrequest'; } ...
php
{ "resource": "" }
q267749
SqliteDriver.connect
test
public function connect() { /* $this->db = new \SQLiteDatabase( $this->db_name, isset($this->db_options['chmod']) ? $this->db_options['chmod'] : 0644, $err ); if ($err) throw new ErrorException( sprintf('Can not connect or create SQLite databas...
php
{ "resource": "" }
q267750
SqliteDriver.escape
test
static function escape($str = null, $double_quotes = false) { return sqlite_escape_string( true===$double_quotes ? str_replace('"', '""', $str) : $str ); }
php
{ "resource": "" }
q267751
AssetBundle.init
test
public function init() { if ($this->sourcePath !== null) { $this->sourcePath = rtrim(Reaction::$app->getAlias($this->sourcePath), '/\\'); } if ($this->basePath !== null) { $this->basePath = rtrim(Reaction::$app->getAlias($this->basePath), '/\\'); } if ...
php
{ "resource": "" }
q267752
AbstractModel.hasSlugField
test
public function hasSlugField() { foreach($this->_table_structure as $_field=>$field_structure) { if (isset($field_structure['slug']) && $field_structure['slug']===true) { return true; } } return false; }
php
{ "resource": "" }
q267753
AbstractModel.getSpecialFields
test
public function getSpecialFields($field, $value = true) { $fields = array(); foreach($this->_table_structure as $_field=>$field_structure) { if (isset($field_structure[$field]) && $field_structure[$field]===$value) { $fields[] = $_field; } } re...
php
{ "resource": "" }
q267754
AbstractModel.getFieldsByType
test
public function getFieldsByType($type) { $fields = array(); foreach($this->_table_structure as $_field=>$field_structure) { if (isset($field_structure['type']) && $field_structure['type']==$type) { $fields[] = $_field; } } return $fields; }
php
{ "resource": "" }
q267755
HTTP2.date
test
public function date($time = null) { if (!isset($time)) { $time = time(); } elseif (!is_numeric($time) && (-1 === $time = strtotime($time))) { return false; } // RFC822 or RFC850 $format = ini_get('y2k_compliance') ? 'D, d M Y' : 'l, d-M-y'; ...
php
{ "resource": "" }
q267756
HTTP2.negotiateLanguage
test
public function negotiateLanguage($supported, $default = 'en-US') { $supp = array(); foreach ($supported as $lang => $isSupported) { if ($isSupported) { $supp[strtolower($lang)] = $lang; } } if (!count($supp)) { return $default; ...
php
{ "resource": "" }
q267757
HTTP2.negotiateCharset
test
public function negotiateCharset($supported, $default = 'ISO-8859-1') { $supp = array(); foreach ($supported as $charset) { $supp[strtolower($charset)] = $charset; } if (!count($supp)) { return $default; } if (isset($_SERVER['HTTP_ACCEPT_CHAR...
php
{ "resource": "" }
q267758
HTTP2.negotiateMimeType
test
public function negotiateMimeType($supported, $default) { $supp = array(); foreach ($supported as $type) { $supp[strtolower($type)] = $type; } if (!count($supp)) { return $default; } if (isset($_SERVER['HTTP_ACCEPT'])) { $accepts ...
php
{ "resource": "" }
q267759
HTTP2.matchAccept
test
protected function matchAccept($header, $supported) { $matches = $this->sortAccept($header); foreach ($matches as $key => $q) { if (isset($supported[$key])) { return $supported[$key]; } } // If any (i.e. "*") is acceptable, return the first sup...
php
{ "resource": "" }
q267760
HTTP2.sortAccept
test
protected function sortAccept($header) { $matches = array(); foreach (explode(',', $header) as $option) { $option = array_map('trim', explode(';', $option)); $l = strtolower($option[0]); if (isset($option[1])) { $q = (float) str_replace('q=', '', ...
php
{ "resource": "" }
q267761
HTTP2.head
test
public function head($url, $timeout = 10) { $p = parse_url($url); if (!isset($p['scheme'])) { $p = parse_url($this->absoluteURI($url)); } elseif ($p['scheme'] != 'http') { throw new InvalidArgumentException( 'Unsupported protocol: '. $p['scheme'] ...
php
{ "resource": "" }
q267762
HTTP2.convertCharset
test
protected function convertCharset($from, $to, $str) { if (function_exists('mb_convert_encoding')) { return mb_convert_encoding($str, $to, $from); } else if (function_exists('iconv')) { return iconv($from, $to, $str); } return $str; }
php
{ "resource": "" }
q267763
AutoObjectMapper.getEntityManager
test
static function getEntityManager($emname) { $_this = self::getInstance(); $emname = $_this->buildEntityName($emname); $known_manager = $_this->registry->getEntry($emname, 'entityManager'); if ($known_manager) { return $known_manager; } else { // $manager = ...
php
{ "resource": "" }
q267764
AutoObjectMapper.getObjectsStructure
test
static function getObjectsStructure($dbname = null) { $_this = self::getInstance(); $dbname = $_this->buildEntityName($dbname); $known_structure = $_this->registry->getEntry($dbname, 'objectStructure'); if ($known_structure) { return $known_structure; } else { ...
php
{ "resource": "" }
q267765
AutoObjectMapper.getAutoObject
test
static function getAutoObject($tablename = null, $dbname = null) { if (empty($tablename)) return false; $tables = self::getObjectsStructure( $dbname ); if ($tables) { foreach ($tables as $_tbl_name=>$_tbl_obj) { if ($_tbl_obj->getTableName()==$tablename) { ...
php
{ "resource": "" }
q267766
AutoObjectMapper.getTableStructure
test
static function getTableStructure($tablename = null, $dbname = null) { $_tbl_obj = self::getAutoObject( $tablename, $dbname ); if (!empty($_tbl_obj)) { return $_tbl_obj->getStructureEntry('structure'); } return false; }
php
{ "resource": "" }
q267767
AutoObjectMapper.getModel
test
static function getModel($tablename = null, $dbname = null) { $_tbl_obj = self::getAutoObject( $tablename, $dbname ); if (!empty($_tbl_obj)) { return $_tbl_obj->getModel(); } return false; }
php
{ "resource": "" }
q267768
AutoObjectMapper.buildObjectsStructure
test
protected function buildObjectsStructure($dbname = null) { $dbname = str_replace(array(CarteBlanche::getPath('root_path'), CarteBlanche::getPath('config_dir')), '', $dbname); $tables_def = CarteBlanche::getConfig($dbname.'_database.db_structure'); $tables_def_file = Locator::locateConfig($ta...
php
{ "resource": "" }
q267769
Length.prepareError
test
protected function prepareError($code) { $min = $this->getArgValue('min'); $max = $this->getArgValue('max'); $error = Translation::get($code); $error = str_replace('%min%', $min, $error); $error = str_replace('%max%', $max, $error); return $error; }
php
{ "resource": "" }
q267770
BudgetMonthMapper.check
test
public function check($budgets, \DateTimeImmutable $date) { foreach ($budgets as $budget) { $this->checkBudget($budget, $date); if ($budget->hasChildren()) { foreach ($budget->getChildren() as $child) { $this->checkBudget($child, $date); ...
php
{ "resource": "" }
q267771
BudgetMonthMapper.checkBudget
test
protected function checkBudget(Budget $budget, \DateTimeImmutable $date) { try { $this->addWhere('budget_id', $budget->getId()); $this->addWhere('budget_month_date', $date->format('Y-m-d')); $this->selectOne(); } catch (ExceptionNoData $exception) { ...
php
{ "resource": "" }
q267772
BudgetMonthMapper.findByBudgetId
test
public function findByBudgetId($budgetId, \DateTimeImmutable $date) { $this->addWhere('budget_id', $budgetId); $this->addWhere('budget_month_date', $date->format('Y-m-d')); $result = $this->selectOne(); return $result; }
php
{ "resource": "" }
q267773
AccountAbstract.setIdParent
test
public function setIdParent($idParent) { $idParent = (int) $idParent; if ($this->idParent < 0) { throw new \UnderflowException('Value of "idParent" must be greater than 0'); } if ($this->exists() && $this->idParent !== $idParent) { $this->updated['idParent'...
php
{ "resource": "" }
q267774
AccountAbstract.setIsMain
test
public function setIsMain($isMain) { $isMain = (bool) $isMain; if ($this->exists() && $this->isMain !== $isMain) { $this->updated['isMain'] = true; } $this->isMain = $isMain; return $this; }
php
{ "resource": "" }
q267775
AccountAbstract.getAccountUser
test
public function getAccountUser($isForceReload = false) { if ($isForceReload || null === $this->joinOneCacheAccountUser) { $mapper = new AccountUserMapper($this->dependencyContainer->getDatabase('money')); $this->joinOneCacheAccountUser = $mapper->findByKeys(array( 'ac...
php
{ "resource": "" }
q267776
AccountAbstract.getBank
test
public function getBank($isForceReload = false) { if ($isForceReload || null === $this->joinOneCacheBank) { $mapper = new BankMapper($this->dependencyContainer->getDatabase('money')); $this->joinOneCacheBank = $mapper->findByKeys(array( 'bank_id' => $this->getBankId()...
php
{ "resource": "" }
q267777
ParserAbstract.parse
test
public function parse(Account $account, $file) { $file = new \SplFileObject($file); $file->setCsvControl($this->csvDelimiter, $this->csvEnclosure, $this->csvEscape); $file->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY | \SplFileObject::READ...
php
{ "resource": "" }
q267778
Transaction.getTypeIcon
test
public function getTypeIcon() { switch ($this->getType()) { case 'CB': $icon = 'credit-card'; break; case 'VIR': $icon = 'arrow-circle-o-' . ($this->isNegativeAmount() ? 'up' : 'down'); break; case 'PRE': ...
php
{ "resource": "" }
q267779
MysqlDBAdapter.buildQuery
test
public function buildQuery(QC $qc, $type = null) { if (!$type) $type = $qc->getType(); $methodName = 'build' . ucfirst($type); if (method_exists($this, $methodName)) { $result = $this->$methodName($qc); } else { throw new MysqlDBAdapterException('Invalid method s...
php
{ "resource": "" }
q267780
MysqlDBAdapter.escapeOne
test
protected function escapeOne($value, $type = false) { if ($type === false) { $type = gettype($value); } if (strpos($value, '#sql#') !== false) { return substr($value, 5); } if (in_array($type, array('integer'))) { return $value; } elsei...
php
{ "resource": "" }
q267781
NativeRedirectResponse.createRedirect
test
public static function createRedirect( string $uri = null, int $status = StatusCode::FOUND, array $headers = [] ): RedirectResponse { return new static('', $status, $headers, $uri); }
php
{ "resource": "" }
q267782
NativeRedirectResponse.secure
test
public function secure(string $path = null): RedirectResponse { // If not path was set if (null === $path) { // If the uri is already set if (null !== $this->uri) { // Set the path to it $path = $this->uri; } else { ...
php
{ "resource": "" }
q267783
NativeRedirectResponse.back
test
public function back(): RedirectResponse { $refererUri = request()->headers()->get('Referer'); // Ensure the route being redirected to is a valid internal route if (! router()->isInternalUri($refererUri)) { // If not set as the index $refererUri = '/'; } ...
php
{ "resource": "" }
q267784
NativeRedirectResponse.throw
test
public function throw(): void { throw new HttpRedirectException( $this->statusCode, $this->uri, null, $this->headers->all() ); }
php
{ "resource": "" }
q267785
CommandsListCommand.filterCommands
test
protected function filterCommands(array &$commands, int &$longestLength, string $namespace = null): void { $globalCommands = []; /** @var \Valkyrja\Console\Command $command */ foreach ($commands as $key => $command) { $parts = explode(':', $command->getName()); ...
php
{ "resource": "" }
q267786
CommandsListCommand.sortCommands
test
protected function sortCommands(array &$commands): void { usort( $commands, function (Command $item1, Command $item2) { return $item1->getName() <=> $item2->getName(); } ); }
php
{ "resource": "" }
q267787
CommandsListCommand.commandSection
test
protected function commandSection(Command $command, string &$previousSection): void { $parts = explode(':', $command->getName()); $commandName = $parts[1] ?? null; $currentSection = $commandName ? $parts[0] : 'global'; if ($previousSection !== $currentSection) { ...
php
{ "resource": "" }
q267788
Session.initSession
test
function initSession() { static $initSessionCalled = false; if($initSessionCalled == true){ return; } $initSessionCalled = true; $currentCookieParams = session_get_cookie_params(); $domainInfo = $this->domain->getDomainInfo(); session_s...
php
{ "resource": "" }
q267789
Timer.start
test
public static function start($name = null) { if (null === $name) { static::$time = -static::getTime(); } else { static::$times[$name] = -static::getTime(); } }
php
{ "resource": "" }
q267790
Timer.get
test
public static function get($name = null) { if (null === $name) { $time = static::$time; } elseif (isset(static::$times[$name])) { $time = static::$times[$name]; } else { throw new \LogicException('Timer with given name does not exist!'); } ...
php
{ "resource": "" }
q267791
Timer.display
test
public static function display($name = null, $round = 3) { $time = round(static::get($name), $round); $name = ($name === null ? 'GLOBAL' : $name); if (PHP_SAPI !== 'cli') { echo ' <div style="background-color: #99CCCC"> <strong>Timer[' . $name . ']: </strong> ' . $time . ' s...
php
{ "resource": "" }
q267792
ProvidersAwareTrait.initializeProvided
test
public function initializeProvided(string $itemId): void { /** @var \Valkyrja\Support\Providers\Provides $provider */ $provider = self::$provided[$itemId]; // Register the provider $this->register($provider, true); }
php
{ "resource": "" }
q267793
Reaction.init
test
public static function init(Composer\Autoload\ClassLoader $composer = null, $configsPath = null, $appType = StaticApplicationInterface::APP_TYPE_WEB) { static::initBasic($composer, $configsPath, $appType); static::initStaticApp(); }
php
{ "resource": "" }
q267794
Reaction.initBasic
test
public static function initBasic(Composer\Autoload\ClassLoader $composer = null, $configsPath = null, $appType = StaticApplicationInterface::APP_TYPE_WEB) { if (!isset($composer)) { $composer = static::locateClassLoader(); } if (!isset($configsPath)) { $configsPath = ...
php
{ "resource": "" }
q267795
Reaction.locateConfigsPath
test
protected static function locateConfigsPath() { $cwd = getcwd(); $defaultDir = DIRECTORY_SEPARATOR . 'Config'; $path = $cwd . $defaultDir; if (!file_exists($path) || !is_dir($path)) { return null; } return $path; }
php
{ "resource": "" }
q267796
Reaction.locateClassLoader
test
protected static function locateClassLoader() { $cwd = getcwd(); $path = $cwd . DIRECTORY_SEPARATOR . 'vendor/autoload.php'; if (!file_exists($path) || !is_file($path)) { return null; } return include $path; }
php
{ "resource": "" }
q267797
Reaction.create
test
public static function create($type, array $params = []) { if (is_string($type)) { return static::$di->getOrCreate($type, $params); } elseif (is_array($type) && isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$di...
php
{ "resource": "" }
q267798
Reaction.getConfigReader
test
protected static function getConfigReader($flush = false) { if ($flush || !isset(static::$config)) { $conf = [ 'path' => static::$configsPath, 'appType' => static::$appType, ]; static::$config = new \Reaction\Base\ConfigReader($conf); ...
php
{ "resource": "" }
q267799
Reaction.initContainer
test
protected static function initContainer() { $config = static::getConfigReader()->get('container'); Container::setDefaultContainer(new Container($config)); static::$di = Container::getDefaultContainer(); }
php
{ "resource": "" }