_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q250200
FMSummernoteExtension.prepareArrayParameter
validation
private function prepareArrayParameter($name) { if (isset($this->parameters[$name])) { $parameterArray = $this->parameters[$name]; $count = count($parameterArray); $str = "['".$parameterArray[0]."'"; for ($i = 1; $i < $count; ++$i) { ...
php
{ "resource": "" }
q250201
OpenStreetMapObject.sendRequest
validation
public function sendRequest($path, $method = 'GET', $headers = array(), $data = '') { // Send the request. switch ($method) { case 'GET': $response = $this->client->get($path, $headers); break; case 'POST': $response = $this->client->post($path, $data, $headers); break; } // Validat...
php
{ "resource": "" }
q250202
CSVTable.fromMinkResponse
validation
public static function fromMinkResponse(\Behat\Mink\Session $session) { return self::newInstance()->makeMinkResponseCSVTableParser()->parse($session); }
php
{ "resource": "" }
q250203
FilterUtilHelper.extractArrayCriteria
validation
private static function extractArrayCriteria($key, array $criteria) { if (!empty($criteria[$key])) { return array($criteria[$key]); } if (!empty($criteria[$key.'s'])) { return $criteria[$key.'s']; } return array(); }
php
{ "resource": "" }
q250204
FilterUtilHelper.extractDateCriteria
validation
private static function extractDateCriteria($key, array $criteria) { $date = (!empty($criteria[$key])) ? $criteria[$key] : null; if (is_string($date)) { $date = \DateTime::createFromFormat('Y-m-d', $date); } if (false === $date) { throw new InvalidArgumentEx...
php
{ "resource": "" }
q250205
FilterUtilHelper.matchesArrayCriteria
validation
private static function matchesArrayCriteria($key, $object, array $criteria) { $criteria = self::extractArrayCriteria($key, $criteria); if (count($criteria) === 0) { return true; } $getter = sprintf('get%s', ucfirst($key)); if (!method_exists($object, $getter))...
php
{ "resource": "" }
q250206
ExtendedPdoAdapter.rewriteCountQuery
validation
public function rewriteCountQuery($query) { if (\preg_match('/^\s*SELECT\s+\bDISTINCT\b/is', $query) || \preg_match('/\s+GROUP\s+BY\s+/is', $query)) { return ''; } $openParenthesis = '(?:\()'; $closeParenthesis = '(?:\))'; $subQueryInSelect = $openParenthesis . '....
php
{ "resource": "" }
q250207
CurrencyCodeUtil.exists
validation
public static function exists($currencyCode) { $currencyCode = trim(strtoupper($currencyCode)); return array_key_exists($currencyCode, self::$codes); }
php
{ "resource": "" }
q250208
CurrencyCodeUtil.clean
validation
public static function clean($currencyCode) { $clean = trim(strtoupper($currencyCode)); if (!self::exists($clean)) { throw new UnknownCurrencyCodeException(sprintf('Unknown currency code "%s".', $currencyCode)); } return $clean; }
php
{ "resource": "" }
q250209
FileRepository.load
validation
protected function load() { $this->rates = array(); $this->latest = array(); $handle = fopen($this->pathToFile, 'rb'); if (!$handle) { throw new RuntimeException(sprintf('Error opening file on path "%s".', $this->pathToFile)); // @codeCoverageIgnore } w...
php
{ "resource": "" }
q250210
FileRepository.initialize
validation
protected function initialize() { /** @noinspection MkdirRaceConditionInspection */ if (!file_exists(dirname($this->pathToFile)) && !mkdir(dirname($this->pathToFile), 0777, true)) { throw new RuntimeException(sprintf('Could not create storage file on path "%s".', $this->pathToFile)); ...
php
{ "resource": "" }
q250211
FileRepository.toJson
validation
protected function toJson(RateInterface $rate) { return json_encode(array( 'sourceName' => $rate->getSourceName(), 'value' => $rate->getValue(), 'currencyCode' => $rate->getCurrencyCode(), 'rateType' => $rate->getRateType(), 'date' => $rate->getDat...
php
{ "resource": "" }
q250212
FileRepository.fromJson
validation
protected function fromJson($json) { $data = json_decode($json, true); return new Rate( $data['sourceName'], (float) $data['value'], $data['currencyCode'], $data['rateType'], \DateTime::createFromFormat(\DateTime::ATOM, $data['date']), ...
php
{ "resource": "" }
q250213
FileRepository.paginate
validation
protected function paginate(array $rates, $criteria) { if (!array_key_exists('offset', $criteria) && !array_key_exists('limit', $criteria)) { return $rates; } $range = array(); $offset = array_key_exists('offset', $criteria) ? $criteria['offset'] : 0; $limit = mi...
php
{ "resource": "" }
q250214
SourcesRegistry.filter
validation
private function filter($sources, array $filters = array()) { $result = array(); foreach ($sources as $source) { if (SourceFilterUtil::matches($source, $filters)) { $result[] = $source; } } return $result; }
php
{ "resource": "" }
q250215
Configuration.setOutputFormat
validation
public function setOutputFormat($format) { $output = array('xml', 'html', 'text', 'text-main'); if (!in_array($format, $output)) { throw new \InvalidArgumentException(sprintf( 'Available output format: %s', implode(', ', $output) )); } ...
php
{ "resource": "" }
q250216
CSVStreamTableParser.parse
validation
public function parse($stream) { if ( ! ($this->isValidStream($stream))) { throw new \InvalidArgumentException(__METHOD__.' requires a valid stream resource'); } $original_position = \ftell($stream); try { \fseek($stream, 0); return new PaddedTab...
php
{ "resource": "" }
q250217
ExchangeRateException.typeOf
validation
public static function typeOf($arg) { if (null === $arg) { return 'NULL'; } if (is_object($arg)) { return get_class($arg); } return gettype($arg); }
php
{ "resource": "" }
q250218
Wrapper.setParameter
validation
public function setParameter($name, $value) { if (!isset($ref)) { $ref = new \ReflectionClass($this->config); } $function = sprintf('set%s', ucfirst($name)); if (!$ref->hasMethod($function)) { throw new \InvalidArgumentException(sprintf( 'The f...
php
{ "resource": "" }
q250219
DoctrineDbalRepository.getRateKey
validation
protected function getRateKey($currencyCode, $date, $rateType, $sourceName) { return str_replace( ['%currency_code%', '%date%', '%rate_type%', '%source_name%'], [$currencyCode, $date->format('Y-m-d'), $rateType, $sourceName], '%currency_code%_%date%_%rate_type%_%source_na...
php
{ "resource": "" }
q250220
DoctrineDbalRepository.initialize
validation
protected function initialize() { if ($this->connection->getSchemaManager()->tablesExist([$this->tableName])) { return; // @codeCoverageIgnore } $schema = new Schema(); $table = $schema->createTable($this->tableName); $table->addColumn('source_name', 'string', [...
php
{ "resource": "" }
q250221
DoctrineDbalRepository.buildRateFromTableRowData
validation
private function buildRateFromTableRowData(array $row) { return new Rate( $row['source_name'], (float)$row['rate_value'], $row['currency_code'], $row['rate_type'], \DateTime::createFromFormat('Y-m-d', $row['rate_date']), $row['base_curr...
php
{ "resource": "" }
q250222
RateFilterUtil.matchesDateCriteria
validation
private static function matchesDateCriteria($key, RateInterface $rate, array $criteria) { $date = self::extractDateCriteria($key, $criteria); if ($date === null) { return true; } if ($key === 'dateFrom') { $rateDate = new \DateTime($rate->getDate()->format(\...
php
{ "resource": "" }
q250223
RatesConfigurationRegistry.filter
validation
private function filter($configurations, array $criteria) { $result = array(); /** * @var Configuration $configuration */ foreach ($configurations as $configuration) { if (ConfigurationFilterUtil::matches($configuration, $criteria)) { $result[]...
php
{ "resource": "" }
q250224
AssertTable.isSame
validation
public function isSame(TableNode $expected, TableNode $actual, $message = NULL) { $this->doAssert( 'Failed asserting that two tables were identical: ', [], $expected, $actual, $message ); }
php
{ "resource": "" }
q250225
AssertTable.isEqual
validation
public function isEqual(TableNode $expected, TableNode $actual, $message = NULL) { $this->doAssert( 'Failed asserting that two tables were equivalent: ', ['ignoreColumnSequence' => TRUE], $expected, $actual, $message ); }
php
{ "resource": "" }
q250226
AssertTable.isComparable
validation
public function isComparable( TableNode $expected, TableNode $actual, array $diff_options, $message = NULL ) { $this->doAssert( 'Failed comparing two tables: ', $diff_options, $expected, $actual, $message ); ...
php
{ "resource": "" }
q250227
AbstractTable.get_columns
validation
public function get_columns() { return array( 'id' => new IntegerBased( 'BIGINT', 'id', array( 'NOT NULL', 'auto_increment' ), array( 20 ) ), 'message' => new StringBased( 'VARCHAR', 'message', array(), array( 255 ) ), 'level' => new StringBased( 'VARCHAR', 'level', array(), array( 20 ) ), 'l...
php
{ "resource": "" }
q250228
HttpStatus.parseStatus
validation
public static function parseStatus($statusLine): HttpStatus { list ($proto, $code) = sscanf($statusLine, "%s %d %s"); return new HttpStatus($code, $proto); }
php
{ "resource": "" }
q250229
HttpStatus.toStatusLine
validation
public function toStatusLine(): string { return sprintf("%s %d %s", $this->proto, $this->code, self::getStatus($this->code)); }
php
{ "resource": "" }
q250230
UI.getTemplate
validation
public function getTemplate($data_type, $type) { $options = (array) $this->config->getType($data_type, $type); return new UI\Template($data_type, $type, $options); }
php
{ "resource": "" }
q250231
UI.getTemplates
validation
public function getTemplates() { $templates = array(); $types = $this->config->getTypes(); foreach ($types as $type => $type_options) { foreach ($type_options as $subtype => $subtype_options) { $templates[$type][$subtype] = (array) $subtype_options; } } return $templates; }
php
{ "resource": "" }
q250232
EntityFactory.build
validation
public function build($attributes = null) { if ($attributes instanceof \ElggEntity) { return $attributes; } if (is_numeric($attributes)) { return $this->get($attributes); } $attributes = (array) $attributes; if (!empty($attributes['guid'])) { return $this->get($attributes['guid']); } $typ...
php
{ "resource": "" }
q250233
EntityFactory.getAttributeNames
validation
public function getAttributeNames($entity) { if (!$entity instanceof \ElggEntity) { return array(); } $default = array( 'guid', 'type', 'subtype', 'owner_guid', 'container_guid', 'site_guid', 'access_id', 'time_created', 'time_updated', 'last_action', 'enabled', ); swi...
php
{ "resource": "" }
q250234
ArtificialIntelligence.expecting
validation
public function expecting() { $possibilities = count($this->samples); $orderedByOccurance = array_count_values($this->samples); array_multisort($orderedByOccurance, SORT_DESC); $probabilities = []; foreach ($orderedByOccurance as $item => $value) { $probabilitie...
php
{ "resource": "" }
q250235
Session.update
validation
private function update() { if (null !== $this->namespace) { $_SESSION[$this->namespace] = $this->sessionData; } else { $_SESSION = $this->sessionData; } }
php
{ "resource": "" }
q250236
RamlConverter.addActions
validation
protected function addActions(SymfonyController $controller, Resource $resource, $chainName = '') { $actions = array(); $chainName = $chainName . '_' . strtolower(str_replace(array('{', '}'), '', $resource->getDisplayName())); foreach ($resource->getMethods() as $method) { $act...
php
{ "resource": "" }
q250237
RamlConverter.buildNamespace
validation
protected function buildNamespace(ApiDefinition $definition, $namespace) { if ($this->config['version_in_namespace'] && $definition->getVersion()) { $namespace .= '\\' . preg_replace( array('/(^[0-9])/', '/[^a-zA-Z0-9]/'), array('Version\1', '_'), ...
php
{ "resource": "" }
q250238
Directory.isEmpty
validation
public function isEmpty($filter = null): bool { if (! $this->exists()) { throw new DirectoryException("Directory {dir} does not exist", array( 'dir' => $this->path )); } $iter = new \DirectoryIterator($this->path); while ($iter->valid(...
php
{ "resource": "" }
q250239
Directory.exists
validation
public function exists(): bool { if (! file_exists($this->path)) { return false; } if (! is_dir($this->path)) { throw new DirectoryException("Entry {path} exists, but it is not a directory!", array( 'path' => $this->path )); ...
php
{ "resource": "" }
q250240
Directory.fileExists
validation
public function fileExists($fileName): bool { if (! $this->exists()) { return false; } $file = sprintf("%s/%s", $this->path, $fileName); return file_exists($file); }
php
{ "resource": "" }
q250241
Directory.fixDirectorySeparator
validation
private function fixDirectorySeparator($path): string { $path = str_replace("\\", DIRECTORY_SEPARATOR, $path); $path = str_replace("/", DIRECTORY_SEPARATOR, $path); return $path; }
php
{ "resource": "" }
q250242
ListTable.column_user
validation
public function column_user( AbstractLog $item ) { $user = $item->get_user(); if ( empty( $user ) ) { echo '-'; } else { echo $user->display_name; } }
php
{ "resource": "" }
q250243
ListTable.column_time
validation
public function column_time( AbstractLog $item ) { $time = $item->get_time(); if ( empty( $time ) ) { echo '-'; } else { echo $time->format( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ); } }
php
{ "resource": "" }
q250244
ListTable.extra_tablenav
validation
protected function extra_tablenav( $which ) { if ( $which !== 'top' ) { return; } $this->months_dropdown( '' ); $selected = isset( $_GET['level'] ) ? $_GET['level'] : ''; ?> <label for="filter-by-level" class="screen-reader-text"> <?php echo $this->translations['levelFilterLabel']; ?> </label> ...
php
{ "resource": "" }
q250245
ListTable.months_dropdown
validation
protected function months_dropdown( $post_type ) { global $wpdb, $wp_locale; $tn = $this->table->get_table_name( $wpdb ); $months = $wpdb->get_results( " SELECT DISTINCT YEAR( time ) AS year, MONTH( time ) AS month FROM $tn ORDER BY time DESC " ); $month_count = count( $months ); if ( ! $month_...
php
{ "resource": "" }
q250246
ListTable.get_levels
validation
protected function get_levels() { return array( LogLevel::EMERGENCY => 'Emergency', LogLevel::ALERT => 'Alert', LogLevel::CRITICAL => 'Critical', LogLevel::ERROR => 'Error', LogLevel::WARNING => 'Warning', LogLevel::NOTICE => 'Notice', LogLevel::INFO => 'Info', LogLevel::DEB...
php
{ "resource": "" }
q250247
FieldFactory.build
validation
public function build($options = array()) { if (is_string($options)) { $options = array( 'type' => $options, ); } else if (!is_array($options)) { $options = array( 'type' => 'text', ); } if (empty($options['type'])) { $options['type'] = 'text'; } if (empty($options['data_type'])) {...
php
{ "resource": "" }
q250248
FieldCollection.sort
validation
public function sort() { $this->uasort(function($a, $b) { $priority_a = (int) $a->get('priority') ? : 500; $priority_b = (int) $b->get('priority') ? : 500; if ($priority_a == $priority_b) { return 0; } return ($priority_a < $priority_b) ? -1 : 1; }); return $this; }
php
{ "resource": "" }
q250249
Column.prepareColumn
validation
private function prepareColumn(Row $row): string { $nullable = $row->Null === 'YES'; if ($row->Default === null && !$nullable) { $default = ' NOT null'; } elseif ($row->Default === null && $nullable) { $default = ' DEFAULT null'; } else { $default = ($nullable ? '' : ' NOT null') . " DEFAULT '{$row->...
php
{ "resource": "" }
q250250
Column.decimal
validation
public function decimal(int $total, int $decimal): self { $this->type = 'decimal(' . $total . ',' . $decimal . ')'; return $this; }
php
{ "resource": "" }
q250251
Column.char
validation
public function char(int $size = 36, string $charset = null): self { $this->type = 'char(' . $size . ')' . $this->stringOptions($charset); return $this; }
php
{ "resource": "" }
q250252
Column.tinytext
validation
public function tinytext(string $charset = null): self { $this->type = 'tinytext' . $this->stringOptions($charset); return $this; }
php
{ "resource": "" }
q250253
Column.text
validation
public function text(string $charset = null): self { $this->type = 'text' . $this->stringOptions($charset); return $this; }
php
{ "resource": "" }
q250254
Column.mediumtext
validation
public function mediumtext(string $charset = null): self { $this->type = 'mediumtext' . $this->stringOptions($charset); return $this; }
php
{ "resource": "" }
q250255
Column.longtext
validation
public function longtext(string $charset = null): self { $this->type = 'longtext' . $this->stringOptions($charset); return $this; }
php
{ "resource": "" }
q250256
ThemeHelper.getRoot
validation
function getRoot() { $sm = $this->sl->getServiceLocator(); $event = $sm->get('Application') ->getMvcEvent(); return $event->getViewModel(); }
php
{ "resource": "" }
q250257
UserController.markAllNotificationsAsRead
validation
public function markAllNotificationsAsRead() { /** @var \Unite\UnisysApi\Models\User $object */ $object = Auth::user(); $object->unreadNotifications->markAsRead(); \Cache::tags('response')->flush(); return $this->successJsonResponse(); }
php
{ "resource": "" }
q250258
Linguistics.getWords
validation
public function getWords($string, $minLength = null) { $tokenizer = new Whitespace(); $words = $tokenizer->tokenize($string); if (!is_null($minLength)) { foreach ($words as $key => $word) { if (strlen($word) <= $minLength) { unset($words[$key]...
php
{ "resource": "" }
q250259
Linguistics.getActionWords
validation
public function getActionWords($string, $language = 'english') { $words = $this->getWords($string); $filter = new ActionWordsFilter($language); $actionWords = []; foreach ($words as $word) { $word = $this->removePunctuation($word); if (!is_null($filter->filte...
php
{ "resource": "" }
q250260
Linguistics.getKeywords
validation
public function getKeywords($string, $amount = 10) { $words = $this->getWords($string); $analysis = new FrequencyAnalysis($words); $keywords = $analysis->getKeyValuesByFrequency(); return array_slice($keywords, 0, $amount); }
php
{ "resource": "" }
q250261
Linguistics.getUniqueWords
validation
public function getUniqueWords($string) { $words = $this->getWords($string); $analysis = new FrequencyAnalysis($words); $words = $analysis->getKeyValuesByFrequency(); return array_unique(array_keys($words)); }
php
{ "resource": "" }
q250262
Linguistics.getWordsByComplexity
validation
public function getWordsByComplexity($string) { $words = $this->getWords($string); $analysis = new FrequencyAnalysis($words); $sortedWords = $analysis->getKeyValuesByFrequency(); $wordsByFrequency = array_unique(array_keys($sortedWords)); usort($wordsByFrequency, function ($...
php
{ "resource": "" }
q250263
Linguistics.getStopWords
validation
public function getStopWords($string, $language = 'english') { $words = $this->getWords($string); $filter = new StopWordsFilter($language); $stopWords = []; foreach ($words as $word) { if (!is_null($filter->filter($word))) { $stopWords[] = $word; ...
php
{ "resource": "" }
q250264
Linguistics.hasConfirmation
validation
public function hasConfirmation($string) { $result = false; $words = $this->getWords($string); foreach ($words as $word) { if (in_array($word, $this->confirmationWords)) { $result = true; } } return $result; }
php
{ "resource": "" }
q250265
Linguistics.hasDenial
validation
public function hasDenial($string) { $result = false; $words = $this->getWords($string); foreach ($words as $word) { if (in_array($word, $this->denialWords)) { $result = true; } } return $result; }
php
{ "resource": "" }
q250266
Linguistics.hasUrl
validation
public function hasUrl($string) { $result = false; $words = $this->getWords($string); foreach ($words as $word) { if (preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $word)) { $result = true; } }...
php
{ "resource": "" }
q250267
Linguistics.hasEmail
validation
public function hasEmail($string) { $result = false; $tokenizer = new General(); $words = $tokenizer->tokenize($string); foreach ($words as $word) { if (filter_var($word, FILTER_VALIDATE_EMAIL)) { $result = true; } } return $r...
php
{ "resource": "" }
q250268
Linguistics.isQuestion
validation
public function isQuestion($string) { $probability = 0; if (strpos($string, '?')) { $probability += 1; } $words = $this->getWords($string); foreach ($this->inquiryWords as $queryWord) { if (!strncmp(strtolower($string), $queryWord, strlen($queryWord...
php
{ "resource": "" }
q250269
AbstractDataFixture.randomizeSamples
validation
protected function randomizeSamples($referencePrefix, array $samples, $limit = 1) { $sample = array_rand($samples, $limit); if (1 === $limit) { $referenceName = sprintf('%s_%s', $referencePrefix, $samples[$sample]); return $this->getReference($referenceN...
php
{ "resource": "" }
q250270
ErrorController.error
validation
public function error(Request $request) { $this->response->setCode(404); printf("<h2>%s</h2>", HttpStatus::getStatus(404)); printf("Requested document %s on %s could not be found!", $request->getAction(), $request->getController()); }
php
{ "resource": "" }
q250271
ErrorController.exception
validation
public function exception(Request $request) { $ex = $request->getException(); $this->response->setCode(500); printf("<h2>%s</h2>", HttpStatus::getStatus(500)); while ($ex != null) { printf("<h3>%s</h3><pre>%s</pre>", $ex->getMessage(), $ex->getTraceAsString()); ...
php
{ "resource": "" }
q250272
Manager.execute
validation
public function execute(Closure $callback) { foreach ($this->getServices() as $service) { try { return $callback($this->container->make($service)); } catch (Exception $e) { // Move on } } throw new RuntimeException('Could n...
php
{ "resource": "" }
q250273
TimestampableSubscriber.loadClassMetadata
validation
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $this->classMetadata = $eventArgs->getClassMetadata(); $reflectionClass = $this->classMetadata->getReflectionClass(); if (null === $reflectionClass) { return; } if ($this->hasMethod($...
php
{ "resource": "" }
q250274
TimestampableSubscriber.mapField
validation
protected function mapField($field) { if (!$this->classMetadata->hasField($field)) { $this->classMetadata->mapField([ 'fieldName' => $field, 'type' => 'datetime', 'nullable' => true, ]); } }
php
{ "resource": "" }
q250275
Mutex.init
validation
protected function init($key) { if (!isset($this->files[$key])) { $this->files[$key] = fopen($this->dir . $key . '.lockfile', 'w+'); $this->owns[$key] = false; } }
php
{ "resource": "" }
q250276
TopicMapper.persist
validation
public function persist(TopicInterface $thread) { if ($thread->getId() > 0) { $this->update($thread, null, null, new TopicHydrator()); } else { $this->insert($thread, null, new TopicHydrator()); } return $thread; }
php
{ "resource": "" }
q250277
TopicMapper.insert
validation
protected function insert($entity, $tableName = null, HydratorInterface $hydrator = null) { $result = parent::insert($entity, $tableName, $hydrator); $entity->setId($result->getGeneratedValue()); return $result; }
php
{ "resource": "" }
q250278
TopicMapper.update
validation
protected function update($entity, $where = null, $tableName = null, HydratorInterface $hydrator = null) { if (! $where) { $where = 'id = ' . $entity->getId(); } return parent::update($entity, $where, $tableName, $hydrator); }
php
{ "resource": "" }
q250279
Mapper.execute
validation
protected function execute(QueryBuilder $builder): ?Result { return $this->connection->queryArgs($builder->getQuerySql(), $builder->getQueryParameters()); }
php
{ "resource": "" }
q250280
Mapper.getByHash
validation
public function getByHash($columns, string $hash): ?IEntity { if ($this->manager->hasher === null) { throw new MissingServiceException('Hasher is missing'); } return $this->toEntity($this->manager->hasher->hashSQL($this->builder(), $columns, $hash)); }
php
{ "resource": "" }
q250281
Mapper.getMax
validation
public function getMax(string $column): int { return $this->connection->query('SELECT IFNULL(MAX(%column), 0) position FROM %table', $column, $this->getTableName())->fetch()->position; }
php
{ "resource": "" }
q250282
EnvUpdateCommand.getEnvValue
validation
public function getEnvValue(array $expectedEnv, array $actualEnv) { $actualValue = ''; $isStarted = false; foreach ($expectedEnv as $key => $defaultValue) { if (array_key_exists($key, $actualEnv)) { if ($this->option('force')) { $defaultValue =...
php
{ "resource": "" }
q250283
EnvUpdateCommand.emptyEnvironment
validation
private function emptyEnvironment() { foreach (array_keys($_ENV) as $key) { putenv($key); unset($_ENV[$key]); unset($_SERVER[$key]); } }
php
{ "resource": "" }
q250284
SimpleLogger.logImpl
validation
protected function logImpl($level, $message, array $context = array()) { if (! $this->levelHasReached($level)) { return; } if ($this->isRotationNeeded()) { unlink($this->file); } $ms = $this->getMessage($level, $message, $context); ...
php
{ "resource": "" }
q250285
SimpleLogger.isRotationNeeded
validation
private function isRotationNeeded() { clearstatcache(); if (! file_exists($this->file)) { return false; } $result = false; $attributes = stat($this->file); if ($attributes == false || $attributes['size'] >= $this->maxLog...
php
{ "resource": "" }
q250286
Settings.getConfig
validation
protected function getConfig() { if ($this->config === null) { if (file_exists($this->filename)) { $this->filename = realpath($this->filename); $this->config = new Config(include $this->filename, true); } else { $this->filename = getcwd...
php
{ "resource": "" }
q250287
Config.registerType
validation
public function registerType($type, $classname, $options = array()) { if (!class_exists($classname) || !is_callable(array($classname, 'getDataType'))) { return; } $data_type = call_user_func(array($classname, 'getDataType')); $options = (array) $options; $options['type'] = $type; $options['class_name'...
php
{ "resource": "" }
q250288
Config.getType
validation
public function getType($data_type = 'metadata', $type = 'text') { if (isset($this->types[$data_type][$type])) { return $this->types[$data_type][$type]; } return false; }
php
{ "resource": "" }
q250289
Form.renderFields
validation
private function renderFields($rendered, $fields) { foreach ($fields as $field) { if (! isset($field['name'])) { throw new ControlException("Field must have at least a name!"); } $fieldType = isset($field['type']) ? $field['type'] : 'text'; $id...
php
{ "resource": "" }
q250290
Form.renderButtons
validation
private function renderButtons($rendered, $buttons) { foreach ($buttons as $button) { if (! isset($button['name'])) { throw new ControlException("Button must have at least a name!"); } $buttonType = isset($button['type']) ? $button['type'] : "submit"; ...
php
{ "resource": "" }
q250291
BasicLogger.checkLevel
validation
private static function checkLevel($level) { if ($level != LogLevel::ALERT && $level != LogLevel::CRITICAL && $level != LogLevel::DEBUG && // $level != LogLevel::EMERGENCY && $level != LogLevel::ERROR && $level != LogLevel::INFO && // $level != LogLevel::NOTICE && $level != LogLevel::WARNING...
php
{ "resource": "" }
q250292
BasicLogger.getMessage
validation
protected function getMessage($level, $message, array $context = array()): MemoryStream { /** * This check implements the specification request. */ self::checkLevel($level); $ms = new MemoryStream(); $ms->write(strftime("%Y-%m-%d %H:%M:%S", time())...
php
{ "resource": "" }
q250293
MenuExtension.getMenuItemsJson
validation
public function getMenuItemsJson(Collection $menuItems, $currentOwner) { $this->alreadySetIds = []; $this->position = 0; $this->currentOwner = $currentOwner; return json_encode($this->recursiveMenuItemHandling($menuItems)); }
php
{ "resource": "" }
q250294
MenuExtension.recursiveMenuItemHandling
validation
private function recursiveMenuItemHandling(Collection $menuItems) { $data = []; foreach($menuItems as $menuItem) { // This is necessary to avoid to loop on children only when already included as previous parent children if(!in_array($menuItem->getId(), $this->alreadySetIds)) { ...
php
{ "resource": "" }
q250295
Table.createRelationTable
validation
public function createRelationTable($tableName): self { $table = $this->getTableData($tableName); $name = $this->name . '_x_' . $table->name; return $this->relationTables[] = $this->tableFactory->create($name, $this->prefix); }
php
{ "resource": "" }
q250296
Table.addColumnToRename
validation
public function addColumnToRename(string $name, Column $column): self { $this->oldColumns[$name] = $column; return $this; }
php
{ "resource": "" }
q250297
Table.changeColumns
validation
private function changeColumns(): void { $change = []; foreach ($this->oldColumns as $name => $column) { if ($this->columnExists($name)) { $change[] = "[$name] $column"; } } if (!empty($change)) { $this->connection->query("ALTER TABLE %table CHANGE " . implode(', CHANGE ', $change), $this->name); ...
php
{ "resource": "" }
q250298
Table.addPrimaryKey
validation
public function addPrimaryKey(string $name): Column { $column = $this->addColumn($name); $this->setPrimaryKey($name); return $column; }
php
{ "resource": "" }
q250299
Table.addForeignKey
validation
public function addForeignKey(string $name, $mapperClass, $onDelete = true, $onUpdate = false): Column { $table = $this->getTableData($mapperClass); $constrait = new Constrait($name, $this, $table, $onDelete, $onUpdate); $this->constraints[$constrait->name] = $constrait; return $constrait->column; }
php
{ "resource": "" }