_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q20200
PhoneNumberMatcher.limit
train
protected static function limit($lower, $upper) { if (($lower < 0) || ($upper <= 0) || ($upper < $lower)) { throw
php
{ "resource": "" }
q20201
PhoneNumberMatcher.isLatinLetter
train
public static function isLatinLetter($letter) { // Combining marks are a subset of non-spacing-mark. if (preg_match('/\p{L}/u', $letter) !== 1 && preg_match('/\p{Mn}/u', $letter) !== 1) { return false; }
php
{ "resource": "" }
q20202
PhoneNumberMatcher.getNationalNumberGroups
train
protected static function getNationalNumberGroups( PhoneNumberUtil $util, PhoneNumber $number, NumberFormat $formattingPattern = null ) { if ($formattingPattern === null) { // This will be in the format +CC-DG;ext=EXT where DG represents groups of digits. $rfc...
php
{ "resource": "" }
q20203
PhoneNumber.clear
train
public function clear() { $this->clearCountryCode(); $this->clearNationalNumber(); $this->clearExtension(); $this->clearItalianLeadingZero(); $this->clearNumberOfLeadingZeros(); $this->clearRawInput();
php
{ "resource": "" }
q20204
PhoneNumber.mergeFrom
train
public function mergeFrom(PhoneNumber $other) { if ($other->hasCountryCode()) { $this->setCountryCode($other->getCountryCode()); } if ($other->hasNationalNumber()) { $this->setNationalNumber($other->getNationalNumber()); } if ($other->hasExtension()) {...
php
{ "resource": "" }
q20205
PhoneNumber.setNumberOfLeadingZeros
train
public function setNumberOfLeadingZeros($value) { $this->hasNumberOfLeadingZeros = true;
php
{ "resource": "" }
q20206
PhoneNumber.equals
train
public function equals(PhoneNumber $other) { $sameType = get_class($other) == get_class($this); $sameCountry = $this->hasCountryCode() == $other->hasCountryCode() && (!$this->hasCountryCode() || $this->getCountryCode() == $other->getCountryCode()); $sameNational = $this->hasNatio...
php
{ "resource": "" }
q20207
GenerateTimeZonesMapData.parseTextFile
train
private function parseTextFile() { $data = file($this->inputTextFile); $timeZoneMap = array(); foreach ($data as $line) { // Remove \n $line = str_replace(array("\n", "\r"), '', $line); $line = trim($line); if (strlen($line) == 0 || substr($...
php
{ "resource": "" }
q20208
PhoneNumberOfflineGeocoder.getDescriptionForNumber
train
public function getDescriptionForNumber(PhoneNumber $number, $locale, $userRegion = null) { $numberType = $this->phoneUtil->getNumberType($number); if ($numberType === PhoneNumberType::UNKNOWN) { return ''; } if (!$this->phoneUtil->isNumberGeographical($numberType, $num...
php
{ "resource": "" }
q20209
PhoneNumberOfflineGeocoder.getCountryNameForNumber
train
protected function getCountryNameForNumber(PhoneNumber $number, $locale) { $regionCodes = $this->phoneUtil->getRegionCodesForCountryCode($number->getCountryCode()); if (count($regionCodes) === 1) { return $this->getRegionDisplayName($regionCodes[0], $locale); } $regionW...
php
{ "resource": "" }
q20210
PhoneNumberOfflineGeocoder.getRegionDisplayName
train
protected function getRegionDisplayName($regionCode, $locale) { if ($regionCode === null || $regionCode == 'ZZ' || $regionCode === PhoneNumberUtil::REGION_CODE_FOR_NON_GEO_ENTITY)
php
{ "resource": "" }
q20211
PhoneNumberOfflineGeocoder.getDescriptionForValidNumber
train
public function getDescriptionForValidNumber(PhoneNumber $number, $locale, $userRegion = null) { // If the user region matches the number's region, then we just show the lower-level // description, if one exists - if no description exists, we will show the region(country) name // for the num...
php
{ "resource": "" }
q20212
BaseIpHelper.expandIPv6
train
public static function expandIPv6($ip) { $addr = inet_pton($ip); if ($addr === false) { return false; } $hex = unpack('H*hex', $addr);
php
{ "resource": "" }
q20213
Template.compose
train
public function compose(MessageInterface $message, $params = []) { $this->message = $message; if (is_array($this->viewName)) { if (isset($this->viewName['html'])) { $html = $this->render($this->viewName['html'], $params, $this->htmlLayout); } if (...
php
{ "resource": "" }
q20214
Event.setResult
train
public function setResult($result): self { $this->_result = $result;
php
{ "resource": "" }
q20215
Event.getName
train
public function getName() { if ($this->_name === null) {
php
{ "resource": "" }
q20216
HeaderCollection.fromArray
train
public function fromArray(array $array) { $this->removeAll(); foreach ($array as $name => $values) { if (\is_array($values)) { foreach ($values as $value) {
php
{ "resource": "" }
q20217
BaseYii.createObject
train
public static function createObject($config, array $params = [], ContainerInterface $container
php
{ "resource": "" }
q20218
BaseYii.log
train
public static function log($level, $message, $category = 'application') { if (LogLevel::DEBUG === $level && !YII_DEBUG) { return; } $logger = static::get('logger', null, false); if ($logger) {
php
{ "resource": "" }
q20219
BaseYii.getLocaleString
train
public static function getLocaleString(string $default = 'en-US'): string { $i18n = static::get('i18n', null, false);
php
{ "resource": "" }
q20220
BaseYii.getSourceLocaleString
train
public static function getSourceLocaleString(string $default = 'en-US'): string { $view = static::get('view', null, false);
php
{ "resource": "" }
q20221
BaseYii.getTimeZone
train
public static function getTimeZone(string $default = 'UTC'): string { $i18n = static::get('i18n', null, false);
php
{ "resource": "" }
q20222
BaseYii.getEncoding
train
public static function getEncoding(ContainerInterface $container = null): string { $i18n = static::get('i18n', $container, false);
php
{ "resource": "" }
q20223
BaseYii.get
train
public static function get(string $name, ContainerInterface $container = null, bool $throwException = true) { if ($container === null) { $container = static::$container; } if ($container !== null && $container->has($name)) { return static::$container->get($name);
php
{ "resource": "" }
q20224
Security.decrypt
train
protected function decrypt($data, $passwordBased, $secret, $info) { if (!extension_loaded('openssl')) { throw new InvalidConfigException('Encryption requires the OpenSSL PHP extension'); } if (!isset($this->allowedCiphers[$this->cipher][0], $this->allowedCiphers[$this->cipher][1]...
php
{ "resource": "" }
q20225
Module.createController
train
public function createController($route) { if ($route === '') { $route = $this->defaultRoute; } // double slashes or leading/ending slashes may cause substr problem $route = trim($route, '/'); if (strpos($route, '//') !== false) { return false; ...
php
{ "resource": "" }
q20226
Module.get
train
public function get($id, bool $throwException = true) { if (!$this->_container->has($id)) { if ($throwException) { throw
php
{ "resource": "" }
q20227
MessageTrait.getHeaderCollection
train
public function getHeaderCollection() { if ($this->_headerCollection === null) { $headerCollection = new HeaderCollection(); $headerCollection->fromArray($this->defaultHeaders());
php
{ "resource": "" }
q20228
MessageTrait.setHeaders
train
public function setHeaders($headers) { $headerCollection = $this->getHeaderCollection();
php
{ "resource": "" }
q20229
MessageTrait.withBody
train
public function withBody(StreamInterface $body) { if ($this->getBody() === $body) {
php
{ "resource": "" }
q20230
BaseUrl.canonical
train
public static function canonical() { $params = Yii::getApp()->controller->actionParams;
php
{ "resource": "" }
q20231
BaseHtml.beginTag
train
public static function beginTag($name, $options = []) { if ($name === null || $name === false) { return ''; }
php
{ "resource": "" }
q20232
BaseHtml.getInputId
train
public static function getInputId($model, $attribute) { $name = strtolower(static::getInputName($model, $attribute));
php
{ "resource": "" }
q20233
Aliases.set
train
public function set(string $alias, ?string $path): void { if (strncmp($alias, '@', 1)) { $alias = '@' . $alias; } $pos = strpos($alias, '/'); $root = $pos === false ? $alias : substr($alias, 0, $pos); if ($path !== null) { $path = strncmp($path, '@', 1...
php
{ "resource": "" }
q20234
FileValidator.getSizeLimit
train
public function getSizeLimit() { // Get the lowest between post_max_size and upload_max_filesize, log a warning if the first is < than the latter $limit = $this->sizeToBytes(ini_get('upload_max_filesize')); $postLimit = $this->sizeToBytes(ini_get('post_max_size')); if ($postLimit > 0...
php
{ "resource": "" }
q20235
BaseFileHelper.unlink
train
public static function unlink($path): bool { $isWindows = DIRECTORY_SEPARATOR === '\\'; if (!$isWindows) { return unlink($path); } if (is_link($path) &&
php
{ "resource": "" }
q20236
BaseFileHelper.firstWildcardInPattern
train
private static function firstWildcardInPattern($pattern) { $wildcards = ['*', '?', '[', '\\']; $wildcardSearch = function ($carry, $item) use ($pattern) { $position = strpos($pattern, $item);
php
{ "resource": "" }
q20237
Application.debug
train
public function debug($message, string $category = 'application'): void {
php
{ "resource": "" }
q20238
Application.log
train
public function log(string $level, $message, $category = 'application'): void {
php
{ "resource": "" }
q20239
Application.setBasePath
train
public function setBasePath($path) { parent::setBasePath($path); $this->setAlias('@app', $this->getBasePath());
php
{ "resource": "" }
q20240
Application.run
train
public function run() { if (YII_ENABLE_ERROR_HANDLER) { $this->get('errorHandler')->register(); } try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(RequestEvent::BEFORE); $this->state = self::STATE_HANDLING_REQUEST; ...
php
{ "resource": "" }
q20241
Formatter.asNtext
train
public function asNtext($value) { if ($value === null) { return $this->getNullDisplay();
php
{ "resource": "" }
q20242
Formatter.asImage
train
public function asImage($value, $options = []) { if ($value === null) { return $this->getNullDisplay();
php
{ "resource": "" }
q20243
Formatter.asBoolean
train
public function asBoolean($value) { if ($value === null) { return $this->getNullDisplay(); }
php
{ "resource": "" }
q20244
Formatter.asScientific
train
public function asScientific($value, $decimals = null, $options = [], $textOptions = []) { if ($value === null) { return $this->getNullDisplay(); } $value = $this->normalizeNumericValue($value); if ($this->_intlLoaded) { $f = $this->createNumberFormatter(Numb...
php
{ "resource": "" }
q20245
Formatter.asCurrency
train
public function asCurrency($value, $currency = null, $options = [], $textOptions = []) { if ($value === null) { return $this->getNullDisplay(); } $normalizedValue = $this->normalizeNumericValue($value); if ($this->isNormalizedValueMispresented($value, $n...
php
{ "resource": "" }
q20246
Formatter.asSpellout
train
public function asSpellout($value) { if ($value === null) { return $this->getNullDisplay(); } $value = $this->normalizeNumericValue($value); if ($this->_intlLoaded) { $f = $this->createNumberFormatter(NumberFormatter::SPELLOUT); if (($result = $f->...
php
{ "resource": "" }
q20247
Formatter.createNumberFormatter
train
protected function createNumberFormatter($style, $decimals = null, $options = [], $textOptions = []) { $formatter = new NumberFormatter($this->getLocale(), $style); // set text attributes foreach ($this->numberFormatterTextOptions as $name => $attribute) { $formatter->setTextAtt...
php
{ "resource": "" }
q20248
Formatter.normalizeNumericStringValue
train
protected function normalizeNumericStringValue($value) { $separatorPosition = strrpos($value, '.'); if ($separatorPosition !== false) { $integerPart = substr($value, 0, $separatorPosition); $fractionalPart = substr($value, $separatorPosition + 1); } else { ...
php
{ "resource": "" }
q20249
Component.on
train
public function on($name, $handler, array $params = [], $append = true) { $this->ensureBehaviors(); if (strpos($name, '*') !== false) { if ($append || empty($this->_eventWildcards[$name])) { $this->_eventWildcards[$name][] = [$handler, $params]; } else { ...
php
{ "resource": "" }
q20250
ErrorHandler.register
train
public function register() { ini_set('display_errors', false); set_exception_handler([$this, 'handleException']); set_error_handler([$this, 'handleError']); if ($this->memoryReserveSize > 0) {
php
{ "resource": "" }
q20251
ErrorHandler.flushLogger
train
protected function flushLogger() { if ($this->logger instanceof \Yiisoft\Log\Logger) { $this->logger->flush(true); // attempt to invoke logger destructor:
php
{ "resource": "" }
q20252
Model.validateMultiple
train
public static function validateMultiple($models, $attributeNames = null, $clearErrors = true) { $valid = true; /* @var $model Model */ foreach ($models as $model) {
php
{ "resource": "" }
q20253
Translator.init
train
public function init() { parent::init(); if (!isset($this->translations['yii']) && !isset($this->translations['yii*'])) { $this->translations['yii'] = [ '__class' => PhpMessageSource::class, 'sourceLanguage' => 'en-US',
php
{ "resource": "" }
q20254
BaseHtmlPurifier.process
train
public static function process(string $content, $config = null): string { $configInstance = static::createConfig($config); $configInstance->autoFinalize
php
{ "resource": "" }
q20255
BaseHtmlPurifier.truncateCharacters
train
public static function truncateCharacters(string $content, int $count, string $suffix = '...', string $encoding = 'utf-8', $config = null): string { $config = static::createConfig($config); $tokens = \HTMLPurifier_Lexer::create($config)->tokenizeHTML($content, $config, new \HTMLPurifier_Context());...
php
{ "resource": "" }
q20256
Uri.setComponent
train
protected function setComponent($name, $value) { if ($this->_string !== null) { $this->_components = $this->parseUri($this->_string); }
php
{ "resource": "" }
q20257
Uri.getComponents
train
protected function getComponents() { if ($this->_components === null) { if ($this->_string === null) { return []; }
php
{ "resource": "" }
q20258
Uri.composeUri
train
protected function composeUri(array $components) { $uri = ''; $scheme = empty($components['scheme']) ? 'http' : $components['scheme']; if ($scheme !== '') { $uri .= $scheme . ':'; } $authority = $this->composeAuthority($components); if ($authority !== '...
php
{ "resource": "" }
q20259
Uri.isDefaultPort
train
protected function isDefaultPort($scheme, $port) { if (!isset(self::$defaultPorts[$scheme])) { return false;
php
{ "resource": "" }
q20260
BaseMessage.send
train
public function send(MailerInterface $mailer = null) { if ($mailer === null && $this->mailer === null) { $mailer = Yii::getApp()->getMailer();
php
{ "resource": "" }
q20261
Locale.getFallbackLocale
train
public function getFallbackLocale(): self { if ($this->variant !== null) { return $this->withVariant(null); } if ($this->region !== null) { return $this->withRegion(null); }
php
{ "resource": "" }
q20262
Pagination.createUrl
train
public function createUrl($page, $pageSize = null, $absolute = false) { $page = (int) $page; $pageSize = (int) $pageSize; if (($params = $this->params) === null) { $request = Yii::getApp()->getRequest(); $params = $request instanceof Request ? $request->getQueryParams...
php
{ "resource": "" }
q20263
BaseObject.__isset
train
public function __isset($name) { $getter = 'get' . $name; if (method_exists($this,
php
{ "resource": "" }
q20264
BaseObject.canGetProperty
train
public function canGetProperty($name, $checkVars = true) { return method_exists($this, 'get' . $name)
php
{ "resource": "" }
q20265
I18N.translate
train
public function translate(string $category, string $message, array $params = [], string $language =
php
{ "resource": "" }
q20266
I18N.getCurrencySymbol
train
public function getCurrencySymbol($currencyCode = null): string { if (!extension_loaded('intl')) { throw new InvalidConfigException('Locale component requires PHP intl extension to be installed.'); } $locale = $this->locale; if ($currencyCode !== null) {
php
{ "resource": "" }
q20267
PhpMessageSource.loadMessagesFromFile
train
protected function loadMessagesFromFile($messageFile) { if (is_file($messageFile)) { $messages = include $messageFile;
php
{ "resource": "" }
q20268
ClassmapController.actionCreate
train
public function actionCreate($root = null, $mapFile = null) { if ($root === null) { $root = YII_PATH; } $root = FileHelper::normalizePath($root); if ($mapFile === null) { $mapFile = YII_PATH . '/classes.php'; } $options = [ 'filter'...
php
{ "resource": "" }
q20269
Sort.createSortParam
train
public function createSortParam($attribute) { if (!isset($this->attributes[$attribute])) { throw new InvalidConfigException("Unknown attribute: $attribute"); } $definition = $this->attributes[$attribute]; $directions = $this->getAttributeOrders(); if (isset($direc...
php
{ "resource": "" }
q20270
TranslationEvent.missing
train
public static function missing(string $category, $message, string $language)
php
{ "resource": "" }
q20271
PatchCollection.fromJson
train
public static function fromJson($json) { if (!is_object($json)) { $json = json_decode($json); } $collection = new static(); foreach ($json->patches as $package => $patches) { foreach ($patches as $patch_json) {
php
{ "resource": "" }
q20272
Patches.getPatchResolvers
train
public function getPatchResolvers() { $resolvers = []; $plugin_manager = $this->composer->getPluginManager(); foreach ($plugin_manager->getPluginCapabilities( 'cweagans\Composer\Capability\ResolverProvider', ['composer' => $this->composer, 'io' => $this->io] )...
php
{ "resource": "" }
q20273
Patches.resolvePatches
train
public function resolvePatches(PackageEvent $event) { // No need to resolve patches more than once. if ($this->patchesResolved) { return; } // Let each resolver discover patches and add them to the PatchCollection. /** @var ResolverInterface $resolver */ ...
php
{ "resource": "" }
q20274
Patches.checkPatches
train
public function checkPatches(Event $event) { if (!$this->isPatchingEnabled()) { return; } try { $repositoryManager = $this->composer->getRepositoryManager(); $localRepository = $repositoryManager->getLocalRepository(); $installationManager = $...
php
{ "resource": "" }
q20275
Patches.getPackageFromOperation
train
protected function getPackageFromOperation(OperationInterface $operation) { if ($operation instanceof InstallOperation) { $package = $operation->getPackage(); } elseif ($operation instanceof UpdateOperation) { $package = $operation->getTargetPackage();
php
{ "resource": "" }
q20276
Patches.getAndApplyPatch
train
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url) { // Local patch file. if (file_exists($patch_url)) { $filename = realpath($patch_url); } else { // Generate random (but not cryptographically so) filename. $file...
php
{ "resource": "" }
q20277
Patches.isPatchingEnabled
train
protected function isPatchingEnabled() { $enabled = true; $has_no_patches = empty($extra['patches']); $has_no_patches_file = ($this->getConfig('patches-file') === ''); $patching_disabled = $this->getConfig('disable-patching');
php
{ "resource": "" }
q20278
Patch.fromJson
train
public static function fromJson($json) { if (!is_object($json)) { $json = json_decode($json); } $properties = ['package', 'description', 'url', 'sha1', 'depth']; $patch = new static(); foreach ($properties as $property) {
php
{ "resource": "" }
q20279
ResolverBase.findPatchesInJson
train
public function findPatchesInJson($patches) { // Given an array of patch data (pulled directly from the root composer.json // or a patches file), figure out what patch format each package is using and // marshall everything into Patch objects. foreach ($patches as $package => $patch_...
php
{ "resource": "" }
q20280
PatchesFile.readPatchesFile
train
protected function readPatchesFile($patches_file) { $patches = file_get_contents($patches_file); $patches = json_decode($patches, true); // First, check for JSON syntax issues. $json_error = json_last_error_msg(); if ($json_error !== "No error") { throw new \Inva...
php
{ "resource": "" }
q20281
Observable.interval
train
public static function interval(int $interval, AsyncSchedulerInterface $scheduler = null):
php
{ "resource": "" }
q20282
Observable.of
train
public static function of($value, SchedulerInterface $scheduler = null): ReturnObservable
php
{ "resource": "" }
q20283
Observable.error
train
public static function error(\Throwable $error, SchedulerInterface $scheduler = null):
php
{ "resource": "" }
q20284
Observable.merge
train
public function merge(ObservableInterface $otherObservable): Observable { return (new AnonymousObservable(function (ObserverInterface $observer) use ($otherObservable) { $observer->onNext($this);
php
{ "resource": "" }
q20285
Observable.fromIterator
train
public static function fromIterator(\Iterator $iterator, SchedulerInterface $scheduler = null): IteratorObservable { return new
php
{ "resource": "" }
q20286
Observable.range
train
public static function range(int $start, int $count, SchedulerInterface $scheduler = null):
php
{ "resource": "" }
q20287
Observable.mapWithIndex
train
public function mapWithIndex(callable $selector): Observable { $index = 0; return $this->map(function ($value) use
php
{ "resource": "" }
q20288
Observable.skipWhileWithIndex
train
public function skipWhileWithIndex(callable $predicate): Observable { $index = 0; return $this->skipWhile(function ($value)
php
{ "resource": "" }
q20289
Observable.take
train
public function take(int $count): Observable { if ($count === 0) { return self::empty(); }
php
{ "resource": "" }
q20290
Observable.takeWhileWithIndex
train
public function takeWhileWithIndex(callable $predicate): Observable { $index = 0; return $this->takeWhile(function ($value)
php
{ "resource": "" }
q20291
Observable.groupBy
train
public function groupBy(callable $keySelector, callable $elementSelector = null, callable $keySerializer = null): Observable
php
{ "resource": "" }
q20292
Observable.reduce
train
public function reduce(callable $accumulator, $seed = null): Observable { return $this->lift(function
php
{ "resource": "" }
q20293
Observable.distinct
train
public function distinct(callable $comparer = null): Observable { return $this->lift(function
php
{ "resource": "" }
q20294
Observable.distinctKey
train
public function distinctKey(callable $keySelector, callable $comparer = null): Observable { return $this->lift(function () use ($keySelector, $comparer) {
php
{ "resource": "" }
q20295
Observable.distinctUntilChanged
train
public function distinctUntilChanged(callable $comparer = null): Observable { return $this->lift(function () use ($comparer) { return
php
{ "resource": "" }
q20296
Observable.distinctUntilKeyChanged
train
public function distinctUntilKeyChanged(callable $keySelector = null, callable $comparer = null): Observable { return $this->lift(function () use ($keySelector, $comparer) {
php
{ "resource": "" }
q20297
Observable.do
train
public function do($onNextOrObserver = null, callable $onError = null, callable $onCompleted = null): Observable { if ($onNextOrObserver instanceof ObserverInterface) { $observer = $onNextOrObserver; } elseif (is_callable($onNextOrObserver)) { $observer = new DoObserver($onNe...
php
{ "resource": "" }
q20298
Observable.timer
train
public static function timer(int $dueTime, AsyncSchedulerInterface $scheduler = null):
php
{ "resource": "" }
q20299
Observable.concatMap
train
public function concatMap(callable $selector, callable $resultSelector = null): Observable { return $this->lift(function () use ($selector, $resultSelector) { return
php
{ "resource": "" }