_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q267800
|
Reaction.initStaticApp
|
test
|
public static function initStaticApp()
{
$config = static::getConfigReader()->get('appStatic');
$config['class'] = StaticApplicationInterface::class;
//Use config after creation, so Reaction::$app will be available inside StaticApplicationInterface components
$appLateConfig = [];
$appLateConfigKeys = ['components'];
foreach ($appLateConfigKeys as $appKey) {
if (isset($config[$appKey])) {
$appLateConfig[$appKey] = $config[$appKey];
unset($config[$appKey]);
|
php
|
{
"resource": ""
}
|
q267801
|
CSRFGuard.tokensMatch
|
test
|
protected function tokensMatch(Request $request)
{
$token = $this->getTokenFromRequest($request);
$storedToken = $this->getToken();
|
php
|
{
"resource": ""
}
|
q267802
|
CSRFGuard.getTokenFromRequest
|
test
|
protected function getTokenFromRequest(Request $request)
{
$token
|
php
|
{
"resource": ""
}
|
q267803
|
DarkSkyPlugin.init
|
test
|
public function init()
{
$config = $this->getConfig();
if (!isset($config['api_key'])) {
throw new \Exception('Unable to locate darksky_api_key in bot configuration.');
}
$this->darksky = new \DarkSky($config['api_key']);
$plugin = $this; // PHP 5.3, you suck.
// Look at all this weather!
$this->bot->onChannel('/^!ds (\w+)(.*)/', function(Event $event) use ($plugin) {
|
php
|
{
"resource": ""
}
|
q267804
|
DarkSkyPlugin.getCurrentWeather
|
test
|
public function getCurrentWeather($where, $event)
{
if (!$found = $this->getLatLongForLocation($where)) {
$this->addLatLongError($event);
return;
}
try {
list($lat, $long) = $found;
$forecast = $this->darksky->getBriefForecast($lat, $long);
$event->addResponse(
Response::msg(
|
php
|
{
"resource": ""
}
|
q267805
|
DarkSkyPlugin.getPrecipitation
|
test
|
public function getPrecipitation($match, $event)
{
$location = explode('@', $match);
$where = trim($location[0]);
$when = trim($location[1]);
if (!$found = $this->getLatLongForLocation($where)) {
$this->addLatLongError($event);
return;
}
try {
$time = new \DateTime($when);
list($lat, $long) = $found;
$precipitation = $this->darksky->getPrecipitation(array(
'lat' => $lat,
'long' => $long,
'time' => $time->getTimestamp()
|
php
|
{
"resource": ""
}
|
q267806
|
DarkSkyPlugin.getLatLongForLocation
|
test
|
public function getLatLongForLocation($location)
{
$encoded = urlencode($location);
$response = json_decode(
file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=$encoded"),
true
);
if ($response['status'] === 'OK') {
|
php
|
{
"resource": ""
}
|
q267807
|
DarkSkyPlugin.addErrorMsg
|
test
|
public function addErrorMsg($event, $msg)
{
|
php
|
{
"resource": ""
}
|
q267808
|
DarkSkyPlugin.getEnglishIntensity
|
test
|
private function getEnglishIntensity($intensity)
{
$desc = 'no';
if ($intensity >= 2 && $intensity < 15) {
$desc = 'sporadic';
} else if ($intensity >= 15 && $intensity < 30) {
$desc = 'light';
} else if ($intensity >= 30
|
php
|
{
"resource": ""
}
|
q267809
|
NativeAnnotations.classAnnotations
|
test
|
public function classAnnotations(string $class): array
{
$index = static::CLASS_CACHE . $class;
return self::$annotations[$index]
?? self::$annotations[$index] = $this->setAnnotationValues(
[
'class' => $class,
],
|
php
|
{
"resource": ""
}
|
q267810
|
NativeAnnotations.classMembersAnnotations
|
test
|
public function classMembersAnnotations(string $class): array
{
$index = static::CLASS_MEMBERS_CACHE . $class;
if (isset(self::$annotations[$index])) {
return self::$annotations[$index];
}
return self::$annotations[$index] =
|
php
|
{
"resource": ""
}
|
q267811
|
NativeAnnotations.classAndMembersAnnotations
|
test
|
public function classAndMembersAnnotations(string $class): array
{
$index = static::CLASS_AND_MEMBERS_CACHE . $class;
if (isset(self::$annotations[$index])) {
return self::$annotations[$index];
}
return self::$annotations[$index] =
|
php
|
{
"resource": ""
}
|
q267812
|
NativeAnnotations.propertyAnnotations
|
test
|
public function propertyAnnotations(string $class, string $property): array
{
$index = static::PROPERTY_CACHE . $class . $property;
return self::$annotations[$index]
?? self::$annotations[$index] = $this->setAnnotationValues(
[
'class' => $class,
'property' => $property,
|
php
|
{
"resource": ""
}
|
q267813
|
NativeAnnotations.propertyAnnotationsType
|
test
|
public function propertyAnnotationsType(string $type, string $class, string $property): array
{
return $this->filterAnnotationsByType(
$type,
|
php
|
{
"resource": ""
}
|
q267814
|
NativeAnnotations.propertiesAnnotations
|
test
|
public function propertiesAnnotations(string $class): array
{
$index = static::PROPERTIES_CACHE . $class;
if (isset(self::$annotations[$index])) {
return self::$annotations[$index];
}
$annotations = [];
// Get the class's reflection
$reflection = $this->getClassReflection($class);
// Iterate through the properties
foreach ($reflection->getProperties() as $property) {
$index = static::METHOD_CACHE . $class . $property->getName();
// Set the property's reflection class in the cache
self::$reflections[$index] = $property;
// Iterate
|
php
|
{
"resource": ""
}
|
q267815
|
NativeAnnotations.methodAnnotations
|
test
|
public function methodAnnotations(string $class, string $method): array
{
$index = static::METHOD_CACHE . $class . $method;
$reflection = $this->getMethodReflection($class, $method);
return self::$annotations[$index]
|
php
|
{
"resource": ""
}
|
q267816
|
NativeAnnotations.methodAnnotationsType
|
test
|
public function methodAnnotationsType(string $type, string $class, string $method): array
{
return $this->filterAnnotationsByType(
$type,
|
php
|
{
"resource": ""
}
|
q267817
|
NativeAnnotations.methodsAnnotations
|
test
|
public function methodsAnnotations(string $class): array
{
$index = static::METHODS_CACHE . $class;
if (isset(self::$annotations[$index])) {
return self::$annotations[$index];
}
$annotations = [];
// Get the class's reflection
$reflection = $this->getClassReflection($class);
// Iterate through the methods
foreach ($reflection->getMethods() as $method) {
$index = static::METHOD_CACHE . $class . $method->getName();
// Set the method's reflection class in the cache
self::$reflections[$index] = $method;
// Iterate
|
php
|
{
"resource": ""
}
|
q267818
|
NativeAnnotations.functionAnnotations
|
test
|
public function functionAnnotations(string $function): array
{
$index = static::FUNCTION_CACHE . $function;
return self::$annotations[$index]
?? self::$annotations[$index] = $this->setAnnotationValues(
|
php
|
{
"resource": ""
}
|
q267819
|
NativeAnnotations.filterAnnotationsByType
|
test
|
public function filterAnnotationsByType(string $type, Annotation ...$annotations): array
{
// Set a list of annotations to return
$annotationsList = [];
// Iterate through the annotation
foreach ($annotations as $annotation) {
// If the annotation's type matches the type requested
|
php
|
{
"resource": ""
}
|
q267820
|
NativeAnnotations.setAnnotationValues
|
test
|
protected function setAnnotationValues(array $properties, Annotation ...$annotations): array
{
foreach ($annotations as $annotation) {
$annotation->setClass($properties['class'] ?? null);
$annotation->setProperty($properties['property'] ?? null);
|
php
|
{
"resource": ""
}
|
q267821
|
NativeAnnotations.getClassReflection
|
test
|
public function getClassReflection(string $class): ReflectionClass
{
$index = static::CLASS_CACHE . $class;
return self::$reflections[$index]
|
php
|
{
"resource": ""
}
|
q267822
|
NativeAnnotations.getPropertyReflection
|
test
|
public function getPropertyReflection(string $class, string $property): ReflectionProperty
{
$index = static::PROPERTY_CACHE . $class . $property;
return self::$reflections[$index]
|
php
|
{
"resource": ""
}
|
q267823
|
NativeAnnotations.getMethodReflection
|
test
|
public function getMethodReflection(string $class, string $method): ReflectionMethod
{
$index = static::METHOD_CACHE . $class . $method;
return self::$reflections[$index]
|
php
|
{
"resource": ""
}
|
q267824
|
NativeAnnotations.getFunctionReflection
|
test
|
public function getFunctionReflection(string $function): ReflectionFunction
{
$index = static::FUNCTION_CACHE . $function;
return self::$reflections[$index]
|
php
|
{
"resource": ""
}
|
q267825
|
NativeAnnotations.getDependencies
|
test
|
protected function getDependencies(ReflectionParameter ...$parameters): array
{
// Setup to find any injectable objects through the service container
$dependencies = [];
// Iterate through the method's parameters
|
php
|
{
"resource": ""
}
|
q267826
|
Segment.getLength
|
test
|
public function getLength()
{
return sqrt(
pow(($this->getPointB()->getAbscissa() - $this->getPointA()->getAbscissa()), 2)
+
|
php
|
{
"resource": ""
}
|
q267827
|
Segment.getCenter
|
test
|
public function getCenter()
{
$abscissas = array(
$this->getPointA()->getAbscissa(), $this->getPointB()->getAbscissa()
);
$ordinates = array(
|
php
|
{
"resource": ""
}
|
q267828
|
ActiveForm.run
|
test
|
public function run()
{
if (!empty($this->_fields)) {
throw new InvalidCallException('Each beginField() should have a matching endField() call.');
}
$content = ob_get_clean();
echo $this->htmlHlp->beginForm($this->action, $this->method, $this->options);
|
php
|
{
"resource": ""
}
|
q267829
|
ActiveForm.field
|
test
|
public function field($model, $attribute, $options = [])
{
$config = $this->fieldConfig;
if ($config instanceof \Closure) {
$config = call_user_func($config, $model, $attribute);
}
if (!isset($config['class'])) {
$config['class'] = $this->fieldClass;
|
php
|
{
"resource": ""
}
|
q267830
|
Config.has
|
test
|
public function has($key)
{
if (strpos($key, '.') === false) {
return $this->hasByKey($key);
|
php
|
{
"resource": ""
}
|
q267831
|
DirectoryModel.getDisplayDirname
|
test
|
public function getDisplayDirname()
{
$_dirname = $this->dirname;
if
|
php
|
{
"resource": ""
}
|
q267832
|
DirectoryModel.scanDir
|
test
|
public function scanDir($recursive = false)
{
if (!$this->exists()) return false;
$_dir = opendir($this->getPath().$this->dirname);
$data = array();
while ($entry = @readdir($_dir)) {
if (!in_array($entry, $this->ignore)) {
if (is_dir($this->getPath().$this->dirname.'/'.$entry)) {
if (true === $recursive){
$_new_dir = new DirectoryModel;
$_new_dir->setPath( $this->getPath().$this->dirname );
|
php
|
{
"resource": ""
}
|
q267833
|
Header.header
|
test
|
final public static function header($string, $replace = true, $http_response_code = null)
{
if ( !$headers = http\Header::parse($string) ) Returns;
$header = key($headers);
if ( $replace || !isset(self::$list[$header]) ) {
self::$list[$header] = array();
}
|
php
|
{
"resource": ""
}
|
q267834
|
Header.headers_list
|
test
|
final public static function headers_list()
{
$results = array();
foreach (self::$list as $headers) {
$results =
|
php
|
{
"resource": ""
}
|
q267835
|
DBOperator.createDB
|
test
|
public function createDB($DBName, $charset = 'utf8', $collation = 'utf8_unicode_ci') {
|
php
|
{
"resource": ""
}
|
q267836
|
DBOperator.getDBTables
|
test
|
public function getDBTables($force_fetch = false) {
if ($this->_tables && !$force_fetch) return $this->_tables;
$res = QC::executeSQL('SHOW TABLES');
$this->_tables = array();
if ($res->rowCount()) {
$res = $res->fetchAll(\PDO::FETCH_NUM);
|
php
|
{
"resource": ""
}
|
q267837
|
DBOperator.updateDBFromStructure
|
test
|
public function updateDBFromStructure($structure, $safeUpdate = true) {
$diffs = $this->getDifferenceSQL($structure);
if ($diffs['result'] === true) {
QC::executeSQL('SET FOREIGN_KEY_CHECKS = 0');
|
php
|
{
"resource": ""
}
|
q267838
|
DBOperator.updateDBRelations
|
test
|
public function updateDBRelations($modelName, $structure) {
if (empty($structure['relations'])) return true;
foreach($structure['relations'] as $relationName => $relationInfo) {
$info = ModelOperator::calculateRelationVariables($modelName, $relationName);
switch($info['relationType']) {
case 'many_to_many':
|
php
|
{
"resource": ""
}
|
q267839
|
DBOperator.updateManyTable
|
test
|
public function updateManyTable($info) {
$structure = array(
'table' => $info['manyTable'],
'columns' => array(),
'indexes' => array(),
'constraints' => array(),
);
$localName = Inflector::singularize($info['localTable']);
$foreignName = Inflector::singularize($info['foreignTable']);
$structure['columns']['id'] = array('type' => 'int(11) unsigned', 'auto_increment'=>true);
$structure['columns']['id_'. $localName] = 'int(11) unsigned';
$structure['columns']['id_'. $foreignName] = 'int(11) unsigned';
$structure['indexes']['primary'] = array('columns'=>array('id'), 'type'=>'primary');
$structure['indexes']['unique_id_'.$localName.'_id_'.$foreignName] = array(
'columns' => array(
'id_'.$localName,
'id_'.$foreignName
),
'type' => 'unique'
);
$foreignKeysInfo = array(
'local_table' => $info['manyTable'],
'foreign_table' => $info['localTable'],
'local_field' => 'id_'.$localName,
'foreign_field' => $info['foreignKey']
);
|
php
|
{
"resource": ""
}
|
q267840
|
DBOperator.generateTableSQL
|
test
|
public function generateTableSQL($structure) {
$sql = 'CREATE TABLE' . ' IF NOT EXISTS `' . $structure['table'].'` (' . "\n";
foreach($structure['columns'] as $column=>$info) {
if (!is_array($info)) $info = array('type'=>$info);
if (!isset($info['name'])) $info['name'] = $column;
if (!empty($info['virtual'])) continue;
$sql .= $this->generateColumnSQL($info).','."\n";
}
if (!empty($structure['indexes'])) {
foreach($structure['indexes'] as $name=>$info) {
if (!isset($info['name'])) $info['name'] = $name;
$sql .= $this->generateIndexSQL($info).','."\n";
}
}
|
php
|
{
"resource": ""
}
|
q267841
|
DBOperator.generateColumnSQL
|
test
|
private function generateColumnSQL($info) {
$sql = '';
if (isset($info['old_name'])) {
$sql = '`'.$info['old_name'].'` ';
}
$sql .= '`'.$info['name'].'` '.$this->getSQLTypeForField($info);
if (isset($info['unsigned'])) $sql .= ' unsigned';
if (isset($info['zerofill'])) $sql .= ' zerofill';
if (isset($info['auto_increment'])) {
$sql .= ' NOT
|
php
|
{
"resource": ""
}
|
q267842
|
DBOperator.generateIndexSQL
|
test
|
private function generateIndexSQL($info) {
$keys = $info['columns'];
$sql = '';
if (!isset($info['type'])) $info['type'] = ($info['name'] == 'primary' ? 'primary' : 'simple');
switch ($info['type']) {
case 'primary':
$sql .= 'PRIMARY KEY (`'.(is_array($keys) ? implode('`, `', $keys) : $keys).'`)';
break;
case 'unique':
case 'simple':
|
php
|
{
"resource": ""
}
|
q267843
|
DBOperator.generateConstraintSQL
|
test
|
private function generateConstraintSQL($info) {
$name = isset($info['name']) ? $info['name'] : $this->generateForeignKeyName($info);
$sql = 'CONSTRAINT `'.$name.'` FOREIGN KEY (`'.$info['local_field'].'`) REFERENCES `'
|
php
|
{
"resource": ""
}
|
q267844
|
Keyvalue.getKeyvaluesByKeyType
|
test
|
public static function getKeyvaluesByKeyType($keyType)
{
if (empty($keyType)) {
// return empty array
return [];
}
$tableCache = static::tableToArray();
// Read through the entire table cache looking for keys that match
// the keyType
$result = [];
|
php
|
{
"resource": ""
}
|
q267845
|
Keyvalue.getKeyValuesByType
|
test
|
public static function getKeyValuesByType($keyType)
{
$keyvalues = self::getKeyvaluesByKeyType($keyType);
// Sort through the enums of the found type and reformat those
// as a keyvalue => keyname list.
$list = [];
|
php
|
{
"resource": ""
}
|
q267846
|
AnnotationsReader.getClass
|
test
|
public function getClass($class, $refresh = false)
{
$reflector = $this->getClassReflection($class);
$cacheKey = $reflector->getName();
if (!$refresh && $this->cacheExists($cacheKey)) {
return $this->getFromCache($cacheKey);
}
/** @var array|null $annotations */
|
php
|
{
"resource": ""
}
|
q267847
|
AnnotationsReader.getClassExact
|
test
|
public function getClassExact($class, $annotationClass, $refresh = false)
{
$annotations = $this->getClass($class, $refresh);
foreach ($annotations as $annotation) {
|
php
|
{
"resource": ""
}
|
q267848
|
AnnotationsReader.getProperty
|
test
|
public function getProperty($property, $class = null, $refresh = false)
{
$propertyReflection = $this->getPropertyReflection($property, $class);
$classReflection = $propertyReflection->getDeclaringClass();
$cacheKey = $classReflection->getName() . '$' . $propertyReflection->getName();
if (!$refresh && $this->cacheExists($cacheKey)) {
return $this->getFromCache($cacheKey);
}
|
php
|
{
"resource": ""
}
|
q267849
|
AnnotationsReader.getPropertyExact
|
test
|
public function getPropertyExact($property, $annotationClass, $class = null, $refresh = false)
{
$annotations = $this->getProperty($property, $class, $refresh);
foreach ($annotations as $annotation) {
|
php
|
{
"resource": ""
}
|
q267850
|
AnnotationsReader.getMethod
|
test
|
public function getMethod($method, $class = null, $refresh = false)
{
$methodReflection = $this->getMethodReflection($method, $class);
$classReflection = $methodReflection->getDeclaringClass();
$cacheKey = $classReflection->getName() . '#' . $methodReflection->getName();
if (!$refresh && $this->cacheExists($cacheKey)) {
return $this->getFromCache($cacheKey);
}
|
php
|
{
"resource": ""
}
|
q267851
|
AnnotationsReader.getMethodExact
|
test
|
public function getMethodExact($method, $annotationClass, $class = null, $refresh = false)
{
$annotations = $this->getMethod($method, $class, $refresh);
foreach ($annotations as $annotation) {
|
php
|
{
"resource": ""
}
|
q267852
|
AnnotationsReader.getReader
|
test
|
protected function getReader()
{
if (!isset($this->_reader)) {
ClassFinderHelper::findClassesPsr4($this->annotationNamespaces);
|
php
|
{
"resource": ""
}
|
q267853
|
AnnotationsReader.getMethodReflection
|
test
|
protected function getMethodReflection($method, $class = null)
{
if (is_object($method) && $method instanceof \ReflectionMethod) {
return $method;
}
if ($class === null) {
|
php
|
{
"resource": ""
}
|
q267854
|
AnnotationsReader.getFromCache
|
test
|
protected function getFromCache($key)
{
return
|
php
|
{
"resource": ""
}
|
q267855
|
AnnotationsReader.setToCache
|
test
|
protected function setToCache($key, $value = null)
{
if (!isset($value)) {
unset($this->_cache[$value]);
|
php
|
{
"resource": ""
}
|
q267856
|
MockSettings.getPaths
|
test
|
private static function getPaths($key){
$paths = array();
$sourcePaths = explode(".", $key);
foreach ($sourcePaths as $sourcePath){
$subPaths = preg_split('/\[(.*?)\]/',$sourcePath,-1,PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
|
php
|
{
"resource": ""
}
|
q267857
|
ExtendedCache.processKey
|
test
|
protected function processKey($key) {
if (is_string($key)) {
return $key;
} else {
|
php
|
{
"resource": ""
}
|
q267858
|
Observed.checkEventClassName
|
test
|
private function checkEventClassName(string $eventClassName): Observed
{
if (!\class_exists($eventClassName)) {
throw new \RuntimeException('Missing event class '.$eventClassName);
}
|
php
|
{
"resource": ""
}
|
q267859
|
Observed.buildEvent
|
test
|
private function buildEvent()
{
$currentEnabledStates = $this->getObject()->listEnabledStates();
$lastEnabledStates = $this->getLastEnabledStates();
//New state = current states - old states
$incomingStates = \array_diff($currentEnabledStates, $lastEnabledStates);
//Outgoing state = lst states - current
|
php
|
{
"resource": ""
}
|
q267860
|
ArrayTools.avg
|
test
|
public static function avg($array)
{
$total = 0;
foreach ($array as $value) {
if (is_numeric($value)) {
|
php
|
{
"resource": ""
}
|
q267861
|
QueryParameters.orderBy
|
test
|
public function orderBy($field, $direction = self::ASCENDING) {
|
php
|
{
"resource": ""
}
|
q267862
|
TypeHint.read
|
test
|
public function read()
{
if (is_null($constructor = $this->reflector->getConstructor())) {
return [];
}
$parameters = [];
foreach ($constructor->getParameters() as $reflectionParameter) {
/**
* @var \ReflectionParameter $parameter
*/
$parameter = [
"isClass" => ! is_null($reflectionParameter->getClass()),
"hasDefaultValue" => $reflectionParameter->isDefaultValueAvailable(),
];
if ($parameter["isClass"]) {
|
php
|
{
"resource": ""
}
|
q267863
|
PropertyAccessor.getValue
|
test
|
public function getValue($object, $path)
{
$paths = (array) preg_split('#(\[((?>[^\[\]]+)|(?R))*\])#i', $path, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
for ($i = 0; $i < count($paths); ++$i) {
$path = trim((string) $paths[$i], '.');
if ('[' == substr($path, 0, 1)) {
++$i;
}
if (preg_match('#[^a-z0-9\.\]\[]+#i', $path)) {
$expression = trim($path, '[]');
|
php
|
{
"resource": ""
}
|
q267864
|
PropertyAccessor.setValue
|
test
|
public function setValue($object, $path, $value)
{
|
php
|
{
"resource": ""
}
|
q267865
|
PropertyAccessor.filter
|
test
|
public function filter(array $objects, $expression)
{
$filteredObjects = [];
foreach ($objects as $key => $object) {
try {
if (@$this->language->evaluate('object.'.$expression, ['object' => $object])) {
$filteredObjects[] = $object;
|
php
|
{
"resource": ""
}
|
q267866
|
PHPMailerMail.setFrom
|
test
|
public function setFrom(string $address, string $name = ''):
|
php
|
{
"resource": ""
}
|
q267867
|
PHPMailerMail.addAddress
|
test
|
public function addAddress(string $address, string $name =
|
php
|
{
"resource": ""
}
|
q267868
|
PHPMailerMail.addReplyTo
|
test
|
public function addReplyTo(string $address, string $name =
|
php
|
{
"resource": ""
}
|
q267869
|
PHPMailerMail.addCC
|
test
|
public function addCC(string $address, string $name = ''):
|
php
|
{
"resource": ""
}
|
q267870
|
PHPMailerMail.addBCC
|
test
|
public function addBCC(string $address, string $name = ''):
|
php
|
{
"resource": ""
}
|
q267871
|
PHPMailerMail.addAttachment
|
test
|
public function addAttachment(string $path, string $name =
|
php
|
{
"resource": ""
}
|
q267872
|
CacheAllCommand.run
|
test
|
public function run(string $sync = null): int
{
$containerCache = console()->matchCommand(ContainerCacheCommand::COMMAND);
$consoleCache = console()->matchCommand(ConsoleCacheCommand::COMMAND);
$eventsCache = console()->matchCommand(EventsCacheCommand::COMMAND);
$routesCache = console()->matchCommand(RoutesCacheCommand::COMMAND);
console()->dispatchCommand($containerCache);
console()->dispatchCommand($consoleCache);
console()->dispatchCommand($eventsCache);
console()->dispatchCommand($routesCache);
$configCache = console()->matchCommand(ConfigCacheCommand::COMMAND);
console()->dispatchCommand($configCache);
if (null !== $sync && config()['app']['debug']) {
$files = [
|
php
|
{
"resource": ""
}
|
q267873
|
Router.setReferer
|
test
|
public static function setReferer($uri = null)
{
if (empty($uri)) $uri = UrlHelper::getRequestUrl();
|
php
|
{
"resource": ""
}
|
q267874
|
Router.getReferer
|
test
|
public static function getReferer()
{
return (CarteBlanche::getContainer()->get('session')->has('referer') ?
|
php
|
{
"resource": ""
}
|
q267875
|
Router.buildUrl
|
test
|
public function buildUrl($param = null, $value = null, $separator = '&')
{
if (!is_array($param) && !empty($value)) {
$param = array( $param=>$value );
}
$default_args = array(
'controller' => CarteBlanche::getConfig('routing.mvc.default_controller'),
'action' => CarteBlanche::getConfig('routing.mvc.default_action')
);
if (!empty($param)) {
foreach ($param as $_var=>$_val) {
if (!empty($_val)) {
$_meth = 'fromUrl'.TextHelper::toCamelCase($_var);
if (method_exists($this, $_meth)) {
$_val = call_user_func_array(array($this, $_meth), array($_val));
}
if (array_key_exists($_var, $default_args) && (
|
php
|
{
"resource": ""
}
|
q267876
|
DownSynchronizer.downloadPackage
|
test
|
protected function downloadPackage()
{
$this->crowdinClient->api('export')->execute();
$path = $this->createArchiveDirectory();
/** @var Download $download */
$download = $this->crowdinClient->api('download');
$download->setCopyDestination($path);
|
php
|
{
"resource": ""
}
|
q267877
|
DownSynchronizer.extractPackage
|
test
|
protected function extractPackage($projectPath)
{
$this->archive->setExtractPath($projectPath);
|
php
|
{
"resource": ""
}
|
q267878
|
DownSynchronizer.resetDefaultLocaleTranslations
|
test
|
protected function resetDefaultLocaleTranslations()
{
$translations = $this->translationsFinder->getDefaultLocaleTranslations();
foreach
|
php
|
{
"resource": ""
}
|
q267879
|
Request_With_Content_Types._strpos
|
test
|
protected function _strpos( $haystack, $needle ) {
return function_exists( 'mb_strpos' ) ? mb_strpos(
|
php
|
{
"resource": ""
}
|
q267880
|
BackendMenuBuilder.createSidebarMenu
|
test
|
public function createSidebarMenu(Request $request)
{
$menu = $this->factory->createItem('root', array(
'childrenAttributes' => array(
'class' => 'big-menu',
)
));
$section = 'sidebar';
$menu->addChild('home',array(
'route' => '',//Route
|
php
|
{
"resource": ""
}
|
q267881
|
BackendMenuBuilder.addExampleMenu
|
test
|
function addExampleMenu(ItemInterface $menu, $section) {
$child = $this->factory->createItem('example',
$this->getSubLevelOptions(array(
'uri' => null,
'labelAttributes' => array('icon' => 'icon-book',),
))
)
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.main', $section)));
$child
->addChild('example.company', array(
'route' => '',
))
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.company', $section)));
$child
->addChild('example.technical_reports', array(
'route' => '',
))
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.technical_reports', $section)));
$subchild = $this->factory->createItem('subexample',
$this->getSubLevelOptions(array(
'uri' => null,
'labelAttributes' => array('icon' => 'icon-book',),
|
php
|
{
"resource": ""
}
|
q267882
|
MigrationsServiceProvider.register
|
test
|
public function register() {
$this->loadEntitiesFrom(__DIR__);
$this->app->singleton('migration.repository', function($app) {
return new DoctrineMigrationRepository(
function() use($app) {
return $app->make(EntityManagerInterface::class);
},
function() use($app) {
return $app->make(SchemaTool::class);
|
php
|
{
"resource": ""
}
|
q267883
|
LiveFilesystemPublisher.publishPages
|
test
|
public function publishPages($urls)
{
LivePubHelper::init_pub();
|
php
|
{
"resource": ""
}
|
q267884
|
Updater.update
|
test
|
public function update($params = array())
{
$this->adapter->execute($this->toSql(),
|
php
|
{
"resource": ""
}
|
q267885
|
GettextPoFile.load
|
test
|
public function load($context, $filePath = null)
{
if (isset($filePath)) {
$this->filePath = $filePath;
}
if (!isset($this->_messages)) {
$this->loadAll();
|
php
|
{
"resource": ""
}
|
q267886
|
GettextPoFile.getCategories
|
test
|
public function getCategories()
{
if (!isset($this->_messages)) {
$this->loadAll();
}
$categories
|
php
|
{
"resource": ""
}
|
q267887
|
GetOrderInvoiceRequestHandler.getFileName
|
test
|
protected function getFileName(Response $response)
{
$headers = $response->getHeaders();
$contentDisposition = isset($headers['Content-Disposition'][0]) ?
|
php
|
{
"resource": ""
}
|
q267888
|
NativeServerRequest.validateUploadedFiles
|
test
|
protected function validateUploadedFiles(array $uploadedFiles): void
{
foreach ($uploadedFiles as $file) {
if (\is_array($file)) {
$this->validateUploadedFiles($file);
|
php
|
{
"resource": ""
}
|
q267889
|
AbstractDetection.initResultObject
|
test
|
protected function initResultObject()
{
if(!array_key_exists('default', $this->config)) {
return null;
}
// init default value from data
|
php
|
{
"resource": ""
}
|
q267890
|
AbstractDetection.getPattern
|
test
|
private function getPattern(string $patternId, array $patternData): array
{
if (array_key_exists('default', $patternData) && $patternData['default'] === true) {
|
php
|
{
"resource": ""
}
|
q267891
|
AbstractDetection.setAttributes
|
test
|
protected function setAttributes(array $info)
{
$result = $this->detector->getResultObject();
if (array_key_exists('attributes', $info)) {
foreach ($info['attributes'] as $attributeKey
|
php
|
{
"resource": ""
}
|
q267892
|
AbstractDetection.detectByKey
|
test
|
protected function detectByKey($keyName = 'family'): array
{
foreach ($this->config as $key => $data) {
if ($key === 'default') {
continue;
}
$detectedData = $this->detectByType($key);
|
php
|
{
"resource": ""
}
|
q267893
|
Environment.onShell
|
test
|
public function onShell(): bool {
$check = true;
if (PHP_SAPI != Environment::SERVER_CLI) {
|
php
|
{
"resource": ""
}
|
q267894
|
Base.getConfig
|
test
|
public function getConfig()
{
if (!isset($config)) {
$this->config =
|
php
|
{
"resource": ""
}
|
q267895
|
Location.DMSLatitude
|
test
|
public function DMSLatitude($format = '%d %d %F %s') {
$lat = $this->convertDecToDMS($this->latitude());
$direction = 'N';
if ($lat['degrees'] < 0) {
$direction
|
php
|
{
"resource": ""
}
|
q267896
|
Location.DMSLongitude
|
test
|
public function DMSLongitude($format = '%d %d %F %s') {
$long = $this->convertDecToDMS($this->longitude());
$direction = 'E';
if ($long['degrees'] < 0) {
$direction
|
php
|
{
"resource": ""
}
|
q267897
|
Location.latitudeRange
|
test
|
public function latitudeRange($distance) {
$long = deg2rad($this->longitude());
$lat = deg2rad($this->latitude());
$radius = $this->earthRadius($this->latitude());
$angle = $distance / $radius;
$rightangle = pi() / 2;
$minlat = $lat - $angle;
if ($minlat < -$rightangle) { // wrapped around the south pole
$overshoot = -$minlat - $rightangle;
$minlat = -$rightangle + $overshoot;
if ($minlat > $maxlat) { $maxlat = $minlat; }
$minlat = -$rightangle;
}
$maxlat = $lat + $angle;
if ($maxlat > $rightangle) { // wrapped around the north pole
|
php
|
{
"resource": ""
}
|
q267898
|
Location.longitudeRange
|
test
|
public function longitudeRange($distance) {
$long = deg2rad($this->longitude());
$lat = deg2rad($this->latitude());
$radius = $this->earthRadius($this->latitude());
$angle = $distance / $radius;
$diff = asin(sin($angle) / cos($lat));
$minlong = $long - $diff;
if ($minlong < -pi()) {
$minlong = $minlong + pi() * 2;
|
php
|
{
"resource": ""
}
|
q267899
|
Location.distance
|
test
|
public function distance(LocationInterface $location, $method = 'default') {
if (!isset($this->distanceCache[$method])) {
if (!isset($this->distanceMethods[$method])) {
throw new Exception('Distance method not registered.');
}
elseif (!class_exists($this->distanceMethods[$method])) {
throw new Exception('The class associated with the name does not exist.');
}
// @todo:
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.