_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| 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);
}
| php | {
"resource": ""
} |
q267701 | Reflection.setPropertiesValue | test | public static function setPropertiesValue($object, array $properties)
{
foreach ($properties as $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 {
$classAnnotations = $reader->getClassAnnotations($reflection);
foreach ($classAnnotations as $classAnnotation) {
| 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(); | php | {
"resource": ""
} |
q267704 | ReflectionHelper.isInstantiable | test | public static function isInstantiable($className)
{
$reflection = static::getClassReflection($className);
if ($reflection === null) {
| 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($objectOrName, $methodName); | 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);
| 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::getMethodReflection($objectOrName, $method);
} else {
return null;
}
if ($reflection->getNumberOfRequiredParameters() === 0) {
return $returnType === static::ARG_CHECK_RETURN_DATA ? [] : true;
}
$methodParams | php | {
"resource": ""
} |
q267708 | ReflectionHelper.getReflectionFromCache | test | protected static function getReflectionFromCache($type = self::REFLECTION_CLASS, $objectOrName, ...$params)
{
| 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;
}
| 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 {
| 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 ($object instanceof $class) {
$isMethod = substr($getter, -2) === '()';
if ($isMethod) {
| php | {
"resource": ""
} |
q267712 | ReflectionHelper.parseDocCommentSummary | test | protected static function parseDocCommentSummary($reflection)
{
$docLines = preg_split('~\R~u', $reflection->getDocComment());
if (isset($docLines[1])) {
| php | {
"resource": ""
} |
q267713 | ReflectionHelper.getClassDoc | test | protected static function getClassDoc($object, $parseMethod = 'parseDocCommentSummary')
{
try {
$reflection = new \ReflectionClass($object);
$docData = static::$parseMethod($reflection);
| 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 \ReflectionProperty) {
$reflection = $method;
//Method is string
} else {
//Check that object is not a \ReflectionClass
$object = $object instanceof \ReflectionClass ? $object->getName() : $object;
| php | {
"resource": ""
} |
q267715 | Db.initByConfig | test | public function initByConfig($key, $config)
{
if(empty($config))
{
throw new Exception('db config is empty');
}
$driver = | php | {
"resource": ""
} |
q267716 | FlashMessages._mapNameSpace | test | private function _mapNameSpace($foundationClass)
{
if (isset($this->_nsMap[$foundationClass])) {
| 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 amount of whitespace from following lines
| php | {
"resource": ""
} |
q267718 | PEAR_PackageFile_Parser_v2.postProcess | test | function postProcess($data, $element)
{
if ($element == 'notes') {
| 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;
| php | {
"resource": ""
} |
q267720 | Photo.fetchImages | test | private function fetchImages($photoId)
{
$query = array_merge(
$this->defaultQuery,
[
'method' => 'flickr.photos.getSizes',
| 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'], | php | {
"resource": ""
} |
q267722 | UrlManager.findPlaceholderStartPos | test | protected function findPlaceholderStartPos($path) {
$brFgPos = strpos($path, '{');
$brSqPos = strpos($path, '[');
if ($brFgPos === false && $brSqPos === false) {
return false;
}
$len = | php | {
"resource": ""
} |
q267723 | UrlManager.buildRoutePath | test | protected function buildRoutePath($path, &$params) {
$path = $this->replacePlaceholders($path, $params);
| 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_intersect($paramsKeys, $routeData['params']);
| 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) {
| php | {
"resource": ""
} |
q267726 | MessageSource.init | test | public function init()
{
parent::init();
if ($this->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]);
}
return $categoriesFind
->otherwise(function() { return []; })
->then(function($categories) use ($languages) {
$promises = [];
foreach ($categories as $category) {
foreach ($languages as $language) {
$key = $language . '/' . $category;
$promises[$key] = $this->loadMessages($category, $language);
}
| php | {
"resource": ""
} |
q267728 | MessageSource.findCategoriesByPattern | test | protected function findCategoriesByPattern($pattern)
{
return $this->findAllCategories()
->then(function($categories) use ($pattern) {
$matches = [];
foreach ($categories as $category) {
| 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)) {
| 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) {
header($name . ': ' . $value, false);
}
| 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 found.';
}
$content = '';
if ($this->displayErrors) {
try {
$exceptions = [
$exception,
];
$e = $exception;
while ($e = $e->getPrevious()) {
$exceptions[] = $e;
}
$count = \count($exceptions);
$total = $count;
/**
* @var int
* @var \Throwable $e
*/
foreach ($exceptions as $position => $e) {
$ind = $count - $position;
$class = $this->formatClass(\get_class($e));
$message = nl2br($this->escapeHtml($e->getMessage()));
$content .= sprintf(
<<<'EOF'
<h2 class="block_exception clear_fix">
<span class="exception_counter">%d/%d</span>
<span class="exception_title">%s%s:</span>
<span class="exception_message">%s</span>
</h2>
<div class="block">
<ol class="traces list_exception">
EOF
,
$ind,
$total,
$class,
$this->formatPath(
$e->getTrace()[0]['file'] ?? 'Unknown file',
$e->getTrace()[0]['line'] ?? 0
),
$message
);
foreach ($e->getTrace() as $trace) {
$traceClass = $trace['class'] ?? '';
$traceArgs = $trace['args'] ?? [];
$traceType = $trace['type'] ?? '';
$traceFunction = $trace['function'] ?? '';
$content .= ' <li>';
if ($trace['function']) {
$content .= sprintf(
| 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->escapeHtml($linkFormat),
| 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))
);
} elseif (\is_array($item)) {
$formattedValue = sprintf(
'<em>array</em>(%s)',
$this->formatArgs($item)
);
} elseif (\is_string($item)) {
$formattedValue = sprintf("'%s'", $this->escapeHtml($item));
} elseif (null === $item) {
$formattedValue = '<em>null</em>';
} elseif (\is_bool($item)) {
$formattedValue = '<em>'
. strtolower(var_export($item, true))
. '</em>';
} elseif (\is_resource($item)) {
| php | {
"resource": ""
} |
q267734 | ExceptionHandler.escapeHtml | test | protected function escapeHtml(string $str): string
{
return htmlspecialchars(
$str,
| php | {
"resource": ""
} |
q267735 | LaravelValidationService.with | test | public function with(array $data, array $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 | 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 activity listener for connection');
| 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());
| php | {
"resource": ""
} |
q267740 | Plugin.callbackGrimReaper | test | public function callbackGrimReaper(TimerInterface $caller)
{
$connection = $caller->getData();
$this->getLogger()->debug('CTCP PING timeout reached, | php | {
"resource": ""
} |
q267741 | CommandDispatcherFactory.getProxyCommandHandler | test | protected function getProxyCommandHandler(ServiceLocatorInterface $serviceLocator, string $key): object
{
$eventStore = $serviceLocator->getService(EventStoreInterface::class);
$eventPublisher = $serviceLocator->getService(EventPublisherInterface::class);
| 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();
| php | {
"resource": ""
} |
q267743 | ConfigLoader.loadBundles | test | final public function loadBundles()
{
$projectBundleConfig = [];
if (is_readable($this->getConfigDir() . '/bundles.yml')) {
$projectBundleConfig = Yaml::parse(
| 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;
}
if ( is_readable( $file ) ) {
$json = file_get_contents( $file );
if ( $json === false ) {
$this->logger->error( 'Error reading file', array(
'method' => __METHOD__,
'file' => $file,
) );
continue;
}
$data = json_decode( $json, true );
if | php | {
"resource": ""
} |
q267745 | Requester.setHttpHeaders | test | public function setHttpHeaders(array $inHttpHeaders, $inMerge=false) {
if ($inMerge) {
$this->__httpHeaders = | php | {
"resource": ""
} |
q267746 | Requester.setServerCgiEnvironmentVariables | test | public function setServerCgiEnvironmentVariables(array $inServerCgiEnvironmentVariables, $inMerge=false) {
if ($inMerge) {
$this->__serverCgiEnvironmentVariables = | 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('&', $bodyContent);
// Prepare the request's headers.
if (! array_key_exists('Content-Type', $this->__httpHeaders)) {
| 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';
}
if (! array_key_exists('Accept', $this->__httpHeaders)) {
$this->__httpHeaders['Accept'] = | 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 | php | {
"resource": ""
} |
q267750 | SqliteDriver.escape | test | static function escape($str = null, $double_quotes = false)
{
return sqlite_escape_string(
| php | {
"resource": ""
} |
q267751 | AssetBundle.init | test | public function init()
{
if ($this->sourcePath !== null) {
$this->sourcePath = rtrim(Reaction::$app->getAlias($this->sourcePath), '/\\');
}
if | php | {
"resource": ""
} |
q267752 | AbstractModel.hasSlugField | test | public function hasSlugField()
{
foreach($this->_table_structure as $_field=>$field_structure) {
| php | {
"resource": ""
} |
q267753 | AbstractModel.getSpecialFields | test | public function getSpecialFields($field, $value = true)
{
$fields = array();
foreach($this->_table_structure as $_field=>$field_structure) { | php | {
"resource": ""
} |
q267754 | AbstractModel.getFieldsByType | test | public function getFieldsByType($type)
{
$fields = array();
foreach($this->_table_structure as $_field=>$field_structure) { | 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;
}
// | 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;
}
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$match = $this->matchAccept(
$_SERVER['HTTP_ACCEPT_LANGUAGE'],
$supp
);
| 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)) {
| 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 = $this->sortAccept($_SERVER['HTTP_ACCEPT']);
foreach ($accepts as $type => $q) {
if (substr($type, -2) != '/*') {
if (isset($supp[$type])) {
return $supp[$type];
}
continue;
}
if ($type == '*/*') {
| 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];
}
| 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=', '', $option[1]);
} else {
$q = null;
// Assign default low weight for generic values
if ($l == '*/*') {
$q = 0.01;
} elseif (substr($l, -1) == '*') {
$q = 0.02;
| 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']
);
}
$port = isset($p['port']) ? $p['port'] : 80;
if (!$fp = @fsockopen($p['host'], $port, $eno, $estr, $timeout)) {
throw new HTTP2_Exception("Connection error: $estr ($eno)");
}
$path = !empty($p['path']) ? $p['path'] : '/';
$path .= !empty($p['query']) ? '?' . $p['query'] : '';
fputs($fp, "HEAD $path HTTP/1.0\r\n");
fputs($fp, 'Host: ' . $p['host'] . ':' . $port . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
| 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);
} | 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 = $_this->buildEntityManager($emname); | 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) {
| php | {
"resource": ""
} |
q267766 | AutoObjectMapper.getTableStructure | test | static function getTableStructure($tablename = null, $dbname = null)
{
$_tbl_obj = self::getAutoObject( $tablename, $dbname );
if (!empty($_tbl_obj)) {
| php | {
"resource": ""
} |
q267767 | AutoObjectMapper.getModel | test | static function getModel($tablename = null, $dbname = null)
{
$_tbl_obj = self::getAutoObject( $tablename, $dbname );
if (!empty($_tbl_obj)) {
| 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($tables_def);
if ($tables_def_file && @file_exists($tables_def_file) && @is_file($tables_def_file)) {
$table = array();
include $tables_def_file;
if (!empty($tables)) {
$tables_stacks=array();
foreach ($tables as $_tbl) {
$_t_n = $_tbl['table'];
$tables_stacks[$_t_n] = new \CarteBlanche\Library\AutoObject\AutoObject( $_t_n, $_tbl, $_t_n, $dbname );
$this->registry->setEntry(
$_tbl['table'],
$tables_stacks[$_t_n],
| php | {
"resource": ""
} |
q267769 | Length.prepareError | test | protected function prepareError($code)
{
$min = $this->getArgValue('min');
$max = $this->getArgValue('max');
$error = Translation::get($code);
| 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 | 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) {
//~ If not exist, create this budget month
//$dateNow = new \DateTimeImmutable();
$dateStart = new \DateTimeImmutable($budget->getDateStart());
$dateEnd = null;
if (!empty($budget->getDateEnd())) {
$dateEnd = new \DateTimeImmutable($budget->getDateEnd());
}
$isInRecurrence = $budget->isRecurrent() && $dateStart < $date && | php | {
"resource": ""
} |
q267772 | BudgetMonthMapper.findByBudgetId | test | public function findByBudgetId($budgetId, \DateTimeImmutable $date)
{
$this->addWhere('budget_id', $budgetId);
| php | {
"resource": ""
} |
q267773 | AccountAbstract.setIdParent | test | public function setIdParent($idParent)
{
$idParent = (int) $idParent;
if ($this->idParent < 0) {
throw new \UnderflowException('Value of "idParent" | php | {
"resource": ""
} |
q267774 | AccountAbstract.setIsMain | test | public function setIsMain($isMain)
{
$isMain = (bool) $isMain;
if ($this->exists() && $this->isMain !== $isMain) {
$this->updated['isMain'] | 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(
| 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(
| 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_CSV);
$transactionMapper = new TransactionMapper(Database::get('money'));
| 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':
$icon = 'arrow-circle-up';
break;
| 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 {
| 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);
| php | {
"resource": ""
} |
q267781 | NativeRedirectResponse.createRedirect | test | public static function createRedirect(
string $uri = null,
int $status = StatusCode::FOUND,
| 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 {
// Otherwise set the path to the current path w/ query string
$path = request()->getPath();
}
}
// If the path doesn't start with a /
| php | {
"resource": ""
} |
q267783 | NativeRedirectResponse.back | test | public function back(): RedirectResponse
{
$refererUri = request()->headers()->get('Referer');
// Ensure the route being redirected to is a | php | {
"resource": ""
} |
q267784 | NativeRedirectResponse.throw | test | public function throw(): void
{
throw new HttpRedirectException(
| 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());
$commandName = $parts[1] ?? null;
$commandNamespace = $commandName ? $parts[0] : 'global';
// If there was a namespace passed to the command (commands
// namespace) and the namespace for this command doesn't match
// what was passed then get rid of it so only commands in the
// namespace are shown.
if ($commandNamespace !== $namespace && null !== $namespace) {
unset($commands[$key]);
continue;
}
$longestLength = max(\strlen($command->getName()), $longestLength);
// If this is a global namespaced command
if ('global' === $commandNamespace) {
// Set it in the global commands array so when we show the | php | {
"resource": ""
} |
q267786 | CommandsListCommand.sortCommands | test | protected function sortCommands(array &$commands): void
{
usort(
$commands,
| 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) {
output()->formatter()->cyan();
| 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_set_cookie_params(
$currentCookieParams["lifetime"],
$currentCookieParams["path"],
'.'.$domainInfo->rootCanonicalDomain, //leading dot according to http://www.faqs.org/rfcs/rfc2109.html
| php | {
"resource": ""
} |
q267789 | Timer.start | test | public static function start($name = null)
{
if (null === $name) {
static::$time = -static::getTime();
} else { | 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 {
| 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 | php | {
"resource": ""
} |
q267792 | ProvidersAwareTrait.initializeProvided | test | public function initializeProvided(string $itemId): void
{
/** @var \Valkyrja\Support\Providers\Provides $provider | php | {
"resource": ""
} |
q267793 | Reaction.init | test | public static function init(Composer\Autoload\ClassLoader $composer = null, $configsPath = null, $appType = | 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 = static::locateConfigsPath();
| php | {
"resource": ""
} |
q267795 | Reaction.locateConfigsPath | test | protected static function locateConfigsPath()
{
$cwd = getcwd();
$defaultDir = DIRECTORY_SEPARATOR . 'Config';
$path = $cwd . $defaultDir;
| php | {
"resource": ""
} |
q267796 | Reaction.locateClassLoader | test | protected static function locateClassLoader()
{
$cwd = getcwd();
$path = $cwd . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
| 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->getOrCreate($class, $params, $type);
} elseif (is_callable($type, true)) {
return static::$di->invoke($type, $params);
| php | {
"resource": ""
} |
q267798 | Reaction.getConfigReader | test | protected static function getConfigReader($flush = false)
{
if ($flush || !isset(static::$config)) {
$conf = [
'path' => static::$configsPath,
'appType' => static::$appType,
| php | {
"resource": ""
} |
q267799 | Reaction.initContainer | test | protected static function initContainer()
{
$config = static::getConfigReader()->get('container');
Container::setDefaultContainer(new | php | {
"resource": ""
} |