_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q265600
|
ActiveRecordModel.findAll
|
test
|
public function findAll()
{
$this->checkDb();
return $this->db->connect()
->select()
->from($this->tableName)
|
php
|
{
"resource": ""
}
|
q265601
|
ActiveRecordModel.findAllWhere
|
test
|
public function findAllWhere($where, $value)
{
$this->checkDb();
$params = is_array($value) ? $value : [$value];
return $this->db->connect()
->select()
->from($this->tableName)
|
php
|
{
"resource": ""
}
|
q265602
|
ActiveRecordModel.create
|
test
|
protected function create()
{
$this->checkDb();
$properties = $this->getProperties();
unset($properties[$this->tableIdColumn]);
$columns = array_keys($properties);
$values = array_values($properties);
$this->db->connect()
|
php
|
{
"resource": ""
}
|
q265603
|
ActiveRecordModel.updateWhere
|
test
|
protected function updateWhere($where, $value)
{
$this->checkDb();
$properties = $this->getProperties();
$columns = array_keys($properties);
$values = array_values($properties);
$values1 = is_array($value)
? $value
|
php
|
{
"resource": ""
}
|
q265604
|
Pattern.parseNotation
|
test
|
protected function parseNotation($notation)
{
$out = str_replace(['[', ']'], ['(?:', ')?'], $notation);
$enhancement = '(?P<\2>' . self::REGVAL . ')';
|
php
|
{
"resource": ""
}
|
q265605
|
Pattern.applyConditions
|
test
|
protected function applyConditions($expression, $conditions)
{
$search = $replace = [];
foreach ($conditions as $key
|
php
|
{
"resource": ""
}
|
q265606
|
Mean.calculate
|
test
|
public function calculate(): FormulasInterface
{
if (! $this->dataSet instanceof DataSet) {
throw new WrongUsageException('DataSet was not provided for mean calculus');
}
$dataSetSize = $this->dataSet->getSize();
$this->result = [];
foreach ($this->dataSet as $instance) {
foreach ($instance->getDimensions() as $index => $dimension) {
$this->result[0][$index] = $this->result[0][$index] ?? 0;
$this->result[0][$index] += $dimension / $dataSetSize;
}
|
php
|
{
"resource": ""
}
|
q265607
|
HttpClientFactory.create
|
test
|
public function create(HttpClient $client = null): PluginClient
|
php
|
{
"resource": ""
}
|
q265608
|
BinaryFileResponse.setFile
|
test
|
public function setFile($file, $contentDisposition = null, $etag = false, $lastModified = true)
{
if (!$file instanceof File) {
if ($file instanceof \SplFileInfo) {
$file = new File($file->getPathname());
} else {
$file = new File((string) $file);
}
}
if (!$file->isReadable()) {
throw new FileException('File must be readable.');
}
$this->file = $file;
if ($etag === true)
$this->setAutoEtag();
elseif (!empty($etag))
$this->setEtag($etag);
if ($lastModified
|
php
|
{
"resource": ""
}
|
q265609
|
RemoteLoader.addTemplate
|
test
|
public function addTemplate($name, $url, $ttl, array $blocks, array $metadata)
{
$this->templates[$name] = [
'url' => $url,
'ttl' => $ttl,
'blocks' => $blocks,
|
php
|
{
"resource": ""
}
|
q265610
|
RemoteLoader.checkCacheFileTtl
|
test
|
private function checkCacheFileTtl($name)
{
// this method is called only if env->isAutoReload() == FALSE
if (
false !== ($cacheFile = $this->container->get('twig')->getCacheFilename($name))
|
php
|
{
"resource": ""
}
|
q265611
|
RemoteLoader.placeholdersToBlocks
|
test
|
private function placeholdersToBlocks(array $blocks, $source)
{
$usedBlockMap = [];
$placeholderToBlockMap = [];
$pattern = '';
$first = true;
foreach ($blocks as $blockName => $block) {
$first ? $first = false : $pattern .= '|';
$pattern .= \preg_quote($block['placeholder'], '/');
$placeholderToBlockMap[$block['placeholder']] = $blockName;
}
return \preg_replace_callback(
\sprintf('/(%s)/', $pattern),
function (array $match) use ($placeholderToBlockMap, &$usedBlockMap) {
$blockName =
|
php
|
{
"resource": ""
}
|
q265612
|
RemoteLoader.getMetadata
|
test
|
private function getMetadata($name)
{
$this->ensureExists($name);
return
|
php
|
{
"resource": ""
}
|
q265613
|
YamlDefinitionLoaderFactory.buildDefinitionProvider
|
test
|
public static function buildDefinitionProvider(Discovery $discovery)
{
$bindings = $discovery->findBindings('definition-interop/yaml-definition-files');
$definitionProviders = [];
foreach ($bindings as $binding) {
foreach ($binding->getResources() as $resource) {
|
php
|
{
"resource": ""
}
|
q265614
|
FormulasResults.of
|
test
|
public function of(string $formulaName)
{
if (! isset($this->results[$formulaName])) {
|
php
|
{
"resource": ""
}
|
q265615
|
FormulasResults.save
|
test
|
public function save(FormulasInterface $formula): FormulasResults
{
if ($this->isValid($formula)) {
$this->results[get_class($formula)] = $formula->getResult();
}
|
php
|
{
"resource": ""
}
|
q265616
|
Helper.addHeader
|
test
|
public function addHeader(ItemInterface $item, $text)
{
return $item->addChild('header_' . \rand())
|
php
|
{
"resource": ""
}
|
q265617
|
Helper.setDropdown
|
test
|
public function setDropdown(ItemInterface $dropDownItem)
{
$dropDownItem
->setUri('#')
->setLinkattribute('class', 'dropdown-toggle')
->setLinkattribute('data-toggle', 'dropdown')
->setAttribute('class', 'dropdown')
|
php
|
{
"resource": ""
}
|
q265618
|
Helper.isUserGranted
|
test
|
public function isUserGranted($attributes, $subject = null): bool
|
php
|
{
"resource": ""
}
|
q265619
|
ResponseFactory.download
|
test
|
public function download($file, $name = null, array $headers = [], $options = [], $disposition = 'attachment')
{
!empty($options['cached']) && $headers = array_merge($headers, ['Cache-Control' => 'private, max-age=3600, must-revalidate', 'Pragma' => 'cache']);
!empty($options['mime_type']) && $headers = array_merge($headers, ['Content-Type' => $options['mime_type']]);
$response = new BinaryFileResponse($file, 200, $headers, true, $disposition);
if
|
php
|
{
"resource": ""
}
|
q265620
|
YandexAdapter.getUrl
|
test
|
private function getUrl($type, $key)
{
switch ($type) {
case 'album':
$url = 'album/%s/';
break;
case 'photo':
$url = 'photo/%s/';
break;
case 'albumPhotos':
$url = 'album/%s/photos/';
break;
case 'albums':
$url = 'albums/';
|
php
|
{
"resource": ""
}
|
q265621
|
YandexAdapter.setListCover
|
test
|
private function setListCover(array $listCover, Gallery $album)
{
foreach ($listCover as
|
php
|
{
"resource": ""
}
|
q265622
|
YandexAdapter.getDataByType
|
test
|
private function getDataByType($key, $type = 'photo')
{
$url
|
php
|
{
"resource": ""
}
|
q265623
|
YandexAdapter.getData
|
test
|
private function getData($url)
{
try {
$request = $this->client->get($url);
$response = $request->send();
$decoder = new JsonDecode(true);
$data = $decoder->decode($response->getBody(true), 'json');
if (isset($data['links']['next'])) {
$next = $this->getData($data['links']['next']);
|
php
|
{
"resource": ""
}
|
q265624
|
RouteInstaller.install
|
test
|
public static function install($baseUri = null) {
$baseUri = $baseUri ? "$baseUri/" : "";
\Route::post($baseUri . "resources/bulk/{resource}", "Foothing\RepositoryController\Controllers\ResourceController@postBulk");
\Route::put($baseUri . "resources/bulk/{resource}", "Foothing\RepositoryController\Controllers\ResourceController@putBulk");
\Route::put($baseUri . "resources/{resource}/{id}/link/{relation}/{related}/{relatedId}", "Foothing\RepositoryController\Controllers\ResourceController@putLink");
\Route::delete($baseUri . "resources/{resource}/{id}/link/{relation}/{related}/{relatedId}", "Foothing\RepositoryController\Controllers\ResourceController@deleteLink");
|
php
|
{
"resource": ""
}
|
q265625
|
DocParser.isValidDate
|
test
|
private function isValidDate($date){
return preg_match('#[0-3][0-9]\/[0-1][0-9]\/[2][0][0-9][0-9]#', $date)
&&
checkdate((int)substr($date, 3, 2),
|
php
|
{
"resource": ""
}
|
q265626
|
pxcmd.wrap_gui_frame
|
test
|
public function wrap_gui_frame( $content ){
$this->bowl()->send($content);
unset($content);
@header( 'Content-type: text/html; charset="UTF-8"' );
// リソースをキャッシュ領域にコピー
$path_pxcache = $this->px->fs()->get_realpath( $this->px->get_path_controot().$this->px->conf()->public_cache_dir.'/px/' );
$realpath_pxcache = $this->px->fs()->get_realpath( $this->px->get_realpath_docroot().$path_pxcache );
$this->px->fs()->mkdir( $realpath_pxcache );
$this->px->fs()->copy_r( __DIR__.'/files/', $realpath_pxcache );
$pxcmd = $this->px->get_px_command();
ob_start();?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title><?= htmlspecialchars( $this->px->conf()->name ) ?></title>
<!-- jQuery -->
<script src="<?= htmlspecialchars( $path_pxcache.'scripts/jquery-1.10.1.min.js' ); ?>" type="text/javascript"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="<?= htmlspecialchars( $path_pxcache.'styles/bootstrap/css/bootstrap.min.css' ); ?>">
<script src="<?= htmlspecialchars( $path_pxcache.'styles/bootstrap/js/bootstrap.min.js' ); ?>"></script>
<!-- FESS -->
<link rel="stylesheet" href="<?= htmlspecialchars( $path_pxcache.'styles/contents.css' ); ?>" type="text/css" />
<!-- layout -->
<link rel="stylesheet" href="<?= htmlspecialchars( $path_pxcache.'styles/layout.css' ); ?>" type="text/css" />
<?= $this->bowl()->pull('head') ?>
</head>
<body class="pxcmd">
<div class="pxcmd-outline">
|
php
|
{
"resource": ""
}
|
q265627
|
Kernel.run
|
test
|
public function run($commandline)
{
$this->bootstrap();
$artisan = $this->getArtisan();
$artisan->setCatchExceptions(false);
$artisan->run($input
|
php
|
{
"resource": ""
}
|
q265628
|
ReflectionMethod.factory
|
test
|
public static function factory($class, $method = null)
{
if (is_object($class))
$class = get_class($class);
$class = (string)$class;
if (!isset(self::$methods[$class])) {
$classReflection = new \ReflectionClass($class);
$methods = $classReflection->getMethods();
self::$methods[$class] = array();
foreach ($methods as $methodReflection) {
if ($methodReflection->class != $class) {
self::$methods[$class][$methodReflection->name] = self::factory($methodReflection->class, $methodReflection->name);
} else {
self::$methods[$class][$methodReflection->name] = new self($class, $methodReflection->name);
self::$methods[$class][$methodReflection->name]->setAccessible(true);
|
php
|
{
"resource": ""
}
|
q265629
|
RedisDriver.createSession
|
test
|
function createSession(SessionManager $sessionManager, $userProfile = null)
{
$sessionLifeTime = $sessionManager->getSessionConfig()->getLifetime();
$initialData = [];
$profiles = [];
if ($userProfile) {
$profiles = [$userProfile];
}
$initialData['profiles'] = $profiles;
$initialData['data'] = [];
$dataString = $this->serializer->serialize($initialData);
$lockToken = null;
for ($count = 0; $count < 10; $count++) {
$sessionId = $this->idGenerator->generateSessionID();
$lockToken = $this->acquireLockIfRequired($sessionId, $sessionManager);
$dataKey = generateSessionDataKey($sessionId);
$set = $this->redisClient->set(
$dataKey,
$dataString,
'EX',
$sessionLifeTime,
'NX'
);
|
php
|
{
"resource": ""
}
|
q265630
|
Agent.sendEntity
|
test
|
private function sendEntity($entity_name, array $data, $key_id)
{
$client = $this->getClient();
$this->getLogger()->info('Sending new ' . $entity_name . '.');
try {
$this->getLogger()->info('Try to PUT data to existing ' . $entity_name . ' record.');
$data[$key_id . '_uri'] = $data[$key_id];
$client->getCommand('put' . $entity_name, $data)
->execute();
} catch (ClientErrorResponseException $e) {
if ($e->getResponse()->getStatusCode() === 404) {
// The server doesn't exist yet. We need to POST it.
|
php
|
{
"resource": ""
}
|
q265631
|
ProviderFacter.registerProviders
|
test
|
public function registerProviders()
{
$finder = new Finder();
$finder->files()
->ignoreUnreadableDirs()
->in($this->providers_dir)
->sortByName()
|
php
|
{
"resource": ""
}
|
q265632
|
ProviderFacter.registerProviderFromFile
|
test
|
public function registerProviderFromFile(\SplFileInfo $provider_file)
{
$class_name = $this->providers_namespace . '\\'
|
php
|
{
"resource": ""
}
|
q265633
|
ProviderFacter.getFacts
|
test
|
public function getFacts($cached = true)
{
if (is_null($this->facts)) {
|
php
|
{
"resource": ""
}
|
q265634
|
ProviderFacter.populateFacts
|
test
|
public function populateFacts()
{
$this->facts = array();
foreach ($this->providers as
|
php
|
{
"resource": ""
}
|
q265635
|
EventSourcedAggregateRoot.record
|
test
|
private function record($domainEvent)
{
$this->ensureChangesEventStream();
|
php
|
{
"resource": ""
}
|
q265636
|
EventSourcedAggregateRoot.apply
|
test
|
public function apply($domainEvent)
{
$domainEvent = $this->ensureDomainEvent($domainEvent);
$eventHandlerName = $this->getEventHandlerName($domainEvent);
if (method_exists($this, $eventHandlerName)) {
|
php
|
{
"resource": ""
}
|
q265637
|
px.fnc_call_plugin_funcs
|
test
|
private function fnc_call_plugin_funcs( $func_list ){
if( is_null($func_list) ){ return false; }
$param_arr = func_get_args();
array_shift($param_arr);
if( @!empty( $func_list ) ){
// functions
if( is_object($func_list) ){
$func_list = get_object_vars( $func_list );
}
if( is_string($func_list) ){
$fnc_name = $func_list;
$fnc_name = preg_replace( '/^\\\\*/', '\\', $fnc_name );
$option_value = null;
preg_match( '/^(.*?)(?:\\((.*)\\))?$/s', $fnc_name, $matched );
if(array_key_exists( 1, $matched )){
$fnc_name = @$matched[1];
}
if(array_key_exists( 2, $matched )){
$option_value = @$matched[2];
}
unset($matched);
if( strlen( trim($option_value) ) ){
$option_value = json_decode( $option_value );
}else{
$option_value = null;
}
// var_dump($fnc_name);
// var_dump($option_value);
$this->proc_num ++;
if( @!strlen($this->proc_id) ){
|
php
|
{
"resource": ""
}
|
q265638
|
BarTable.draw
|
test
|
public function draw($data) {
// if the data is sane, and the widths have been set (if not calculate them)
if ($this->dataCheck($data)) {
$barStyle = new Style();
// set the colors to the bar text and fill
$barStyle->setColors($this->barText, $this->barFill);
$bodyStyle = new Style();
// set the colors to the body text and fill
$bodyStyle->setColors($this->bodyText, $this->bodyFill);
// calculate the widths
$this->calculateWidths($data);
// calculate the total width
$totalWidth = $this->calcTotalWidth();
// if at least one of the columns has header text
if ($this->hasHeader()) {
$headers = $this->getHeaderText();
// if a title was specified
if ($this->title) {
// center the title
$justifiedText = $this->clio->justify($this->title, "center", $totalWidth);
// create a title style
$titleStyle = new Style();
$titleStyle->setBold()->setTextColor($this->bodyText);
// ask Clio to draw it
$this->clio->style($titleStyle)->display($justifiedText)->clear()->newLine();
}
// draw the row of cells
$this->drawRow($headers, $barStyle);
}
// go through each
|
php
|
{
"resource": ""
}
|
q265639
|
Calculator.calculate
|
test
|
public function calculate(FormulasInterface $formula): Calculator
{
$formula
->using($this->dataSet)
->knowing($this->results)
|
php
|
{
"resource": ""
}
|
q265640
|
LayoutHelper.hasLayout
|
test
|
public function hasLayout()
{
$masterRequest = $this->requestStack->getMasterRequest();
$currentRequest = $this->requestStack->getCurrentRequest();
if (
$masterRequest->isXmlHttpRequest()
|
php
|
{
"resource": ""
}
|
q265641
|
Style.initialize
|
test
|
public function initialize(TerminalStateInterface $state) {
// both bold and underscore will have a value of true or false (not undefined
$this->setBold($state->isBold());
$this->setUnderscore($state->isUnderscore());
// for colors, if the color is not valid, then it will stay undefined in this context
// get the text color
$textColor = $state->getTextColor();
// if the text color is valid
if ($textColor->isValid()) {
// set it
$this->setTextColor($textColor);
} else {
// the text color is not valid, null out the text color
$this->setTextColor(null);
}
// get the fill
|
php
|
{
"resource": ""
}
|
q265642
|
Style.overrideMembersTo
|
test
|
public function overrideMembersTo(StyleInterface $style) {
// text color
$styleTextColor = $style->getTextColor();
// only change if there is a text color set
if ($styleTextColor) {
// clone the text color
$this->textColor = clone $styleTextColor;
}
// fill color
$styleFillColor = $style->getFillColor();
// only change if there is a fill color set
if ($styleFillColor) {
// clone the fill color
$this->fillColor = clone $styleFillColor;
}
// font styling
// get the overriding bold
$bold = $style->getBold();
// only change the bold, if it is set to something
if (!is_null($bold)) {
|
php
|
{
"resource": ""
}
|
q265643
|
Style.clearStyling
|
test
|
public function clearStyling() {
// reset the colors to null
$this->textColor = $this->fillColor = null;
// reset the underscore and bold to
|
php
|
{
"resource": ""
}
|
q265644
|
Style.setTextColor
|
test
|
public function setTextColor($color) {
// if it is null, just remember null
if (is_null($color)) {
// undefined
$this->textColor = null;
// it is an instance of Color
} elseif ($color instanceof Color) {
// clone it
$this->textColor = clone $color;
// it is some other type
}
|
php
|
{
"resource": ""
}
|
q265645
|
Style.setFillColor
|
test
|
public function setFillColor($color) {
// if it is null, just remember null
if (is_null($color)) {
// undefined
$this->fillColor = null;
// if it is an instance of a color
} elseif ($color instanceof Color) {
// clone it
$this->fillColor = clone $color;
} else
{
|
php
|
{
"resource": ""
}
|
q265646
|
Style.setColors
|
test
|
public function setColors($textColor, $fillColor) {
// set the text color
self::setTextColor($textColor);
// set the fill color
|
php
|
{
"resource": ""
}
|
q265647
|
Style.reverseColors
|
test
|
public function reverseColors() {
// switch them
$text = $this->textColor;
$this->textColor
|
php
|
{
"resource": ""
}
|
q265648
|
ReflectionFunction.factory
|
test
|
public static function factory($function)
{
$function = (string)$function;
if (!isset(self::$functions[$function]))
|
php
|
{
"resource": ""
}
|
q265649
|
Autoloader.loadPlugins
|
test
|
public function loadPlugins()
{
$this->checkCache();
$this->validatePlugins();
$this->countPlugins();
foreach (self::$cache['plugins'] as $plugin_file => $plugin_info) {
|
php
|
{
"resource": ""
}
|
q265650
|
Autoloader.showInAdmin
|
test
|
public function showInAdmin($show, $type)
{
$screen = get_current_screen();
$current = is_multisite() ? 'plugins-network' : 'plugins';
if ($screen->{'base'} != $current || $type != 'mustuse' || !current_user_can('activate_plugins')) {
return $show;
}
$this->updateCache();
|
php
|
{
"resource": ""
}
|
q265651
|
Autoloader.checkCache
|
test
|
private function checkCache()
{
$cache = get_site_option('bedrock_autoloader');
if ($cache === false) {
|
php
|
{
"resource": ""
}
|
q265652
|
Autoloader.updateCache
|
test
|
private function updateCache()
{
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
self::$auto_plugins = get_plugins(self::$relative_path);
self::$mu_plugins = get_mu_plugins();
$plugins = array_diff_key(self::$auto_plugins, self::$mu_plugins);
$rebuild = !is_array(self::$cache['plugins']);
|
php
|
{
"resource": ""
}
|
q265653
|
Autoloader.pluginHooks
|
test
|
private function pluginHooks()
{
if (!is_array(self::$activated)) {
return;
}
foreach (self::$activated as $plugin_file => $plugin_info) {
add_action('wp_loaded',
|
php
|
{
"resource": ""
}
|
q265654
|
Multilog.channel
|
test
|
public function channel($name)
{
if (array_key_exists($name, $this->channels))
|
php
|
{
"resource": ""
}
|
q265655
|
Multilog.initLoggers
|
test
|
private function initLoggers(array $loggers)
{
foreach ($loggers as
|
php
|
{
"resource": ""
}
|
q265656
|
Multilog.createLogger
|
test
|
private function createLogger($channel, array $config)
{
// Setup configuration
// Use default laravel logs path
$storagePath = $this->app->make('path.storage');
$filepath = $storagePath . '/logs/' . $config['stream'];
$logger = new Logger($channel);
$handler = new StreamHandler($filepath);
// Daily rotation
if ($config['daily']) {
$handler = new RotatingFileHandler($filepath, 1);
}
// Format line
if
|
php
|
{
"resource": ""
}
|
q265657
|
LocationController.getObjectsAction
|
test
|
public function getObjectsAction()
{
$qb = $this->getQueryBuilder();
$qb->select(\CampaignChain\CoreBundle\Controller\REST\LocationController::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Location', 'l');
$qb->where('l.channel IS NULL');
$qb->orderBy('l.name');
$qb = $this->getModuleRelation($qb, 'l.locationModule', self::MODULE_URI);
|
php
|
{
"resource": ""
}
|
q265658
|
ReflectionClass.factory
|
test
|
public static function factory($class)
{
if (is_object($class))
$class = get_class($class);
|
php
|
{
"resource": ""
}
|
q265659
|
ReflectionClass.getInterfaces
|
test
|
public function getInterfaces()
{
$interfaceNames = $this->getInterfaceNames();
$interfaces = array();
foreach ($interfaceNames as $interface)
|
php
|
{
"resource": ""
}
|
q265660
|
ReflectionClass.getParentClass
|
test
|
public function getParentClass()
{
$parentClass = parent::getParentClass();
if ($parentClass) {
|
php
|
{
"resource": ""
}
|
q265661
|
ReflectionClass.getMethods
|
test
|
public function getMethods($filter = null)
{
$args = func_get_args();
$methods = ReflectionMethod::factory($this->name);
if (count($args)) {
|
php
|
{
"resource": ""
}
|
q265662
|
ReflectionClass.getProperties
|
test
|
public function getProperties($filter = null)
{
$args = func_get_args();
$properties = ReflectionProperty::factory($this->name);
if (count($args)) {
|
php
|
{
"resource": ""
}
|
q265663
|
Request.is
|
test
|
public function is( $type ) {
switch ( $type ) {
case 'admin':
return is_admin();
case 'ajax':
return defined( 'DOING_AJAX' );
case 'cron':
return defined( 'DOING_CRON' );
case
|
php
|
{
"resource": ""
}
|
q265664
|
StyleAggregate.addStyle
|
test
|
public function addStyle(MaterializedResource $resource, $mediaType = 'all')
{
$this->styles[$resource->getPath()] = array(
'resource' => $resource,
|
php
|
{
"resource": ""
}
|
q265665
|
StyleAggregate.getAggregateStyle
|
test
|
public function getAggregateStyle()
{
$styles = $this->rewritePaths($this->styles);
$styles = $this->wrapMediaRules($styles);
$content
|
php
|
{
"resource": ""
}
|
q265666
|
StyleAggregate.rewritePaths
|
test
|
protected function rewritePaths(array $styles)
{
foreach ($styles as &$style) {
/** @var $resource MaterializedResource */
$resource = $style['resource'];
$replaceCallback = function ($match) use ($resource) {
return "url('".$resource->resolvePath($match[1])."')";
|
php
|
{
"resource": ""
}
|
q265667
|
StyleAggregate.wrapMediaRules
|
test
|
protected function wrapMediaRules(array $styles)
{
foreach ($styles as &$style) {
// Wrap in media rule if a media rule does not already exist in a non-all media style.
if ($style['media'] != 'all' && strpos($style['content'], '@media') === false) {
|
php
|
{
"resource": ""
}
|
q265668
|
StyleAggregate.moveImportsToStart
|
test
|
protected function moveImportsToStart($content)
{
$imports = '';
$replaceCallback = function ($match) use (&$imports) {
$imports .= $match[0];
return '';
};
|
php
|
{
"resource": ""
}
|
q265669
|
SessionArchiveInFiles.get
|
test
|
public function get($id, $remove = false)
{
$self = $this;
/** @var File $file */
$file = null;
$getPromise = $this->getArchiveFilePath($id, true)->then(
function($filePath) use (&$file) {
$file = \Reaction::$app->fs->file($filePath);
return $file->exists()->then(
function() use (&$file) {
return $file->open('r');
}
);
}
)->then(
function($stream = null) use (&$file) {
return $file->getContents();
}
)->then(
function($dataStr) use ($self, &$file, $remove) {
try {
$data = $self->getHandler()->unserializeData($dataStr);
} catch (\InvalidArgumentException $exception) {
$data = null;
}
|
php
|
{
"resource": ""
}
|
q265670
|
SessionArchiveInFiles.remove
|
test
|
public function remove($id)
{
return $this->getArchiveFilePath($id, true)->then(
function($filePath) {
|
php
|
{
"resource": ""
}
|
q265671
|
SessionArchiveInFiles.getArchivePath
|
test
|
protected function getArchivePath() {
if (!isset($this->_archivePath)) {
$this->_archivePath = \Reaction::$app->getAlias($this->archivePath);
$path = \Reaction::$app->getAlias($this->archivePath);
$self = $this;
$fs = \Reaction::$app->fs;
$dirAsFile = $fs->file($path);
$pathPromise = $dirAsFile->exists()->then(
null,
function() use ($path) {
return FileHelperAsc::createDir($path, 0777, true);
}
)->then(
function() use (&$self, $path) {
$self->_archivePath = $path;
|
php
|
{
"resource": ""
}
|
q265672
|
SessionArchiveInFiles.getArchiveFilePath
|
test
|
protected function getArchiveFilePath($id, $existCheck = false)
{
$fileName = $id . '.json';
return $this->getArchivePath()->then(
function($dirPath) use ($fileName) {
return rtrim($dirPath) . DIRECTORY_SEPARATOR . $fileName;
}
)->then(
function($filePath) use ($existCheck) {
if ($existCheck) {
return \Reaction::$app->fs->file($filePath)->exists()->then(
|
php
|
{
"resource": ""
}
|
q265673
|
ArrayHelper.cleanupMergedValues
|
test
|
public static function cleanupMergedValues($array = []) {
if (!is_array($array)) {
return $array;
}
foreach ($array as $key => $value) {
if($value instanceof IgnoreArrayValue || $value instanceof ReplaceArrayValue) {
$array[$key] = $value->value;
} elseif
|
php
|
{
"resource": ""
}
|
q265674
|
ArrayHelper.filter
|
test
|
public static function filter($array, $filters)
{
$result = [];
$forbiddenVars = [];
foreach ($filters as $filter) {
static::applyArrayFilter($array, $filter, $result, $forbiddenVars);
}
foreach ($forbiddenVars as $var) {
|
php
|
{
"resource": ""
}
|
q265675
|
SystemSpec.it_should_return_terminal_screen_size
|
test
|
function it_should_return_terminal_screen_size()
{
self::getTerminalSizes()->shouldBeArray();
self::getTerminalSizes()->shouldHaveKey("width");
|
php
|
{
"resource": ""
}
|
q265676
|
HtmlHelper.style
|
test
|
public function style($content, $options = [], $encoding = null)
{
|
php
|
{
"resource": ""
}
|
q265677
|
HtmlHelper.script
|
test
|
public function script($content, $options = [], $encoding = null)
{
|
php
|
{
"resource": ""
}
|
q265678
|
HtmlHelper.mailto
|
test
|
public function mailto($text, $email = null, $options = [], $encoding = null)
{
$this->ensureTranslated($text);
$this->ensureTranslated($email);
return
|
php
|
{
"resource": ""
}
|
q265679
|
HtmlHelper.staticControl
|
test
|
public function staticControl($value, $options = [])
{
$this->ensureTranslated($value);
return
|
php
|
{
"resource": ""
}
|
q265680
|
HtmlHelper.activeStaticControl
|
test
|
public function activeStaticControl($model, $attribute, $options = [])
{
if (isset($options['value'])) {
$this->ensureTranslated($options['value']);
|
php
|
{
"resource": ""
}
|
q265681
|
HtmlHelper.addCssStyle
|
test
|
public function addCssStyle(&$options, $style, $overwrite = true)
{
|
php
|
{
"resource": ""
}
|
q265682
|
Publisher.makeDirectory
|
test
|
protected function makeDirectory()
{
$path = $this->getPath();
if( ! $this->filesystem()->isDirectory($path))
{
|
php
|
{
"resource": ""
}
|
q265683
|
Publisher.filesToPublish
|
test
|
public function filesToPublish($path)
{
$fs = $this->filesystem();
if( ! $fs->exists($path) && ! $fs->isDirectory($path))
{
throw new \InvalidArgumentException("$path set to be published in does not exist.");
|
php
|
{
"resource": ""
}
|
q265684
|
User.init
|
test
|
public function init()
{
parent::init();
if ($this->identityClass === null) {
throw new InvalidConfigException('User::identityClass must be set.');
}
if ($this->enableAutoLogin && !isset($this->identityCookie['name'])) {
throw new InvalidConfigException('User::identityCookie must contain the "name" element.');
}
|
php
|
{
"resource": ""
}
|
q265685
|
User.login
|
test
|
public function login(IdentityInterface $identity, $duration = 0)
{
//Using root resolve function for promise conversion
return resolve(true)
->then(function() use (&$identity, $duration) {
return $this->beforeLogin($identity, false, $duration);
})->then(function() use (&$identity, $duration) {
$this->switchIdentity($identity, $duration);
|
php
|
{
"resource": ""
}
|
q265686
|
User.regenerateCsrfToken
|
test
|
protected function regenerateCsrfToken()
{
$request = $this->request;
if ($request->enableCsrfCookie
|
php
|
{
"resource": ""
}
|
q265687
|
User.loginByCookie
|
test
|
protected function loginByCookie()
{
return $this->getIdentityAndDurationFromCookie()
->then(function($data) {
if (isset($data['identity'], $data['duration'])) {
/** @var IdentityInterface $identity */
$identity = $data['identity'];
$duration = $data['duration'];
return $this->beforeLogin($identity, true, $duration)
->then(function() use (&$identity, $duration) {
$this->switchIdentity($identity, $this->autoRenewCookie ? $duration : 0);
$id = $identity->getId();
$ip = $this->request->getUserIP();
|
php
|
{
"resource": ""
}
|
q265688
|
User.getReturnUrl
|
test
|
public function getReturnUrl($defaultUrl = null)
{
$url = $this->app->session->get($this->returnUrlParam, $defaultUrl);
if (is_array($url)) {
if (isset($url[0])) {
return $this->app->urlManager->createUrl($url);
|
php
|
{
"resource": ""
}
|
q265689
|
User.loginRequired
|
test
|
public function loginRequired($checkAjax = true, $checkAcceptHeader = true)
{
$request = $this->request;
$canRedirect = !$checkAcceptHeader || $this->checkRedirectAcceptable();
if ($this->enableSession
&& $request->getIsGet()
&& (!$checkAjax || !$request->getIsAjax())
&& $canRedirect
) {
$this->setReturnUrl($request->getUrl());
}
if ($this->loginUrl !== null && $canRedirect) {
|
php
|
{
"resource": ""
}
|
q265690
|
User.renewIdentityCookie
|
test
|
protected function renewIdentityCookie()
{
$name = $this->identityCookie['name'];
$value = $this->request->getCookies()->getValue($name);
if ($value !== null) {
$data = json_decode($value, true);
if (is_array($data) && isset($data[2])) {
|
php
|
{
"resource": ""
}
|
q265691
|
User.renewAuthStatus
|
test
|
protected function renewAuthStatus()
{
$session = $this->app->session;
$id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($this->idParam) : null;
if ($id === null) {
$identityPromise = resolve(null);
} else {
/* @var $class IdentityInterface */
$class = $this->identityClass;
$identityPromise = $class::findIdentity($id);
}
return $identityPromise
->then(function($identity) use ($session) {
/** @var IdentityInterface $identity */
$this->setIdentity($identity);
$logoutPromise = resolve(true);
if ($identity !== null && ($this->authTimeout !== null || $this->absoluteAuthTimeout !== null)) {
$expire = $this->authTimeout !== null ? $session->get($this->authTimeoutParam) : null;
$expireAbsolute = $this->absoluteAuthTimeout !== null ? $session->get($this->absoluteAuthTimeoutParam) : null;
if ($expire !== null && $expire < time() || $expireAbsolute !== null && $expireAbsolute < time()) {
$logoutPromise = $this->logout(false);
|
php
|
{
"resource": ""
}
|
q265692
|
User.can
|
test
|
public function can($permissionName, $params = [], $allowCaching = true)
{
//Special permissions for logged in status handling
if (in_array($permissionName, [static::PERMISSION_NOT_LOGGED_IN, static::PERMISSION_LOGGED_IN])) {
$isGuest = $this->getIsGuest();
if ($isGuest && static::PERMISSION_NOT_LOGGED_IN || !$isGuest && static::PERMISSION_LOGGED_IN) {
return resolve(true);
}
return reject(new Error("Uses::can() - denied by logged in status"));
}
if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
return $this->_access[$permissionName]
? resolve(true)
: reject(new Error("Uses::can() - denied"));
}
|
php
|
{
"resource": ""
}
|
q265693
|
Day.getDaysOfWeek
|
test
|
public static function getDaysOfWeek(): array
{
return [
self::WEEK_DAY_MONDAY,
self::WEEK_DAY_TUESDAY,
self::WEEK_DAY_WEDNESDAY,
self::WEEK_DAY_THURSDAY,
|
php
|
{
"resource": ""
}
|
q265694
|
File.save
|
test
|
public function save($dir, $filename = null)
{
// clean
$dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if(!$filename) {
|
php
|
{
"resource": ""
}
|
q265695
|
QueryBuilder.execute
|
test
|
public function execute()
{
if ($this->type == self::SELECT) {
return $this->connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes);
} else {
|
php
|
{
"resource": ""
}
|
q265696
|
QueryBuilder.delete
|
test
|
public function delete($delete = null, $alias = null)
{
$this->type = self::DELETE;
if (!$delete) {
|
php
|
{
"resource": ""
}
|
q265697
|
QueryBuilder.insert
|
test
|
public function insert($insert = null)
{
$this->type = self::INSERT;
if (!$insert) {
|
php
|
{
"resource": ""
}
|
q265698
|
QueryBuilder.innerJoin
|
test
|
public function innerJoin($fromAlias, $join, $alias, $condition = null)
{
return $this->add('join', array(
$fromAlias => array(
'joinType' => 'inner',
|
php
|
{
"resource": ""
}
|
q265699
|
QueryBuilder.where
|
test
|
public function where($predicates)
{
if (!(func_num_args() == 1 && $predicates instanceof CompositeExpression)) {
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.