_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q10700
TicketControllerExtension.TicketForm
train
public function TicketForm() { if ($this->owner->Tickets()->count() && $this->owner->getTicketsAvailable()) { $ticketForm = new TicketForm($this->owner, 'TicketForm',
php
{ "resource": "" }
q10701
TicketControllerExtension.WaitingListRegistrationForm
train
public function WaitingListRegistrationForm() { if ( $this->owner->Tickets()->count() && $this->owner->getTicketsSoldOut() && !$this->owner->getEventExpired() ) {
php
{ "resource": "" }
q10702
HipChatHandler.getAlertColor
train
protected function getAlertColor($level) { switch (true) { case $level >= Logger::ERROR: return 'red'; case $level >= Logger::WARNING:
php
{ "resource": "" }
q10703
SonarTask.setConfig
train
private function setConfig(\Phalcon\Config $config) { if(defined(CURRENT_TASK) === true) {
php
{ "resource": "" }
q10704
SonarTask.setLogger
train
private function setLogger() { $config = $this->getConfig(); if($config->offsetExists('errors') === true && $config->errors === true) {
php
{ "resource": "" }
q10705
SonarTask.setSilentErrorHandler
train
public function setSilentErrorHandler() { set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) { if (0 === error_reporting()) {
php
{ "resource": "" }
q10706
Cache.checkFile
train
private function checkFile(string &$file): bool { $file = "{$this->directory}/{$file}";
php
{ "resource": "" }
q10707
EntityMap.getKey
train
public function getKey($item, $return_all = false) { if ($return_all === true) { return $this->getKeys(); }
php
{ "resource": "" }
q10708
RecordHandler.getPlayerPosition
train
public function getPlayerPosition($login) { return isset($this->positionPerPlayer[$login]) ?
php
{ "resource": "" }
q10709
RecordHandler.getPlayerRecord
train
public function getPlayerRecord($login) { return isset($this->recordsPerPlayer[$login]) ?
php
{ "resource": "" }
q10710
RecordHandler.loadForMap
train
public function loadForMap($mapUid, $nbLaps) { // Free old records from memory first. foreach ($this->records as $record) { $record->clearAllReferences(false); unset($record); } foreach ($this->recordsPerPlayer as $record) { $record->clearAllReferences(false); unset($record); } RecordTableMap::clearInstancePool(); // Load them amm new. $this->recordsPerPlayer = []; $this->positionPerPlayer = []; $this->currentMapUid = $mapUid; $this->currentNbLaps = $nbLaps; $this->records = $this->recordQueryBuilder
php
{ "resource": "" }
q10711
RecordHandler.loadForPlayers
train
public function loadForPlayers($mapUid, $nbLaps, $logins) { $logins = array_diff($logins, array_keys($this->recordsPerPlayer)); if (!empty($logins)) {
php
{ "resource": "" }
q10712
RecordHandler.save
train
public function save() { $con = Propel::getWriteConnection(RecordTableMap::DATABASE_NAME); $con->beginTransaction(); foreach ($this->recordsPerPlayer as $record) {
php
{ "resource": "" }
q10713
RecordHandler.getNewRecord
train
protected function getNewRecord($login) { $record = new Record(); $record->setPlayer($this->playerDb->get($login));
php
{ "resource": "" }
q10714
RecordHandler.updateRecordStats
train
protected function updateRecordStats(Record $record, $score) { $record->setAvgScore( (($record->getAvgScore() * $record->getNbFinish()) + $score)
php
{ "resource": "" }
q10715
GeoService.location
train
public function location($param) { try { $result = $this->geocoder->geocode($param); // parse data
php
{ "resource": "" }
q10716
Flot.getExtraFunctionCalls
train
public function getExtraFunctionCalls($dataArrayJs, $optionsJs) { $extraFunctionCalls = array(); if ($this->zooming) { $extraFunctionCalls[] = sprintf( self::ZOOMING_FUNCTION, $dataArrayJs, $optionsJs, $dataArrayJs, $optionsJs ); } if ($this->useLabels) { $seriesLabels = json_encode($this->pointLabels); $top = ''; $left = ''; $pixelCount = '15'; for ( $i = 0; $i < strlen($this->labelSettings['location']); $i++ ) { switch ( $this->labelSettings['location'][$i] ) { case 'n': $top = '-'.$pixelCount; break; case 'e': $left = '+'.$pixelCount; break; case 's': $top = '+'.$pixelCount; break; case 'w':
php
{ "resource": "" }
q10717
Flot.setAxisOptions
train
public function setAxisOptions($axis, $name, $value) { if( strtolower($axis) === 'x' || strtolower($axis) === 'y' ) { $axis = strtolower($axis) . 'axis'; if ( array_key_exists( $name, $this->nativeOpts[$axis] ) ) { $this->setNestedOptVal( $this->options, $axis, $name, $value ); } else { $key = 'axes.'.$axis.'.'.$name; if ( isset( $this->optsMapper[$key] ) ) {
php
{ "resource": "" }
q10718
Flot.initializeSeries
train
public function initializeSeries( $series ) { parent::initializeSeries($series);
php
{ "resource": "" }
q10719
Flot.getOptionsJS
train
protected function getOptionsJS() { foreach ($this->optsMapper as $opt => $mapped) { if (($currOpt = $this->getOptVal($this->options, $opt)) && ($currOpt !== null)) { $this->setOpt($this->options, $mapped, $currOpt); $this->unsetOpt($this->options, $opt); } } $opts = $this->options; // stupid pie plugin if ( $this->getOptVal( $opts, 'seriesStorage', 'pie', 'show' ) === null ) {
php
{ "resource": "" }
q10720
Flot.getOptVal
train
protected function getOptVal(array $opts, $option) { $ploded = explode('.', $option); $arr = $opts; $val = null; while ($curr = array_shift($ploded)) {
php
{ "resource": "" }
q10721
Flot.setOpt
train
protected function setOpt(array &$opts, $mapperString, $val) { $args = explode( '.', $mapperString );
php
{ "resource": "" }
q10722
Flot.unsetOpt
train
protected function unsetOpt(array &$opts, $mapperString) { $ploded = explode('.', $mapperString); $arr = &$opts; while ($curr = array_shift($ploded)) { if (isset($arr[$curr])) { if (is_array($arr[$curr])) {
php
{ "resource": "" }
q10723
Flot.setSeriesLineWidth
train
public function setSeriesLineWidth( $series, $value ) { return $this->setNestedOptVal( $this->options, 'seriesStorage',
php
{ "resource": "" }
q10724
Flot.setSeriesShowLine
train
public function setSeriesShowLine( $series, $bool ) { return $this->setNestedOptVal( $this->options, 'seriesStorage',
php
{ "resource": "" }
q10725
Flot.setSeriesShowMarker
train
public function setSeriesShowMarker( $series, $bool ) { return $this->setNestedOptVal( $this->options, 'seriesStorage',
php
{ "resource": "" }
q10726
Flot.setAxisTicks
train
public function setAxisTicks($axis, array $ticks = array() ) { if ( in_array($axis, array('x', 'y') ) ) { $isString = false; $alternateTicks = array(); $cnt = 1; foreach ($ticks as $tick) { if (!(ctype_digit($tick) || is_int($tick))) { $isString = true; // this is O(2N) so deal with it foreach
php
{ "resource": "" }
q10727
EmbeddedEntityListRule.execute
train
protected function execute($value, EntityInterface $parent_entity = null) { $success = true; $list = null; if ($value instanceof EntityList) { $list = $value; } elseif (null === $value) { $list = new EntityList(); } elseif ($value instanceof EntityInterface) { $list = new EntityList(); $list->push($value); } elseif (is_array($value)) { $list = new EntityList(); $success = $this->createEntityList($value, $list, $parent_entity); } else { $this->throwError('invalid_value_type'); return false; } $count = count($list); if ($this->hasOption(self::OPTION_MIN_COUNT)) { $min_count = $this->getOption(self::OPTION_MIN_COUNT, 0); if ($count < (int)$min_count) { $this->throwError('min_count', [ 'count' => $count, 'min_count' => $min_count ]); $success = false; } }
php
{ "resource": "" }
q10728
Jukebox.onPodiumStart
train
public function onPodiumStart($time) { $jbMap = $this->jukeboxService->getFirst(); if ($jbMap) { $length = count($this->jukeboxService->getMapQueue()); $this->chatNotification->sendMessage('expansion_jukebox.chat.nextjbmap', null, [ "%mapname%" => $jbMap->getMap()->name, "%mapauthor%" => $jbMap->getMap()->author, "%nickname%" => $jbMap->getPlayer()->getNickName(), "%length%" => $length, ]);
php
{ "resource": "" }
q10729
DefaultTemplateEngine.draw
train
public function draw(string $file, array $data) : string { $this->file = $file; $this->data =
php
{ "resource": "" }
q10730
DefaultTemplateEngine.getOutputs
train
private function getOutputs() : string { ob_start(); extract($this->data); require $this->file;
php
{ "resource": "" }
q10731
EloquentSetting.update
train
public function update(array $data, $Setting = null) { if(empty($Setting)) { $Setting = $this->byId($data['id']); } foreach ($data as $key => $value)
php
{ "resource": "" }
q10732
Text.maxCharWidth
train
public static function maxCharWidth($string) { $chars = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); if (!$chars) { return 0; }
php
{ "resource": "" }
q10733
Text.stripLinks
train
public static function stripLinks($text, $replaceWith = '') { $text = preg_replace('/(?:(?:[^\s\:>]+:)?\/\/|www\.)[^\s\.]+\.\w+[^\s<]+/u', $replaceWith, $text);
php
{ "resource": "" }
q10734
Text.stripSocials
train
public static function stripSocials($text, $replaceWith = '') { $text = preg_replace('/(?<=\s|^|>)@[^\s<]+/u', $replaceWith, $text);
php
{ "resource": "" }
q10735
Text.toBool
train
public static function toBool($string) { if (is_null($string)) { return false; } if (!is_scalar($string)) { throw new InvalidArgumentException("Value must be scalar"); } if (!is_string($string)) {
php
{ "resource": "" }
q10736
Text.toCase
train
public static function toCase($string, $case) { switch ($case) { case self::UPPER: $string = mb_strtoupper($string); break; case self::LOWER: $string = mb_strtolower($string); break; case self::UPPER_FIRST: $string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1); break; case self::UPPER_WORDS: $string =
php
{ "resource": "" }
q10737
Text.toSingleWhitespace
train
public static function toSingleWhitespace($string, $trim = true) { $string = preg_replace("/\r|\n|\t/", " ", $string); $string = preg_replace("/ {2,}/", " ", $string);
php
{ "resource": "" }
q10738
PlayerRepository.majRankPointGame
train
public function majRankPointGame() { $players = $this->findBy(array(), array('pointGame' => 'DESC'));
php
{ "resource": "" }
q10739
PlayerRepository.majRankMedal
train
public function majRankMedal() { $players = $this->findBy(array(), array('chartRank0' => 'DESC', 'chartRank1' => 'DESC', 'chartRank2' =>
php
{ "resource": "" }
q10740
PlayerRepository.majRankProof
train
public function majRankProof() { $players = $this->findBy(array(), array('nbChartProven' => 'DESC'));
php
{ "resource": "" }
q10741
ComposerUtils.getDirectories
train
public static function getDirectories() { Logger::info("Resolving dependencies for project"); $packages = array(); $root = dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))); $composer = file_get_contents($root . DIRECTORY_SEPARATOR . 'composer.json'); $composer = json_decode($composer, true); if (array_key_exists('require', $composer) && !empty($composer['require'])) { foreach ($composer['require'] as $requirement => $version) { $packages = array_merge(self::readFile($requirement), $packages); } } else {
php
{ "resource": "" }
q10742
ComposerUtils.readFile
train
public static function readFile($package) { $root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))); $path = implode(DIRECTORY_SEPARATOR, array($root, $package, 'composer.json')); Logger::trace("Reading composer file %s", $path); if (file_exists($path)) { $composer = json_decode(file_get_contents($path), true); if (array_key_exists('require', $composer) && !empty($composer['require'])) { $directories = array($package); Logger::trace("Checking dependencies for package %s", $package); foreach ($composer['require'] as $requirement => $version) {
php
{ "resource": "" }
q10743
PaymentSlipPdf.writePaymentSlipLines
train
protected function writePaymentSlipLines($elementName, array $element) { if (!is_string($elementName)) { throw new \InvalidArgumentException('$elementName is not a string!'); } if (!isset($element['lines'])) { throw new \InvalidArgumentException('$element contains not "lines" key!'); } if (!isset($element['attributes'])) { throw new \InvalidArgumentException('$element contains not "attributes" key!'); } $lines = $element['lines']; $attributes = $element['attributes']; if (!is_array($lines)) { throw new \InvalidArgumentException('$lines is not an array!'); } if (!is_array($attributes)) { throw
php
{ "resource": "" }
q10744
PaymentSlipPdf.createPaymentSlip
train
public function createPaymentSlip(PaymentSlip $paymentSlip) { $this->paymentSlip = $paymentSlip; // Place background image if ($paymentSlip->getDisplayBackground()) { $this->displayImage($paymentSlip->getSlipBackground()); } $elements = $paymentSlip->getAllElements(); // Go through all elements, write
php
{ "resource": "" }
q10745
Builder.setTable
train
public function setTable(string $table): self { $this->table =
php
{ "resource": "" }
q10746
Builder.selectMore
train
public function selectMore($field, string $as = null): self
php
{ "resource": "" }
q10747
Builder.selectJsonMore
train
public function selectJsonMore($field, string $as, string $type =
php
{ "resource": "" }
q10748
Builder.selectRandom
train
public function selectRandom($field): self { return $this->push('select', $this->prepareField($field))
php
{ "resource": "" }
q10749
Builder.joinLeft
train
public function joinLeft(string $to, string $as, string $on, $onParams =
php
{ "resource": "" }
q10750
Builder.joinUsing
train
public function joinUsing(string $to, string $as, string $using, $usingParams = null, string $type = ''): self { return $this->push('join', sprintf('%sJOIN %s AS %s USING (%s)', $type ? strtoupper($type) .' ' : '',
php
{ "resource": "" }
q10751
Builder.joinLeftUsing
train
public function joinLeftUsing(string $to, string $as, string $using, $usingParams =
php
{ "resource": "" }
q10752
Builder.whereEqual
train
public function whereEqual($field, $param, string $op = ''): self {
php
{ "resource": "" }
q10753
Builder.whereNull
train
public function whereNull($field, string $op = ''): self {
php
{ "resource": "" }
q10754
Builder.whereIn
train
public function whereIn($field, $param, string $op = ''): self { $ops = ['?']; if (is_array($param)) { $ops = array_fill(0, count($param), '?'); }
php
{ "resource": "" }
q10755
Builder.whereBetween
train
public function whereBetween($field, array $params, string $op = ''): self {
php
{ "resource": "" }
q10756
Builder.whereLike
train
public function whereLike($field, $arguments, bool $ilike = false, bool $not = false, string $op = ''): self { // @note to me.. // 'foo%' Anything starts with "foo" // '%foo' Anything ends with "foo" // '%foo%' Anything have "foo" in any position // 'f_o%' Anything have "o" in the second position // 'f_%_%' Anything starts with "f" and are at least 3 characters in length // 'f%o' Anything starts with "f" and ends with "o" $arguments = (array) $arguments; $searchArguments = array_slice($arguments, 0, 3); if ($arguments != null) { // eg: (??, ['%', 'apple', '%', 'id']), (%n, ['%', 'apple', '%', 'id']) $field = $this->agent->prepare($field, array_slice($arguments, 3)); } $search = ''; switch (count($searchArguments)) { case 1: // none, eg: 'apple', ['apple'] [$start, $search, $end] = ['', $searchArguments[0], '']; break; case 2: // start/end, eg: ['%', 'apple'], ['apple', '%'] if ($searchArguments[0] == '%') { [$start, $search, $end] = ['%', $searchArguments[1], '']; } elseif ($searchArguments[1] == '%') { [$start, $search, $end] = ['', $searchArguments[0], '%']; } break; case 3: // both, eg: ['%', 'apple', '%'] [$start, $search, $end] = $searchArguments; break; } $search = trim((string) $search); if ($search == '') { throw new BuilderException('Like search cannot be empty!'); } $not = $not ? 'NOT ' : ''; if (is_string($field) && strpos($field, '(') === false) {
php
{ "resource": "" }
q10757
Builder.whereNotLike
train
public function whereNotLike($field, $arguments, bool $ilike = false, string $op = ''): self { return
php
{ "resource": "" }
q10758
Builder.whereLikeBoth
train
public function whereLikeBoth($field, string $search, bool $ilike = false, bool $not = false, string $op = ''): self {
php
{ "resource": "" }
q10759
Builder.whereExists
train
public function whereExists($query, array $queryParams = null, string $op = ''): self { if ($query instanceof Builder) { $query = $query->toString(); } if ($queryParams != null) {
php
{ "resource": "" }
q10760
Builder.whereId
train
public function whereId(string $field, $id, string $op =
php
{ "resource": "" }
q10761
Builder.whereIds
train
public function whereIds(string $field, array $ids, string $op =
php
{ "resource": "" }
q10762
Builder.orderBy
train
public function orderBy($field, string $op = null): self { // check operator is valid if ($op == null) { return $this->push('orderBy', $this->prepareField($field)); } $op = strtoupper($op); if ($op != self::OP_ASC && $op !=
php
{ "resource": "" }
q10763
Builder.prepareField
train
private function prepareField($field, bool $join = true) { if ($field == '*') { return $field; } if ($field instanceof Builder || $field instanceof Sql) { return '('. $field->toString() .')'; } elseif ($field instanceof Identifier) { return $this->agent->escapeIdentifier($field); } if (is_string($field)) { $field = Util::split(',', trim($field)); } if (is_array($field)) {
php
{ "resource": "" }
q10764
Locale.sanitizeCountry
train
public static function sanitizeCountry($locale, $default = null) { if ($locale instanceof Locale) { return $locale->getCountry(); } if ($default) { $default = Locale::sanitizeCountry($default, null); } $locale = (string) $locale; $locale = trim($locale);
php
{ "resource": "" }
q10765
Locale.sanitizeLanguage
train
public static function sanitizeLanguage($locale, $default = null) { if ($locale instanceof Locale) { return $locale->getLanguage(); } if ($default) { $default = Locale::sanitizeLanguage($default, null); } $locale = (string) $locale; $locale = trim($locale);
php
{ "resource": "" }
q10766
Locale.sanitizeLocale
train
public static function sanitizeLocale($locale, $default = null) { if ($locale instanceof Locale) { return $locale->getLocale(); } if ($default) { $default = Locale::sanitizeLocale($default, null); } $locale = (string) $locale;
php
{ "resource": "" }
q10767
Locale.getCountryName
train
public function getCountryName($inLocale = null) { $inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
php
{ "resource": "" }
q10768
Locale.getCountryNameFor
train
public function getCountryNameFor($locale, $inLocale = null) { $locale = '_' . Locale::sanitizeCountry($locale); $inLocale
php
{ "resource": "" }
q10769
Locale.getLanguageName
train
public function getLanguageName($inLocale = null) { $inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
php
{ "resource": "" }
q10770
Locale.getLanguageNameFor
train
public function getLanguageNameFor($locale, $inLocale = null) { $locale = Locale::sanitizeLanguage($locale) . '_';
php
{ "resource": "" }
q10771
Locale.getLocaleName
train
public function getLocaleName($inLocale = null) { $inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
php
{ "resource": "" }
q10772
Exception.toStackTrace
train
public static function toStackTrace($ex) { $list = []; for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev']) {
php
{ "resource": "" }
q10773
Exception.toThrowableTrace
train
public static function toThrowableTrace($ex) { $list = []; for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev']) {
php
{ "resource": "" }
q10774
Exception.toStackString
train
public static function toStackString($ex) { $stack = []; $i = 0; $trace = static::toStackTrace($ex); $pad = strlen(count($trace)) > 2 ?: 2; foreach ($trace as $element) {
php
{ "resource": "" }
q10775
Exception.toThrowableString
train
public static function toThrowableString($ex) { $stack = []; $i = 0; $trace = static::toThrowableTrace($ex); $pad = strlen(count($trace)) > 2 ?: 2; foreach ($trace as $element) {
php
{ "resource": "" }
q10776
MapRatings.loadRatings
train
private function loadRatings(Map $map) { try { $this->mapRatingsService->load($map); } catch (PropelException $e) {
php
{ "resource": "" }
q10777
GameTitleFetchPass.fetchDataFromRemote
train
protected function fetchDataFromRemote(Filesystem $fileSytem, ContainerBuilder $container) { $curl = new Curl(); $curl->setUrl("https://mp-expansion.com/api/maniaplanet/toZto");
php
{ "resource": "" }
q10778
QueryParser.parseFunctionArgument
train
private function parseFunctionArgument($funcName, $context) { try { return $this->parsePrimitiveValue(); } catch(\Exception $e) { $name = $this->tokenizer->getTokenValue(); if($name) { // ADVANCE $this->tokenizer->readNextToken(); // NESTED FUNCTION if($this->tokenizer->is(TokenType::LEFT_PAREN))
php
{ "resource": "" }
q10779
QueryParser.parseOrderByField
train
private function parseOrderByField() { $retVal = null; $fieldName = $this->tokenizer->getTokenValue(); $this->tokenizer->expect(TokenType::EXPRESSION); if($this->tokenizer->is(TokenType::LEFT_PAREN)) { $retVal = new AST\OrderByFunction($this->parseFunctionExpression($fieldName, Functions\SoqlFunctionInterface::CONTEXT_ORDER_BY)); } else { $retVal = new AST\OrderByField($fieldName); } // ASC/DESC if($this->tokenizer->isKeyword('asc')) { $retVal->setDirection(AST\OrderByField::DIRECTION_ASC); $this->tokenizer->readNextToken(); } elseif($this->tokenizer->isKeyword('desc')) { $retVal->setDirection(AST\OrderByField::DIRECTION_DESC); $this->tokenizer->readNextToken(); } if($this->tokenizer->isKeyword('NULLS')) { $this->tokenizer->readNextToken(); if($this->tokenizer->isKeyword('last')) { $retVal->setNulls(AST\OrderByField::NULLS_LAST);
php
{ "resource": "" }
q10780
MonologInit.createLoggerInstance
train
protected function createLoggerInstance($handler, $target) { $handlerClassName = $handler . 'Handler'; if (class_exists('\Monolog\Logger') && class_exists('\Monolog\Handler\\' . $handlerClassName)) { if (null !== $handlerInstance = $this->createHandlerInstance($handlerClassName, $target)) { $this->instance = new
php
{ "resource": "" }
q10781
MonologInit.createHandlerInstance
train
protected function createHandlerInstance($className, $handlerArgs) { if (method_exists($this, 'init' . $className)) { return call_user_func(array($this, 'init' .
php
{ "resource": "" }
q10782
Mxmap.setMap
train
public function setMap(ChildMap $v = null) { if ($v === null) { $this->setTrackuid(NULL); } else { $this->setTrackuid($v->getMapuid()); } $this->aMap = $v; // Add binding for other direction of this n:n relationship. //
php
{ "resource": "" }
q10783
Mxmap.getMap
train
public function getMap(ConnectionInterface $con = null) { if ($this->aMap === null && (($this->trackuid !== "" && $this->trackuid !== null))) { $this->aMap = ChildMapQuery::create() ->filterByMxmap($this) // here ->findOne($con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be
php
{ "resource": "" }
q10784
Requester.get_content_type
train
public function get_content_type() { $headers = wp_remote_retrieve_headers( $this->response ); if ( ! $headers ) { return; } if ( ! is_object( $headers )
php
{ "resource": "" }
q10785
Requester.get_content
train
public function get_content() { $content = wp_remote_retrieve_body( $this->response
php
{ "resource": "" }
q10786
ObjectStorage.executeCommand
train
private function executeCommand(array $parameters, string $command) { foreach ($parameters as $index => $object) { $parameters[$index]['command'] = $command; } $result = $this->execute($parameters); if (isset($index)) {
php
{ "resource": "" }
q10787
ObjectStorage.validate
train
public function validate($key): bool { if (!is_string($key) || strlen($key) === 0 || $key === '.' || $key === '..' || strpos($key, '/../') !== false || strpos($key, '/./') !== false || strpos($key, '/') === 0 || strpos($key, './') === 0 || strpos($key, '../') === 0 || substr($key, -2)
php
{ "resource": "" }
q10788
ObjectStorage.createFileDirIfNotExists
train
private function createFileDirIfNotExists(string $filename): bool { $pathinfo = pathinfo($filename); if (isset($pathinfo['dirname']) && $pathinfo['dirname'] !== '.') { if (is_dir($pathinfo['dirname'])) { return true; } elseif
php
{ "resource": "" }
q10789
ObjectStorage.createDirIfNotExists
train
private function createDirIfNotExists(string $dir): bool { if (!is_dir($dir)) { try { set_error_handler(function($errno, $errstr, $errfile, $errline) { restore_error_handler(); throw new \IvoPetkov\ObjectStorage\ErrorException($errstr, 0, $errno, $errfile, $errline); }); $result = mkdir($dir, 0777, true); restore_error_handler();
php
{ "resource": "" }
q10790
ObjectStorage.getFiles
train
private function getFiles(string $dir, bool $recursive = false, $limit = null): array { if ($limit === 0) { return []; } $result = []; if (is_dir($dir)) { $list = scandir($dir); if (is_array($list)) { foreach ($list as $filename) { if ($filename != '.' && $filename != '..') { if (is_dir($dir . $filename)) { if ($recursive === true) { $dirResult = $this->getFiles($dir . $filename . '/', true, $limit !== null ? ($limit - sizeof($result)) : null); if (!empty($dirResult)) { foreach ($dirResult as $index => $value) { $dirResult[$index] = $filename . '/' . $value;
php
{ "resource": "" }
q10791
RaceDataProvider.isCompatible
train
public function isCompatible(Map $map): bool { if (!$map->lapRace) { return false; } $nbLaps = 1; if ($map->lapRace) { $nbLaps = $map->nbLaps; } $scriptSettings = $this->gameDataStorage->getScriptOptions(); if ($scriptSettings['S_ForceLapsNb'] != -1) { $nbLaps
php
{ "resource": "" }
q10792
Renderer.compile
train
public function compile($string, $filename = null) { $compiler = $this->getCompiler(); $this->setDebugString($string);
php
{ "resource": "" }
q10793
Renderer.compileFile
train
public function compileFile($path) { $compiler = $this->getCompiler(); $this->setDebugFile($path);
php
{ "resource": "" }
q10794
Renderer.renderAndWriteFile
train
public function renderAndWriteFile($inputFile, $outputFile, array $parameters = []) { $outputDirectory = dirname($outputFile); if (!file_exists($outputDirectory) && !@mkdir($outputDirectory, 0777, true)) { return false; } return
php
{ "resource": "" }
q10795
Renderer.renderDirectory
train
public function renderDirectory($path, $destination = null, $extension = '.html', array $parameters = []) { if (is_array($destination)) { $parameters = $destination; $destination = null; } elseif (is_array($extension)) { $parameters = $extension; $extension = '.html'; } if (!$destination) { $destination = $path; } $path = realpath($path); $destination = realpath($destination); $success = 0; $errors = 0;
php
{ "resource": "" }
q10796
BenGorUserExtension.loadCommands
train
private function loadCommands(ContainerBuilder $container, $user) { $container->setDefinition( 'bengor.user.command.create_' . $user . '_command', (new Definition(CreateUserCommand::class))->addTag('console.command') ); $container->setDefinition( 'bengor.user.command.change_' . $user . '_password_command', (new Definition(ChangePasswordCommand::class))->addTag('console.command') ); $container->setDefinition( 'bengor.user.command.purge_outdated_' . $user .
php
{ "resource": "" }
q10797
Smarty_CacheResource_Mysql.fetch
train
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime) { $this->fetch->execute(array('id' => $id)); $row = $this->fetch->fetch(); $this->fetch->closeCursor(); if ($row) { $content = $row['content'];
php
{ "resource": "" }
q10798
Smarty_CacheResource_Mysql.fetchTimestamp
train
protected function fetchTimestamp($id, $name, $cache_id, $compile_id) { $this->fetchTimestamp->execute(array('id' => $id));
php
{ "resource": "" }
q10799
Smarty_CacheResource_Mysql.save
train
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content) { $this->save->execute(array( 'id' => $id, 'name' => $name, 'cache_id' => $cache_id,
php
{ "resource": "" }