_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q260300
Media.getPublicPath
test
public function getPublicPath() { $mediaPath = config('system.assets.attachment.path', '/storage/app/attachments'); $mediaPath = $this->isPublic()
php
{ "resource": "" }
q260301
Media.getTempPath
test
public function getTempPath() { $path = temp_path().'/attachments'; if (!File::isDirectory($path))
php
{ "resource": "" }
q260302
PostgresqlTrait.typeEnum
test
public function typeEnum(Fluent $column) { $values = array_map(function ($a) { return "'{$a}'"; }, $column->get('values')); $maxlen = 0; foreach ($values as $value) {
php
{ "resource": "" }
q260303
PostgresqlTrait.typeTime
test
public function typeTime(Fluent $column) { if (!empty($column['precision'])) { return [ 'type' => $this->compileTimableColumn($column, 'TIME'),
php
{ "resource": "" }
q260304
PostgresqlTrait.typeTimestamp
test
public function typeTimestamp(Fluent $column) { if (!empty($column['precision'])) { return [ 'type' => $this->compileTimableColumn($column, 'TIMESTAMP'),
php
{ "resource": "" }
q260305
Streaming.curlWriteFunction
test
protected function curlWriteFunction($ch, $content) { if (!$this->hasStarted) { $this->hasStarted = true; $this->getEventsManager()->fire(self::EVENT_START, $this); }
php
{ "resource": "" }
q260306
AssetsJsTask.mainAction
test
public function mainAction() { $this->line('Compiling js... '); $options = $this->config->assets->js->toArray(); $result = $this->getDI()->get(ClosureCompiler::class)->compile($options); if (!empty($result['errors'])) { $this->outputErrors($result['errors'], 'errors', ...
php
{ "resource": "" }
q260307
RegisterTastyIgniter.bootstrap
test
public function bootstrap(Application $app) { // Workaround for CLI and URL based in subdirectory if ($app->runningInConsole()) { $app['url']->forceRootUrl($app['config']->get('app.url')); } // Register singletons $app->singleton('string', function () { ...
php
{ "resource": "" }
q260308
RegisterTastyIgniter.normalizeUrl
test
protected function normalizeUrl($url) { if (substr($url, 0, 1) != '/') $url = '/'.$url;
php
{ "resource": "" }
q260309
Router.add
test
public function add($pattern, $paths = null, $httpMethods = null) { foreach ($httpMethods as $httpMethod) {
php
{ "resource": "" }
q260310
Router.addGet
test
public function addGet($pattern, $paths = null) {
php
{ "resource": "" }
q260311
Router.addPost
test
public function addPost($pattern, $paths = null) {
php
{ "resource": "" }
q260312
Router.addPut
test
public function addPut($pattern, $paths = null) {
php
{ "resource": "" }
q260313
Router.addPatch
test
public function addPatch($pattern, $paths = null) {
php
{ "resource": "" }
q260314
Router.addDelete
test
public function addDelete($pattern, $paths = null) {
php
{ "resource": "" }
q260315
Router.addOptions
test
public function addOptions($pattern, $paths = null) {
php
{ "resource": "" }
q260316
Router.addHead
test
public function addHead($pattern, $paths = null) {
php
{ "resource": "" }
q260317
Template.render
test
public function render($context = []) { $this->mergeGlobals($context); unset($context['this']); $obLevel = ob_get_level(); ob_start(); extract($context); // We'll evaluate the contents of the view inside a try/catch block so we can // flush out any stray o...
php
{ "resource": "" }
q260318
SourceResolver.source
test
public function source($name = null) { if (is_null($name)) {
php
{ "resource": "" }
q260319
MigrationCreator.create
test
public function create($name, $path, $table = null, $create = false) { $this->ensureMigrationDoesntAlreadyExist($name, $path); $stub = $this->getStubContent($table, $create); $populatedStub = $this->populateStub($name, $stub, $table);
php
{ "resource": "" }
q260320
MigrationCreator.ensureMigrationDoesntAlreadyExist
test
protected function ensureMigrationDoesntAlreadyExist($name, $path) { if (class_exists($className = $this->getClassName($name))) { throw new InvalidArgumentException("A {$className} class already exists."); } // TODO Review check for version 2.0 if(!empty($files
php
{ "resource": "" }
q260321
MigrationCreator.getStubContent
test
protected function getStubContent($table, $create) { if (is_null($table)) { $file = $this->stubsPath() . '/blank.stub'; } else { $stub = $create ? 'create.stub' : 'update.stub';
php
{ "resource": "" }
q260322
MigrationCreator.getPath
test
protected function getPath($name, $path) { if (!is_null($prefix = $this->prefix->getPrefix())) { $prefix .= '_';
php
{ "resource": "" }
q260323
Activity.scopeCausedBy
test
public function scopeCausedBy(Builder $query, Model $causer) { return $query
php
{ "resource": "" }
q260324
Activity.scopeForSubject
test
public function scopeForSubject(Builder $query, Model $subject) { return $query
php
{ "resource": "" }
q260325
ConfigRewrite.buildArrayExpression
test
protected function buildArrayExpression($targetKey, $arrayItems = []) { $expression = []; // Opening expression for array items ($1) $expression[] = $this->buildArrayOpeningExpression($arrayItems); // The target key opening ($2) $expression[] = '([\'|"]'.$targetKey.'[\'|"]\...
php
{ "resource": "" }
q260326
BaseTask.getMigrationPaths
test
protected function getMigrationPaths() { // Here, we will check to see if a path option has been defined. If it has we will // use the path relative to the root of the installation folder so our database // migrations may be run for any customized path from within the application. if...
php
{ "resource": "" }
q260327
ViewClearTask.mainAction
test
public function mainAction() { $compileDir = $this->config->view->compiled_path;
php
{ "resource": "" }
q260328
Request.setParams
test
public function setParams($parameters, $merge = false) { if ($merge) { $this->params = array_merge($this->params, $parameters); } else {
php
{ "resource": "" }
q260329
Request.setHeaders
test
public function setHeaders($headers, $merge = false) {
php
{ "resource": "" }
q260330
Request.setProxy
test
public function setProxy($host, $port = 8080, $access = null) { $this->proxy = [ 'host' => $host, 'port' => $port,
php
{ "resource": "" }
q260331
Request.setCookies
test
public function setCookies($cookies, $merge = false) { if ($merge) { $this->cookies = array_merge($this->cookies, $cookies); } else {
php
{ "resource": "" }
q260332
Request.setCookie
test
public function setCookie($key, $value) { if (is_null($key)) { $this->cookies[] = $value; } else {
php
{ "resource": "" }
q260333
Request.setOptions
test
public function setOptions($options, $merge = false) { if ($merge) { $this->options = array_merge($this->options, $options); } else {
php
{ "resource": "" }
q260334
Request.send
test
public function send() { $this ->buildParams() ->buildProxy()
php
{ "resource": "" }
q260335
Request.request
test
public function request($method, $uri, array $params = [], array $options = []) { $this ->setMethod($method) ->setUri($uri); if (!empty($params)) { $this->setParams($params, true);
php
{ "resource": "" }
q260336
Blueprint.build
test
public function build(Db $db, DialectInterface $grammar) { switch ($this->action) { case 'create': return $this->buildCreate($db, $grammar); case 'update': return $this->buildUpdate($db, $grammar); case 'dropIfExists': retur...
php
{ "resource": "" }
q260337
Blueprint.buildTableDefinition
test
protected function buildTableDefinition(DialectInterface $grammar) { // Manage primary key / multiple primary keys $primaries = []; // Extract defined primary index foreach ($this->indexes as $key => $index) { if ($index->get('type') == 'PRIMARY') { forea...
php
{ "resource": "" }
q260338
Blueprint.buildCommands
test
protected function buildCommands(Db $db) { $columns = $db->describeColumns($this->table, $this->schema); foreach ($this->columns as $column) { $this->buildIndexAndForeignFromFluentColumn($column); foreach ($columns as $c) { if ($c->getName() === $column->get(...
php
{ "resource": "" }
q260339
Blueprint.index
test
public function index($columns, $name = null, $type = __FUNCTION__) {
php
{ "resource": "" }
q260340
Blueprint.float
test
public function float($column, $scale = null) { return $this->addColumn(__FUNCTION__, $column,
php
{ "resource": "" }
q260341
Blueprint.double
test
public function double($column, $scale = null) { return $this->addColumn(__FUNCTION__, $column,
php
{ "resource": "" }
q260342
Blueprint.decimal
test
public function decimal($column, $scale = null) { return $this->addColumn(__FUNCTION__, $column,
php
{ "resource": "" }
q260343
Blueprint.nullableTimestamps
test
public function nullableTimestamps($precision = 0) { $this->timestamps($precision);
php
{ "resource": "" }
q260344
Blueprint.nullableTimestampsTz
test
public function nullableTimestampsTz($precision = 0) { $this->timestampsTz($precision);
php
{ "resource": "" }
q260345
Blueprint.morphs
test
public function morphs($name, $indexName = null) { $this->unsignedInteger("{$name}_id"); $this->string("{$name}_type");
php
{ "resource": "" }
q260346
Blueprint.nullableMorphs
test
public function nullableMorphs($name, $indexName = null) { $this->unsignedInteger("{$name}_id")->nullable();
php
{ "resource": "" }
q260347
Blueprint.addColumn
test
protected function addColumn($type, $name, array $parameters = []) { return $this->columns[$name] =
php
{ "resource": "" }
q260348
Blueprint.createReferenceName
test
protected function createReferenceName(array $columns, $on, array $references) { $strColumns = implode('_', $columns); $strReferences = implode('_', $references); $rawReferenceName = [$this->table, $strColumns, 'foreign', $on, $strReferences]; $rawReferenceName = array_map(function...
php
{ "resource": "" }
q260349
Arr.add
test
public static function add($array, $key, $value) { if (is_null(self::get($array, $key))) {
php
{ "resource": "" }
q260350
Arr.collapse
test
public static function collapse($array) { $results = []; foreach ($array as $values) { if (!self::accessible($values)) { continue; }
php
{ "resource": "" }
q260351
Arr.read
test
public static function read($array, $key, $default = null) { if (is_null($key)) {
php
{ "resource": "" }
q260352
Arr.fetch
test
public static function fetch($array, $key, $default = null) { if (is_null($key)) {
php
{ "resource": "" }
q260353
Arr.pull
test
public static function pull(&$array, $key, $default = null) { $value = self::get($array, $key, $default);
php
{ "resource": "" }
q260354
Arr.map
test
public static function map($callback, array $array, $recursive = false) { if($recursive){ $func = function ($item) use (&$func, &$callback) {
php
{ "resource": "" }
q260355
Arr.explodePluckParameters
test
public static function explodePluckParameters($value, $key) { $value = is_string($value) ? explode('.', $value) : $value; $key = is_null($key) ||
php
{ "resource": "" }
q260356
Str.levenshtein
test
public static function levenshtein($word, $words, $order = SORT_ASC, $sort_flags = SORT_REGULAR) { foreach ($words as $w) { $result[$w] = levenshtein($word, $w); } if ($order & SORT_DESC) {
php
{ "resource": "" }
q260357
Str.capitalize
test
public static function capitalize($value) { static $capitalizeCache; $key = $value; if (isset($capitalizeCache[$key])) { return
php
{ "resource": "" }
q260358
Str.ucfirst
test
public static function ucfirst($string) {
php
{ "resource": "" }
q260359
StringFormatter.format
test
public function format(Location $location, string $format): string { $replace = [ self::STREET_NUMBER => $location->getStreetNumber(), self::STREET_NAME => $location->getStreetName(), self::LOCALITY => $location->getLocality(), self::POSTAL_CODE => $location->...
php
{ "resource": "" }
q260360
Url.register
test
protected function register() { $url = new \Phalcon\Mvc\Url(); $appConf = $this->getDI()->getShared(Services::CONFIG)->app; $url->setBaseUri($appConf->base_uri);
php
{ "resource": "" }
q260361
Script.getComposerCmd
test
protected function getComposerCmd() { if (!file_exists($this->getBasePath() . '/composer.phar')) {
php
{ "resource": "" }
q260362
StreamContext.buildParams
test
protected function buildParams() { if ($this->isPostMethod()) { $params = $this->params; if ($this->isJsonRequest()) { return $this ->setOption('content', $params = json_encode($params)) ->setHeader('Cont...
php
{ "resource": "" }
q260363
StreamContext.buildHeaders
test
protected function buildHeaders() { $headers = $this->header->build();
php
{ "resource": "" }
q260364
StreamContext.buildProxy
test
protected function buildProxy() { if (isset($this->proxy['host'])) { $uri = new Uri([ 'scheme' => 'tcp', 'host' => $this->proxy['host'], 'port' => isset($this->proxy['port']) ? $this->proxy['port'] : 80, ]);
php
{ "resource": "" }
q260365
StreamContext.buildCookies
test
protected function buildCookies() { if (!empty($this->cookies)) {
php
{ "resource": "" }
q260366
HasEvents.observe
test
public static function observe($class) { $instance = new static; $className = is_string($class) ? $class : get_class($class); // When registering a model observer, we will spin through the possible events // and determine if this observer has that method. If it does, we will hook ...
php
{ "resource": "" }
q260367
HasEvents.registerModelEvent
test
protected static function registerModelEvent($event, $callback, $priority = 0) { if (isset(static::$dispatcher)) { $name = static::class;
php
{ "resource": "" }
q260368
HasEvents.bootNicerEvents
test
protected function bootNicerEvents() { $class = get_called_class(); if (isset(static::$eventsBooted[$class])) { return; } $radicals = ['creat', 'sav', 'updat', 'delet', 'retriev']; $hooks = ['before' => 'ing', 'after' => 'ed']; foreach ($radicals as $ra...
php
{ "resource": "" }
q260369
HasEvents.flushEventListeners
test
public static function flushEventListeners() { if (!isset(static::$dispatcher)) { return; } $instance = new static;
php
{ "resource": "" }
q260370
Manager.createLocationModelQuery
test
protected function createLocationModelQuery() { $model = $this->createLocationModel(); $query = $model->newQuery();
php
{ "resource": "" }
q260371
Manager.getById
test
public function getById($identifier) { $query = $this->createLocationModelQuery(); $location
php
{ "resource": "" }
q260372
Manager.getBySlug
test
public function getBySlug($slug) { $model = $this->createLocationModel(); $query = $this->createLocationModelQuery();
php
{ "resource": "" }
q260373
FlashBag.message
test
public function message($message = null, $level = null) { // If no message was provided, we should update // the most recently added message. if (!$message) { return $this->updateLastMessage(compact('level')); } if (!$message instanceof
php
{ "resource": "" }
q260374
FlashBag.overlay
test
public function overlay($message = null, $title = '') { if (!$message) { return $this->updateLastMessage(['title' => $title, 'overlay' => TRUE]); }
php
{ "resource": "" }
q260375
FlashBag.clear
test
public function clear() { $this->store->forget($this->sessionKey);
php
{ "resource": "" }
q260376
Router.addTask
test
public function addTask($command, $class, $action = null, array $params = []) { $params['task'] = $class; $params['action'] = $action; preg_match_all('/\{([\w_]+)\}/', $command, $matches);
php
{ "resource": "" }
q260377
MigrationsServicesProvider.registering
test
public function registering() { $di = Di::getDefault(); $this->registerPrefix($di);
php
{ "resource": "" }
q260378
MigrationsServicesProvider.registerPrefix
test
protected function registerPrefix(DiInterface $di) { $di->set(PrefixInterface::class, function () { $config = $this->get(Services::CONFIG);
php
{ "resource": "" }
q260379
MigrationsServicesProvider.registerStorage
test
protected function registerStorage(DiInterface $di) { $di->set(StorageInterface::class, function () { $config = $this->get(Services::CONFIG);
php
{ "resource": "" }
q260380
AppServiceProvider.boot
test
public function boot() { if ($module = $this->getModule(func_get_args())) { // Register paths for: config, translator, view $modulePath = app_path($module);
php
{ "resource": "" }
q260381
Builder.like
test
public function like($column, $value, $side = 'both', $boolean =
php
{ "resource": "" }
q260382
Builder.pluckDates
test
public function pluckDates($column, $keyFormat = '%Y-%m', $valueFormat = '%F %Y') { $dates = []; $collection = $this->selectRaw("{$column}, MONTH({$column}) as month, YEAR({$column}) as year") ->groupBy([$column, 'month', 'year'])->get(); if ($collection) { ...
php
{ "resource": "" }
q260383
Builder.findOrNew
test
public function findOrNew($id, $columns = ['*']) { if (!is_null($model = $this->find($id, $columns))) { return $model; } $attributes = $this->toBase()->getConnection()->getSchemaBuilder()->getColumnListing($this->model->getTable());
php
{ "resource": "" }
q260384
Manager.user
test
public function user() { if ($this->loggedOut) { return null; } if (!is_null($this->user)) { return $this->user; } $user = null; if (!is_null($id = $this->retrieveIdentifier())) { $user = $this->retrieveUserByIdentifier($id); ...
php
{ "resource": "" }
q260385
Manager.logout
test
public function logout() { $this->user = null; $this->loggedOut = true;
php
{ "resource": "" }
q260386
Manager.login
test
public function login(User $user, $remember = false) { if (!$user) { return false; } $this->regenerateSessionId(); $this->{Services::SESSION}->set($this->sessionKey(), $user->getAuthIdentifier()); if ($remember) { $rememberToken = Str::random(60); ...
php
{ "resource": "" }
q260387
Manager.retrieveUserByToken
test
protected function retrieveUserByToken($identifier, $token) { $user = $this->retrieveUserByIdentifier($identifier);
php
{ "resource": "" }
q260388
Manager.retrieveUserByCredentials
test
protected function retrieveUserByCredentials(array $credentials) { $class = $this->modelClass(); $identifier = $class::getAuthIdentifierName(); $password = $class::getAuthPasswordName(); $user = $this->retrieveUserByIdentifier(Arr::fetch($credentials, $identifier)); if (...
php
{ "resource": "" }
q260389
Debugger.dbProfilerRegister
test
private function dbProfilerRegister() { $profiler = self::registerProfiler('db', '<i class="nuc db"></i>'); $this->em->attach( Events::DB, function (Event $event, Adapter\Pdo $connection) use ($profiler) { $eventType = $event->getType(); if ($eventTyp...
php
{ "resource": "" }
q260390
Debugger.viewProfilerRegister
test
private function viewProfilerRegister() { $this->em->attach( Events::VIEW, function (Event $event, $src, $data) { $eventType = $event->getType(); if ($eventType === 'beforeRender') { self::$viewProfiles['render'][] = self::$viewProfiles['__re...
php
{ "resource": "" }
q260391
MakerTask.writeMigration
test
protected function writeMigration($name, $table, $create) { $file = pathinfo($this->creator->create( $name, $this->getMigrationPath(), $table, $create
php
{ "resource": "" }
q260392
LogsActivity.eventsToBeRecorded
test
protected static function eventsToBeRecorded() { if (isset(static::$recordEvents)) { return collect(static::$recordEvents); } $events = collect([ 'created', 'updated',
php
{ "resource": "" }
q260393
VarDump.arrayDump
test
private function arrayDump($var, $id = null, $idLabel = null) { $dump = ''; if (!is_null($id)) { if (is_null($idLabel)) { $idLabel = '#' . $id; } $dump .= '<span class="nuc-toggle nuc-toggle-array" data-target="nuc-ref-' . $id . '">' . $idLabel . '...
php
{ "resource": "" }
q260394
VarDump.getVarId
test
private function getVarId($var) { if (is_object($var)) { $hash = spl_object_hash($var); } elseif (is_resource($var)) { $hash = intval($var) . '#resource#' . get_resource_type($var); } elseif (is_array($var) && $this->checkArrayRecursion($var)) { $hash = $t...
php
{ "resource": "" }
q260395
VarDump.genArrayHash
test
private function genArrayHash(array $var) { static $dump; if (!isset($dump)) { $dump = []; } if (in_array($var, $dump, true)) { return 'array recursion'; } $dump[] = $var; $hash = []; foreach ($var as $k => $v) { ...
php
{ "resource": "" }
q260396
VarDump.checkArrayRecursion
test
private function checkArrayRecursion(array $var) { static $dump; if (!isset($dump)) { $dump = []; } if (in_array($var, $dump, true)) { return true; } $dump[] = $var; $return = false; foreach ($var as $item) { if...
php
{ "resource": "" }
q260397
VarDump.checkObjectRecursion
test
private function checkObjectRecursion($obj) { static $dump; if (!isset($dump)) { $dump = []; } if (in_array($obj, $dump, true)) { return true; } $dump[] = $obj; $return = false; $props = Reflexion::getReflectionProperties($...
php
{ "resource": "" }
q260398
VarDump.dump
test
public static function dump(...$vars) { // We force the start of the session so that it is initialized before the first exit. switch (session_status()) { case PHP_SESSION_DISABLED: case PHP_SESSION_ACTIVE: break; default: $di = Di::...
php
{ "resource": "" }
q260399
ListTask.mainAction
test
public function mainAction() { $this->displayHeader(); $routes = $this->router->getRoutes(); $delimiter = Route::getDelimiter(); foreach ($routes as $route) { /** @var Route $route */ // Default route $pattern = $route->getPattern(); ...
php
{ "resource": "" }