_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q245900
Container.getChainStrategy
validation
public function getChainStrategy() { $strategy = new ChainBuildStrategy(); $strategy->pushStrategy($this->getTravisCiStrategy()); $strategy->pushStrategy($this->getJoliCiStrategy()); return $strategy; }
php
{ "resource": "" }
q245901
Container.getConsoleLogger
validation
public function getConsoleLogger($verbose = false) { $logger = new Logger("standalone-logger"); $handler = new StreamHandler("php://stdout", $verbose ? Logger::DEBUG : Logger::INFO); $simpleFormatter = new SimpleFormatter(); $handler->setFormatter($simpleFormatter); $logger->pushHandler($handler); if (!$verbose) { $stdErrHandler = new StreamHandler("php://stderr", Logger::DEBUG); $fingerCrossedHandler = new FingersCrossedHandler($stdErrHandler, new ErrorLevelActivationStrategy(Logger::ERROR), 10); $logger->pushHandler($fingerCrossedHandler); $stdErrHandler->setFormatter($simpleFormatter); } return $logger; }
php
{ "resource": "" }
q245902
Message.send
validation
public function send() { $eventManager = $this->getManager()->getEventsManager(); if ($eventManager) { $result = $eventManager->fire('mailer:beforeSend', $this); } else { $result = true; } if ($result === false) { return false; } $this->failedRecipients = []; //send to queue $queue = $this->getManager()->getQueue(); //$queueName = $this-> if ($this->auth) { $queue->putInTube($this->queueName, [ 'message' => $this->getMessage(), 'auth' => $this->smtp, ]); } else { $queue->putInTube($this->queueName, $this->getMessage()); } /* $count = $this->getManager()->getSwift()->send($this->getMessage(), $this->failedRecipients); if ($eventManager) { $eventManager->fire('mailer:afterSend', $this, [$count, $this->failedRecipients]); } return $count;*/ }
php
{ "resource": "" }
q245903
Message.sendNow
validation
public function sendNow() { $config = $this->getManager()->getDI()->getConfig(); $message = $this->getMessage(); $username = $config->email->username; $password = $config->email->password; $host = $config->email->host; $port = $config->email->port; $transport = \Swift_SmtpTransport::newInstance($host, $port); $transport->setUsername($username); $transport->setPassword($password); $swift = \Swift_Mailer::newInstance($transport); $failures = []; $swift->send($message, $failures); }
php
{ "resource": "" }
q245904
Message.smtp
validation
public function smtp(array $params) { //validate the user params if (!array_key_exists('username', $params)) { throw new Exception('We need a username'); } if (!array_key_exists('password', $params)) { throw new Exception('We need a password'); } $this->smtp = $params; $this->auth = true; return $this; }
php
{ "resource": "" }
q245905
Message.setDynamicContent
validation
public function setDynamicContent(array $params, string $content) { $processed_content = preg_replace_callback( '~\{(.*?)\}~si', function ($match) use ($params) { return str_replace($match[0], isset($params[$match[1]]) ? $params[$match[1]] : $match[0], $match[0]); }, $content ); return $processed_content; }
php
{ "resource": "" }
q245906
Manager.createMessage
validation
public function createMessage() { $eventsManager = $this->getEventsManager(); if ($eventsManager) { $eventsManager->fire('mailer:beforeCreateMessage', $this); } /** @var $message Message */ $message = $this->getDI()->get('\Baka\Mail\Message', [$this]); if (($from = $this->getConfig('from'))) { $message->from($from['email'], isset($from['name']) ? $from['name'] : null); } if ($eventsManager) { $eventsManager->fire('mailer:afterCreateMessage', $this, $message); } return $message; }
php
{ "resource": "" }
q245907
Manager.configure
validation
protected function configure(array $config) { $this->config = $config; $this->registerSwiftTransport(); $this->registerSwiftMailer(); $this->registerQueue(); }
php
{ "resource": "" }
q245908
Manager.setRenderView
validation
public function setRenderView($viewPath, $params) { //Set volt tempalte enging and specify the cache path $this->setViewEngines([ '.volt' => function ($view = null) { $volt = new Volt($view); $volt->setOptions([ 'compiledPath' => APP_PATH . '/cache/volt/', 'compiledSeparator' => '_', 'compileAlways' => !$this->getDI()->get('config')->application->production, ]); return $volt; } ]); $view = $this->getView(); $content = $view->render($viewPath, $params); return $content; }
php
{ "resource": "" }
q245909
Generator.generate
validation
public function generate() { $this->beforeGeneration(); $this->config->getLogger()->startBreak('Class Generation'); foreach ($this->XSDMap as $fhirElementName => $mapEntry) { $this->config->getLogger()->debug("Generating class for element {$fhirElementName}..."); $classTemplate = ClassGenerator::buildFHIRElementClassTemplate($this->config, $this->XSDMap, $mapEntry); FileUtils::createDirsFromNS($classTemplate->getNamespace(), $this->config); // Generate class file MethodGenerator::implementConstructor($this->config, $classTemplate); $classTemplate->writeToFile($this->config->getOutputPath()); $this->mapTemplate->addEntry($classTemplate); $this->autoloadMap->addPHPFHIRClassEntry($classTemplate); $this->config->getLogger()->debug("{$fhirElementName} completed."); } $this->config->getLogger()->endBreak('Class Generation'); $this->afterGeneration(); }
php
{ "resource": "" }
q245910
Generator.beforeGeneration
validation
protected function beforeGeneration() { // Class props $this->config->getLogger()->startBreak('XSD Parsing'); $this->XSDMap = XSDMapGenerator::buildXSDMap($this->config); $this->config->getLogger()->endBreak('XSD Parsing'); // Initialize some classes and things. $this->config->getLogger()->startBreak('Generator Class Initialization'); self::_initializeClasses($this->config); $this->autoloadMap = new AutoloaderTemplate($this->config); $this->mapTemplate = new ParserMapTemplate($this->config); $this->autoloadMap->addEntry( $this->mapTemplate->getClassName(), $this->mapTemplate->getClassPath() ); $helperTemplate = new HelperTemplate($this->config); $helperTemplate->writeToFile(); $this->autoloadMap->addEntry( $helperTemplate->getClassName(), $helperTemplate->getClassPath() ); $this->config->getLogger()->endBreak('Generator Class Initialization'); }
php
{ "resource": "" }
q245911
Generator.afterGeneration
validation
protected function afterGeneration() { $this->mapTemplate->writeToFile(); $this->autoloadMap->writeToFile(); $responseParserTemplate = new ResponseParserTemplate($this->config); $this->autoloadMap->addEntry( $responseParserTemplate->getClassName(), $responseParserTemplate->getClassPath() ); $responseParserTemplate->writeToFile(); }
php
{ "resource": "" }
q245912
BaseMethodTemplate.addBlockToBody
validation
public function addBlockToBody($block) { $this->body = array_merge($this->body, explode(PHP_EOL, $block)); }
php
{ "resource": "" }
q245913
ViewCollection.setPaths
validation
public function setPaths(array $paths) : object { foreach ($paths as $path) { if (!(is_dir($path) && is_readable($path))) { throw new Exception("Directory '$path' is not readable."); } } $this->paths = $paths; return $this; }
php
{ "resource": "" }
q245914
ViewCollection.getTemplateFile
validation
public function getTemplateFile($template) { $file = $template . $this->suffix; if (is_file($file)) { return $file; } foreach ($this->paths as $path) { $file = $path . "/" . $template . $this->suffix; if (is_file($file)) { return $file; } } throw new Exception("Could not find template file '$template'."); }
php
{ "resource": "" }
q245915
ViewCollection.addCallback
validation
public function addCallback($callback, $data = [], $region = "main", $sort = 0) { $view = new View(); $view->set(["callback" => $callback], $data, $sort, "callback"); $this->views[$region][] = $view; return $this; }
php
{ "resource": "" }
q245916
ViewCollection.addString
validation
public function addString($content, $region = "main", $sort = 0) { $view = new View(); $view->set($content, [], $sort, "string"); $this->views[$region][] = $view; return $this; }
php
{ "resource": "" }
q245917
ViewCollection.render
validation
public function render($region = "main") { if (!isset($this->views[$region])) { return $this; } mergesort($this->views[$region], function ($viewA, $viewB) { $sortA = $viewA->sortOrder(); $sortB = $viewB->sortOrder(); if ($sortA == $sortB) { return 0; } return $sortA < $sortB ? -1 : 1; }); foreach ($this->views[$region] as $view) { $view->render($this->di); } }
php
{ "resource": "" }
q245918
ViewCollection.renderBuffered
validation
public function renderBuffered($region = "main") { ob_start(); $this->render($region); $res = ob_get_contents(); ob_end_clean(); return $res; }
php
{ "resource": "" }
q245919
ViewRenderFile.render
validation
public function render(string $file, array $data) : void { if (!is_readable($file)) { throw new Exception("Could not find template file: " . $this->template); } $di = $this->di; $app = null; if ($di->has("app")) { $app = $di->get("app"); } extract($data); require $file; }
php
{ "resource": "" }
q245920
View.set
validation
public function set($template, $data = [], $sort = 0, $type = "file") { if (empty($template)) { $type = "empty"; } elseif (is_array($template)) { if (isset($template["callback"])) { $type = "callback"; $this->template = $template["callback"]; } else { $this->template = $template["template"]; } $this->sortOrder = $template["sort"] ?? $sort; $this->type = $template["type"] ?? $type; // Merge data array $data1 = $template["data"] ?? []; if (empty($data)) { $this->templateData = $data1; } else if (empty($data1)) { $this->templateData = $data; } else { foreach ($data as $key => $val) { if (is_array($val)) { if (!array_key_exists($key, $data1)) { $data1[$key] = []; } $data1[$key] = array_merge($data1[$key], $val); } else { $data1[$key] = $val; } $this->templateData = $data1; } } return; } $this->template = $template; $this->templateData = $data; $this->sortOrder = $sort; $this->type = $type; return $this; }
php
{ "resource": "" }
q245921
View.render
validation
public function render(ContainerInterface $di = null) { switch ($this->type) { case "file": if ($di->has("viewRenderFile")) { $viewRender = $di->get("viewRenderFile"); } else { $viewRender = new ViewRenderFile($di); $viewRender->setDI($di); } $viewRender->render($this->template, $this->templateData); break; case "callback": if (!is_callable($this->template)) { throw new Exception("View is expecting a valid callback, provided callback seems to not be a callable."); } echo call_user_func($this->template, $this->templateData); break; case "string": echo $this->template; break; case "empty": break; default: throw new Exception("Not a valid template type: '{$this->type}'."); } }
php
{ "resource": "" }
q245922
Timer.start
validation
public static function start(string $key = 'default'): void { if (isset(self::$timers[$key])) { self::$timers[$key]->start(); } else { self::$timers[$key] = new Stopwatch(); } }
php
{ "resource": "" }
q245923
Timer.formatTime
validation
private static function formatTime(float $value, $format): string { switch ($format) { case static::FORMAT_PRECISE: return (string) ($value * 1000); case static::FORMAT_MILLISECONDS: return (string) round($value * 1000, 2); case static::FORMAT_SECONDS: return (string) round($value, 3); default: return (string) ($value * 1000); } }
php
{ "resource": "" }
q245924
Timer.stop
validation
public static function stop($key = 'default'): void { if (isset(self::$timers[$key])) { self::$timers[$key]->stop(); } else { throw new \LogicException('Stopping timer when the given key timer was not initialized.'); } }
php
{ "resource": "" }
q245925
Result.setValueNormalization
validation
public function setValueNormalization(bool $enabled = false) { if ($enabled === true) { $this->initColumnConversions(); } else { $this->toIntColumns = []; $this->toFloatColumns = []; $this->toStringColumns = []; $this->toBoolColumns = []; $this->toDateTimeColumns = []; $this->toDriverColumns = []; } }
php
{ "resource": "" }
q245926
QueryBuilder.select
validation
public function select(?string $expression = null, ...$args): self { $this->dirty(); $this->select = $expression === null ? null : [$expression]; $this->args['select'] = $args; return $this; }
php
{ "resource": "" }
q245927
QueryBuilder.addSelect
validation
public function addSelect(string $expression, ...$args): self { if (!is_string($expression)) { throw new InvalidArgumentException('Select expression has to be a string.'); } $this->dirty(); $this->select[] = $expression; $this->pushArgs('select', $args); return $this; }
php
{ "resource": "" }
q245928
QueryBuilder.where
validation
public function where(?string $expression = null, ...$args): self { $this->dirty(); $this->where = $expression; $this->args['where'] = $args; return $this; }
php
{ "resource": "" }
q245929
QueryBuilder.andWhere
validation
public function andWhere(string $expression, ...$args): self { $this->dirty(); $this->where = $this->where ? '(' . $this->where . ') AND (' . $expression . ')' : $expression; $this->pushArgs('where', $args); return $this; }
php
{ "resource": "" }
q245930
QueryBuilder.groupBy
validation
public function groupBy(?string $expression = null, ...$args): self { $this->dirty(); $this->group = $expression === null ? null : [$expression]; $this->args['group'] = $args; return $this; }
php
{ "resource": "" }
q245931
QueryBuilder.addGroupBy
validation
public function addGroupBy($expression, ...$args): self { $this->dirty(); $this->group[] = $expression; $this->pushArgs('group', $args); return $this; }
php
{ "resource": "" }
q245932
QueryBuilder.having
validation
public function having(?string $expression = null, ...$args): self { $this->dirty(); $this->having = $expression; $this->args['having'] = $args; return $this; }
php
{ "resource": "" }
q245933
QueryBuilder.andHaving
validation
public function andHaving(string $expression, ...$args): self { $this->dirty(); $this->having = $this->having ? '(' . $this->having . ') AND (' . $expression . ')' : $expression; $this->pushArgs('having', $args); return $this; }
php
{ "resource": "" }
q245934
QueryBuilder.orderBy
validation
public function orderBy(?string $expression = null, ...$args): self { $this->dirty(); $this->order = $expression === null ? null : [$expression]; $this->args['order'] = $args; return $this; }
php
{ "resource": "" }
q245935
QueryBuilder.addOrderBy
validation
public function addOrderBy(string $expression, ...$args): self { $this->dirty(); $this->order[] = $expression; $this->pushArgs('order', $args); return $this; }
php
{ "resource": "" }
q245936
QueryBuilder.limitBy
validation
public function limitBy(?int $limit, int $offset = null): self { $this->dirty(); $this->limit = $limit || $offset ? [$limit, $offset] : null; return $this; }
php
{ "resource": "" }
q245937
CSRF.getToken
validation
public static function getToken($token_name = self::TOKEN_NAME) { if (empty($_SESSION[$token_name])) { static::generateToken($token_name); } return $_SESSION[$token_name]; }
php
{ "resource": "" }
q245938
CSRF.validate
validation
public static function validate($request_data = array(), $token_name = self::TOKEN_NAME) { if (empty($_SESSION[$token_name])) { static::generateToken($token_name); return false; } elseif (empty($request_data[$token_name])) { return false; } else { if(static::compare($request_data[$token_name], static::getToken($token_name))){ static::generateToken($token_name); return true; } else { return false; } } }
php
{ "resource": "" }
q245939
CSRF.compare
validation
public static function compare($hasha = "", $hashb = "") { // we want hashes_are_not_equal to be false by the end of this if the strings are identical // if the strings are NOT equal length this will return true, else false $hashes_are_not_equal = strlen($hasha) ^ strlen($hashb); // compare the shortest of the two strings (the above line will still kick back a failure if the lengths weren't equal. this just keeps us from over-flowing our strings when comparing $length = min(strlen($hasha), strlen($hashb)); $hasha = substr($hasha, 0, $length); $hashb = substr($hashb, 0, $length); // iterate through the hashes comparing them character by character // if a character does not match, then return true, so the hashes are not equal for ($i = 0; $i < strlen($hasha); $i++) { $hashes_are_not_equal += !(ord($hasha[$i]) === ord($hashb[$i])); } // if not hashes are not equal, then hashes are equal return !$hashes_are_not_equal; }
php
{ "resource": "" }
q245940
ZipArchive.errorInfo
validation
public function errorInfo() { static $statusStrings = array( \ZipArchive::ER_OK => 'No error', \ZipArchive::ER_MULTIDISK => 'Multi-disk zip archives not supported', \ZipArchive::ER_RENAME => 'Renaming temporary file failed', \ZipArchive::ER_CLOSE => 'Closing zip archive failed', \ZipArchive::ER_SEEK => 'Seek error', \ZipArchive::ER_READ => 'Read error', \ZipArchive::ER_WRITE => 'Write error', \ZipArchive::ER_CRC => 'CRC error', \ZipArchive::ER_ZIPCLOSED => 'Containing zip archive was closed', \ZipArchive::ER_NOENT => 'No such file', \ZipArchive::ER_EXISTS => 'File already exists', \ZipArchive::ER_OPEN => 'Can\'t open file', \ZipArchive::ER_TMPOPEN => 'Failure to create temporary file', \ZipArchive::ER_ZLIB => 'Zlib error', \ZipArchive::ER_MEMORY => 'Malloc failure', \ZipArchive::ER_CHANGED => 'Entry has been changed', \ZipArchive::ER_COMPNOTSUPP => 'Compression method not supported', \ZipArchive::ER_EOF => 'Premature EOF', \ZipArchive::ER_INVAL => 'Invalid argument', \ZipArchive::ER_NOZIP => 'Not a zip archive', \ZipArchive::ER_INTERNAL => 'Internal error', \ZipArchive::ER_INCONS => 'Zip archive inconsistent', \ZipArchive::ER_REMOVE => 'Can\'t remove file', \ZipArchive::ER_DELETED => 'Entry has been deleted', ); if (isset($statusStrings[$this->ziparchive->status])) { $statusString = $statusStrings[$this->ziparchive->status]; } else { $statusString = 'Unknown status'; } return $statusString . '(' . $this->ziparchive->status . ')'; }
php
{ "resource": "" }
q245941
CiconiaCommand.handleInput
validation
protected function handleInput(InputInterface $input) { if ($file = $input->getArgument('file')) { if (!file_exists($file)) { throw new \InvalidArgumentException(sprintf('The input file "%s" not found', $file)); } return file_get_contents($file); } else { $contents = ''; if ($stdin = fopen('php://stdin', 'r')) { // Warning: stream_set_blocking always fails on Windows if (stream_set_blocking($stdin, false)) { $contents = stream_get_contents($stdin); } fclose($stdin); } // @codeCoverageIgnoreStart if ($contents) { return $contents; } // @codeCoverageIgnoreEnd } throw new \InvalidArgumentException('No input file'); }
php
{ "resource": "" }
q245942
CiconiaCommand.createCiconia
validation
protected function createCiconia(InputInterface $input) { if ($input->getOption('diagnose')) { $ciconia = new \Ciconia\Diagnose\Ciconia(); } else { $ciconia = new Ciconia(); } if ($input->getOption('format') == 'xhtml') { $ciconia->setRenderer(new XhtmlRenderer()); } if ($input->getOption('gfm')) { $ciconia->addExtensions([ new FencedCodeBlockExtension(), new InlineStyleExtension(), new TaskListExtension(), new WhiteSpaceExtension(), new TableExtension(), new UrlAutoLinkExtension() ]); } return $ciconia; }
php
{ "resource": "" }
q245943
CiconiaCommand.runHelp
validation
protected function runHelp(InputInterface $input, OutputInterface $output) { /* @var HelpCommand $help */ $help = $this->getApplication()->find('help'); $help->setCommand($this); $help->run($input, $output); }
php
{ "resource": "" }
q245944
CiconiaCommand.lint
validation
protected function lint(OutputInterface $output, Ciconia $ciconia, $content) { try { $ciconia->render($content, array('strict' => true)); $output->writeln('No syntax errors detected.'); return 0; } catch (SyntaxError $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); return 1; } }
php
{ "resource": "" }
q245945
Collection.get
validation
public function get($name) { if (!$this->exists($name)) { throw new \OutOfBoundsException(sprintf('Undefined offset "%s"', $name)); } return $this->objects[(string)$name]; }
php
{ "resource": "" }
q245946
Collection.slice
validation
public function slice($offset, $length = null) { return new Collection(array_slice($this->objects, $offset, $length)); }
php
{ "resource": "" }
q245947
Collection.each
validation
public function each(callable $callable) { foreach ($this->objects as $key => $value) { if (false === call_user_func_array($callable, array($value, $key))) { break; } } return $this; }
php
{ "resource": "" }
q245948
InlineStyleExtension.processMultipleUnderScore
validation
public function processMultipleUnderScore(Text $text) { $text->replace('{<pre>.*?</pre>}m', function (Text $w) { $md5 = md5($w); $this->hashes[$md5] = $w; return "{gfm-extraction-$md5}"; }); $text->replace('/^(?! {4}|\t)(\[?\w+_\w+_\w[\w_]*\]?)/', function (Text $w, Text $word) { $underscores = $word->split('//')->filter(function (Text $item) { return $item == '_'; }); if (count($underscores) >= 2) { $word->replaceString('_', '\\_'); } return $word; }); /** @noinspection PhpUnusedParameterInspection */ $text->replace('/\{gfm-extraction-([0-9a-f]{32})\}/m', function (Text $w, Text $md5) { return "\n\n" . $this->hashes[(string)$md5]; }); }
php
{ "resource": "" }
q245949
LinkExtension.initialize
validation
public function initialize(Text $text, array $options = array()) { /** @noinspection PhpUnusedParameterInspection */ $text->replace('{ ^[ ]{0,' . $options['tabWidth'] . '}\[(.+)\]: # id = $1 [ \t]* \n? # maybe *one* newline [ \t]* <?(\S+?)>? # url = $2 [ \t]* \n? # maybe one newline [ \t]* (?: (?<=\s) # lookbehind for whitespace ["\'(] (.+?) # title = $3 ["\')] [ \t]* )? # title is optional (?:\n+|\Z) }xm', function (Text $whole, Text $id, Text $url, Text $title = null) { $id->lower(); $this->markdown->emit('escape.special_chars', [$url->replace('/(?<!\\\\)_/', '\\\\_')]); $this->markdown->getUrlRegistry()->set($id, htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false)); if ($title) { $this->markdown->getTitleRegistry()->set($id, preg_replace('/"/', '&quot;', $title)); } return ''; }); }
php
{ "resource": "" }
q245950
WhitespaceExtension.initialize
validation
public function initialize(Text $text) { $text->replaceString("\r\n", "\n"); $text->replaceString("\r", "\n"); $text->append("\n\n"); $this->markdown->emit('detab', array($text)); $text->replace('/^[ \t]+$/m', ''); }
php
{ "resource": "" }
q245951
WhitespaceExtension.detab
validation
public function detab(Text $text, array $options = array()) { /** @noinspection PhpUnusedParameterInspection */ $text->replace('/(.*?)\t/', function (Text $whole, Text $string) use ($options) { return $string . str_repeat(' ', $options['tabWidth'] - $string->getLength() % $options['tabWidth']); }); }
php
{ "resource": "" }
q245952
Text.wrap
validation
public function wrap($start, $end) { $this->text = $start . $this->text . $end; return $this; }
php
{ "resource": "" }
q245953
Text.escapeHtml
validation
public function escapeHtml($option = ENT_QUOTES) { $this->text = htmlspecialchars($this->text, $option, 'UTF-8', false); return $this; }
php
{ "resource": "" }
q245954
Text.replace
validation
public function replace($pattern, $replacement) { if (is_callable($replacement)) { $this->text = preg_replace_callback($pattern, function ($matches) use ($replacement) { $args = array_map(function ($item) { return new Text($item); }, $matches); return call_user_func_array($replacement, $args); }, $this->text); } else { $this->text = preg_replace($pattern, $replacement, $this->text); } return $this; }
php
{ "resource": "" }
q245955
Text.replaceString
validation
public function replaceString($search, $replace) { $this->text = str_replace($search, $replace, $this->text); return $this; }
php
{ "resource": "" }
q245956
Text.split
validation
public function split($pattern, $flags = PREG_SPLIT_DELIM_CAPTURE) { return new Collection( array_map(function ($item) { return new static($item); }, preg_split($pattern, $this->text, -1, $flags)) ); }
php
{ "resource": "" }
q245957
EmitterTrait.on
validation
public function on($event, callable $callback, $priority = 10) { if (!isset($this->callbacks[$event])) { $this->callbacks[$event] = [true, []]; } $this->callbacks[$event][0] = false; $this->callbacks[$event][1][] = array($priority, $callback); return $this; }
php
{ "resource": "" }
q245958
EmitterTrait.emit
validation
public function emit($event, $parameters) { if (!isset($this->callbacks[$event])) { return; } if (!$this->callbacks[$event][0]) { usort($this->callbacks[$event][1], function ($A, $B) { if ($A[0] == $B[0]) { return 0; } return ($A[0] > $B[0]) ? 1 : -1; }); $this->callbacks[$event][0] = true; } foreach ($this->callbacks[$event][1] as $item) { call_user_func_array($item[1], $this->buildParameters($parameters)); } }
php
{ "resource": "" }
q245959
UrlAutoLinkExtension.processStandardUrl
validation
public function processStandardUrl(Text $text) { $hashes = array(); // escape <code> $text->replace('{<code>.*?</code>}m', function (Text $w) use (&$hashes) { $md5 = md5($w); $hashes[$md5] = $w; return "{gfm-extraction-$md5}"; }); $text->replace('{(?<!]\(|"|<|\[)((?:https?|ftp)://[^\'">\s]+)(?!>|\"|\])}', '<\1>'); /** @noinspection PhpUnusedParameterInspection */ $text->replace('/\{gfm-extraction-([0-9a-f]{32})\}/m', function (Text $w, Text $md5) use (&$hashes) { return $hashes[(string)$md5]; }); }
php
{ "resource": "" }
q245960
AttributesExtension.processBlockTags
validation
public function processBlockTags(Tag $tag) { if ($tag->isInline()) { return; } $text = null; $tag->getText()->replace('/(^{([^:\(\)]+)}[ \t]*\n?|(?:[ \t]*|\n?){([^:\(\)]+)}\n*$)/', function (Text $w) use (&$text) { $text = $w->trim()->trim('{}'); return ''; }); if ($text) { $tag->setAttributes($this->parseAttributes($text)); } }
php
{ "resource": "" }
q245961
HashRegistry.register
validation
public function register(Text $text) { $hash = $this->generateHash($text); $this->set($hash, $text); return new Text($hash); }
php
{ "resource": "" }
q245962
ListExtension.processListItems
validation
public function processListItems(Text $list, array $options = array(), $level = 0) { $list->replace('/\n{2,}\z/', "\n"); /** @noinspection PhpUnusedParameterInspection */ $list->replace('{ (\n)? # leading line = $1 (^[ \t]*) # leading whitespace = $2 (' . $this->getPattern() . ') [ \t]+ # list marker = $3 ((?s:.+?) # list item text = $4 (\n{1,2})) (?= \n* (\z | \2 (' . $this->getPattern() . ') [ \t]+)) }mx', function (Text $w, Text $leadingLine, Text $ls, Text $m, Text $item) use ($options, $level) { if ((string)$leadingLine || $item->match('/\n{2,}/')) { $this->markdown->emit('outdent', array($item)); $this->markdown->emit('block', array($item)); } else { $this->markdown->emit('outdent', array($item)); $this->processList($item, $options, ++$level); $item->rtrim(); $this->markdown->emit('inline', array($item)); } return $this->getRenderer()->renderListItem($item) . "\n"; }); }
php
{ "resource": "" }
q245963
Tag.setText
validation
public function setText($text) { $this->text = $text; if (!$this->text instanceof Text) { $this->text = new Text($this->text); } return $this; }
php
{ "resource": "" }
q245964
Tag.setAttribute
validation
public function setAttribute($attribute, $value = null) { $this->attributes->set($attribute, $value); return $this; }
php
{ "resource": "" }
q245965
Tag.render
validation
public function render() { $html = new Text(); $html ->append('<') ->append($this->getName()); foreach ($this->attributes as $name => $value) { $html->append(' ') ->append($name) ->append('=') ->append('"') ->append($value) ->append('"'); } if ($this->text->isEmpty()) { if ($this->type == self::TYPE_BLOCK) { return (string)$html->append('>')->append('</')->append($this->getName())->append('>'); } else { return (string)$html->append($this->emptyTagSuffix); } } return (string)$html ->append('>') ->append($this->text) ->append('</') ->append($this->getName()) ->append('>'); }
php
{ "resource": "" }
q245966
Inflector.addRule
validation
private function addRule($data, $ruleType) { if (\is_string($data)) { $data = array($data); } elseif (!\is_array($data)) { // Do not translate. throw new InvalidArgumentException('Invalid inflector rule data.'); } foreach ($data as $rule) { // Ensure a string is pushed. array_push($this->rules[$ruleType], (string) $rule); } }
php
{ "resource": "" }
q245967
Inflector.getCachedPlural
validation
private function getCachedPlural($singular) { $singular = StringHelper::strtolower($singular); // Check if the word is in cache. if (isset($this->cache[$singular])) { return $this->cache[$singular]; } return false; }
php
{ "resource": "" }
q245968
Inflector.getCachedSingular
validation
private function getCachedSingular($plural) { $plural = StringHelper::strtolower($plural); return array_search($plural, $this->cache); }
php
{ "resource": "" }
q245969
Inflector.setCache
validation
private function setCache($singular, $plural = null) { $singular = StringHelper::strtolower($singular); if ($plural === null) { $plural = $singular; } else { $plural = StringHelper::strtolower($plural); } $this->cache[$singular] = $plural; }
php
{ "resource": "" }
q245970
Inflector.isSingular
validation
public function isSingular($word) { // Try the cache for a known inflection. $inflection = $this->getCachedPlural($word); if ($inflection !== false) { return true; } $pluralWord = $this->toPlural($word); if ($pluralWord === false) { return false; } // Compute the inflection to cache the values, and compare. return $this->toSingular($pluralWord) == $word; }
php
{ "resource": "" }
q245971
StringHelper.transcode
validation
public static function transcode($source, $fromEncoding, $toEncoding) { if (\is_string($source)) { switch (ICONV_IMPL) { case 'glibc': return @iconv($fromEncoding, $toEncoding . '//TRANSLIT,IGNORE', $source); case 'libiconv': default: return iconv($fromEncoding, $toEncoding . '//IGNORE//TRANSLIT', $source); } } }
php
{ "resource": "" }
q245972
StringHelper.unicode_to_utf16
validation
public static function unicode_to_utf16($str) { if (\extension_loaded('mbstring')) { return preg_replace_callback( '/\\\\u([0-9a-fA-F]{4})/', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UTF-16BE'); }, $str ); } return $str; }
php
{ "resource": "" }
q245973
WP_Session.set_expiration
validation
protected function set_expiration() { $this->exp_variant = time() + (int) apply_filters( 'wp_session_expiration_variant', 24 * 60 ); $this->expires = time() + (int) apply_filters( 'wp_session_expiration', 30 * 60 ); }
php
{ "resource": "" }
q245974
WP_Session.set_cookie
validation
protected function set_cookie() { @setcookie( WP_SESSION_COOKIE, $this->session_id . '||' . $this->expires . '||' . $this->exp_variant, $this->expires, COOKIEPATH, COOKIE_DOMAIN ); }
php
{ "resource": "" }
q245975
WP_Session.write_data
validation
public function write_data() { $option_key = "_wp_session_{$this->session_id}"; // Only write the collection to the DB if it's changed. if ( $this->dirty ) { if ( false === get_option( $option_key ) ) { add_option( "_wp_session_{$this->session_id}", $this->container, '', 'no' ); add_option( "_wp_session_expires_{$this->session_id}", $this->expires, '', 'no' ); } else { delete_option( "_wp_session_{$this->session_id}" ); add_option( "_wp_session_{$this->session_id}", $this->container, '', 'no' ); } } }
php
{ "resource": "" }
q245976
WP_Session.regenerate_id
validation
public function regenerate_id( $delete_old = false ) { if ( $delete_old ) { delete_option( "_wp_session_{$this->session_id}" ); } $this->session_id = $this->generate_id(); $this->set_cookie(); }
php
{ "resource": "" }
q245977
CollectAsynchronousEventNames.process
validation
public function process(ContainerBuilder $container) { $serviceId = 'simple_bus.asynchronous.publishes_predefined_messages_middleware'; if (!$container->hasDefinition($serviceId)) { return; } $names = array(); $this->collectServiceIds( $container, 'asynchronous_event_subscriber', 'subscribes_to', function ($key) use (&$names) { $names[] = $key; } ); $container->getDefinition($serviceId)->replaceArgument(2, array_unique($names)); }
php
{ "resource": "" }
q245978
Mailer.sendException
validation
public function sendException(Request $request, \Exception $exception) { if (!$this->enabled) { return; } $serverParams = $request->server->all(); if (isset($serverParams['PHP_AUTH_PW'])) { $serverParams['PHP_AUTH_PW'] = '*****'; } $message = \Swift_Message::newInstance() ->setSubject('Error message from '.$request->getHost().' - '.$exception->getMessage()) ->setFrom($this->from) ->setTo($this->to) ->setContentType('text/html') ->setBody( $this->templating->render( "SoclozMonitoringBundle:Notify:exception.html.twig", array( 'request' => $request, 'exception' => $exception, 'exception_class' => \get_class($exception), 'request_headers' => $request->server->getHeaders(), 'request_attributes' => $this->mailerTransformer->transform($request->attributes->all()), 'server_params' => $this->mailerTransformer->transform($serverParams), ) ) ); try { $this->getMailer()->send($message); } catch (\Exception $e) { $this->logger->error('Sending mail error - '.$e->getMessage()); } }
php
{ "resource": "" }
q245979
Exceptions.onKernelException
validation
public function onKernelException(GetResponseForExceptionEvent $event) { if ($this->isIgnored($event->getException())) { return; } if ($this->mailer) { $this->mailer->sendException($event->getRequest(), $event->getException()); } if ($this->statsd) { $this->statsd->increment("exception"); } }
php
{ "resource": "" }
q245980
GdprOptinModule.clearTmp
validation
public static function clearTmp($clearFolderPath = '') { $folderPath = self::_getFolderToClear($clearFolderPath); $directoryHandler = opendir($folderPath); if (!empty($directoryHandler)) { while (false !== ($fileName = readdir($directoryHandler))) { $filePath = $folderPath . DIRECTORY_SEPARATOR . $fileName; self::_clear($fileName, $filePath); } closedir($directoryHandler); } return true; }
php
{ "resource": "" }
q245981
GdprOptinModule._clear
validation
protected static function _clear($fileName, $filePath) { if (!in_array($fileName, ['.', '..', '.gitkeep', '.htaccess'])) { if (is_file($filePath)) { @unlink($filePath); } else { self::clearTmp($filePath); } } }
php
{ "resource": "" }
q245982
SoclozMonitoringExtension.createProfilerProbes
validation
private function createProfilerProbes($name, ContainerBuilder $container) { $key = sprintf("socloz_monitoring.profiler.probe.definition.%s", $name); if ($container->hasParameter($key)) { $definition = $container->getParameter($key); return array($this->createProbeDefinition($name, Probe::TRACKER_CALLS | Probe::TRACKER_TIMING, $definition, $container)); } else { return array( $this->createProbeDefinition( $name, Probe::TRACKER_CALLS, $container->getParameter($key.'.calls'), $container ), $this->createProbeDefinition( $name, Probe::TRACKER_TIMING, $container->getParameter($key.'.timing'), $container ), ); } }
php
{ "resource": "" }
q245983
ReviewController.isReviewOptInValidationRequired
validation
public function isReviewOptInValidationRequired() { return (bool)\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam(self::REVIEW_OPTIN_PARAM); }
php
{ "resource": "" }
q245984
ReviewController.validateOptIn
validation
public function validateOptIn() { $optInValue = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('rvw_oegdproptin'); if ($this->isReviewOptInValidationRequired() && !$optInValue) { return false; } return true; }
php
{ "resource": "" }
q245985
ReviewController.isReviewOptInError
validation
public function isReviewOptInError() { $formSent = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('rvw_oegdproptin') !== null; $review = oxNew(\OxidEsales\Eshop\Application\Controller\ReviewController::class); $result = false; if ($formSent && !$review->validateOptIn()) { $result = true; } return $result; }
php
{ "resource": "" }
q245986
Review.isReviewOptInValidationRequired
validation
public function isReviewOptInValidationRequired() { $review = oxNew(\OxidEsales\Eshop\Application\Controller\ReviewController::class); return $review->isReviewOptInValidationRequired(); }
php
{ "resource": "" }
q245987
Review.isReviewOptInError
validation
public function isReviewOptInError() { $review = oxNew(\OxidEsales\Eshop\Application\Controller\ReviewController::class); return $review->isReviewOptInError(); }
php
{ "resource": "" }
q245988
Plan.listPlans
validation
public function listPlans(array $filters = [], bool $withAddons = true, string $addonType = null): array { $cacheKey = 'plans'; $hit = $this->getFromCache($cacheKey); if (false === $hit) { $response = $this->sendRequest('GET', 'plans'); $plans = $this->processResponse($response); $hit = $plans['plans']; $this->saveToCache($cacheKey, $hit); } $hit = $this->filterPlans($hit, $filters); if ($withAddons) { $hit = $this->getAddonsForPlan($hit, $addonType); } return $hit; }
php
{ "resource": "" }
q245989
Plan.getPlan
validation
public function getPlan(string $planCode): array { $cacheKey = sprintf('plan_%s', $planCode); $hit = $this->getFromCache($cacheKey); if (false === $hit) { $response = $this->sendRequest('GET', sprintf('plans/%s', $planCode)); $data = $this->processResponse($response); $plan = $data['plan']; $this->saveToCache($cacheKey, $plan); return $plan; } return $hit; }
php
{ "resource": "" }
q245990
Plan.getAddonsForPlan
validation
public function getAddonsForPlan(array $plans, string $addonType = null): array { $addonApi = new Addon($this->token, $this->organizationId, $this->cache, $this->ttl); foreach ($plans as &$plan) { $addons = []; foreach ($plan['addons'] as $planAddon) { $addon = $addonApi->getAddon($planAddon['addon_code']); if (null !== $addonType) { if (($addon['type'] == $addonType) && (in_array($addonType, self::$addonTypes))) { $addons[] = $addon; } } else { $addons[] = $addon; } } $plan['addons'] = $addons; } return $plans; }
php
{ "resource": "" }
q245991
Plan.filterPlans
validation
public function filterPlans(array $plans, array $filters): array { foreach ($filters as $key => $filter) { if (array_key_exists($key, current($plans))) { $plans = array_filter($plans, function ($element) use ($key, $filter) { return $element[$key] == $filter; }); } } return $plans; }
php
{ "resource": "" }
q245992
Plan.getPriceByPlanCode
validation
public function getPriceByPlanCode(string $planCode): float { $plan = $this->getPlan($planCode); return (array_key_exists('recurring_price', $plan)) ? $plan['recurring_price'] : 0; }
php
{ "resource": "" }
q245993
ContactController.send
validation
public function send() { $optInValue = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('c_oegdproptin'); if ($this->isOptInValidationRequired() && !$optInValue) { \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('OEGDPROPTIN_CONTACT_FORM_ERROR_MESSAGE'); $this->optInError = true; return false; } return parent::send(); }
php
{ "resource": "" }
q245994
ContactController.getContactFormMethod
validation
private function getContactFormMethod() { $method = self::CONTACT_FORM_METHOD_DEFAULT; if ($configMethod = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('OeGdprOptinContactFormMethod')) { $method = $configMethod; } return $method; }
php
{ "resource": "" }
q245995
Xhprof.startProfiling
validation
public function startProfiling() { if (PHP_SAPI == 'cli') { $_SERVER['REMOTE_ADDR'] = null; $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; } if (function_exists('xhprof_enable') && count($this->probes) > 0) { $this->profiling = true; xhprof_enable($this->memory ? XHPROF_FLAGS_MEMORY : null); } }
php
{ "resource": "" }
q245996
Xhprof.stopProfiling
validation
public function stopProfiling() { if (!$this->profiling) { return false; } $this->profiling = false; $xhprof_data = xhprof_disable(); if (is_array($xhprof_data)) { $this->parser->parse($xhprof_data); } foreach ($this->probes as $probe) { $name = $probe->getName(); if ($probe->isTimingProbe()) { $this->timers[$name] = $probe->getTime(); } if ($probe->isCallsProbe()) { $this->counters[$name] = $probe->getCount(); } } return true; }
php
{ "resource": "" }
q245997
MailerTransformer.transform
validation
public function transform($value) { if ($value instanceof \Traversable || is_array($value)) { return $this->transformIterable($value); } if (is_bool($value)) { return $this->transformBoolean($value); } if (is_scalar($value) || (is_object($value) && method_exists($value, '__toString'))) { return $value; } if ($value instanceof Cache) { return $this->transformCacheAnnotation($value); } if ($value instanceof Method) { return $this->transformMethodAnnotation($value); } if ($value instanceof ParamConverter) { return $this->transformParamConverter($value); } if ($value instanceof Security) { return $this->transformSecurity($value); } if ($value instanceof Template) { return $this->transformTemplate($value); } return get_class($value); }
php
{ "resource": "" }
q245998
MailerTransformer.transformIterable
validation
protected function transformIterable($value) { $params = array(); foreach ($value as $key => $val) { if (!empty($val)) { $params[$key] = $this->transform($val); } } return $params; }
php
{ "resource": "" }
q245999
MailerTransformer.transformCacheAnnotation
validation
protected function transformCacheAnnotation(Cache $cache) { return array( 'expires' => $cache->getExpires(), 'maxage' => $cache->getMaxAge(), 'smaxage' => $cache->getSMaxAge(), 'public' => $this->transformBoolean($cache->isPublic()), 'vary' => $cache->getVary(), 'lastModified' => $cache->getLastModified(), 'etag' => $cache->getETag(), ); }
php
{ "resource": "" }