_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q234900 | Router.filterUri | train | private function filterUri(string $passedUri): string
{
//sanitize url
$url = \filter_var($passedUri, FILTER_SANITIZE_URL);
//check for rewrite mode
$url = \str_replace($this->rewriteModeOffRouter, '', $url);
//remove basepath
$url = \substr($url, \strlen($this->bas... | php | {
"resource": ""
} |
q234901 | Session.refresh | train | private function refresh(): void
{
$time = \time();
if (isset($this->data['time']) && $this->data['time'] <= ($time - $this->expire)) {
//delete session data
$this->data = [];
//regenerate session
$this->regenerate();
}
$this->setSe... | php | {
"resource": ""
} |
q234902 | Session.setSessionData | train | private function setSessionData(int $time): void
{
$this->id = \session_id();
$this->data['time'] = $time;
$this->data['expire'] = $this->expire;
$this->status = \session_status();
} | php | {
"resource": ""
} |
q234903 | AbstractController.notifyDanger | train | protected function notifyDanger($content) {
$notification = NotificationFactory::newDangerNotification($content);
return $this->notify(NotificationEvents::NOTIFICATION_DANGER, $notification);
} | php | {
"resource": ""
} |
q234904 | AbstractController.notifyInfo | train | protected function notifyInfo($content) {
$notification = NotificationFactory::newInfoNotification($content);
return $this->notify(NotificationEvents::NOTIFICATION_INFO, $notification);
} | php | {
"resource": ""
} |
q234905 | AbstractController.notifySuccess | train | protected function notifySuccess($content) {
$notification = NotificationFactory::newSuccessNotification($content);
return $this->notify(NotificationEvents::NOTIFICATION_SUCCESS, $notification);
} | php | {
"resource": ""
} |
q234906 | AbstractController.notifyWarning | train | protected function notifyWarning($content) {
$notification = NotificationFactory::newWarningNotification($content);
return $this->notify(NotificationEvents::NOTIFICATION_WARNING, $notification);
} | php | {
"resource": ""
} |
q234907 | FOSUserBreadcrumbNodes.getGlyphiconBreadcrumbNodes | train | public static function getGlyphiconBreadcrumbNodes() {
$breadcrumbNodes = [];
$breadcrumbNodes[] = new BreadcrumbNode("label.edit_profile", "g:user", "fos_user_profile_edit", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.show_profile", "g:user"... | php | {
"resource": ""
} |
q234908 | PrivacyCookieTwigExtension.showPrivacyCookieBanner | train | public function showPrivacyCookieBanner(
Twig_Environment $twigEnvironment,
$policyPageUrl = null,
array $options = array()
) {
$options['policyPageUrl'] = $policyPageUrl;
return $twigEnvironment->render(
'EzSystemsPrivacyCookieBundle::privacycookie.html.twig',
... | php | {
"resource": ""
} |
q234909 | AbstractButtonTwigExtension.bootstrapButton | train | protected function bootstrapButton(ButtonInterface $button, $icon) {
$attributes = [];
$attributes["class"] = ["btn", ButtonRenderer::renderType($button)];
$attributes["class"][] = ButtonRenderer::renderBlock($button);
$attributes["class"][] = ButtonRenderer::ren... | php | {
"resource": ""
} |
q234910 | AbstractNavTwigExtension.bootstrapNavs | train | protected function bootstrapNavs(array $items, $class, $stacked) {
$attributes = [];
$attributes["class"][] = "nav";
$attributes["class"][] = $class;
$attributes["class"][] = true === $stacked ? "nav-stacked" : null;
$innerHTML = [];
foreach ($items as $current) {
... | php | {
"resource": ""
} |
q234911 | CrudCommand.askForCreateSP | train | private function askForCreateSP(string $spType, string $tableName): void
{
$question = sprintf('Create SP for <dbo>%s</dbo> ? (default Yes): ', $spType);
$question = new ConfirmationQuestion($question, true);
if ($this->helper->ask($this->input, $this->output, $question))
{
$defaultSpName = strt... | php | {
"resource": ""
} |
q234912 | CrudCommand.generateSP | train | private function generateSP(string $tableName, string $spType, string $spName): string
{
switch ($spType)
{
case 'UPDATE':
$routine = new UpdateRoutine($this->input,
$this->output,
$this->helper,
... | php | {
"resource": ""
} |
q234913 | CrudCommand.printAllTables | train | private function printAllTables(array $tableList): void
{
if ($this->input->getOption('tables'))
{
$tableData = array_chunk($tableList, 4);
$array = [];
foreach ($tableData as $parts)
{
$partsArray = [];
foreach ($parts as $part)
{
$partsArray[] = ... | php | {
"resource": ""
} |
q234914 | CrudCommand.startAsking | train | private function startAsking(array $tableList): void
{
$question = new Question('Please enter <note>TABLE NAME</note>: ');
$tableName = $this->helper->ask($this->input, $this->output, $question);
$key = StaticDataLayer::searchInRowSet('table_name', $tableName, $tableList);
if (!isset($key))
{
... | php | {
"resource": ""
} |
q234915 | Card.image | train | public function image($large, $small = null)
{
$this->image = [
'smallImageUrl' => $small ?? $large,
'largeImageUrl' => $large,
];
return $this;
} | php | {
"resource": ""
} |
q234916 | Scope.createNewScope | train | public static function createNewScope(
int $id,
string $name,
string $description = null,
bool $isDefault = false
): Scope {
$scope = new static();
$scope->id = $id;
$scope->name = $name;
$scope->description = $description;
$scope->isDefault =... | php | {
"resource": ""
} |
q234917 | Authentication.login | train | public function login(string $userName, string $password, string $storedUserName = '', string $storedPassword = '', int $storedId): bool
{
if ($userName === $storedUserName && $this->password->verify($password, $storedPassword)) {
//write valid login on session
$this->session->loginT... | php | {
"resource": ""
} |
q234918 | Authentication.refresh | train | private function refresh(): bool
{
//check for login data on in current session
if (empty($this->session->login)) {
return false;
}
//take time
$time = \time();
//check if login expired
if (($this->session->loginTime + $this->session->expire) < $... | php | {
"resource": ""
} |
q234919 | ClientService.registerClient | train | public function registerClient(string $name, array $redirectUris): array
{
do {
$client = Client::createNewClient($name, $redirectUris);
} while ($this->clientRepository->idExists($client->getId()));
$secret = $client->generateSecret();
$client = $this->clientRepository-... | php | {
"resource": ""
} |
q234920 | AbstractImageTwigExtension.bootstrapImage | train | protected function bootstrapImage($src, $alt, $width, $height, $class, $usemap) {
$template = "<img %attributes%/>";
$attributes = [];
$attributes["src"] = $src;
$attributes["alt"] = $alt;
$attributes["width"] = $width;
$attributes["height"] = $height;
$... | php | {
"resource": ""
} |
q234921 | NavTwigExtension.bootstrapNavsPills | train | public function bootstrapNavsPills(array $args = []) {
return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-pills", ArrayHelper::get($args, "stacked", false));
} | php | {
"resource": ""
} |
q234922 | Thread.getOffset | train | public function getOffset($limit = self::LIMIT, $order = 'desc') {
if ($limit === 0) {
return 0;
}
if ($order == 'asc' || $order == 'time_created::asc') {
$before = $this->getCommentsBefore(array('count' => true, 'offset' => 0));
} else {
$before = $this->getCommentsAfter(array('count' => true, 'offset... | php | {
"resource": ""
} |
q234923 | Thread.delete | train | public function delete($recursive = true) {
$success = 0;
$count = $this->getCount();
$comments = $this->getAll()->setIncrementOffset(false);
foreach ($comments as $comment) {
if ($comment->delete($recursive)) {
$success++;
}
}
return ($success == $count);
} | php | {
"resource": ""
} |
q234924 | Thread.getAll | train | public function getAll($getter = 'elgg_get_entities_from_metadata', $options = array()) {
$options['limit'] = 0;
$options = $this->getFilterOptions($options);
return new ElggBatch($getter, $options);
} | php | {
"resource": ""
} |
q234925 | Thread.getCommentsBefore | train | public function getCommentsBefore(array $options = array()) {
$options['wheres'][] = "
e.time_created < {$this->comment->time_created}
";
$options['order_by'] = 'e.time_created ASC';
$comments = elgg_get_entities_from_metadata($this->getFilterOptions($options));
if (is_array($comments)) {
return array_r... | php | {
"resource": ""
} |
q234926 | RoutineWrapperGeneratorCommand.generateWrapperClass | train | private function generateWrapperClass(): void
{
$this->io->title('Wrapper');
/** @var NameMangler $mangler */
$mangler = new $this->nameMangler();
$routines = $this->readRoutineMetadata();
if (!empty($routines))
{
// Sort routines by their wrapper method name.
$sorted_routines =... | php | {
"resource": ""
} |
q234927 | RoutineWrapperGeneratorCommand.readRoutineMetadata | train | private function readRoutineMetadata(): array
{
$data = file_get_contents($this->metadataFilename);
$routines = (array)json_decode($data, true);
if (json_last_error()!=JSON_ERROR_NONE)
{
throw new RuntimeException("Error decoding JSON: '%s'.", json_last_error_msg());
}
return $routines... | php | {
"resource": ""
} |
q234928 | RoutineWrapperGeneratorCommand.storeWrapperClass | train | private function storeWrapperClass(): void
{
$code = $this->codeStore->getCode();
switch ($this->wrapperClassType)
{
case 'static':
// Nothing to do.
break;
case 'non static':
$code = NonStatic::nonStatic($code);
break;
default:
throw new Fallen... | php | {
"resource": ""
} |
q234929 | RoutineWrapperGeneratorCommand.writeClassHeader | train | private function writeClassHeader(): void
{
$p = strrpos($this->wrapperClassName, '\\');
if ($p!==false)
{
$namespace = ltrim(substr($this->wrapperClassName, 0, $p), '\\');
$class_name = substr($this->wrapperClassName, $p + 1);
}
else
{
$namespace = null;
$class_name ... | php | {
"resource": ""
} |
q234930 | RoutineWrapperGeneratorCommand.writeClassTrailer | train | private function writeClassTrailer(): void
{
$this->codeStore->appendSeparator();
$this->codeStore->append('}');
$this->codeStore->append('');
$this->codeStore->appendSeparator();
} | php | {
"resource": ""
} |
q234931 | RoutineWrapperGeneratorCommand.writeRoutineFunction | train | private function writeRoutineFunction(array $routine, NameMangler $nameMangler): void
{
$wrapper = Wrapper::createRoutineWrapper($routine, $this->codeStore, $nameMangler, $this->lobAsString);
$wrapper->writeRoutineFunction();
$this->imports = array_merge($this->imports, $wrapper->getImports());
} | php | {
"resource": ""
} |
q234932 | EnhancedAuthentication.getAttemptsLeftWithSameUser | train | public function getAttemptsLeftWithSameUser(string $userName): int
{
$attemptsLeft = ((int) $this->maxAttemptsForUserName) - $this->enhancedAuthenticationMapper->fetchAttemptsWithSameUser($userName, $this->banTimeInSeconds);
return \max(0, $attemptsLeft);
} | php | {
"resource": ""
} |
q234933 | EnhancedAuthentication.getAttemptsLeftWithSameSession | train | public function getAttemptsLeftWithSameSession(string $sessionId): int
{
$attemptsLeft = ((int) $this->maxAttemptsForSessionId) - $this->enhancedAuthenticationMapper->fetchAttemptsWithSameSession($sessionId, $this->banTimeInSeconds);
return \max(0, $attemptsLeft);
} | php | {
"resource": ""
} |
q234934 | EnhancedAuthentication.getAttemptsLeftWithSameIp | train | public function getAttemptsLeftWithSameIp(string $ipAddress): int
{
$attemptsLeft = ((int) $this->maxAttemptsForIpAddress) - $this->enhancedAuthenticationMapper->fetchAttemptsWithSameIp($ipAddress, $this->banTimeInSeconds);
return \max(0, $attemptsLeft);
} | php | {
"resource": ""
} |
q234935 | ResourceServer.extractAccessToken | train | private function extractAccessToken(ServerRequestInterface $request)
{
// The preferred way is using Authorization header
if ($request->hasHeader('Authorization')) {
// Header value is expected to be "Bearer xxx"
$parts = explode(' ', $request->getHeaderLine('Authorization'))... | php | {
"resource": ""
} |
q234936 | AbstractStorageFactory.returnStorageObject | train | protected function returnStorageObject()
{
$driver = $this->driver;
$options = $this->options;
if (isset($this->supportedDriver[$driver])) {
$class = $this->supportedDriver[$driver];
return new $class($options);
}
throw new InvalidArgumentException(... | php | {
"resource": ""
} |
q234937 | FrontController.run | train | public function run(): void
{
//attach Oserver to Subjetc
$this->model->attach($this->view);
//run action before controller
$this->beforeAfterController('before');
$this->beforeAfterControllerAction('before');
//run controller
$this->runController();
... | php | {
"resource": ""
} |
q234938 | FrontController.beforeAfterControllerAction | train | private function beforeAfterControllerAction(string $when): void
{
$method = $when.\ucfirst($this->routeAction);
if (\method_exists($this->controller, $method) && $method !== $when) {
\call_user_func([$this->controller, $method]);
}
} | php | {
"resource": ""
} |
q234939 | FrontController.beforeAfterController | train | private function beforeAfterController(string $when): void
{
if (\method_exists($this->controller, $when)) {
\call_user_func([$this->controller, $when]);
}
} | php | {
"resource": ""
} |
q234940 | FrontController.runController | train | private function runController(): void
{
//get route information
$action = $this->routeAction;
$param = $this->routeParam;
//action - call controller passing params
if (!empty($param)) {
\call_user_func_array([$this->controller, $action], $param);
ret... | php | {
"resource": ""
} |
q234941 | FrontController.runView | train | private function runView(): void
{
$action = ($this->routeAction) ? $this->routeAction : 'index';
\call_user_func([$this->view, $action]);
} | php | {
"resource": ""
} |
q234942 | DataLayerException.getMarkedQuery | train | public function getMarkedQuery(string $style = 'error'): array
{
$query = trim($this->query); // MySQL ignores leading whitespace in queries.
$message = [];
if (strpos($query, PHP_EOL)!==false && $this->isQueryError())
{
// Query is a multi line query.
// The format of a 1064 message is... | php | {
"resource": ""
} |
q234943 | RoleLabelTwigExtension.applyColor | train | private function applyColor($label, $content, $color) {
$searches = ">" . $content;
$replaces = " style=\"background-color:" . $color . ";\"" . $searches;
return StringHelper::replace($label, [$searches], [$replaces]);
} | php | {
"resource": ""
} |
q234944 | RoleLabelTwigExtension.bootstrapRoleLabelFunction | train | public function bootstrapRoleLabelFunction(UserInterface $user = null, array $roleColors = [], array $roleTrans = []) {
if (null === $user) {
return "";
}
$output = [];
foreach ($user->getRoles() as $current) {
$role = true === $current instanceof Role ? $curr... | php | {
"resource": ""
} |
q234945 | Wrapper.createRoutineWrapper | train | public static function createRoutineWrapper(array $routine,
PhpCodeStore $codeStore,
NameMangler $nameMangler,
bool $lobAsString): Wrapper
{
switch ($routine['designation'])
... | php | {
"resource": ""
} |
q234946 | Wrapper.isBlobParameter | train | public function isBlobParameter(?array $parameters): bool
{
$hasBlob = false;
if ($parameters)
{
foreach ($parameters as $parameter_info)
{
$hasBlob = $hasBlob || DataTypeHelper::isBlobParameter($parameter_info['data_type']);
}
}
return $hasBlob;
} | php | {
"resource": ""
} |
q234947 | Wrapper.writeRoutineFunction | train | public function writeRoutineFunction(): void
{
if (!$this->lobAsStringFlag && $this->isBlobParameter($this->routine['parameters']))
{
$this->writeRoutineFunctionWithLob();
}
else
{
$this->writeRoutineFunctionWithoutLob();
}
} | php | {
"resource": ""
} |
q234948 | Wrapper.writeRoutineFunctionWithoutLob | train | public function writeRoutineFunctionWithoutLob(): void
{
$wrapperArgs = $this->getWrapperArgs();
$methodName = $this->nameMangler->getMethodName($this->routine['routine_name']);
$returnType = $this->getReturnTypeDeclaration();
$this->codeStore->appendSeparator();
$this->generatePhpDoc();
$t... | php | {
"resource": ""
} |
q234949 | Wrapper.getRoutineArgs | train | protected function getRoutineArgs(): string
{
$ret = '';
foreach ($this->routine['parameters'] as $parameter_info)
{
$mangledName = $this->nameMangler->getParameterName($parameter_info['parameter_name']);
if ($ret) $ret .= ',';
$ret .= DataTypeHelper::escapePhpExpression($parameter_inf... | php | {
"resource": ""
} |
q234950 | Wrapper.getWrapperArgs | train | protected function getWrapperArgs(): string
{
$ret = '';
if ($this->routine['designation']=='bulk')
{
$ret .= 'BulkHandler $bulkHandler';
}
foreach ($this->routine['parameters'] as $i => $parameter)
{
if ($ret!='') $ret .= ', ';
$dataType = DataTypeHelper::columnTypeToP... | php | {
"resource": ""
} |
q234951 | Wrapper.generatePhpDoc | train | private function generatePhpDoc(): void
{
$this->codeStore->append('/**', false);
// Generate phpdoc with short description of routine wrapper.
$this->generatePhpDocSortDescription();
// Generate phpdoc with long description of routine wrapper.
$this->generatePhpDocLongDescription();
// Gen... | php | {
"resource": ""
} |
q234952 | Wrapper.generatePhpDocBlockReturn | train | private function generatePhpDocBlockReturn(): void
{
$return = $this->getDocBlockReturnType();
if ($return!=='')
{
$this->codeStore->append(' *', false);
$this->codeStore->append(' * @return '.$return, false);
}
} | php | {
"resource": ""
} |
q234953 | Wrapper.generatePhpDocLongDescription | train | private function generatePhpDocLongDescription(): void
{
if ($this->routine['phpdoc']['long_description']!=='')
{
$this->codeStore->append(' * '.$this->routine['phpdoc']['long_description'], false);
}
} | php | {
"resource": ""
} |
q234954 | Wrapper.generatePhpDocParameters | train | private function generatePhpDocParameters(): void
{
$parameters = [];
foreach ($this->routine['phpdoc']['parameters'] as $parameter)
{
$mangledName = $this->nameMangler->getParameterName($parameter['parameter_name']);
$parameters[] = ['php_name' => '$'.$mangledName,
... | php | {
"resource": ""
} |
q234955 | Wrapper.generatePhpDocSortDescription | train | private function generatePhpDocSortDescription(): void
{
if ($this->routine['phpdoc']['sort_description']!=='')
{
$this->codeStore->append(' * '.$this->routine['phpdoc']['sort_description'], false);
}
} | php | {
"resource": ""
} |
q234956 | SelectorHelper.matchPath | train | public static function matchPath(string $pattern, string $path, bool $isCaseSensitive = true): bool
{
// Explicitly exclude directory itself.
if ($path=='' && $pattern=='**/*')
{
return false;
}
$dirSep = preg_quote(DIRECTORY_SEPARATOR, '/');
$trailingDirSep = '(('.$dirSep.')?|(... | php | {
"resource": ""
} |
q234957 | Droplets.resize | train | public function resize($dropletId, array $parameters)
{
if (!array_key_exists('size_id', $parameters) || !is_int($parameters['size_id'])) {
throw new \InvalidArgumentException('You need to provide an integer "size_id".');
}
return $this->processQuery($this->buildQuery($dropletId... | php | {
"resource": ""
} |
q234958 | Droplets.snapshot | train | public function snapshot($dropletId, array $parameters = array())
{
return $this->processQuery($this->buildQuery($dropletId, DropletsActions::ACTION_SNAPSHOT, $parameters));
} | php | {
"resource": ""
} |
q234959 | Droplets.restore | train | public function restore($dropletId, array $parameters)
{
if (!array_key_exists('image_id', $parameters) || !is_int($parameters['image_id'])) {
throw new \InvalidArgumentException('You need to provide the "image_id" to restore.');
}
return $this->processQuery($this->buildQuery($d... | php | {
"resource": ""
} |
q234960 | Droplets.rebuild | train | public function rebuild($dropletId, array $parameters)
{
if (!array_key_exists('image_id', $parameters) || !is_int($parameters['image_id'])) {
throw new \InvalidArgumentException('You need to provide the "image_id" to rebuild.');
}
return $this->processQuery($this->buildQuery($d... | php | {
"resource": ""
} |
q234961 | Droplets.rename | train | public function rename($dropletId, array $parameters)
{
if (!array_key_exists('name', $parameters) || !is_string($parameters['name'])) {
throw new \InvalidArgumentException('You need to provide a string "name".');
}
return $this->processQuery($this->buildQuery($dropletId, Drople... | php | {
"resource": ""
} |
q234962 | ExtendedPDO.queryWithParam | train | public function queryWithParam(string $query, array $param): PDOStatement
{
$statement = $this->prepare($query);
foreach ($param as $value) {
$this->checkValue($value);
//reassign as reference
//because bindParam need it as reference
$ref = $value;
... | php | {
"resource": ""
} |
q234963 | UUID4.check | train | private function check(string $uuid): void
{
$uuid32 = \str_replace('-', '', $uuid);
if (\preg_match('/^[0-9a-f]{8}[0-9a-f]{4}[4][0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/i', $uuid32) !== 1) {
throw new InvalidArgumentException('Invalid UUID version 4 provided.');
}
$th... | php | {
"resource": ""
} |
q234964 | UUID4.generate | train | private function generate(): void
{
$this->hexUUID = \sprintf(
'%s-%s-%s-%s-%s',
// 8 hex characters
\bin2hex(\random_bytes(4)),
// 4 hex characters
\bin2hex(\random_bytes(2)),
// "4" for the UUID version + 3 hex characters
... | php | {
"resource": ""
} |
q234965 | PermissionTrait.canById | train | public function canById(int $permissionId): bool
{
if (isset($this->permission[$permissionId])) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q234966 | PermissionTrait.canByName | train | public function canByName(string $permissionName): bool
{
if (\in_array($permissionName, \array_column($this->permission, 'name'), true)) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q234967 | AbstractToken.createNew | train | protected static function createNew(
int $ttl,
TokenOwnerInterface $owner = null,
Client $client = null,
array $scopes = null
): self {
if (is_array($scopes)) {
$scopes = array_map(function ($scope) {
return (string) $scope;
}, $scopes)... | php | {
"resource": ""
} |
q234968 | AbstractToken.matchScopes | train | public function matchScopes($scopes): bool
{
$scopes = is_string($scopes) ? explode(' ', $scopes) : $scopes;
$diff = array_diff($scopes, $this->scopes);
return empty($diff);
} | php | {
"resource": ""
} |
q234969 | DiskCache.doesFileChecksFailed | train | private function doesFileChecksFailed(string $file): bool
{
//check if file exist
if (!\file_exists($file)) {
return true;
}
//take cache from file
$cacheValue = include $file;
//check if cache is expired and delete file from storage
if ($cacheVa... | php | {
"resource": ""
} |
q234970 | Role.isUserInRoleById | train | public function isUserInRoleById(int $userId): bool
{
if (isset($this->users[$userId])) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q234971 | Role.isUserInRoleByName | train | public function isUserInRoleByName(string $userName): bool
{
if (\in_array($userName, \array_column($this->users, 'name'), true)) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q234972 | ConstantsCommand.executeColumnWidths | train | private function executeColumnWidths(): void
{
$this->loadOldColumns();
$this->loadColumns();
$this->enhanceColumns();
$this->mergeColumns();
$this->writeColumns();
} | php | {
"resource": ""
} |
q234973 | ConstantsCommand.executeEnabled | train | private function executeEnabled(): void
{
if ($this->constantsFilename!==null)
{
$this->executeColumnWidths();
}
if ($this->className!==null)
{
$this->executeCreateConstants();
}
$this->logNumberOfConstants();
} | php | {
"resource": ""
} |
q234974 | ConstantsCommand.loadLabels | train | private function loadLabels(): void
{
$tables = DataLayer::getLabelTables();
foreach ($tables as $table)
{
$rows = DataLayer::getLabelsFromTable($table['table_name'], $table['id'], $table['label']);
foreach ($rows as $row)
{
$this->labels[$row['label']] = $row['id'];
}
... | php | {
"resource": ""
} |
q234975 | ConstantsCommand.logNumberOfConstants | train | private function logNumberOfConstants(): void
{
$n_id = sizeof($this->labels);
$n_len = sizeof($this->constants) - $n_id;
$this->io->writeln('');
$this->io->text(sprintf('Number of constants based on column widths: %d', $n_len));
$this->io->text(sprintf('Number of constants based on database IDs... | php | {
"resource": ""
} |
q234976 | ConstantsCommand.makeConstantStatements | train | private function makeConstantStatements(): array
{
$width1 = 0;
$width2 = 0;
$constants = [];
foreach ($this->constants as $constant => $value)
{
$width1 = max(mb_strlen($constant), $width1);
$width2 = max(mb_strlen((string)$value), $width2);
}
$line_format = sprintf(' ... | php | {
"resource": ""
} |
q234977 | ConstantsCommand.readConfigFile | train | private function readConfigFile(string $configFilename): array
{
$settings = parse_ini_file($configFilename, true);
$this->constantsFilename = self::getSetting($settings, false, 'constants', 'columns');
$this->className = self::getSetting($settings, false, 'constants', 'class');
return $sett... | php | {
"resource": ""
} |
q234978 | RoutineLoaderHelper.extractColumnsFromTableDescription | train | private static function extractColumnsFromTableDescription(array $description): array
{
$ret = [];
foreach ($description as $column)
{
preg_match('/^(\w+)(.*)?$/', $column['Type'], $parts1);
$tmp = ['column_name' => $column['Field'],
'data_type' => $parts1[1],
... | php | {
"resource": ""
} |
q234979 | RoutineLoaderHelper.loadStoredRoutine | train | public function loadStoredRoutine(): array
{
$this->routineName = pathinfo($this->sourceFilename, PATHINFO_FILENAME);
$this->phpStratumOldMetadata = $this->phpStratumMetadata;
$this->filemtime = filemtime($this->sourceFilename);
$load = $this->mustLoadStoredRoutine();
if ($l... | php | {
"resource": ""
} |
q234980 | RoutineLoaderHelper.dropRoutine | train | private function dropRoutine(): void
{
if (isset($this->rdbmsOldRoutineMetadata))
{
MetaDataLayer::dropRoutine($this->rdbmsOldRoutineMetadata['routine_type'], $this->routineName);
}
} | php | {
"resource": ""
} |
q234981 | RoutineLoaderHelper.extractBulkInsertTableColumnsInfo | train | private function extractBulkInsertTableColumnsInfo(): void
{
// Return immediately if designation type is not appropriate for this method.
if ($this->designationType!='bulk_insert') return;
// Check if table is a temporary table or a non-temporary table.
$table_is_non_temporary = MetaDataLayer::check... | php | {
"resource": ""
} |
q234982 | RoutineLoaderHelper.extractDesignationType | train | private function extractDesignationType(): void
{
$found = true;
$key = array_search('begin', $this->routineSourceCodeLines);
if ($key!==false)
{
for ($i = 1; $i<$key; $i++)
{
$n = preg_match('/^\s*--\s+type:\s*(\w+)\s*(.+)?\s*$/',
$this->routineSourceCod... | php | {
"resource": ""
} |
q234983 | RoutineLoaderHelper.extractDocBlockPartsWrapper | train | private function extractDocBlockPartsWrapper(): void
{
// Get the DocBlock parts from the source of the stored routine.
$this->extractDocBlockPartsSource();
// Generate the parameters parts of the DocBlock to be used by the wrapper.
$parameters = [];
foreach ($this->parameters as $parameter_info)... | php | {
"resource": ""
} |
q234984 | RoutineLoaderHelper.extractExtendedParametersInfo | train | private function extractExtendedParametersInfo(): void
{
$key = array_search('begin', $this->routineSourceCodeLines);
if ($key!==false)
{
for ($i = 1; $i<$key; $i++)
{
$k = preg_match('/^\s*--\s+param:(?:\s*(\w+)\s+(\w+)(?:(?:\s+([^\s-])\s+([^\s-])\s+([^\s-])\s*$)|(?:\s*$)))?/',
... | php | {
"resource": ""
} |
q234985 | RoutineLoaderHelper.extractPlaceholders | train | private function extractPlaceholders(): void
{
$unknown = [];
preg_match_all('(@[A-Za-z0-9\_\.]+(\%type)?@)', $this->routineSourceCode, $matches);
if (!empty($matches[0]))
{
foreach ($matches[0] as $placeholder)
{
if (isset($this->replacePairs[strtoupper($placeholder)]))
{... | php | {
"resource": ""
} |
q234986 | RoutineLoaderHelper.extractReturnType | train | private function extractReturnType(): void
{
// Return immediately if designation type is not appropriate for this method.
if (!in_array($this->designationType, ['function', 'singleton0', 'singleton1'])) return;
$key = array_search('begin', $this->routineSourceCodeLines);
if ($key!==false)
{
... | php | {
"resource": ""
} |
q234987 | RoutineLoaderHelper.extractRoutineParametersInfo | train | private function extractRoutineParametersInfo(): void
{
$routine_parameters = MetaDataLayer::getRoutineParameters($this->routineName);
foreach ($routine_parameters as $key => $routine_parameter)
{
if ($routine_parameter['parameter_name'])
{
$data_type_descriptor = $routine_parameter['d... | php | {
"resource": ""
} |
q234988 | RoutineLoaderHelper.getParameterDocDescription | train | private function getParameterDocDescription(string $name): ?string
{
if (isset($this->docBlockPartsSource['parameters']))
{
foreach ($this->docBlockPartsSource['parameters'] as $parameter_doc_info)
{
if ($parameter_doc_info['name']===$name) return $parameter_doc_info['description'];
... | php | {
"resource": ""
} |
q234989 | RoutineLoaderHelper.loadRoutineFile | train | private function loadRoutineFile(): void
{
// Set magic constants specific for this stored routine.
$this->setMagicConstants();
// Replace all place holders with their values.
$lines = explode("\n", $this->routineSourceCode);
$routine_source = [];
foreach ($lines as $i => &$line)
... | php | {
"resource": ""
} |
q234990 | RoutineLoaderHelper.mustLoadStoredRoutine | train | private function mustLoadStoredRoutine(): bool
{
// If this is the first time we see the source file it must be loaded.
if (!isset($this->phpStratumOldMetadata)) return true;
// If the source file has changed the source file must be loaded.
if ($this->phpStratumOldMetadata['timestamp']!=$this->filemt... | php | {
"resource": ""
} |
q234991 | RoutineLoaderHelper.readSourceCode | train | private function readSourceCode(): void
{
$this->routineSourceCode = file_get_contents($this->sourceFilename);
$this->routineSourceCodeLines = explode("\n", $this->routineSourceCode);
if ($this->routineSourceCodeLines===false)
{
throw new RoutineLoaderException('Source file is empty');
... | php | {
"resource": ""
} |
q234992 | RoutineLoaderHelper.setMagicConstants | train | private function setMagicConstants(): void
{
$real_path = realpath($this->sourceFilename);
$this->replace['__FILE__'] = "'".MetaDataLayer::realEscapeString($real_path)."'";
$this->replace['__ROUTINE__'] = "'".$this->routineName."'";
$this->replace['__DIR__'] = "'".MetaDataLayer::realEscapeStri... | php | {
"resource": ""
} |
q234993 | RoutineLoaderHelper.unsetMagicConstants | train | private function unsetMagicConstants(): void
{
unset($this->replace['__FILE__']);
unset($this->replace['__ROUTINE__']);
unset($this->replace['__DIR__']);
unset($this->replace['__LINE__']);
} | php | {
"resource": ""
} |
q234994 | RoutineLoaderHelper.updateMetadata | train | private function updateMetadata(): void
{
$this->phpStratumMetadata['routine_name'] = $this->routineName;
$this->phpStratumMetadata['designation'] = $this->designationType;
$this->phpStratumMetadata['return'] = $this->returnType;
$this->phpStratumMetadata['paramete... | php | {
"resource": ""
} |
q234995 | RoutineLoaderHelper.updateParametersInfo | train | private function updateParametersInfo(): void
{
if (!empty($this->extendedParameters))
{
foreach ($this->extendedParameters as $spec_param_name => $spec_param_info)
{
$param_not_exist = true;
foreach ($this->parameters as $key => $param_info)
{
if ($param_info['pa... | php | {
"resource": ""
} |
q234996 | RoutineLoaderHelper.validateParameterLists | train | private function validateParameterLists(): void
{
// Make list with names of parameters used in database.
$database_parameters_names = [];
foreach ($this->parameters as $parameter_info)
{
$database_parameters_names[] = $parameter_info['parameter_name'];
}
// Make list with names of para... | php | {
"resource": ""
} |
q234997 | RoutineLoaderHelper.validateReturnType | train | private function validateReturnType(): void
{
// Return immediately if designation type is not appropriate for this method.
if (!in_array($this->designationType, ['function', 'singleton0', 'singleton1'])) return;
$types = explode('|', $this->returnType);
$diff = array_diff($types, ['string', 'int', ... | php | {
"resource": ""
} |
q234998 | Notifications.format | train | public static function format($hook, $type, $notification, $params) {
$event = elgg_extract('event', $params);
$comment = $event->getObject();
$recipient = elgg_extract('recipient', $params);
$language = elgg_extract('language', $params);
if (!$comment instanceof Comment) {
return;
}
$entity = $comm... | php | {
"resource": ""
} |
q234999 | Notifications.getSubscriptions | train | public static function getSubscriptions($hook, $type, $return, $params) {
$event = elgg_extract('event', $params);
if (!$event instanceof SubscriptionNotificationEvent) {
return;
}
$object = $event->getObject();
if (!$object instanceof Comment) {
return;
}
$subscriptions = [];
$actor_subscripti... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.