_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q29300
DAL.identifierQuotes
train
protected function identifierQuotes($str) { #for every word return preg_replace_callback('/(?<![\.a-zA-Z0-9_'.$this->quote.'\(\)])[a-z_][a-zA-Z0-9._]*/', function($matches) { $res = []; foreach(explode('.', $matches[0]) as $substr) { if(preg_match('/^[a-z_][a-zA-Z0-9_]*$/', $substr)) $res[] = $...
php
{ "resource": "" }
q29301
DAL.buildColumns
train
protected function buildColumns() { $select = []; $params = []; if(!$this->columns) return ['*', []]; else { foreach($this->columns as $alias=>$column) { if($column instanceof static) { $sql = $column->buildSQL(); $params = array_merge($params, $column->getParameters()); $sele...
php
{ "resource": "" }
q29302
DAL.getDefaultTable
train
protected function getDefaultTable($real=false) { if(count($this->tables) === 1) { if($real) return array_values($this->tables)[0]; else return array_keys($this->tables)[0]; } else return null; }
php
{ "resource": "" }
q29303
DAL.buildWhere
train
protected function buildWhere($default=null) { $r = $this->processConditions($this->where, 'and', false, $default!==null ? $default:$this->getDefaultTable()); if($r[0]) return ["\n".'WHERE '.$r[0], $r[1]]; else return ['', []]; }
php
{ "resource": "" }
q29304
DAL.buildGroupBy
train
protected function buildGroupBy() { if(!$this->groupBy || !$this->groupBy[0]) return ['', []]; $groupBy = $this->groupBy; $groupBySql = $groupBy[0]; $groupByParameters = $groupBy[1]; $res = []; foreach(explode(',', $groupBySql) as $column) { if($this->isIdentifier(trim($column))) $r...
php
{ "resource": "" }
q29305
DAL.buildOrderby
train
protected function buildOrderby() { if(!$this->orderBy || !$this->orderBy[0]) return ['', []]; $res = []; $orderBy = $this->orderBy; $orderBySql = $orderBy[0]; $orderByParameters = $orderBy[1]; foreach(explode(',', $orderBySql) as $orderbystr) { $orderbystr = trim($orderbystr); pre...
php
{ "resource": "" }
q29306
DAL.buildJointures
train
protected function buildJointures() { $params = []; $jointures = ''; foreach($this->joins as $alias=>$jointure) { $type = $jointure[0]; $table = $jointure[1]; $conditions = $jointure[2]; $alias = $alias !== $table ? $alias:null; $res = $this->buildJointure($type, $table, $conditions, $alias...
php
{ "resource": "" }
q29307
DAL.buildJointure
train
protected function buildJointure($type, $table, $conditions, $alias=null) { $params = []; $jointure = ''; switch($type) { case 'leftjoin': $jointure = "\n".'LEFT JOIN '; break; case 'rightjoin': $jointure = "\n".'RIGHT JOIN '; break; case 'innerjoin': $jointure = "\n".'INNE...
php
{ "resource": "" }
q29308
DAL.buildTables
train
protected function buildTables($with_alias=true) { $tables = []; $params = []; if(!$this->tables) throw new \Exception('Must set tables with method from($tables) before running the query.'); foreach($this->tables as $alias=>$table) { if($table instanceof static) { $tables[] = '('.$table->buildS...
php
{ "resource": "" }
q29309
DAL.replaceRaws
train
protected function replaceRaws(&$sql, &$params) { $i = 0; $sql = preg_replace_callback('/\?/', function() use(&$i, &$params) { if($params[$i] instanceof static) { $r = $params[$i]; $sql = $r->buildSQL(); $params = array_merge(array_slice($params, 0, $i), $r->getParameters(), array_slice($params...
php
{ "resource": "" }
q29310
DAL.buildSQL
train
public function buildSQL($union=false) { $params = []; list($tables, $tableparams) = $this->buildTables(); $params = array_merge($params, $tableparams); list($columns, $columnsparams) = $this->buildColumns(); $params = array_merge($params, $columnsparams); list($jointures, $joinparams) = $this->...
php
{ "resource": "" }
q29311
DAL.replaceTableInConditions
train
public function replaceTableInConditions($conditions, $oldTable, $newTable) { foreach($conditions as $k=>$v) { if(is_array($v)) $v = $this->replaceTableInConditions($v, $oldTable, $newTable); else $v = preg_replace('/(?<![a-zA-Z0-9_])'.$oldTable.'\./', $newTable.'.', $v); if(is_string($k)) { ...
php
{ "resource": "" }
q29312
DAL.replaceTable
train
public function replaceTable($oldTable, $newTable) { $this->where = $this->replaceTableInConditions($this->where, $oldTable, $newTable); $this->joins = $this->replaceTableInConditions($this->joins, $oldTable, $newTable); #using regex to replace table names not preceded by one of the following character if($...
php
{ "resource": "" }
q29313
DAL.values
train
public function values($column) { $res = []; while($row = $this->next()) $res[] = $row[$column]; return $res; }
php
{ "resource": "" }
q29314
DAL.update
train
public function update(array $values) { $sql = $this->buildUpdateSQL($values); $params = $this->getParameters(); return $this->db->query($sql, $params)->affected(); }
php
{ "resource": "" }
q29315
DAL.delete
train
public function delete(array $tables=[]) { $sql = $this->buildDeleteSQL($tables); $params = $this->getParameters(); return $this->db->query($sql, $params)->affected(); }
php
{ "resource": "" }
q29316
DAL._function
train
protected function _function($fct, $what=null, $group_by=null) { if($what === null) $what = '*'; $fct = strtoupper($fct); $clone = clone $this; if($fct === 'COUNT') { $clone->offset(null); $clone->limit(null); } $alias = strtolower($fct); if($group_by) { $dal = new static($this-...
php
{ "resource": "" }
q29317
DAL.count
train
public function count($what=null, $group_by=null) { $r = $this->_function('COUNT', $what, $group_by); if(!is_array($r)) $r = (int)$r; return $r; }
php
{ "resource": "" }
q29318
DAL.replaceParams
train
protected function replaceParams($sql, array $params) { $i=0; return preg_replace_callback('/\?/', function() use(&$i, $params, $sql) { $rep = $params[$i++]; if(!$rep instanceof Raw && !$rep instanceof static) return "'".addslashes($rep)."'"; else return '?'; }, $sql); }
php
{ "resource": "" }
q29319
DAL.dbgSelect
train
public function dbgSelect() { $sql = $this->buildSQL(); $params = $this->getParameters(); return $this->replaceParams($sql, $params); }
php
{ "resource": "" }
q29320
DAL.dbgUpdate
train
public function dbgUpdate(array $values) { $sql = $this->buildUpdateSQL($values); $params = $this->getParameters(); return $this->replaceParams($sql, $params); }
php
{ "resource": "" }
q29321
DAL.dbgInsert
train
public function dbgInsert(array $values, array $update=[], array $contraint=[]) { $sql = $this->buildInsertSQL([$values], $update, $constraint); $params = $this->getParameters(); return $this->replaceParams($sql, $params); }
php
{ "resource": "" }
q29322
DAL.dbgInsertMany
train
public function dbgInsertMany(array $rows, array $update=[], array $constraint=[]) { $sql = $this->buildInsertSQL($rows, $update, $constraint); $params = $this->getParameters(); return $this->replaceParams($sql, $params); }
php
{ "resource": "" }
q29323
DAL.dbgDelete
train
public function dbgDelete(array $tables=[]) { $sql = $this->buildDeleteSQL($tables); $params = $this->getParameters(); return $this->replaceParams($sql, $params); }
php
{ "resource": "" }
q29324
BaseCommand.verbose
train
protected function verbose($message, $level) { if ($this->output->getVerbosity() >= $level) { $this->output->write($message); } }
php
{ "resource": "" }
q29325
BaseCommand.doesUrlMatchToAtLeastOnePattern
train
protected function doesUrlMatchToAtLeastOnePattern($url, array $patterns) { foreach ($patterns as $pattern) { $regex = '|' . $pattern . '|'; $this->verbose( "Checking url '" . $url . "' with regex '" . $regex . "' -> ", OutputInterface::VERBOSITY_VERBO...
php
{ "resource": "" }
q29326
AdminUtilities.generateSortableColumnHeader
train
public function generateSortableColumnHeader($params, &$smarty) { // The current order of the table $current_order = $this->getParam($params, 'current_order'); // The column ascending order $order = $this->getParam($params, 'order'); // The column descending order label ...
php
{ "resource": "" }
q29327
CommandTrait.splash
train
protected function splash($text, $hide_splash = false) { if (!$hide_splash) { $this->line(''); $this->line(' ___ _ _ '); $this->line(' / \ __ _ | |_ __ _ ___ ___ | |_ ___ '); $this->line(" / /\ // _` || __|/ _` |/...
php
{ "resource": "" }
q29328
CommandTrait.getDatasets
train
protected function getDatasets($dataset = false) { $source_packages = config('datasets.source', []); $result = []; foreach ($source_packages as $folder) { // Get folder contents of datasets $datasets = new Filesystem(new Adapter(base_path('vendor/'.$folder.'/datase...
php
{ "resource": "" }
q29329
CommandTrait.loadConfig
train
protected function loadConfig($dataset) { $config_file = $this->getDatasets($dataset); $config = include $config_file; $this->checkConfig($config); return $config; }
php
{ "resource": "" }
q29330
CommandTrait.checkConfig
train
protected function checkConfig($config) { $required_fields = ['namespace', 'table', 'path', 'mapping', 'import_keys']; foreach ($required_fields as $key) { if (!array_has($config, $key)) { $this->error(sprintf('Missing \'%s\' from the dataset configuration file.', $key))...
php
{ "resource": "" }
q29331
CommandTrait.verifyConnection
train
protected function verifyConnection() { if (count(config('database.connections', [])) > 1) { $connections = array_keys(config('database.connections')); $default = array_search(config('database.default'), $connections); return $this->choice('Which connection do we use?', ...
php
{ "resource": "" }
q29332
CommandTrait.getNextInteration
train
private function getNextInteration() { // Get the next interator. $migrations = new Filesystem(new Adapter(base_path('database/migrations'))); try { $files = $migrations->listContents(); } catch (\Exception $exception) { $this->error($exception->getMessage())...
php
{ "resource": "" }
q29333
Report.fullMessage
train
public function fullMessage() { if($this->self) $str = (string)$this->self.':'; else $str = (string)$this->first().':'; foreach($this->rules as $rule) $str .= "\n\t".$rule; foreach($this->attributes as $attribute) $str .= "\n\t".$attribute->first(); return $str; }
php
{ "resource": "" }
q29334
Report.error
train
public function error($rule=null) { if($rule === null) return $this->self; elseif(isset($this->rules[$rule])) return $this->rules[$rule]; elseif($attribute = $this->attribute($rule)) return $attribute->error(); }
php
{ "resource": "" }
q29335
Report.errors
train
public function errors($nested=true) { $errors = $this->rules; foreach($this->attributes as $attribute=>$report) $errors[$attribute] = $nested ? $report->errors():$report->error(); return $errors; }
php
{ "resource": "" }
q29336
Report.first
train
public function first($attribute=null) { if($attribute !== null) return $this->attribute($attribute)->first(); else { if($this->rules) return array_values($this->rules)[0]; elseif($this->attributes) return array_values($this->attributes)[0]->error(); } }
php
{ "resource": "" }
q29337
Report.failed
train
public function failed() { $failed = []; foreach($this->attributes as $attribute=>$report) { $attrFailed = $report->failed(); if($attrFailed) $failed[$attribute] = $attrFailed; else $failed[] = $attribute; } return $failed; }
php
{ "resource": "" }
q29338
Report.attribute
train
public function attribute($attribute, Report $report=null) { if(is_string($attribute)) $attribute = explode('.', $attribute); $next = array_shift($attribute); if(!isset($this->attributes[$next])) $this->attributes[$next] = new static; if($report !== null) { if(count($attribute) == 0) $this->attri...
php
{ "resource": "" }
q29339
CheckSrcCommand.searchUrlPatterns
train
protected function searchUrlPatterns(\stdClass $json, array $patterns) { $errors = array(); foreach ($json->packages as $package) { if (!isset($package->source)) { $this->verbose('Source not found in "' . $package->name . "\"\n", OutputInterface::VERBOSITY_VERBOSE); ...
php
{ "resource": "" }
q29340
SwiftMailerConverter.convert
train
public function convert(Email $email): \Swift_Message { $message = $this->createInstance()->setSubject($email->getSubject()); $message->setBoundary($boundary = \md5(\uniqid())); $this->addAddresses($email, $message); $this->addParts($email, $message, $boundary); $this->addHe...
php
{ "resource": "" }
q29341
SwiftMailerConverter.addAddresses
train
protected function addAddresses(Email $notification, \Swift_Message $email) { foreach ($notification->getTo() as $to) { $this->addAddress($email, 'to', $to); } foreach ($notification->getCc() as $cc) { $this->addAddress($email, 'cc', $cc); } foreach ...
php
{ "resource": "" }
q29342
SwiftMailerConverter.addParts
train
protected function addParts(Email $notification, \Swift_Message $email, string $boundary) { $parts = $notification->getParts(); if (1 === \count($parts)) { $part = \reset($parts); $email->setBody($part->getContent(), $part->getContentType()); if ($encoder = $this...
php
{ "resource": "" }
q29343
SwiftMailerConverter.addAttachments
train
protected function addAttachments(Email $notification, \Swift_Message $email) { foreach ($notification->getAttachments() as $attachment) { $email->attach( new \Swift_Attachment( $attachment->getContent(), $attachment->getName(), ...
php
{ "resource": "" }
q29344
ResultSet.addResult
train
public function addResult(Result $result): self { $handler = $result->getHandlerName(); $this->results[$handler][] = $result; return $this; }
php
{ "resource": "" }
q29345
ResultSet.all
train
public function all(): array { $results = []; \array_walk_recursive($this->results, function ($v) use (&$results) { $results[] = $v; }); return $results; }
php
{ "resource": "" }
q29346
TabsPlugin.getTemplate
train
private function getTemplate() { if ($this->template) { return $this->template; } return $this->template = $this->twig->load('@EkynaCms/Editor/Block/tabs.html.twig'); }
php
{ "resource": "" }
q29347
MatisseSettings.initContext
train
function initContext (DocumentContext $ctx) { $ctx->condenseLiterals = $this->collapseWhitespace; $ctx->controllers = $this->controllers; $ctx->controllerNamespaces = $this->controllerNamespaces; $ctx->registerTags ($this->tags); $ctx->setFilterHandler ($this->filterHandler); $ctx...
php
{ "resource": "" }
q29348
MatisseSettings.registerControllers
train
function registerControllers (ModuleInfo $moduleInfo, array $mappings) { $ctr =& $this->controllers; foreach ($mappings as $path => $class) { $path = "$moduleInfo->path/{$this->viewEngineSettings->moduleViewsPath()}/$path"; $ctr[$path] = $class; } return $this; }
php
{ "resource": "" }
q29349
MatisseSettings.registerMacros
train
function registerMacros (ModuleInfo $moduleInfo) { $path = "{$this->kernelSettings->baseDirectory}/$moduleInfo->path/{$this->viewEngineSettings->moduleViewsPath()}/$this->moduleMacrosPath"; if (fileExists ($path)) { $all = FilesystemFlow::from ($path) ->onlyDirectories (...
php
{ "resource": "" }
q29350
ComponentException.properties
train
static private function properties (array $props) { return "<h6>Assigned properties</h6><table class=grid> " . str_replace (["'", '...'], ["<i>'</i>", '<i>...</i>'], implode ('', map ($props, function ($v, $k) { return "<tr><th>$k<td>" . (is_string ($v) ? "'" . htmlspecialchars ...
php
{ "resource": "" }
q29351
ContentManager.create
train
public function create($subjectOrName) { // Check if container or name is defined if ( !$subjectOrName instanceof ContentSubjectInterface && !(is_string($subjectOrName) && 0 < strlen($subjectOrName)) ) { throw new InvalidOperationException("Excepted instan...
php
{ "resource": "" }
q29352
ContentManager.fixContainersPositions
train
public function fixContainersPositions(ContentInterface $content) { $this->sortChildrenByPosition($content, 'containers'); $containers = $content->getContainers(); $position = 0; foreach ($containers as $container) { $container->setPosition($position); $posi...
php
{ "resource": "" }
q29353
Tilmeld.gatekeeper
train
public static function gatekeeper($ability = null) { if (!isset(self::$currentUser)) { return false; } return self::$currentUser->gatekeeper($ability); }
php
{ "resource": "" }
q29354
Tilmeld.configure
train
public static function configure($config = []) { $defaults = include dirname(__DIR__).'/conf/defaults.php'; self::$config = array_replace($defaults, $config); // Set up access control hooks when Nymph is called. if (!isset(Nymph::$driver)) { throw new Exception('Tilmeld can\'t be configured befor...
php
{ "resource": "" }
q29355
Tilmeld.fillSession
train
public static function fillSession($user) { if (!isset(self::$serverTimezone)) { self::$serverTimezone = date_default_timezone_get(); } self::$currentUser = $user; date_default_timezone_set($user->getTimezone()); self::$currentUser->updateDataProtection(); }
php
{ "resource": "" }
q29356
Tilmeld.clearSession
train
public static function clearSession() { $user = self::$currentUser; self::$currentUser = null; if (isset(self::$serverTimezone)) { date_default_timezone_set(self::$serverTimezone); } if ($user) { $user->updateDataProtection(); } }
php
{ "resource": "" }
q29357
Tilmeld.extractToken
train
public static function extractToken($token) { $extract = self::$config['jwt_extract']($token); if (!$extract) { return false; } $guid = $extract['guid']; $user = Nymph::getEntity( ['class' => '\Tilmeld\Entities\User'], ['&', 'guid' => $guid ] ); if (!...
php
{ "resource": "" }
q29358
Tilmeld.authenticate
train
public static function authenticate() { // If a client does't support cookies, they can use the X-TILMELDAUTH header // to provide the auth token. if (!empty($_SERVER['HTTP_X_TILMELDAUTH']) && empty($_COOKIE['TILMELDAUTH'])) { $fromAuthHeader = true; $authToken = $_SERVER['HTTP_X_TILMELDAUTH']; ...
php
{ "resource": "" }
q29359
Tilmeld.login
train
public static function login($user, $sendAuthHeader) { if (isset($user->guid) && $user->enabled) { $token = self::$config['jwt_builder']($user); $appUrlParts = parse_url(self::$config['app_url']); setcookie( 'TILMELDAUTH', $token, time() + self::$config['jwt_expire'],...
php
{ "resource": "" }
q29360
Tilmeld.logout
train
public static function logout() { self::clearSession(); $appUrlParts = parse_url(self::$config['app_url']); setcookie( 'TILMELDAUTH', '', null, $appUrlParts['path'], $appUrlParts['host'] ); }
php
{ "resource": "" }
q29361
Tilmeld.groupSort
train
public static function groupSort( &$array, $property = null, $caseSensitive = false, $reverse = false ) { Nymph::hsort($array, $property, 'parent', $caseSensitive, $reverse); }
php
{ "resource": "" }
q29362
Format.formatDate
train
public function formatDate($params, $template = null) { $date = $this->getParam($params, "date", false); if ($date === false) { // Check if we have a timestamp $timestamp = $this->getParam($params, "timestamp", false); if ($timestamp === false) { ...
php
{ "resource": "" }
q29363
Format.formatTwoDimensionalArray
train
public function formatTwoDimensionalArray($params) { $output = ''; $values = $this->getParam($params, "values", null); $separators = $this->getParam($params, "separators", [' : ', ' / ', ' | ']); if (!is_array($values)) { return $output; } foreach ($valu...
php
{ "resource": "" }
q29364
SlideShowGenerator.generateSlideShows
train
public function generateSlideShows() { foreach ($this->names as $tag => $name) { $this->output->write(sprintf( '- <comment>%s</comment> %s ', $name, str_pad('.', 44 - mb_strlen($name), '.', STR_PAD_LEFT) )); if (null !== $s...
php
{ "resource": "" }
q29365
ScheduleExtension.getColor
train
private function getColor(array $notes, $noteIndex) { if (!is_integer($noteIndex) || !array_key_exists($noteIndex, $notes)) { return null; } $noteObj = $notes[$noteIndex]; if (!is_object($noteObj) || !property_exists($noteObj, 'color')) { return null; ...
php
{ "resource": "" }
q29366
ScheduleExtension.getExposent
train
private function getExposent($noteIndex) { $footNote = $this->getFootNote($noteIndex); if (empty($footNote)) { return null; } return $footNote; }
php
{ "resource": "" }
q29367
ScheduleExtension.colorizeMminute
train
private function colorizeMminute($minute = '', array $colors = []) { $cleanedColors = array_filter($colors); if (empty($cleanedColors)) { return $minute; } return sprintf('<span class="block-color" style="background-color: %s">%s</span>', current($cleanedColors), $minut...
php
{ "resource": "" }
q29368
ScheduleExtension.addExponents
train
private function addExponents($minute = '', array $exponents = [], $notesType = null) { $cleanedExposents = array_filter($exponents); $exposantsNb = count($cleanedExposents); if ($notesType == LayoutConfig::NOTES_TYPE_COLOR && $exposantsNb < 2) { return $minute; } ...
php
{ "resource": "" }
q29369
Socket.setCloseOnError
train
public function setCloseOnError($close) { if (!is_bool($close)) { throw new \Plop\Exception('Invalid value'); } $this->closeOnError = $close; return $this; }
php
{ "resource": "" }
q29370
Socket.setInitialRetryDelay
train
public function setInitialRetryDelay($delay) { if (!(is_int($delay) || is_float($delay)) || $delay < 0) { throw new \Plop\Exception('Invalid value'); } $this->retryStart = $delay; return $this; }
php
{ "resource": "" }
q29371
Socket.setRetryFactor
train
public function setRetryFactor($factor) { if (!(is_int($factor) || is_float($factor)) || $factor < 1) { throw new \Plop\Exception('Invalid value'); } $this->retryFactor = $factor; return $this; }
php
{ "resource": "" }
q29372
Socket.setMaximumRetryDelay
train
public function setMaximumRetryDelay($max) { if (!(is_int($max) || is_float($max)) || $max < 0) { throw new \Plop\Exception('Invalid value'); } $this->retryMax = $max; return $this; }
php
{ "resource": "" }
q29373
Socket.makeSocket
train
protected function makeSocket($timeout = 1) { return fsockopen( 'tcp://' . $this->host, $this->port, $errno, $errstr, $timeout ); }
php
{ "resource": "" }
q29374
Socket.createSocket
train
protected function createSocket() { $now = $this->getCurrentTime(); if ($this->retryTime === null) { $attempt = true; } else { $attempt = ($now >= $this->retryTime); } if (!$attempt) { return; } $this->socket = $this->make...
php
{ "resource": "" }
q29375
Socket.send
train
protected function send($s) { if (!$this->socket) { $this->createSocket(); } if (!$this->socket) { return false; } $written = 0; while ($s != '') { $written = $this->write($s); if ($written === false) { ...
php
{ "resource": "" }
q29376
Socket.makePickle
train
protected function makePickle(\Plop\RecordInterface $record) { // To maintain full compatibility with Python, // we should emulate pickle here, but it seems // to be quite some work and PHP already has // it's own serialization mechanism anyway. $s = serialize($record); ...
php
{ "resource": "" }
q29377
ThemeTrait.setActiveTheme
train
public function setActiveTheme($themeName = '') { Event::fire('theme.before_is_set', [$this]); if($themeName) { if(!self::ifExists($themeName)) { throw new \Exception($themeName . ' Theme could not be found in file directory.'); } }else{ ...
php
{ "resource": "" }
q29378
ThemeTrait.getConfig
train
public static function getConfig($themeDirectory) { $getConfigValues = []; // make absolute path work if(is_dir($themeDirectory)) { $path = $themeDirectory.'/config.json'; }else{ $path = base_path()."/themes/".$themeDirectory.'/config.json'; } ...
php
{ "resource": "" }
q29379
ThemeTrait.getNamespaceOf
train
public static function getNamespaceOf($themeDirectoryName) { if(self::ifExists($themeDirectoryName)) { $themeConfig = self::getConfig($themeDirectoryName); if(isset($themeConfig['namespace'])) { return "Themes\\" . $themeConfig['namespace']; } } ...
php
{ "resource": "" }
q29380
ThemeTrait.view
train
public static function view($view, $itemID = null) { $baseViewsPath = self::getActiveTheme().'/views/'.$view; // General By ID: {template}-{ID}.blade.php $newView = '-' . $itemID; if ($itemID && self::viewExists($view.$newView)) { return $baseViewsPath.$newView; ...
php
{ "resource": "" }
q29381
ThemeTrait.configs
train
public static function configs() { $files = File::allFiles(base_path().'/themes'); $result = []; foreach ($files as $file){ if($file->getBasename() == "config.json") { $result[] = self::getConfig($file->getPath()); } } return $result; ...
php
{ "resource": "" }
q29382
CoreFunction.mock
train
public static function mock(string $function): MockedFunction { $mock = new MockedFunction($function); self::$mocks[] = $mock; $closure = new ClosureGenerator($function); uopz_set_return($function, $closure->generate(), true); return $mock; }
php
{ "resource": "" }
q29383
CoreFunction.call
train
public static function call(string $function, Arguments $arguments) { $mocks = self::$mocks; $mocks = array_filter($mocks, function (MockedFunction $mock) use ($function) { return $mock->getFunctionName() === $function; }); # First try functions that expect the exact ar...
php
{ "resource": "" }
q29384
CoreFunction.close
train
public static function close(): void { $mocks = self::$mocks; self::$mocks = []; foreach ($mocks as $mock) { uopz_unset_return($mock->getFunctionName()); } foreach ($mocks as $mock) { $function = $mock->getFunctionName(); $arguments = $mo...
php
{ "resource": "" }
q29385
ArrayInput.dotGet
train
private function dotGet(string $name) { $data = $this->data; //Generating path relative to a given name and prefix $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; if (empty($path)) { return $data; } $path = explode('.', rtrim($path, '...
php
{ "resource": "" }
q29386
FileFolderSharedValidation.validateFile
train
public function validateFile(Entity\File $file, $sourceFilePath = null) { $this->validate($file, self::TYPE_FILE, $sourceFilePath); }
php
{ "resource": "" }
q29387
DoctrineNode.belongsTo
train
public function belongsTo(NodeInterface $node) { parent::belongsTo($node); $rep = $this->sourceRepository; if ( ! ($rep instanceof RepositoryInterface)) { throw new Exception\WrongInstance($rep, 'RepositoryInterface'); } $nestedSetRepository = $rep->getNestedSetRepository(); /* @var $nestedSetRepositor...
php
{ "resource": "" }
q29388
DoctrineNode.free
train
public function free(EntityNodeInterface $entity) { $this->repository->free($entity); $this->repository = null; }
php
{ "resource": "" }
q29389
Message.getCommandLine
train
public function getCommandLine() { if (\Yii::$app === null || !$this->getIsConsoleRequest()) { return null; } $params = []; if (isset($_SERVER['argv'])) { $params = $_SERVER['argv']; } return implode(' ', $params); }
php
{ "resource": "" }
q29390
Message.getIsConsoleRequest
train
public function getIsConsoleRequest() { if ($this->_isConsoleRequest === null && \Yii::$app !== null) { if (\Yii::$app->getRequest() instanceof ConsoleRequest) { $this->_isConsoleRequest = true; } elseif (\Yii::$app->getRequest() instanceof WebRequest) { ...
php
{ "resource": "" }
q29391
Message.getSessionId
train
public function getSessionId() { if ( \Yii::$app !== null && \Yii::$app->has('session', true) && \Yii::$app->getSession() !== null && \Yii::$app->getSession()->getIsActive() ) { return \Yii::$app->getSession()->getId(); } else { ...
php
{ "resource": "" }
q29392
Message.getStackTrace
train
public function getStackTrace() { if (!isset($this->message[4]) || empty($this->message[4])) { return null; } $traces = array_map(function ($trace) { return "in {$trace['file']}:{$trace['line']}"; }, $this->message[4]); return implode("\n", $traces); ...
php
{ "resource": "" }
q29393
Message.getText
train
public function getText() { $text = $this->message[0]; if (!is_string($text)) { if ($text instanceof \Throwable || $text instanceof \Exception) { $text = (string) $text; } else { $text = VarDumper::export($text); } } ...
php
{ "resource": "" }
q29394
Message.getUrl
train
public function getUrl() { if (\Yii::$app === null || $this->getIsConsoleRequest()) { return null; } return \Yii::$app->getRequest()->getAbsoluteUrl(); }
php
{ "resource": "" }
q29395
Message.getUserId
train
public function getUserId() { if ( \Yii::$app !== null && \Yii::$app->has('user', true) && \Yii::$app->getUser() !== null ) { $user = \Yii::$app->getUser()->getIdentity(false); if ($user !== null) { return $user->getId(); ...
php
{ "resource": "" }
q29396
RandomReader.getPointer
train
private function getPointer() { if (!isset($this->pointer)) { $this->pointer = fopen($this->source, 'r'); // File read buffering is not supported on HHVM if (!defined('HHVM_VERSION')) { stream_set_chunk_size($this->pointer, 32); stream_set...
php
{ "resource": "" }
q29397
Translation.translate
train
public function translate($params, &$smarty) { // All parameters other than 'l' and 'd' and 'js' are supposed to be variables. Build an array of var => value pairs // and pass it to the translator $vars = array(); foreach ($params as $name => $value) { if (!in_array($nam...
php
{ "resource": "" }
q29398
DBException.setSQL
train
public function setSQL($sql, array $args=[]) { $this->sql = $sql; $this->args = $args; $this->message = $this->getMessage(); if(strlen($sql) > 2048) return $this; $msg = '<br/>'."\n".'SQL: '.$sql; if(count($args) > 0) { $msg .= ' ('.implode(', ', $args).')'; if(strlen($msg) > 2048) return $th...
php
{ "resource": "" }
q29399
RequireUtil.renderHtmlTag
train
public static function renderHtmlTag(array $attributes, $htmlTag, $shortEndTag) { $output = '<'.$htmlTag; foreach ($attributes as $attr => $value) { if (static::isValidValue($value)) { $output .= ' '.$attr.'="'.$value.'"'; } } $output .= $sho...
php
{ "resource": "" }