_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2800 | Uri.getNormalizedUriPath | train | private function getNormalizedUriPath()
{
$path = $this->getPath();
if ($this->getAuthority() === '') {
return preg_replace('#^/+#', '/', $path);
} elseif ($path === '' || $path[0] === '/') {
return $path;
}
return '/' . $path;
} | php | {
"resource": ""
} |
q2801 | RedisCacheService.hGet | train | public function hGet($hashKey, $key)
{
$value = $this->redis->hGet($hashKey, $key);
if ($value) {
$value = gzinflate($value);
}
$jsonData = json_decode($value, true);
return ($jsonData === NULL) ? $value : $jsonData;
} | php | {
"resource": ""
} |
q2802 | RedisCacheService.hSet | train | public function hSet($hashKey, $key, $data, $expireTime = 3600)
{
$data = (is_object($data) || is_array($data)) ? json_encode($data) : $data;
$data = gzdeflate($data, 0);
if (strlen($data) > 4096) {
$data = gzdeflate($data, 6);
}
$status = $this->redis->hSet($h... | php | {
"resource": ""
} |
q2803 | Negotiation.header | train | public function header($header, $level = self::HIGH)
{
$header = strtolower($header);
if (empty($this->headers[$header])) {
return false;
}
return self::qFactor($this->headers[$header], $level);
} | php | {
"resource": ""
} |
q2804 | Negotiation.qFactor | train | public static function qFactor($value, $level = self::HIGH)
{
$multivalues = explode(',', $value);
$headers = array();
foreach ($multivalues as $hvalues) {
if (substr_count($hvalues, ';') > 1) {
throw new Exception('Header contains a value with multiple semicolon... | php | {
"resource": ""
} |
q2805 | Select.joinCondition | train | public function joinCondition()
{
if (!isset($this->_joinCondition)) {
$this->_joinCondition = Factory::filter($this);
}
return $this->_joinCondition;
} | php | {
"resource": ""
} |
q2806 | File.portion | train | public static function portion($path, $init = 0, $end = 1024, $lines = false)
{
self::fullpath($path);
if ($lines !== true) {
return file_get_contents($path, false, null, $init, $end);
}
$i = 1;
$output = '';
$handle = fopen($path, 'rb');
while... | php | {
"resource": ""
} |
q2807 | File.isBinary | train | public static function isBinary($path)
{
self::fullpath($path);
$size = filesize($path);
if ($size >= 0 && $size < 2) {
return false;
}
$finfo = finfo_open(FILEINFO_MIME_ENCODING);
$encode = finfo_buffer($finfo, file_get_contents($path, false, null, 0,... | php | {
"resource": ""
} |
q2808 | File.size | train | public static function size($path)
{
$path = ltrim(self::fullpath($path), '/');
$ch = curl_init('file://' . $path);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$headers = curl_exec(... | php | {
"resource": ""
} |
q2809 | Selector.get | train | public function get($selector, \DOMNode $context = null, $registerNodeNS = true)
{
return $this->exec('query', $selector, $context, $registerNodeNS);
} | php | {
"resource": ""
} |
q2810 | AbstractEvent.isRunning | train | public function isRunning(Datetime $current = null)
{
$current = $current ?: new Datetime;
return $this->hasStarted($current) && !$this->hasEnded($current);
} | php | {
"resource": ""
} |
q2811 | AbstractEvent.detach | train | public function detach()
{
$this->calendar->getEvents()->removeEvent($this);
$this->calendar = null;
return $this;
} | php | {
"resource": ""
} |
q2812 | DefaultCertificateValidator.validateCert | train | public function validateCert($certPem) {
if ($this->getCaCert()) {
self::validate($certPem, $this->getCaCert(), $this->getCrl(), $this->getCrlDistCert());
}
} | php | {
"resource": ""
} |
q2813 | DefaultCertificateValidator.getCrlUrl | train | public function getCrlUrl() {
if ($this->crlUrl === self::AUTOLOAD) {
$this->crlUrl = NULL; // Default if we can't find something else.
$caCertObj = X509Util::loadCACert($this->getCaCert());
// There can be multiple DPs, but in practice CiviRootCA only has one.
$crlDPs = $caCertObj->getExten... | php | {
"resource": ""
} |
q2814 | UriPattern.matchUri | train | public function matchUri($uri, & $matches = [])
{
if ($this->matchAbsoluteUri($uri, $matches)) {
return true;
}
return $this->matchRelativeUri($uri, $matches);
} | php | {
"resource": ""
} |
q2815 | UriPattern.match | train | private function match($pattern, $subject, & $matches)
{
$matches = [];
$subject = (string) $subject;
if ($this->allowNonAscii || preg_match('/^[\\x00-\\x7F]*$/', $subject)) {
if (preg_match($pattern, $subject, $match)) {
$matches = $this->getNamedPatterns($match... | php | {
"resource": ""
} |
q2816 | UriPattern.getNamedPatterns | train | private function getNamedPatterns($matches)
{
foreach ($matches as $key => $value) {
if (!is_string($key) || strlen($value) < 1) {
unset($matches[$key]);
}
}
return $matches;
} | php | {
"resource": ""
} |
q2817 | UriPattern.buildPatterns | train | private static function buildPatterns()
{
$alpha = 'A-Za-z';
$digit = '0-9';
$hex = $digit . 'A-Fa-f';
$unreserved = "$alpha$digit\\-._~";
$delimiters = "!$&'()*+,;=";
$utf8 = '\\x80-\\xFF';
$octet = "(?:[$digit]|[1-9][$digit]|1[$digit]{2}|2[0-4]$digit|25[0-5... | php | {
"resource": ""
} |
q2818 | FileSystem.createDirectories | train | public static function createDirectories(string $path, int $mode = 0777) : void
{
$exception = null;
try {
$success = ErrorCatcher::run(static function() use ($path, $mode) {
return mkdir($path, $mode, true);
});
if ($success === true) {
... | php | {
"resource": ""
} |
q2819 | FileSystem.isFile | train | public static function isFile(string $path) : bool
{
try {
return ErrorCatcher::run(static function() use ($path) {
return is_file($path);
});
} catch (\ErrorException $e) {
throw new IoException('Error checking if ' . $path . ' is a file', 0, $e);... | php | {
"resource": ""
} |
q2820 | FileSystem.isDirectory | train | public static function isDirectory(string $path) : bool
{
try {
return ErrorCatcher::run(static function() use ($path) {
return is_dir($path);
});
} catch (\ErrorException $e) {
throw new IoException('Error checking if ' . $path . ' is a directory'... | php | {
"resource": ""
} |
q2821 | FileSystem.isSymbolicLink | train | public static function isSymbolicLink(string $path) : bool
{
try {
return ErrorCatcher::run(static function() use ($path) {
return is_link($path);
});
} catch (\ErrorException $e) {
throw new IoException('Error checking if ' . $path . ' is a symbol... | php | {
"resource": ""
} |
q2822 | FileSystem.createSymbolicLink | train | public static function createSymbolicLink(string $link, string $target) : void
{
$exception = null;
try {
$success = ErrorCatcher::run(static function() use ($link, $target) {
return symlink($target, $link);
});
if ($success === true) {
... | php | {
"resource": ""
} |
q2823 | FileSystem.readSymbolicLink | train | public static function readSymbolicLink(string $path) : string
{
$exception = null;
try {
$result = ErrorCatcher::run(static function() use ($path) {
return readlink($path);
});
if ($result !== false) {
return $result;
... | php | {
"resource": ""
} |
q2824 | FileSystem.getRealPath | train | public static function getRealPath(string $path) : string
{
$exception = null;
try {
$result = ErrorCatcher::run(static function() use ($path) {
return realpath($path);
});
if ($result !== false) {
return $result;
}
... | php | {
"resource": ""
} |
q2825 | FileSystem.write | train | public static function write(string $path, $data, bool $append = false, bool $lock = false) : int
{
$flags = 0;
if ($append) {
$flags |= FILE_APPEND;
}
if ($lock) {
$flags |= LOCK_EX;
}
$exception = null;
try {
$result = ... | php | {
"resource": ""
} |
q2826 | FileSystem.read | train | public static function read(string $path, int $offset = 0, int $maxLength = null) : string
{
$exception = null;
try {
$result = ErrorCatcher::run(static function() use ($path, $offset, $maxLength) {
if ($maxLength === null) {
return file_get_contents(... | php | {
"resource": ""
} |
q2827 | Curl.getInfo | train | public function getInfo(int $opt = null)
{
if ($opt === null) {
return curl_getinfo($this->curl);
}
return curl_getinfo($this->curl, $opt);
} | php | {
"resource": ""
} |
q2828 | UriParser.parse | train | public function parse($uri)
{
if (!$this->isValidString($uri)) {
return null;
}
$pattern = new UriPattern();
$pattern->allowNonAscii($this->mode !== self::MODE_RFC3986);
if ($pattern->matchUri($uri, $match)) {
try {
return $this->buil... | php | {
"resource": ""
} |
q2829 | UriParser.isValidString | train | private function isValidString($uri)
{
if (preg_match('/^[\\x00-\\x7F]*$/', $uri)) {
return true;
} elseif ($this->mode === self::MODE_RFC3986) {
return false;
}
// Validate UTF-8 via regular expression to avoid mbstring dependency
$pattern =
... | php | {
"resource": ""
} |
q2830 | UriParser.buildUri | train | private function buildUri(array $components)
{
$uri = new Uri();
if (isset($components['reg_name'])) {
$components['host'] = $this->decodeHost($components['host']);
}
foreach (array_intersect_key(self::$setters, $components) as $key => $method) {
$uri = call... | php | {
"resource": ""
} |
q2831 | UriParser.decodeHost | train | private function decodeHost($hostname)
{
if (preg_match('/^[\\x00-\\x7F]*$/', $hostname)) {
return $hostname;
} elseif ($this->mode !== self::MODE_IDNA2003) {
throw new \InvalidArgumentException("Invalid hostname '$hostname'");
}
$hostname = idn_to_ascii($hos... | php | {
"resource": ""
} |
q2832 | App.env | train | public static function env($key, $value = null)
{
if (is_string($value) || is_bool($value) || is_numeric($value)) {
self::$configs[$key] = $value;
} elseif ($value === null && isset(self::$configs[$key])) {
return self::$configs[$key];
}
} | php | {
"resource": ""
} |
q2833 | App.config | train | public static function config($path)
{
$data = \UtilsSandboxLoader('application/Config/' . strtr($path, '.', '/') . '.php');
foreach ($data as $key => $value) {
self::env($key, $value);
}
$data = null;
} | php | {
"resource": ""
} |
q2834 | App.trigger | train | public static function trigger($name, array $args = array())
{
if ($name === 'error') {
self::$state = 5;
}
if (empty(self::$events[$name])) {
return null;
}
$listen = self::$events[$name];
usort($listen, function ($a, $b) {
retu... | php | {
"resource": ""
} |
q2835 | App.off | train | public static function off($name, $callback = null)
{
if (empty(self::$events[$name])) {
return null;
} elseif ($callback === null) {
self::$events[$name] = array();
return null;
}
$evts = self::$events[$name];
foreach ($evts as $key => $... | php | {
"resource": ""
} |
q2836 | App.stop | train | public static function stop($code, $msg = null)
{
Response::status($code, false) && self::trigger('changestatus', array($code, $msg));
if (self::$state < 4) {
self::$state = 4;
self::trigger('finish');
}
exit;
} | php | {
"resource": ""
} |
q2837 | App.exec | train | public static function exec()
{
if (self::$state > 0) {
return null;
}
self::$state = 1;
self::trigger('init');
if (self::env('maintenance')) {
self::$state = 4;
self::stop(503);
}
self::trigger('changestatus', array(\Ut... | php | {
"resource": ""
} |
q2838 | FixedArray.swap | train | public function swap(int $index1, int $index2) : void
{
if ($index1 !== $index2) {
$value = $this[$index1];
$this[$index1] = $this[$index2];
$this[$index2] = $value;
}
} | php | {
"resource": ""
} |
q2839 | FixedArray.shiftUp | train | public function shiftUp(int $index) : void
{
if ($index + 1 === $this->count()) {
return;
}
$this->swap($index, $index + 1);
} | php | {
"resource": ""
} |
q2840 | FixedArray.shiftTo | train | public function shiftTo(int $index, int $newIndex) : void
{
while ($index > $newIndex) {
$this->shiftDown($index);
$index--;
}
while ($index < $newIndex) {
$this->shiftUp($index);
$index++;
}
} | php | {
"resource": ""
} |
q2841 | PadStringExtension.padStringFilter | train | public function padStringFilter($value, $padCharacter, $maxLength, $padType = 'STR_PAD_RIGHT')
{
if ($this->isNullOrEmptyString($padCharacter)) {
throw new \InvalidArgumentException('Pad String Filter cannot accept a null value or empty string as its first argument');
}
if ( ! is... | php | {
"resource": ""
} |
q2842 | OpenGraphGenerator.generate | train | public function generate()
{
$html = array();
foreach ($this->properties as $property => $value):
if (is_array($value)):
foreach ($value as $_value) {
$html[] = strtr(
static::OPENGRAPH_TAG,
array(
'[property]' => static::OPENGRAPH_PREFIX . $property,
'[value]' => $_value
... | php | {
"resource": ""
} |
q2843 | OpenGraphGenerator.fromRaw | train | public function fromRaw($properties)
{
$this->validateProperties($properties);
foreach ($properties as $property => $value) {
$this->properties[$property] = $value;
}
} | php | {
"resource": ""
} |
q2844 | OpenGraphGenerator.fromObject | train | public function fromObject(OpenGraphAware $object)
{
$properties = $object->getOpenGraphData();
$this->validateProperties($properties);
foreach ($properties as $property => $value) {
$this->properties[$property] = $value;
}
} | php | {
"resource": ""
} |
q2845 | OpenGraphGenerator.validateProperties | train | protected function validateProperties($properties)
{
foreach ($this->required as $required) {
if (!array_key_exists($required, $properties)) {
throw new \InvalidArgumentException("Required open graph property [$required] is not present.");
}
}
} | php | {
"resource": ""
} |
q2846 | DataTablesTwigExtension.jQueryDataTablesStandaloneFunction | train | public function jQueryDataTablesStandaloneFunction(array $args = []) {
return $this->jQueryDataTablesStandalone(ArrayHelper::get($args, "selector", ".table"), ArrayHelper::get($args, "language"), ArrayHelper::get($args, "options", []));
} | php | {
"resource": ""
} |
q2847 | HttpRequest.execute | train | public function execute() {
$ch = \curl_init();
$this->setAuth($ch);
try {
switch (strtoupper($this->method)) {
case 'GET':
$this->executeGet($ch);
break;
case 'POST':
$this->executePost($ch)... | php | {
"resource": ""
} |
q2848 | HttpRequest.buildPostBody | train | public function buildPostBody($data = null) {
$reqBody = ($data !== null) ? $data : $this->request_body;
$this->request_body = (string) $reqBody;
} | php | {
"resource": ""
} |
q2849 | HttpRequest.executePutMultipart | train | protected function executePutMultipart($ch) {
$xml = $this->request_body;
$uri_string = $this->file_to_upload[0];
$file_name = $this->file_to_upload[1];
$post = array(
'ResourceDescriptor' => $xml,
$uri_string => '@' . $file_name . ';filename=' . basename($file_... | php | {
"resource": ""
} |
q2850 | HttpRequest.doExecute | train | protected function doExecute(&$curlHandle) {
$this->setCurlOpts($curlHandle);
$response = \curl_exec($curlHandle);
$header_size = \curl_getinfo($curlHandle, CURLINFO_HEADER_SIZE);
$this->response_body = substr($response, $header_size);
$this->response_headers = [];
$l... | php | {
"resource": ""
} |
q2851 | HttpRequest.setCurlOpts | train | protected function setCurlOpts(&$curlHandle) {
\curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10);
\curl_setopt($curlHandle, CURLOPT_URL, $this->url);
\curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
\curl_setopt($curlHandle, CURLOPT_VERBOSE, false);
\curl_setopt($curlHandle,... | php | {
"resource": ""
} |
q2852 | HttpRequest.setAuth | train | protected function setAuth(&$curlHandle) {
if ($this->username !== null && $this->password !== null) {
\curl_setopt($curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
\curl_setopt($curlHandle, CURLOPT_USERPWD, base64_encode($this->username . ':' . $this->password));
// ... | php | {
"resource": ""
} |
q2853 | HttpRequest.getResponseHeader | train | public function getResponseHeader($key = null) {
if (null != $key) {
if (array_key_exists($key, $this->response_headers)) {
return $this->response_headers[$key];
}
} else {
return $this->response_headers;
}
} | php | {
"resource": ""
} |
q2854 | Translatable.bootTranslatable | train | public static function bootTranslatable()
{
static::addGlobalScope(new TranslatableScope);
try {
$observer = app(TranslatableObserverContract::class);
static::observe($observer);
} catch (\Exception $exception) {}
} | php | {
"resource": ""
} |
q2855 | DataTablesNormalizer.normalizeColumn | train | public static function normalizeColumn(DataTablesColumnInterface $column) {
$output = [];
ArrayHelper::set($output, "cellType", $column->getCellType(), [null]);
ArrayHelper::set($output, "classname", $column->getClassname(), [null]);
ArrayHelper::set($output, "contentPadding", $column-... | php | {
"resource": ""
} |
q2856 | DataTablesNormalizer.normalizeResponse | train | public static function normalizeResponse(DataTablesResponseInterface $response) {
$output = [];
$output["data"] = $response->getData();
$output["draw"] = $response->getDraw();
$output["recordsFiltered"] = $response->getRecordsFiltered();
$output["recordsTo... | php | {
"resource": ""
} |
q2857 | Language.isValidCode | train | public static function isValidCode( $code ) {
return
strcspn( $code, ":/\\\000" ) === strlen( $code )
&& !preg_match( Title::getTitleInvalidRegex(), $code );
} | php | {
"resource": ""
} |
q2858 | Language.getLocalisationCache | train | public static function getLocalisationCache() {
if ( is_null( self::$dataCache ) ) {
global $wgLocalisationCacheConf;
$class = $wgLocalisationCacheConf['class'];
self::$dataCache = new $class( $wgLocalisationCacheConf );
}
return self::$dataCache;
} | php | {
"resource": ""
} |
q2859 | Language.getGenderNsText | train | function getGenderNsText( $index, $gender ) {
$ns = self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' );
return isset( $ns[$index][$gender] ) ? $ns[$index][$gender] : $this->getNsText( $index );
} | php | {
"resource": ""
} |
q2860 | Language.getLocalNsIndex | train | function getLocalNsIndex( $text ) {
$lctext = $this->lc( $text );
$ids = $this->getNamespaceIds();
return isset( $ids[$lctext] ) ? $ids[$lctext] : false;
} | php | {
"resource": ""
} |
q2861 | Language.getNsIndex | train | function getNsIndex( $text ) {
$lctext = $this->lc( $text );
if ( ( $ns = MWNamespace::getCanonicalIndex( $lctext ) ) !== null ) {
return $ns;
}
$ids = $this->getNamespaceIds();
return isset( $ids[$lctext] ) ? $ids[$lctext] : false;
} | php | {
"resource": ""
} |
q2862 | Language.hebrewYearStart | train | private static function hebrewYearStart( $year ) {
$a = intval( ( 12 * ( $year - 1 ) + 17 ) % 19 );
$b = intval( ( $year - 1 ) % 4 );
$m = 32.044093161144 + 1.5542417966212 * $a + $b / 4.0 - 0.0031777940220923 * ( $year - 1 );
if ( $m < 0 ) {
$m--;
}
$Mar = intval( $m );
if ( $m < 0 ) {
$m++;
}
... | php | {
"resource": ""
} |
q2863 | Language.romanNumeral | train | static function romanNumeral( $num ) {
static $table = array(
array( '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X' ),
array( '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', 'C' ),
array( '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', 'M' ),
array( '', 'M', 'MM', ... | php | {
"resource": ""
} |
q2864 | Language.uc | train | function uc( $str, $first = false ) {
if ( function_exists( 'mb_strtoupper' ) ) {
if ( $first ) {
if ( $this->isMultibyte( $str ) ) {
return mb_strtoupper( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 );
} else {
return ucfirst( $str );
}
} else {
return $this->isMultibyte( $str ) ? ... | php | {
"resource": ""
} |
q2865 | Language.ucwordbreaks | train | function ucwordbreaks( $str ) {
if ( $this->isMultibyte( $str ) ) {
$str = $this->lc( $str );
// since \b doesn't work for UTF-8, we explicitely define word break chars
$breaks = "[ \-\(\)\}\{\.,\?!]";
// find first letter after word break
$replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)|$brea... | php | {
"resource": ""
} |
q2866 | Language.firstChar | train | function firstChar( $s ) {
$matches = array();
preg_match(
'/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
'[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/',
$s,
$matches
);
if ( isset( $matches[1] ) ) {
if ( strlen( $matches[1] ) != 3 ) {
return $matches[1];
}
// Break down Hangul ... | php | {
"resource": ""
} |
q2867 | Language.normalize | train | function normalize( $s ) {
global $wgAllUnicodeFixes;
$s = UtfNormal::cleanUp( $s );
if ( $wgAllUnicodeFixes ) {
$s = $this->transformUsingPairFile( 'normalize-ar.ser', $s );
$s = $this->transformUsingPairFile( 'normalize-ml.ser', $s );
}
return $s;
} | php | {
"resource": ""
} |
q2868 | Language.getMagic | train | function getMagic( $mw ) {
$this->doMagicHook();
if ( isset( $this->mMagicExtensions[$mw->mId] ) ) {
$rawEntry = $this->mMagicExtensions[$mw->mId];
} else {
$magicWords = $this->getMagicWords();
if ( isset( $magicWords[$mw->mId] ) ) {
$rawEntry = $magicWords[$mw->mId];
} else {
$rawEntry = fa... | php | {
"resource": ""
} |
q2869 | Language.addMagicWordsByLang | train | function addMagicWordsByLang( $newWords ) {
$code = $this->getCode();
$fallbackChain = array();
while ( $code && !in_array( $code, $fallbackChain ) ) {
$fallbackChain[] = $code;
$code = self::getFallbackFor( $code );
}
if ( !in_array( 'en', $fallbackChain ) ) {
$fallbackChain[] = 'en';
}
$fallbac... | php | {
"resource": ""
} |
q2870 | Language.getSpecialPageAliases | train | function getSpecialPageAliases() {
// Cache aliases because it may be slow to load them
if ( is_null( $this->mExtendedSpecialPageAliases ) ) {
// Initialise array
$this->mExtendedSpecialPageAliases =
self::$dataCache->getItem( $this->mCode, 'specialPageAliases' );
wfRunHooks( 'LanguageGetSpecialPageAli... | php | {
"resource": ""
} |
q2871 | Language.preConvertPlural | train | protected function preConvertPlural( /* Array */ $forms, $count ) {
while ( count( $forms ) < $count ) {
$forms[] = $forms[count( $forms ) - 1];
}
return $forms;
} | php | {
"resource": ""
} |
q2872 | Language.getFileName | train | static function getFileName( $prefix = 'Language', $code, $suffix = '.php' ) {
// Protect against path traversal
if ( !Language::isValidCode( $code )
|| strcspn( $code, ":/\\\000" ) !== strlen( $code ) )
{
throw new MWException( "Invalid language code \"$code\"" );
}
return $prefix . str_replace( '-', ... | php | {
"resource": ""
} |
q2873 | MorrisBase.toArray | train | public function toArray()
{
$return = [];
foreach ( $this as $property => $value ) {
if ( '__' == substr( $property, 0, 2 ) || '' === $value || is_null( $value ) || ( is_array( $value ) && empty( $value ) ) ) {
continue;
}
if ( in_array( $property, $this->functions ) && substr( $val... | php | {
"resource": ""
} |
q2874 | MorrisBase.toJSON | train | public function toJSON()
{
$json = json_encode( $this->toArray() );
return str_replace(
[
'"%hoverCallback%"',
'"%formatter%"',
'"%dateFormat%"',
],
[
$this->hoverCallback,
$this->formatter,
$this->dateFormat,
],
$json
... | php | {
"resource": ""
} |
q2875 | MorrisBase.toJavascript | train | public function toJavascript()
{
ob_start();
?>
<script type="text/javascript">
jQuery( function( $ )
{
"use strict";
Morris.<?php echo $this->__chart_type ?>(
<?php echo $this->toJSON() ?>
);
} );
</script>
<?php
$buffer = ob_get_contents()... | php | {
"resource": ""
} |
q2876 | Tx_Oelib_MapperRegistry.getByClassName | train | private function getByClassName($className)
{
if ($className === '') {
throw new \InvalidArgumentException('$className must not be empty.', 1331488868);
}
$unifiedClassName = self::unifyClassName($className);
if (!isset($this->mappers[$unifiedClassName])) {
i... | php | {
"resource": ""
} |
q2877 | AbstractDataTablesProvider.renderButtons | train | protected function renderButtons($entity, $editRoute, $deleteRoute = null, $enableDelete = true) {
// Initialize the titles.
$titles = [];
$titles[] = $this->getTranslator()->trans("label.edit", [], "CoreBundle");
$titles[] = $this->getTranslator()->trans("label.delete", [], "CoreBund... | php | {
"resource": ""
} |
q2878 | AbstractDataTablesProvider.renderFloat | train | protected function renderFloat($number, $decimals = 2, $decPoint = ".", $thousandsSep = ",") {
if (null === $number) {
return "";
}
return number_format($number, $decimals, $decPoint, $thousandsSep);
} | php | {
"resource": ""
} |
q2879 | AbstractDataTablesProvider.wrapContent | train | protected function wrapContent($prefix, $content, $suffix) {
$output = [];
if (null !== $prefix) {
$output[] = $prefix;
}
$output[] = $content;
if (null !== $suffix) {
$output[] = $suffix;
}
return implode("", $output);
} | php | {
"resource": ""
} |
q2880 | Tx_Oelib_Session.getInstance | train | public static function getInstance($type)
{
self::checkType($type);
if (!isset(self::$instances[$type])) {
self::$instances[$type] = new \Tx_Oelib_Session($type);
}
return self::$instances[$type];
} | php | {
"resource": ""
} |
q2881 | Tx_Oelib_Session.setInstance | train | public static function setInstance($type, \Tx_Oelib_Session $instance)
{
self::checkType($type);
self::$instances[$type] = $instance;
} | php | {
"resource": ""
} |
q2882 | GiroCheckout_SDK_PaydirektTransaction.validateParams | train | public function validateParams( $p_aParams, &$p_strError ) {
if( isset($p_aParams['shoppingCartType']) ) {
$strShoppingCartType = trim($p_aParams['shoppingCartType']);
}
if (empty($strShoppingCartType)) {
$strShoppingCartType = "MIXED"; // Default value
}
if( isset($p_aParams['shippin... | php | {
"resource": ""
} |
q2883 | AnnotationLoader.loadClassMetadata | train | public function loadClassMetadata(Mapping\ClassMetadataInterface $metadata)
{
$reflClass = $metadata->getReflectionClass();
//Iterate over properties to get annotations
foreach($reflClass->getProperties() as $property) {
$this->readProperty($propert... | php | {
"resource": ""
} |
q2884 | SitewideContentTaxonomy.updateColumns | train | public function updateColumns($itemType, &$columns)
{
if ($itemType !== 'Pages') {
return;
}
// Check if pages has the tags field
if (!self::enabled()) {
return;
}
// Set column
$field = Config::inst()->get(__CLASS__, 'tag_field');
... | php | {
"resource": ""
} |
q2885 | SitewideContentTaxonomy.enabled | train | public static function enabled()
{
if (!class_exists(TaxonomyTerm::class)) {
return false;
}
// Check if pages has the tags field
$field = Config::inst()->get(__CLASS__, 'tag_field');
return singleton('Page')->hasMethod($field);
} | php | {
"resource": ""
} |
q2886 | SubscriptionFactory.addEntitySubject | train | public function addEntitySubject($id, $type = null, $idKey = "id", $typeKey = "type")
{
if(!isset($this->_subscription->subject)){
$this->_subscription->subject = (object) [
"entities" => [],
"condition" => (object)["attrs" => []]
];
}
... | php | {
"resource": ""
} |
q2887 | SubscriptionFactory.addAttrCondition | train | public function addAttrCondition($attr) {
if(!isset($this->_subscription->subject)){
$this->_subscription->subject = (object) [];
}
if(!isset($this->_subscription->subject->condition)){
$this->_subscription->subject->condition = (object) [];
}
if (!isset... | php | {
"resource": ""
} |
q2888 | SubscriptionFactory.addExpressionCondition | train | public function addExpressionCondition($expression) {
if(!isset($this->_subscription->subject)){
$this->_subscription->subject = (object) [];
}
if(!isset($this->_subscription->subject->condition)){
$this->_subscription->subject->condition = (object) [];
}
... | php | {
"resource": ""
} |
q2889 | Backoff.setOptions | train | public function setOptions(array $options) : BackoffInterface
{
$this->options = array_merge($this->options, $options);
return $this;
} | php | {
"resource": ""
} |
q2890 | Backoff.exponential | train | public function exponential(int $attempt) : float
{
if (!is_int($attempt)) {
throw new InvalidArgumentException('Attempt must be an integer');
}
if ($attempt < 1) {
throw new InvalidArgumentException('Attempt must be >= 1');
}
if ($this->maxAttempsEx... | php | {
"resource": ""
} |
q2891 | Backoff.equalJitter | train | public function equalJitter(int $attempt) : int
{
$half = ($this->exponential($attempt) / 2);
return (int) floor($half + $this->random(0.0, $half));
} | php | {
"resource": ""
} |
q2892 | Backoff.fullJitter | train | public function fullJitter(int $attempt) : int
{
return (int) floor($this->random(0.0, $this->exponential($attempt) / 2));
} | php | {
"resource": ""
} |
q2893 | Backoff.random | train | protected function random(float $min, float $max) : float
{
return ($min + lcg_value() * (abs($max - $min)));
} | php | {
"resource": ""
} |
q2894 | AbstractRequest.getRequestHeaders | train | public function getRequestHeaders()
{
// common headers
$headers = array(
'Accept' => 'application/json',
);
// set content type
if ($this->getHttpMethod() !== 'GET') {
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
}
... | php | {
"resource": ""
} |
q2895 | AbstractRequest.sendData | train | public function sendData($data)
{
// enforce TLS >= v1.2 (https://www.payway.com.au/rest-docs/index.html#basics)
$config = $this->httpClient->getConfig();
$curlOptions = $config->get('curl.options');
$curlOptions[CURLOPT_SSLVERSION] = 6;
$config->set('curl.options', $curlOpti... | php | {
"resource": ""
} |
q2896 | AbstractRequest.addToData | train | public function addToData(array $data = array(), array $parms = array())
{
foreach ($parms as $parm) {
$getter = 'get' . ucfirst($parm);
if (method_exists($this, $getter) && $this->$getter()) {
$data[$parm] = $this->$getter();
}
}
return $... | php | {
"resource": ""
} |
q2897 | Tx_Oelib_ConfigurationRegistry.getByNamespace | train | private function getByNamespace($namespace)
{
$this->checkForNonEmptyNamespace($namespace);
if (!isset($this->configurations[$namespace])) {
$this->configurations[$namespace]
= $this->retrieveConfigurationFromTypoScriptSetup($namespace);
}
return $this->... | php | {
"resource": ""
} |
q2898 | Tx_Oelib_ConfigurationRegistry.set | train | public function set($namespace, \Tx_Oelib_Configuration $configuration)
{
$this->checkForNonEmptyNamespace($namespace);
if (isset($this->configurations[$namespace])) {
$this->dropConfiguration($namespace);
}
$this->configurations[$namespace] = $configuration;
} | php | {
"resource": ""
} |
q2899 | Tx_Oelib_ConfigurationRegistry.retrieveConfigurationFromTypoScriptSetup | train | private function retrieveConfigurationFromTypoScriptSetup($namespace)
{
$data = $this->getCompleteTypoScriptSetup();
$namespaceParts = explode('.', $namespace);
foreach ($namespaceParts as $namespacePart) {
if (!array_key_exists($namespacePart . '.', $data)) {
$d... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.