_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q8400
Initializations.initStrictExceptionsMode
train
protected static function initStrictExceptionsMode ($strictExceptionsMode) { $errorLevelsToExceptions = []; if ($strictExceptionsMode !== FALSE) { $sysCfgDebug = static::getSystemCfgDebugSection(); if (isset($sysCfgDebug['strictExceptions'])) { $rawStrictExceptions = $sysCfgDebug['strictExceptions']; $rawStrictExceptions = is_array($rawStrictExceptions) ? $rawStrictExceptions : explode(',', trim($rawStrictExceptions, '[]')); $errorLevelsToExceptions = array_map( function ($rawErrorLevel) {
php
{ "resource": "" }
q8401
Initializations.initHandlers
train
protected static function initHandlers () { $className = version_compare(PHP_VERSION, '5.5', '>') ? static::class : get_called_class(); foreach (static::$handlers as $key => $value) {
php
{ "resource": "" }
q8402
Initializations.initLogDirectory
train
protected static function initLogDirectory () { //if (static::$logDirectoryInitialized) return; $sysCfgDebug = static::getSystemCfgDebugSection(); $logDirConfiguredPath = isset($sysCfgDebug['logDirectory']) ? $sysCfgDebug['logDirectory'] : static::$LogDirectory; if (mb_substr($logDirConfiguredPath, 0, 1) === '~') { $app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance()); $logDirAbsPath = $app->GetRequest()->GetAppRoot() . '/' . ltrim(mb_substr($logDirConfiguredPath, 1), '/'); } else { $logDirAbsPath = $logDirConfiguredPath; } static::$LogDirectory = $logDirAbsPath; try { if (!is_dir($logDirAbsPath)) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; if (!mkdir($logDirAbsPath, 0777, TRUE)) throw new \RuntimeException( '['.$selfClass."] It was not possible to create log directory: `".$logDirAbsPath."`." );
php
{ "resource": "" }
q8403
Instancing.&
train
public function & InitAll () { /** @var $this \MvcCore\Request */ $this->GetScriptName(); $this->GetAppRoot(); $this->GetMethod(); $this->GetBasePath(); $this->GetScheme(); $this->IsSecure(); $this->GetHostName(); $this->GetHost(); $this->GetRequestPath(); $this->GetFullUrl(); $this->GetReferer(); $this->GetMicrotime(); $this->IsAjax(); if
php
{ "resource": "" }
q8404
Configuration.createResolver
train
public function createResolver() { $resolver = $this->getResolver(); if (isset($resolver)) { $resolver_class = get_class($resolver); // Create new retriever. $retriever = $resolver->getUriRetriever(); if (isset($retriever)) { $retriever_class = get_class($retriever); $new_retriever = new $retriever_class(); } else { $new_retriever = new UriRetriever(); } // Store max depth before init since maxDepth is set on the parent.
php
{ "resource": "" }
q8405
DatabaseQuery.handle
train
public function handle(LogManager $logger): void { $db = \resolve('db'); $callback = $this->buildQueryCallback($logger); foreach ($db->getQueryLog() as $query) { $callback(new QueryExecuted($query['query'],
php
{ "resource": "" }
q8406
DatabaseQuery.buildQueryCallback
train
protected function buildQueryCallback(LogManager $logger): callable { return function (QueryExecuted $query) use ($logger) {
php
{ "resource": "" }
q8407
UrlRewriteSubject.storeIsActive
train
public function storeIsActive($storeViewCode) { // query whether or not, the requested store is available if (isset($this->stores[$storeViewCode])) { return 1 === (integer) $this->stores[$storeViewCode][MemberNames::IS_ACTIVE]; } // throw an exception, if not throw new
php
{ "resource": "" }
q8408
InternalInits.initReverseParamsGetGreedyInfo
train
protected function initReverseParamsGetGreedyInfo (& $reverseSectionsInfo, & $constraints, & $paramName, & $sectionIndex, & $greedyCaught) { // complete greedy flag by star character inside param name $greedyFlag = mb_strpos($paramName, '*') !== FALSE; $sectionIsLast = NULL; // check greedy param specifics if ($greedyFlag) { if ($greedyFlag && $greedyCaught) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \InvalidArgumentException( "[".$selfClass."] Route pattern definition can have only one greedy `<param_name*>` " ." with star (to include everything - all characters and slashes . `.*`) ($this)." ); } $reverseSectionsCount = count($reverseSectionsInfo); $sectionIndexPlusOne = $sectionIndex + 1; if (// next section is optional $sectionIndexPlusOne < $reverseSectionsCount && !($reverseSectionsInfo[$sectionIndexPlusOne]->fixed) ) { // check if param is really greedy or not $constraintDefined = isset($constraints[$paramName]); $constraint = $constraintDefined ? $constraints[$paramName] : NULL ; $greedyReal =
php
{ "resource": "" }
q8409
InternalInits.initFlagsByPatternOrReverse
train
protected function initFlagsByPatternOrReverse ($pattern) { $scheme = static::FLAG_SCHEME_NO; if (mb_strpos($pattern, '//') === 0) { $scheme = static::FLAG_SCHEME_ANY; } else if (mb_strpos($pattern, 'http://') === 0) { $scheme = static::FLAG_SCHEME_HTTP; } else if (mb_strpos($pattern, 'https://') === 0) { $scheme = static::FLAG_SCHEME_HTTPS; } $host = static::FLAG_HOST_NO; if ($scheme) { if (mb_strpos($pattern, static::PLACEHOLDER_HOST) !== FALSE) { $host = static::FLAG_HOST_HOST; } else if (mb_strpos($pattern, static::PLACEHOLDER_DOMAIN) !== FALSE) { $host = static::FLAG_HOST_DOMAIN; } else {
php
{ "resource": "" }
q8410
InternalInits.throwExceptionIfKeyPropertyIsMissing
train
protected function throwExceptionIfKeyPropertyIsMissing ($propsNames) { $propsNames = func_get_args(); $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \LogicException( "[".$selfClass."] Route configuration property/properties is/are" ." missing:
php
{ "resource": "" }
q8411
Cookies.SetCookie
train
public function SetCookie ( $name, $value, $lifetime = 0, $path = '/', $domain = NULL, $secure = NULL, $httpOnly = TRUE ) { if ($this->IsSent()) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \RuntimeException(
php
{ "resource": "" }
q8412
Cookies.DeleteCookie
train
public function DeleteCookie ($name, $path = '/', $domain = NULL,
php
{ "resource": "" }
q8413
AttributeTrait.withAttribute
train
public function withAttribute($key, $value) { $newAttributes = $this->attributes->withAttribute($key, $value); $that = clone($this);
php
{ "resource": "" }
q8414
AttributeTrait.withoutAttribute
train
public function withoutAttribute($key) { $newAttributes = $this->attributes->withoutAttribute($key); $that = clone($this);
php
{ "resource": "" }
q8415
HttpRequest.createCurl
train
protected function createCurl() { $ch = curl_init(); // Add the body first so we can calculate a content length. $body = ''; if ($this->method === self::METHOD_HEAD) { curl_setopt($ch, CURLOPT_NOBODY, true); } elseif ($this->method !== self::METHOD_GET) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->method); $body = $this->makeCurlBody(); if ($body) { curl_setopt($ch, CURLOPT_POSTFIELDS, $body); } } // Decode the headers. $headers = []; foreach ($this->getHeaders() as $key => $values) { foreach ($values as $line) { $headers[] = "$key: $line"; } } if (is_string($body) && !$this->hasHeader('Content-Length')) { $headers[] = 'Content-Length: '.strlen($body); } if (!$this->hasHeader('Expect')) { $headers[] = 'Expect:'; } curl_setopt( $ch, CURLOPT_HTTP_VERSION, $this->getProtocolVersion() == '1.0' ? CURL_HTTP_VERSION_1_0 : CURL_HTTP_VERSION_1_1 ); curl_setopt($ch, CURLOPT_URL, $this->url);
php
{ "resource": "" }
q8416
HttpRequest.makeCurlBody
train
protected function makeCurlBody() { $body = $this->body; if (is_string($body)) { return (string)$body; } $contentType = $this->getHeader('Content-Type');
php
{ "resource": "" }
q8417
HttpRequest.execCurl
train
protected function execCurl($ch) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); $response = curl_exec($ch); // Split the full response into its headers and body $info = curl_getinfo($ch); $code = $info["http_code"]; if ($response) { $header_size = $info["header_size"]; $rawHeaders = substr($response, 0, $header_size); $status = null; $rawBody = substr($response, $header_size);
php
{ "resource": "" }
q8418
RGBColor.isValidChannelValue
train
public function isValidChannelValue($value, $channel) { if (!in_array($channel, self::$channels)) { throw new \InvalidArgumentException('Invalid Channel Name'); }
php
{ "resource": "" }
q8419
RGBColor.setAlpha
train
public function setAlpha($alpha) { $this->assertChannelValue($alpha, self::CHANNEL_ALPHA);
php
{ "resource": "" }
q8420
RGBColor.setRed
train
public function setRed($value) { $this->assertChannelValue($value, self::CHANNEL_RED);
php
{ "resource": "" }
q8421
RGBColor.setGreen
train
public function setGreen($value) { $this->assertChannelValue($value, self::CHANNEL_GREEN);
php
{ "resource": "" }
q8422
RGBColor.setBlue
train
public function setBlue($value) { $this->assertChannelValue($value, self::CHANNEL_BLUE);
php
{ "resource": "" }
q8423
RGBColor.getValue
train
public function getValue() { return (((int) $this->getRed() & 0xFF) << 16) | (((int) $this->getGreen() & 0xFF) << 8) |
php
{ "resource": "" }
q8424
RGBColor.setFromRGBColor
train
public function setFromRGBColor(RGBColor $color) { return $this->setRed($color->getRed()) ->setGreen($color->getGreen())
php
{ "resource": "" }
q8425
RGBColor.setFromArray
train
public function setFromArray(array $color) { return $this->setRed($color[0]) ->setGreen($color[1])
php
{ "resource": "" }
q8426
RGBColor.setFromValue
train
public function setFromValue($rgb, $hasalpha = true) { $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = ($rgb >> 0) & 0xFF; if ($hasalpha) { $a = ($rgb >> 24) & 0xff; return $this->setRed($r) ->setGreen($g)
php
{ "resource": "" }
q8427
RGBColor.setFromHex
train
public function setFromHex($hex, $alpha = 0) { if (!preg_match(self::$HexRegex, $hex)) { throw new \InvalidArgumentException(sprintf( 'Inavlid Hex Color "%s"', $hex )); } $ehex = ltrim($hex, '#'); if (strlen($ehex) === 3) { $ehex = $ehex[0] . $ehex[0] . $ehex[1] . $ehex[1] .
php
{ "resource": "" }
q8428
RGBColor.getRGBColor
train
public function getRGBColor() { return new self( $this->getRed()
php
{ "resource": "" }
q8429
RGBColor.brighter
train
public function brighter($shade = 0.7) { $r = $this->getRed(); $g = $this->getGreen(); $b = $this->getBlue(); $alpha = $this->getAlpha(); $i = (integer) (1.0 / (1.0 - $shade)); if ($r == 0 && $g == 0 && $b == 0) { return new self($i, $i, $i, $alpha); } if ($r > 0 && $r < $i) $r = $i; if ($g > 0 && $g < $i) $g = $i;
php
{ "resource": "" }
q8430
RGBColor.darker
train
public function darker($shade = 0.7) { return $this->setFromArray(array( max(array((integer) $this->getRed() * $shade, 0)) , max(array((integer) $this->getGreen() * $shade, 0))
php
{ "resource": "" }
q8431
RGBColor.blend
train
public function blend(RGBColor $color, $amount) { return $this->setFromArray(array( min(255, min($this->getRed(), $color->getRed()) + round(abs($color->getRed() - $this->getRed()) * $amount)) , min(255, min($this->getGreen(), $color->getGreen()) +
php
{ "resource": "" }
q8432
RGBColor.grayscale
train
public function grayscale() { $gray = min( 255 , round( 0.299 * $this->getRed() +
php
{ "resource": "" }
q8433
RGBColor.assertChannelValue
train
protected function assertChannelValue($value, $channel) { if (!$this->isValidChannelValue($value, $channel)) { throw new \InvalidArgumentException( sprintf('Invalid
php
{ "resource": "" }
q8434
BuildMetaModelOperationsListener.buildCommand
train
private function buildCommand($attribute, array $propertyData) { if ($attribute->get('check_listview') == 1) { $commandName = 'listviewtoggle_' . $attribute->getColName(); } else { $commandName = 'publishtoggle_' . $attribute->getColName(); } $toggle = new ToggleCommand(); $toggle->setName($commandName); $toggle->setLabel($GLOBALS['TL_LANG']['MSC']['metamodelattribute_checkbox']['toggle'][0]); $toggle->setDescription( \sprintf( $GLOBALS['TL_LANG']['MSC']['metamodelattribute_checkbox']['toggle'][1], $attribute->getName() ) ); $extra = $toggle->getExtra(); $extra['icon'] = 'visible.svg'; $objIconEnabled
php
{ "resource": "" }
q8435
BuildMetaModelOperationsListener.createBackendViewDefinition
train
protected function createBackendViewDefinition($container) { if ($container->hasDefinition(Contao2BackendViewDefinitionInterface::NAME)) { $view = $container->getDefinition(Contao2BackendViewDefinitionInterface::NAME); } else {
php
{ "resource": "" }
q8436
BuildMetaModelOperationsListener.handle
train
public function handle(BuildMetaModelOperationsEvent $event) { if (!$this->scopeMatcher->currentScopeIsBackend()) { return; } $allProps = $event->getScreen()['properties']; $properties = \array_map(function ($property) { return ($property['col_name'] ?? null); }, $allProps); foreach ($event->getMetaModel()->getAttributes() as $attribute) { if (!$this->wantToAdd($attribute, $properties)) { continue; } $info = []; foreach ($allProps as $prop) { if ($prop['col_name'] === $attribute->getColName()) { $info = $prop; } } $toggle = $this->buildCommand($attribute, $info); $container = $event->getContainer();
php
{ "resource": "" }
q8437
BuildMetaModelOperationsListener.wantToAdd
train
private function wantToAdd($attribute, array $properties): bool { return ($attribute instanceof Checkbox) &&
php
{ "resource": "" }
q8438
Select.buildBoostedFields
train
public function buildBoostedFields($fields) { // Assume strings are pre-formatted. if (is_string($fields)) { return $fields; } $processed = array(); foreach ($fields as $fieldName => $boost) { if (!is_array($boost)) { $processed[] = $fieldName . '^' . $boost; } else { $field = $fieldName . '~' . $boost[0];
php
{ "resource": "" }
q8439
AbstractPixelate.setBlockSize
train
public function setBlockSize($size) { if ($size <= 1) { throw new \InvalidArgumentException("Pixel Size Must Be Greater Than One");
php
{ "resource": "" }
q8440
Migrator.initialize
train
public function initialize() { if ($this->versionStorage->hasVersioningNode()) { throw new MigratorException('This repository has already been initialized. Will not re-initialize.'); }
php
{ "resource": "" }
q8441
Migrator.resolveTo
train
private function resolveTo($to, $from) { if (is_string($to)) { $to = strtolower($to); } if ($to === 'down') { $to = $this->versionCollection->getPreviousVersion($from); } if ($to === 'up') { $to = $this->versionCollection->getNextVersion($from); } if ($to === 'bottom') { $to = 0; } if ($to === 'top' || null === $to) { $to = $this->versionCollection->getLatestVersion(); } if (0 !== $to && false === strtotime($to)) { throw
php
{ "resource": "" }
q8442
Directory.add
train
public function add($name, Closure $callback = null) { try { $path = $this->finder->find($name); if (isset($this->assets[$path])) { $asset = $this->assets[$path]; } else { $asset = $this->factory->get('asset')->make($path); $asset->isRemote() and $asset->raw(); } is_callable($callback) and call_user_func($callback, $asset); return $this->assets[$path] = $asset;
php
{ "resource": "" }
q8443
Directory.javascript
train
public function javascript($name, Closure $callback = null) { return $this->add($name, function($asset) use ($callback)
php
{ "resource": "" }
q8444
Directory.directory
train
public function directory($path, Closure $callback = null) { try { $path = $this->finder->setWorkingDirectory($path); $this->directories[$path] = new Directory($this->factory, $this->finder, $path); // Once we've set the working directory we'll fire the callback so that any added assets // are relative to the working directory.
php
{ "resource": "" }
q8445
Directory.requireDirectory
train
public function requireDirectory($path = null) { if ( ! is_null($path)) { return $this->directory($path)->requireDirectory(); }
php
{ "resource": "" }
q8446
Directory.requireTree
train
public function requireTree($path = null) { if ( ! is_null($path)) { return $this->directory($path)->requireTree(); }
php
{ "resource": "" }
q8447
Directory.processRequire
train
protected function processRequire(Iterator $iterator) { // sort iterator by name $iterator = new SortingIterator($iterator, 'strnatcasecmp'); // Spin through each of the files within the iterator and if their a valid asset they // are added to the array of assets for this directory.
php
{ "resource": "" }
q8448
Directory.except
train
public function except($assets) { $assets = array_flatten(func_get_args()); // Store the directory instance on a variable that we can inject into the scope of // the closure below. This allows us to call the path conversion method. $directory = $this; $this->assets = $this->assets->filter(function($asset) use ($assets, $directory)
php
{ "resource": "" }
q8449
Directory.getPathRelativeToDirectory
train
public function getPathRelativeToDirectory($path) { // Get the last segment of the directory as asset paths will be relative to this // path. We can then replace this segment with nothing in the assets path.
php
{ "resource": "" }
q8450
Directory.rawOnEnvironment
train
public function rawOnEnvironment($environment) { $this->assets->each(function($asset)
php
{ "resource": "" }
q8451
Directory.getAssets
train
public function getAssets() { $assets = $this->assets; // Spin through each directory and recursively merge the current directories assets // on to the directories assets. This maintains the order of adding in the array // structure. $this->directories->each(function($directory) use (&$assets) { $assets = $directory->getAssets()->merge($assets); }); // Spin through each of the filters and apply them to each of the assets. Every filter // is applied and then later
php
{ "resource": "" }
q8452
LinearGradient.setType
train
public function setType($type) { if (!in_array($type, self::$supported)) { throw new \InvalidArgumentException(sprintf(
php
{ "resource": "" }
q8453
MelisPageTreeTable.getFullDatasPage
train
public function getFullDatasPage($id, $type = '') { $select = $this->tableGateway->getSql()->select(); $select->columns(array('*')); $select->join('melis_cms_page_lang', 'melis_cms_page_lang.plang_page_id = melis_cms_page_tree.tree_page_id', array('plang_lang_id')); $select->join('melis_cms_lang', 'melis_cms_lang.lang_cms_id = melis_cms_page_lang.plang_lang_id', array('*'), $select::JOIN_LEFT); $select->join('melis_cms_page_style', 'melis_cms_page_tree.tree_page_id = melis_cms_page_style.pstyle_page_id', array(), $select::JOIN_LEFT); $select->join('melis_cms_style', ' melis_cms_style.style_id = melis_cms_page_style.pstyle_style_id', array('*'), $select::JOIN_LEFT); if ($type == 'published' || $type == '') $select->join('melis_cms_page_published', 'melis_cms_page_published.page_id = melis_cms_page_tree.tree_page_id', array('*'), $select::JOIN_LEFT); if ($type == 'saved') $select->join('melis_cms_page_saved', 'melis_cms_page_saved.page_id = melis_cms_page_tree.tree_page_id', array('*'), $select::JOIN_LEFT); if ($type == '') {
php
{ "resource": "" }
q8454
MelisPageTreeTable.getPageChildrenByidPage
train
public function getPageChildrenByidPage($id, $publishedOnly = 0) { $select = $this->tableGateway->getSql()->select(); $select->columns(array('*')); $select->join('melis_cms_page_lang', 'melis_cms_page_lang.plang_page_id = melis_cms_page_tree.tree_page_id', array('plang_lang_id')); $select->join('melis_cms_lang', 'melis_cms_lang.lang_cms_id = melis_cms_page_lang.plang_lang_id', array('*'), $select::JOIN_LEFT); $select->join('melis_cms_page_published', 'melis_cms_page_published.page_id = melis_cms_page_tree.tree_page_id', array('*'), $select::JOIN_LEFT); $select->join('melis_cms_page_style', 'melis_cms_page_tree.tree_page_id = melis_cms_page_style.pstyle_page_id', array(), $select::JOIN_LEFT);
php
{ "resource": "" }
q8455
MelisPageTreeTable.getPagesBySearchValue
train
public function getPagesBySearchValue($value, $type = '') { $select = $this->tableGateway->getSql()->select(); $select->columns(array('tree_page_id')); if ($type == 'published' || $type == ''){ $select->join('melis_cms_page_published', 'melis_cms_page_published.page_id = melis_cms_page_tree.tree_page_id', array(), $select::JOIN_LEFT); } if ($type == 'saved'){ $select->join('melis_cms_page_saved', 'melis_cms_page_saved.page_id = melis_cms_page_tree.tree_page_id',
php
{ "resource": "" }
q8456
MelisTemplateTable.getSortedTemplates
train
public function getSortedTemplates() { $select = new Select('melis_cms_template'); $select->order('tpl_zf2_website_folder ASC'); $select->order('tpl_name ASC');
php
{ "resource": "" }
q8457
AbstractPreset.getOverlayCanvas
train
public function getOverlayCanvas($file) { $canvas = new Canvas();
php
{ "resource": "" }
q8458
Headers.&
train
public function & SetDisabledHeaders ($disabledHeaders) { /** @var $this \MvcCore\Response */ $this->disabledHeaders = [];
php
{ "resource": "" }
q8459
TranslationManagerServiceProvider.registerCommands
train
private function registerCommands() { if ($this->app->runningInConsole()) { $this->commands([ \Brotzka\TranslationManager\Module\Console\Commands\TranslationToDatabase::class,
php
{ "resource": "" }
q8460
IniDump.Dump
train
public function Dump () { $environment = static::GetEnvironment(TRUE); list($sections, $envSpecifics) = $this->dumpSectionsInfo(); $levelKey = ''; $basicData = []; $sectionsData = []; foreach ($this->data as $key => & $value) { if (is_object($value) || is_array($value)) { if ($sectionsData) $sectionsData[] = ''; $sectionType = isset($sections[$key]) ? $sections[$key] : 0; $environmentSpecificSection = $sectionType === 3; if ($sectionType) { unset($sections[$key]); $sectionsData[] = ($environmentSpecificSection ? '[' . $environment . ' > ' . $key . ']' : '[' . $key . ']'); $levelKey = ''; } else { $levelKey = (string) $key; } $this->dumpRecursive($levelKey, $value, $sectionsData); if ($environmentSpecificSection
php
{ "resource": "" }
q8461
IniDump.dumpScalarValue
train
protected function dumpScalarValue ($value) { if (is_numeric($value)) { return (string) $value; } else if (is_bool($value)) { return $value ? 'true' : 'false'; } else if ($value === NULL) { return 'null'; } else { static $specialChars = [ '=', '/', '.', '#', '&', '!', '?', '-', '@', "'", '"', '*', '^', '[', ']', '(', ')', '{', '}', '<', '>', '\n', '\r', ]; $valueStr = (string) $value;
php
{ "resource": "" }
q8462
LeafProperty.initDefaultProperties
train
public function initDefaultProperties() { if (isset($this->schema) && $this->setPropertyDefaultValue($this->schema)) {
php
{ "resource": "" }
q8463
BuildCommand.gatherCollections
train
protected function gatherCollections() { if ( ! is_null($collection = $this->input->getArgument('collection'))) { if ( ! $this->environment->has($collection)) { $this->comment('['.$collection.'] Collection not found.');
php
{ "resource": "" }
q8464
AssetFactory.make
train
public function make($path) { $absolutePath = $this->buildAbsolutePath($path); $relativePath = $this->buildRelativePath($absolutePath);
php
{ "resource": "" }
q8465
AssetFactory.buildRelativePath
train
public function buildRelativePath($path) { if (is_null($path)) return $path; $relativePath = str_replace(array(realpath($this->publicPath), '\\'), array('', '/'), $path); // If the asset is not a remote asset then we'll trim the relative path even further to remove // any unnecessary leading or trailing slashes. This will leave us with a nice relative path. if ( ! starts_with($path, '//') and ! (bool) filter_var($path, FILTER_VALIDATE_URL)) { $relativePath = trim($relativePath, '/'); // If the given path is the same as the built relative path then the asset appears to be
php
{ "resource": "" }
q8466
ReadWrite.&
train
public static function & GetConfig ($appRootRelativePath) { if (!isset(self::$configsCache[$appRootRelativePath])) { $app = self::$app ?: self::$app = & \MvcCore\Application::GetInstance(); $systemConfigClass =
php
{ "resource": "" }
q8467
ReadWrite.&
train
protected static function & getConfigInstance ($appRootRelativePath, $systemConfig = FALSE) { $app = self::$app ?: self::$app = & \MvcCore\Application::GetInstance(); $appRoot = self::$appRoot ?: self::$appRoot = $app->GetRequest()->GetAppRoot(); $fullPath = $appRoot . '/' . str_replace( '%appPath%', $app->GetAppDir(), ltrim($appRootRelativePath, '/') ); if (!file_exists($fullPath)) { $result = FALSE; } else {
php
{ "resource": "" }
q8468
SolrClient.normalizeParams
train
public function normalizeParams(RequestHandler $handler, $params) { if (is_string($params)) { $params = array('q' => $params); } elseif (!is_array($params)) {
php
{ "resource": "" }
q8469
OopChecking.CheckClassInterface
train
public static function CheckClassInterface ($testClassName, $interfaceName, $checkStaticMethods = FALSE, $throwException = TRUE) { $result = FALSE; $errorMsg = ''; // check given test class for all implemented instance methods by given interface $interfaceName = trim($interfaceName, '\\'); $testClassType = new \ReflectionClass($testClassName); if (in_array($interfaceName, $testClassType->getInterfaceNames(), TRUE)) { $result = TRUE; } else { $errorMsg = "Class `$testClassName` doesn't implement interface `$interfaceName`."; } if ($result && $checkStaticMethods) { // check given test class for all implemented static methods by given interface $allStaticsImplemented = TRUE; $interfaceMethods = static::checkClassInterfaceGetPublicStaticMethods($interfaceName); foreach ($interfaceMethods as $methodName) { if (!$testClassType->hasMethod($methodName)) { $allStaticsImplemented = FALSE; $errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`."; break; } $testClassStaticMethod = $testClassType->getMethod($methodName); if (!$testClassStaticMethod->isStatic()) { $allStaticsImplemented
php
{ "resource": "" }
q8470
OopChecking.CheckClassTrait
train
public static function CheckClassTrait ($testClassName, $traitName, $checkParentClasses = FALSE, $throwException = TRUE) { $result = FALSE; $errorMsg = ''; // check given test class for all implemented instance methods by given interface $testClassType = new \ReflectionClass($testClassName); if (in_array($traitName, $testClassType->getTraitNames(), TRUE)) { $result = TRUE; } else if ($checkParentClasses) { $currentClassType = $testClassType; while (TRUE) { $parentClass = $currentClassType->getParentClass(); if ($parentClass === FALSE) break; $parentClassType = new \ReflectionClass($parentClass->getName()); if (in_array($traitName, $parentClassType->getTraitNames(), TRUE)) { $result = TRUE; break; } else { $currentClassType = $parentClassType; } }
php
{ "resource": "" }
q8471
OopChecking.&
train
protected static function & checkClassInterfaceGetPublicStaticMethods ($interfaceName) { if (!isset(static::$interfacesStaticMethodsCache[$interfaceName])) { $methods = []; $interfaceType = new \ReflectionClass($interfaceName); $publicOrStaticMethods = $interfaceType->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_STATIC);
php
{ "resource": "" }
q8472
HtmlAttributes.generateHtmlString
train
protected function generateHtmlString(...$attributesList): HtmlString { $attributesArray = $this->buildAttributesArray(...$attributesList);
php
{ "resource": "" }
q8473
HtmlAttributes.buildHtmlString
train
protected function buildHtmlString(array $attributesArray): string { $html = ''; foreach ($attributesArray as $key => $attribute) { $spacer = strlen($html) ? ' ' : ''; if ($key && is_string($key)) {
php
{ "resource": "" }
q8474
StatusCodeContainerTrait.withStatusCode
train
public function withStatusCode(int $code) { if ($this->statusCode == $code) {
php
{ "resource": "" }
q8475
Text.setLineSpacing
train
public function setLineSpacing($spacing) { if ($spacing < 0) { throw new \InvalidArgumentException(sprintf( 'Invalid Line Spacing "%s" - Spacing Must Be Greater Than Zero'
php
{ "resource": "" }
q8476
Text.getBoundingBox
train
public function getBoundingBox($padding = 10) { $bare = imageftbbox( $this->getFontSize() , 0 , $this->getFont() , $this->getString() , array('linespacing' => $this->getLineSpacing()) ); $a = deg2rad($this->getAngle()); $ca = cos($a); $sa = sin($a); $rect = array(); for ($i = 0; $i < 7; $i += 2) { $rect[$i] = round($bare[$i] * $ca + $bare[$i + 1] * $sa); $rect[$i + 1] = round($bare[$i + 1] * $ca - $bare[$i] * $sa); } $minX = min(array($rect[0], $rect[2], $rect[4], $rect[6])); $maxX = max(array($rect[0], $rect[2], $rect[4], $rect[6])); $minY = min(array($rect[1], $rect[3], $rect[5], $rect[7])); $maxY = max(array($rect[1], $rect[3], $rect[5], $rect[7]));
php
{ "resource": "" }
q8477
EndpointCompilerPass.createAuthentication
train
protected function createAuthentication(ContainerBuilder $container, $authentication, $type) { if ($authentication['type'] == 'basic' && (!isset($authentication['username']) || !isset($authentication['password']))) { throw new \LogicException('Username and password are mandatory if using the basic authentication'); } if ($authentication['type'] == 'basic') { // Create an authentication service $authenticationDefinition = new Definition( 'Bluetea\Api\Authentication\BasicAuthentication', array('username' => $authentication['username'], 'password' => $authentication['password']) ); } elseif ($authentication['type'] == 'anonymous') {
php
{ "resource": "" }
q8478
EndpointCompilerPass.createApiClient
train
protected function createApiClient(ContainerBuilder $container, $apiClient, $baseUrl, $type) { if ($apiClient == 'guzzle') { // Create an API client service $apiClientDefinition = new Definition( 'Bluetea\Api\Client\GuzzleClient', array($baseUrl, new Reference(sprintf('jira_rest_api.%s_authentication', $type))) ); $apiClientDefinition->addMethodCall('setContentType', array('application/json'));
php
{ "resource": "" }
q8479
EndpointCompilerPass.initializeEndpoints
train
protected function initializeEndpoints(ContainerBuilder $container, $availableApi) { // Add the jira api client to the jira endpoints if (isset($availableApi['jira'])) { $taggedEndpoints = $container->findTaggedServiceIds('jira_rest_api.jira_endpoint'); foreach ($taggedEndpoints as $serviceId => $attributes) { $endpoint = $container->getDefinition($serviceId); // Override the arguments to prevent errors $endpoint->setArguments(array(new Reference('jira_rest_api.jira_api_client'))); } } // Add the crowd api client to the jira endpoints if
php
{ "resource": "" }
q8480
LoggingBackend.log
train
protected function log($operation, $id = null, $ttl = null, $hit = null) { $message = strtoupper($operation); if ($id !== null) { $id = implode(', ', (array) $id); if ($ttl !== null) { $message = sprintf('%s(%s, ttl=%s)', $message, $id, $ttl); } else { $message = sprintf('%s(%s)', $message, $id); }
php
{ "resource": "" }
q8481
PWELogger.debug_print
train
private static function debug_print($file, $level, $format, $data) { array_shift($data); foreach ($data as $k => $v) { if (is_string($v)) { $data[$k] = str_replace("\n", ' ', $v); } elseif ($v instanceof \Exception) { $data[$k] = $v->__toString(); } elseif (!is_numeric($v)) { $data[$k] = str_replace("\n", " ", json_encode($v)); } } $mtime = microtime(true); $time = 1000 * ($mtime - intval($mtime)); $trace = debug_backtrace(); $location = $trace[2]['function'];
php
{ "resource": "" }
q8482
DBRecordTrait.getListQuery
train
public static function getListQuery( ?array $condition = [], $key = null, $value = null, $indexBy = true, $orderBy = true, $alias = null ) { if( !$alias && is_subclass_of( get_called_class(), ActiveRecord::class ) ) { $table = Yii::$app->db->schema->getRawTableName( ( get_called_class() )::tableName() ); } else if( $alias ) { $table = $alias; } else { $table = ''; } !$table ?: $table .= '.';
php
{ "resource": "" }
q8483
DBRecordTrait.getRawAttributes
train
public function getRawAttributes( ?array $only = null, ?array $except = [], ?bool $schemaOnly = false ) { $values = []; if( $only === null ) { $only = $this->attributes( $only, $except, $schemaOnly ); } foreach( $only as $name ) { $values[ $name ] = $this->getAttribute( $name ); } if( $except )
php
{ "resource": "" }
q8484
Connection.start
train
public function start($browserName) { if (!$this->customSidProvided) { $this->sid
php
{ "resource": "" }
q8485
Connection.executeCommand
train
public function executeCommand($command, array $parameters = array()) { $content = $this->post( sprintf('http://%s:%d/_s_/dyn/Driver_%s', $this->host, $this->port, $command), array_merge($parameters, array('sahisid' => $this->sid)) )->getContent(); if (false !== strpos($content,
php
{ "resource": "" }
q8486
Connection.executeStep
train
public function executeStep($step, $limit = null) { $this->executeCommand('setStep', array('step' => $step)); $limit = $limit ?: $this->limit; $check = 'false'; while ('true' !== $check) { usleep(100000); if (--$limit <= 0) { throw new Exception\ConnectionException( 'Command execution time limit reached: `' . $step . '`'
php
{ "resource": "" }
q8487
Connection.evaluateJavascript
train
public function evaluateJavascript($expression, $limit = null) { $key = '___lastValue___' . uniqid(); $this->executeStep( sprintf("_sahi.setServerVarPlain(%s, JSON.stringify(%s))", json_encode($key), $expression), $limit
php
{ "resource": "" }
q8488
Connection.post
train
private function post($url, array $query = array()) {
php
{ "resource": "" }
q8489
Connection.prepareQueryString
train
private function prepareQueryString(array $query) { $items = array(); foreach ($query as $key => $val) {
php
{ "resource": "" }
q8490
PluginRegistry.getPlugin
train
public function getPlugin($name) { if (!$this->has($name)) { throw new PluginNotFoundException($name,
php
{ "resource": "" }
q8491
LuceneIndexManager.getIndex
train
public function getIndex($indexName) { if (array_key_exists($indexName, $this->indices)) { return
php
{ "resource": "" }
q8492
MelisFrontNavigation.getChildrenRecursive
train
public function getChildrenRecursive($idPage) { $results = array(); $melisTree = $this->serviceLocator->get('MelisEngineTree'); $publishedOnly = 1; $pages = $melisTree->getPageChildren($idPage,$publishedOnly); if ($pages) { $rpages = $pages->toArray(); foreach ($rpages as $page) {
php
{ "resource": "" }
q8493
MelisFrontNavigation.getAllSubpages
train
public function getAllSubpages($pageId) { $results = array(); //Services $melisTree = $this->serviceLocator->get('MelisEngineTree'); $pagePub = $this->getServiceLocator()->get('MelisEngineTablePagePublished'); $pageSave = $this->getServiceLocator()->get('MelisEngineTablePageSaved'); $pageSearchType = null; $pages = $melisTree->getPageChildren($pageId,2); if($pages) { $rpages = $pages->toArray(); foreach ($rpages as $page) { $pageStat = $page['page_status'] ?? null; //if the page is published if($pageStat){ $pageData = $pagePub->getEntryById($page['tree_page_id'])->current(); $pageSearchType = $pageData->page_search_type ?? null; } //if the page is unpublished else{ $pageData = $pageSave->getEntryById($page['tree_page_id'])->current();
php
{ "resource": "" }
q8494
CropExtension.getCropEndpoint
train
public function getCropEndpoint( $endpoint, $parameters = array(), $absolute = UrlGeneratorInterface::ABSOLUTE_PATH ) { $parameters = array_merge($parameters, array('endpoint'
php
{ "resource": "" }
q8495
HOTP.setDigits
train
public function setDigits($digits) { $digits = abs(intval($digits)); if ($digits < 1 || $digits > 10) { throw new \InvalidArgumentException('Digits must be
php
{ "resource": "" }
q8496
HOTP.setHashFunction
train
public function setHashFunction($hashFunction) { $hashFunction = strtolower($hashFunction); if (!in_array($hashFunction, hash_algos())) { throw new \InvalidArgumentException("$hashFunction is
php
{ "resource": "" }
q8497
HOTP.setWindow
train
public function setWindow($window) { $window = abs(intval($window));
php
{ "resource": "" }
q8498
Document.getFieldType
train
public function getFieldType($fieldName) { if (!array_key_exists($fieldName, $this->_fields)) { throw new \Exception("Field name \"$fieldName\" not
php
{ "resource": "" }
q8499
Net_SmartIRC_irccommands.message
train
public function message($type, $destination, $messagearray, $priority = SMARTIRC_MEDIUM ) { if (!is_array($messagearray)) { $messagearray = array($messagearray); } switch ($type) { case SMARTIRC_TYPE_CHANNEL: case SMARTIRC_TYPE_QUERY: foreach ($messagearray as $message) { $this->send('PRIVMSG '.$destination.' :'.$message, $priority); } break; case SMARTIRC_TYPE_ACTION: foreach ($messagearray as $message) { $this->send('PRIVMSG '.$destination.' :'.chr(1).'ACTION ' .$message.chr(1), $priority ); } break; case SMARTIRC_TYPE_NOTICE: foreach ($messagearray as $message) { $this->send('NOTICE '.$destination.' :'.$message, $priority); }
php
{ "resource": "" }