_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q25300
FileVersion.setDefaultMeta
train
public function setDefaultMeta(\Sulu\Bundle\MediaBundle\Entity\FileVersionMeta $defaultMeta
php
{ "resource": "" }
q25301
WebspaceLocalizationController.cgetAction
train
public function cgetAction(Request $request) { $webspaceKey = $request->get('webspace'); /** @var WebspaceManagerInterface $webspaceManager */ $webspaceManager = $this->get('sulu_core.webspace.webspace_manager'); $webspace = $webspaceManager->findWebspaceByKey($webspaceKey); ...
php
{ "resource": "" }
q25302
Category.getMeta
train
public function getMeta() { $arrReturn = []; if (null !== $this->entity->getMeta()) { foreach ($this->entity->getMeta() as $meta) { if (!$meta->getLocale() || $meta->getLocale() === $this->locale) { array_push(
php
{ "resource": "" }
q25303
Category.getCreator
train
public function getCreator() { $strReturn = ''; $creator = $this->entity->getCreator(); if ($creator) {
php
{ "resource": "" }
q25304
Category.getChanger
train
public function getChanger() { $strReturn = ''; $changer = $this->entity->getChanger(); if ($changer) {
php
{ "resource": "" }
q25305
Category.getChildren
train
public function getChildren() { $children = []; if ($this->entity->getChildren()) { foreach ($this->entity->getChildren() as $child) {
php
{ "resource": "" }
q25306
Category.setTranslation
train
public function setTranslation(CategoryTranslationInterface $translation) { $translationEntity = $this->getTranslationByLocale($translation->getLocale()); if (!$translationEntity) { $translationEntity = $translation; $this->entity->addTranslation($translationEntity); ...
php
{ "resource": "" }
q25307
Category.setMeta
train
public function setMeta($metaEntities) { $currentMeta = $this->entity->getMeta(); foreach ($metaEntities as $singleMeta) { $metaEntity = $this->getSingleMetaById($currentMeta, $singleMeta->getId()); if (!$metaEntity) { $metaEntity = $singleMeta; ...
php
{ "resource": "" }
q25308
Category.getParent
train
public function getParent() { $parent = $this->getEntity()->getParent(); if ($parent) {
php
{ "resource": "" }
q25309
Category.getKeywords
train
public function getKeywords() { $keywords = []; $translation = $this->getTranslation(true); if (!$translation) { return $keywords; } foreach ($translation->getKeywords() as
php
{ "resource": "" }
q25310
Category.getUserFullName
train
private function getUserFullName($user) { $strReturn = ''; if ($user && method_exists($user, 'getContact')) { $strReturn = $user->getContact()->getFirstName() .
php
{ "resource": "" }
q25311
Category.getSingleMetaById
train
private function getSingleMetaById($meta, $id) { if (null !== $id) { foreach ($meta as $singleMeta)
php
{ "resource": "" }
q25312
Category.toArray
train
public function toArray() { return [ 'id' => $this->getId(), 'key' => $this->getKey(), 'name' => $this->getName(), 'meta' => $this->getMeta(), 'keywords' => $this->getKeywords(), 'defaultLocale' => $this->getDefaultLocale(),
php
{ "resource": "" }
q25313
Category.getTranslation
train
private function getTranslation($withDefault = false) { $translation = $this->getTranslationByLocale($this->locale); if (true === $withDefault && null === $translation && null !== $this->getDefaultLocale()) {
php
{ "resource": "" }
q25314
IseedCommand.generateFileName
train
protected function generateFileName($table, $prefix=null, $suffix=null) { if (!\Schema::connection($this->option('database') ? $this->option('database') : config('database.default'))->hasTable($table)) { throw new TableNotFoundException("Table $table was not found."); } // Gener...
php
{ "resource": "" }
q25315
Iseed.generateSeed
train
public function generateSeed($table, $prefix=null, $suffix=null, $database = null, $max = 0, $chunkSize = 0, $exclude = null, $prerunEvent = null, $postrunEvent = null, $dumpAuto = true, $indexed = true, $orderBy = null, $direction = 'ASC') { if (!$database) { $database = config('database.defaul...
php
{ "resource": "" }
q25316
Iseed.getData
train
public function getData($table, $max, $exclude = null, $orderBy = null, $direction = 'ASC') { $result = \DB::connection($this->databaseName)->table($table); if (!empty($exclude)) { $allColumns = \DB::connection($this->databaseName)->getSchemaBuilder()->getColumnListing($table); ...
php
{ "resource": "" }
q25317
Iseed.repackSeedData
train
public function repackSeedData($data) { if (!is_array($data)) { $data = $data->toArray(); } $dataArray = array(); if (!empty($data)) { foreach ($data as $row) {
php
{ "resource": "" }
q25318
Iseed.populateStub
train
public function populateStub($class, $stub, $table, $data, $chunkSize = null, $prerunEvent = null, $postrunEvent = null, $indexed = true) { $chunkSize = $chunkSize ?: config('iseed::config.chunk_size'); $inserts = ''; $chunks = array_chunk($data, $chunkSize); foreach ($chunks as $ch...
php
{ "resource": "" }
q25319
Iseed.prettifyArray
train
protected function prettifyArray($array, $indexed = true) { $content = ($indexed) ? var_export($array, true) : preg_replace("/[0-9]+ \=\>/i", '', var_export($array, true)); $lines = explode("\n", $content); $inString = false; $tabCount = 3; for ($i =...
php
{ "resource": "" }
q25320
Iseed.cleanSection
train
public function cleanSection() { $databaseSeederPath = base_path() . config('iseed::config.path') . '/DatabaseSeeder.php'; $content = $this->files->get($databaseSeederPath);
php
{ "resource": "" }
q25321
MinusEqual.mutate
train
public function mutate(Node $node) { return new Node\Expr\AssignOp\Plus($node->var,
php
{ "resource": "" }
q25322
MetricsCalculator.createFromArray
train
public static function createFromArray(array $mutantProcesses): self { $self = new self(); foreach ($mutantProcesses as $process) {
php
{ "resource": "" }
q25323
MetricsCalculator.getCoverageRate
train
public function getCoverageRate(): float { $coveredRate = 0; $coveredByTestsTotal = $this->totalMutantsCount - $this->notCoveredByTestsCount; if ($this->totalMutantsCount) {
php
{ "resource": "" }
q25324
MutationsCollectorVisitor.getOuterMostArrayNode
train
private function getOuterMostArrayNode(Node $node): Node { $outerMostArrayParent = $node; do { if ($node instanceof Node\Expr\Array_) { $outerMostArrayParent = $node; }
php
{ "resource": "" }
q25325
PhpProcess.start
train
public function start(callable $callback = null, array $env = null): void { $phpConfig = new PhpConfig(); $phpConfig->useOriginal();
php
{ "resource": "" }
q25326
ReflectionVisitor.isInsideFunction
train
private function isInsideFunction(Node $node): bool { if (!$node->hasAttribute(ParentConnectorVisitor::PARENT_KEY)) { return false; } $parent = $node->getAttribute(ParentConnectorVisitor::PARENT_KEY);
php
{ "resource": "" }
q25327
InfectionCommand.initialize
train
protected function initialize(InputInterface $input, OutputInterface $output): void { parent::initialize($input, $output); $locator = $this->getContainer()->get('locator'); if ($customConfigPath = $input->getOption('configuration')) { $locator->locate($customConfigPath); ...
php
{ "resource": "" }
q25328
Plus.mutate
train
public function mutate(Node $node) { return new
php
{ "resource": "" }
q25329
OneZeroInteger.mutate
train
public function mutate(Node $node) { if ($node->value === 0) { return new Node\Scalar\LNumber(1);
php
{ "resource": "" }
q25330
OneZeroFloat.mutate
train
public function mutate(Node $node) { if ($node->value === 0.0) { return new Node\Scalar\DNumber(1.0);
php
{ "resource": "" }
q25331
PlusEqual.mutate
train
public function mutate(Node $node) { return new
php
{ "resource": "" }
q25332
PublicVisibility.mutate
train
public function mutate(Node $node) { /* @var ClassMethod $node */ return new ClassMethod( $node->name, [ 'flags' => ($node->flags & ~Class_::MODIFIER_PUBLIC) | Class_::MODIFIER_PROTECTED, 'byRef' => $node->returnsByRef(),
php
{ "resource": "" }
q25333
IntegerNegation.mutate
train
public function mutate(Node $node) { $integerValue = $node->expr instanceof Node\Expr\UnaryMinus ? -$node->expr->expr->value : $node->expr->value;
php
{ "resource": "" }
q25334
FloatNegation.mutate
train
public function mutate(Node $node) { $floatValue = $node->expr instanceof Node\Expr\UnaryMinus ? -$node->expr->expr->value : $node->expr->value;
php
{ "resource": "" }
q25335
AssignmentEqual.mutate
train
public function mutate(Node $node) { return new Node\Expr\Assign($node->left,
php
{ "resource": "" }
q25336
Hook.add
train
public function add($hooks, $callback, $priority = 10, $accepted_args = 3) { foreach ((array) $hooks as $hook) { $this->addHookEvent($hook,
php
{ "resource": "" }
q25337
Hook.remove
train
public function remove($hook, $callback = null, $priority = 10) { // If $callback is null, it means we have chained the methods to // the action/filter instance. If the instance has no callback, return false. if (is_null($callback)) {
php
{ "resource": "" }
q25338
Hook.getCallback
train
public function getCallback($hook) { if (array_key_exists($hook, $this->hooks))
php
{ "resource": "" }
q25339
Hook.addHookEvent
train
protected function addHookEvent($hook, $callback, $priority, $accepted_args) { // Check if $callback is a closure. if ($callback instanceof \Closure || is_array($callback)) { $this->addEventListener($hook, $callback, $priority, $accepted_args); } elseif (is_string($callback)) { ...
php
{ "resource": "" }
q25340
Hook.addClassEvent
train
protected function addClassEvent($hook, $class, $priority, $accepted_args) { $callback = $this->buildClassEventCallback($class, $hook);
php
{ "resource": "" }
q25341
Hook.buildClassEventCallback
train
protected function buildClassEventCallback($class, $hook) { list($class, $method) = $this->parseClassEvent($class, $hook);
php
{ "resource": "" }
q25342
Hook.parseClassEvent
train
protected function parseClassEvent($class, $hook) { if (str_contains($class, '@')) { return explode('@', $class); } // If no method is defined, use the hook name as the method name.
php
{ "resource": "" }
q25343
Factory.make
train
public function make(string $username, string $password, string $email): User { $this->validate(compact('username', 'password', 'email')); $user = wp_create_user($username, $password, $email); if (is_a($user, 'WP_Error')) { if ('existing_user_login' === $user->get_error_code())...
php
{ "resource": "" }
q25344
Factory.validate
train
protected function validate(array $data) { $validator = $this->validator->make( $data, [ 'username' => 'min:6|max:60', 'password' => 'min:6|max:255', 'email' => 'email|max:100' ] ); if ($validator->fails()) ...
php
{ "resource": "" }
q25345
ChoiceFieldTransformer.getOptions
train
protected function getOptions(FieldTypeInterface $field) { $options = parent::getOptions($field);
php
{ "resource": "" }
q25346
ChoiceFieldTransformer.parseChoices
train
protected function parseChoices(array $choices) { $items = []; foreach ($choices as $key => $value) { if (is_array($value)) { // Handle options groups data. $items[] = ['key' => $key, 'value' => '', 'type' => 'group'];
php
{ "resource": "" }
q25347
ChoiceList.format
train
public function format(): ChoiceListInterface { if (empty($this->choices)) {
php
{ "resource": "" }
q25348
ChoiceList.parse
train
protected function parse(array $choices) { $items = []; foreach ($choices as $key => $value) { if (is_array($value)) { $items[$key] = $this->parse($value); } else { if (is_int($key)) { $label = ucfirst(str_replace(['-', '_'...
php
{ "resource": "" }
q25349
Application.registerBaseServiceProviders
train
protected function registerBaseServiceProviders() { $this->register(new EventServiceProvider($this)); $this->register(new
php
{ "resource": "" }
q25350
Application.rootPath
train
public function rootPath($path = '') { if (defined('THEMOSIS_ROOT')) { return
php
{ "resource": "" }
q25351
Application.storagePath
train
public function storagePath($path = '') { if (defined('THEMOSIS_ROOT')) { return $this->rootPath('storage').($path ? DIRECTORY_SEPARATOR.$path : $path); }
php
{ "resource": "" }
q25352
Application.detectEnvironment
train
public function detectEnvironment(Closure $callback) { $args = $_SERVER['argv'] ?? null;
php
{ "resource": "" }
q25353
Application.isDownForMaintenance
train
public function isDownForMaintenance() { $filePath = $this->wordpressPath('.maintenance'); if (function_exists('wp_installing') && ! file_exists($filePath)) {
php
{ "resource": "" }
q25354
Application.loadPlugin
train
public function loadPlugin(string $filePath, string $configPath) { $plugin = (new PluginManager($this, $filePath, new ClassLoader()))->load($configPath);
php
{ "resource": "" }
q25355
Application.loadPlugins
train
public function loadPlugins(string $pluginsPath) { $directories = Collection::make((new Filesystem())->directories($this->mupluginsPath())) ->map(function ($directory) { return ltrim(substr($directory, strrpos($directory, DS)), '\/'); })->toArray();
php
{ "resource": "" }
q25356
Application.registerConfiguredHooks
train
public function registerConfiguredHooks(string $config = '') { if (empty($config)) { $config = 'app.hooks'; }
php
{ "resource": "" }
q25357
Application.registerHook
train
public function registerHook(string $hook) { // Build a "Hookable" instance. // Hookable instances must extend the "Hookable" class. $instance = new $hook($this); $hooks = (array) $instance->hook; if (! method_exists($instance, 'register')) { return;
php
{ "resource": "" }
q25358
Application.loadTheme
train
public function loadTheme(string $dirPath, string $configPath) { $theme = (new ThemeManager($this, $dirPath,
php
{ "resource": "" }
q25359
Application.loadConfigurationFiles
train
public function loadConfigurationFiles(Repository $config, $path = '') { $files = $this->getConfigurationFiles($path); foreach ($files as $key => $path) {
php
{ "resource": "" }
q25360
Application.getConfigurationFiles
train
protected function getConfigurationFiles($path) { $files = []; foreach (Finder::create()->files()->name('*.php')->in($path) as $file) { $directory = $this->getNestedDirectory($file, $path);
php
{ "resource": "" }
q25361
Application.getNestedDirectory
train
protected function getNestedDirectory(SplFileInfo $file, $path) { $directory = $file->getPath(); if ($nested = trim(str_replace($path, '', $directory), DIRECTORY_SEPARATOR)) {
php
{ "resource": "" }
q25362
Application.manage
train
public function manage(string $kernel, $request) { $kernel = $this->make($kernel); $response = $kernel->handle($request); $response->send();
php
{ "resource": "" }
q25363
Application.manageAdmin
train
public function manageAdmin(string $kernel, $request) { if (! $this->isWordPressAdmin() && ! $this->has('action')) {
php
{ "resource": "" }
q25364
Application.dispatchToAdmin
train
protected function dispatchToAdmin(string $kernel, $request) { return function () use ($kernel, $request) { $kernel = $this->make($kernel); /** @var Response $response */ $response = $kernel->handle($request);
php
{ "resource": "" }
q25365
Application.isWordPressAdmin
train
public function isWordPressAdmin() { if (isset($GLOBALS['current_screen']) && is_a($GLOBALS['current_screen'], 'WP_Screen')) { return $GLOBALS['current_screen']->in_admin();
php
{ "resource": "" }
q25366
Application.outputJavascriptGlobal
train
public function outputJavascriptGlobal(string $name, array $data) { $output = "<script type=\"text/javascript\">\n\r"; $output .= "/* <![CDATA[ */\n\r"; $output .= "var {$name} = {\n\r"; if (! empty($data) && is_array($data)) { foreach ($data as $key => $value) {
php
{ "resource": "" }
q25367
IncludesFiles.includes
train
public function includes($path, string $pattern = '*.php') { foreach (Finder::create()->files()->name($pattern)->in($path)->sortByName() as
php
{ "resource": "" }
q25368
WordPressFileHeaders.headers
train
public function headers(string $path, array $headers): array { $data = $this->read($path); $properties = []; foreach ($headers as $field => $regex) { if (preg_match('/^[ \t\/*#@]*'.preg_quote($regex, '/').':(.*)$/mi', $data, $match) && $match[1]) {
php
{ "resource": "" }
q25369
WordPressFileHeaders.read
train
public function read(string $path, int $length = 8192): string { $handle = fopen($path, 'r'); $content = fread($handle, $length);
php
{ "resource": "" }
q25370
Section.getView
train
public function getView(bool $prefixed = false): string { if ($prefixed) {
php
{ "resource": "" }
q25371
Section.setViewData
train
public function setViewData(array $data): SectionInterface { $this->data = $data; // Add default variables to the section view. // We provide a copy of the section instance // so we can iterate over its items from the view.
php
{ "resource": "" }
q25372
PackageManifest.get
train
public function get($key = 'aliases') { return collect($this->getManifest())->flatMap(function ($configuration)
php
{ "resource": "" }
q25373
Manager.getFields
train
public function getFields(MetaboxInterface $metabox, Request $request): MetaboxInterface { foreach ($metabox->repository()->all() as $field)
php
{ "resource": "" }
q25374
Manager.saveFields
train
public function saveFields(MetaboxInterface $metabox, Request $request): MetaboxInterface { $post_id = $request->query('post_id'); $data = $this->getMetaboxData(collect($request->get('fields'))); $fields = $metabox->repository()->all(); /** @var $validator Validator */ $vali...
php
{ "resource": "" }
q25375
Manager.getMetaboxData
train
protected function getMetaboxData(Collection $fields) { $data = []; foreach ($fields as $field) {
php
{ "resource": "" }
q25376
Manager.getMetaboxRules
train
protected function getMetaboxRules(array $fields) { $rules = []; foreach ($fields as $field) { /** @var FieldTypeInterface $field */
php
{ "resource": "" }
q25377
Manager.getMetaboxPlaceholders
train
protected function getMetaboxPlaceholders(array $fields) { $placeholders = []; foreach ($fields as $field) { /** @var FieldTypeInterface $field */
php
{ "resource": "" }
q25378
WordPressHeaders.handle
train
public function handle(Request $request, \Closure $next) { $route = $request->route(); $response = $next($request); if (! $route->hasCondition() && function_exists('is_user_logged_in') && ! is_user_logged_in()) { // We're on a custom route. Remove "no-cache" headers added by Wor...
php
{ "resource": "" }
q25379
FormServiceProvider.register
train
public function register() { $this->registerFractalManager(); /** @var \Illuminate\View\Factory $view */ $view = $this->app['view']; $view->addLocation(__DIR__.'/views'); $this->app->singleton('form', function ($app) { return new FormFactory(
php
{ "resource": "" }
q25380
Factory.add
train
public function add(string $handle, string $path, array $dependencies = [], $version = null, $arg = null) { if (empty($handle) || empty($path)) { throw new \InvalidArgumentException('The asset instance expects
php
{ "resource": "" }
q25381
HooksRepository.load
train
public function load(array $hooks) { if (empty($hooks)) { return; }
php
{ "resource": "" }
q25382
ResetPasswords.reset
train
public function reset(Request $request) { $data = new PasswordResetData(); $form = $this->form(new PasswordResetForm($data)); $form->handleRequest($request); if ($form->isNotValid()) { return back()->withErrors($form->errors()->all()); } $response = $th...
php
{ "resource": "" }
q25383
ResetPasswords.credentials
train
protected function credentials(PasswordResetData $data): array { return [ 'email' => $data->getEmail(), 'password' => $data->getPassword(),
php
{ "resource": "" }
q25384
Taxonomy.setLabels
train
public function setLabels(array $labels): TaxonomyInterface { if (isset($this->args['labels'])) { $this->args['labels'] = array_merge($this->args['labels'], $labels); }
php
{ "resource": "" }
q25385
Taxonomy.setArguments
train
public function setArguments(array $args): TaxonomyInterface
php
{ "resource": "" }
q25386
Taxonomy.set
train
public function set(): TaxonomyInterface { if (function_exists('current_filter') && 'init' === $hook = current_filter()) { $this->register(); } else {
php
{ "resource": "" }
q25387
Taxonomy.register
train
public function register() { register_taxonomy($this->slug,
php
{ "resource": "" }
q25388
Taxonomy.setObjects
train
public function setObjects($objects): TaxonomyInterface { $this->objects = array_unique(array_merge($this->objects, (array) $objects));
php
{ "resource": "" }
q25389
Taxonomy.parseObjectsForCustomStatus
train
protected function parseObjectsForCustomStatus(array $objects): TaxonomyInterface { foreach ($objects as $object) { if ($this->container->bound('themosis.posttype.'.$object)) { $postType = $this->container['themosis.posttype.'.$object];
php
{ "resource": "" }
q25390
Metabox.display
train
public function display($post_type, $post) { if (! is_null($this->capability) && ! current_user_can($this->capability)) { return; } if (! $this->hasTemplateForPost($post)) { return; } $this->filter->add('admin_body_class', function ($classes) { ...
php
{ "resource": "" }
q25391
Metabox.render
train
public function render(\WP_Post $post, array $args) { $args = array_merge($args['args'], [ 'metabox' => $this, 'post' => $post, 'screen' => $this->getScreen() ]); $response = $this->handleCallback($this->getCallback(), $args); if ($response insta...
php
{ "resource": "" }
q25392
Metabox.handle
train
public function handle(array $args) { $this->filter->add('themosis_admin_global', function ($data) use ($args) { if (! isset($data['metabox'])) { $data['metabox'] = [$this->id]; } elseif (isset($data['metabox'])) { $data['metabox'][] =
php
{ "resource": "" }
q25393
Metabox.add
train
public function add($field, SectionInterface $section = null): MetaboxInterface { if ($field instanceof SectionInterface) { $section = $field; if ($section->hasItems()) { foreach ($section->getItems() as $item) { /** @var FieldTypeInterface $item ...
php
{ "resource": "" }
q25394
Metabox.addTranslation
train
public function addTranslation(string $key, string $translation): MetaboxInterface {
php
{ "resource": "" }
q25395
Metabox.setTemplate
train
public function setTemplate($template, string $screen = 'page'): MetaboxInterface {
php
{ "resource": "" }
q25396
Metabox.hasTemplateForPost
train
private function hasTemplateForPost(\WP_Post $post): bool { $postTemplate = get_post_meta($post->ID, '_wp_page_template', true); $templates = isset($this->template[$post->post_type]) ? $this->template[$post->post_type] : []; if (empty($templates)) { // No templates exist for th...
php
{ "resource": "" }
q25397
DataMapperManager.mapFromObjectToField
train
public function mapFromObjectToField($data, FieldTypeInterface $field) { if (! is_object($data)) { $this->triggerException(); } $field->setValue(
php
{ "resource": "" }
q25398
VerifyCsrfToken.getTokenFromRequest
train
protected function getTokenFromRequest(Request $request) { $token = $request->input($this->token) ?: $request->header($this->csrfHeader); if (! $token && $header = $request->header($this->xsrfHeader)) {
php
{ "resource": "" }
q25399
PluginInstallCommand.generatePluginHeaders
train
protected function generatePluginHeaders(string $name) { $description = $this->ask('Description:', ''); $author = $this->ask('Author:', 'Themosis'); $textdomain = $this->ask('Text domain:', trim($name, '\/-_')); $variable = strtoupper($this->ask('Domain variable:', 'PLUGIN_TD')); ...
php
{ "resource": "" }