_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q252500
Casings.pascal2snake
validation
public static function pascal2snake(string $pascal): string { preg_match_all('/((?:^|[A-Z])[a-z]+)/', $pascal, $matches); if($matches !== null && count($matches) > 1 && count($matches[1]) > 1) { $nameParts = $matches[1]; $nameParts = array_map("lcfirst", $nameParts); return implode("_", $nameParts); } else { return lcfirst($pascal); } }
php
{ "resource": "" }
q252501
Casings.snake2pascal
validation
public static function snake2pascal(string $snake): string { $nameParts = explode("_", $snake); $nameParts = array_map("ucfirst", $nameParts); return implode("", $nameParts); }
php
{ "resource": "" }
q252502
RemotableCollection.add
validation
public function add(MethodInterface $method) { if ($this->isUnique($method)) { $this->collection[] = $method; } else { throw new ExtDirectException("Remotable methodname {$method->getAnnotatedName()} already exists, but have to be unique"); } }
php
{ "resource": "" }
q252503
Console.main
validation
public static function main($argv, ContainerInterface $container = null) { $output = self::cyanLine($argv); $app = new Application(''); $app->add(new MigrateMakeCommand()); $app->add(new MigrateUpCommand($container)); $app->add(new MigrateDownCommand()); $app->add(new MigrateResetCommand()); $app->add(new MigrateStatusCommand()); $app->add(new MigrateRefreshCommand()); $app->add(new MigrateFreshCommand($container)); $app->add(new MigrateDropCommand()); $app->add(new SeedRunCommand($container)); $app->add(new SeedMakeCommand()); $app->add(new BinMakeCommand()); $app->run(null, $output); }
php
{ "resource": "" }
q252504
Collection.isUnique
validation
protected function isUnique($instance) { foreach ($this->getCollection() as $entry) { if ($entry->getAnnotatedName() === $instance->getAnnotatedName()) { return false; } } return true; }
php
{ "resource": "" }
q252505
Load.repeat
validation
public function repeat(&$property, $repeatTag, $classes = '', $outerTag = false, $outerClasses = '') { if (isset($property)) { $output = ''; if ($outerTag) { $output .= '<'.$outerTag.' class="'.$outerClasses.'">'; } if (is_array($property)) { foreach ($property as $value) { $output .= '<'.$repeatTag.' class="'.$classes.'">'; $output .= $value; $output .= '</'.$repeatTag.'>'; } } else { $output .= '<'.$repeatTag.' class="'.$classes.'">'; $output .= $property; $output .= '</'.$repeatTag.'>'; } if ($outerTag) { $output .= '</'.$outerTag.'>'; } echo $output; } else echo ''; }
php
{ "resource": "" }
q252506
Load.model
validation
public function model($pathname) { $fullPath = $this->config['pathToModels'] . $this->getPath($pathname) . $this->config['modelsPrefix'] . $this->getName($pathname) . $this->config['modelsPostfix'] . '.php'; include_once($fullPath); }
php
{ "resource": "" }
q252507
Load.library
validation
public function library($pathname, &$caller = false, $exposeToView = false) { $name = $this->getName($pathname); $path = $this->getPath($pathname); // If a reference to the calling object was passed, set an instance of // the library as one of its members. if ($caller) { // If no namespace is given, default to Cora namespace. if ($this->getPathBackslash($pathname) == '') { $lib = '\\Cora\\'.$name; } else { $lib = $pathname; } $libObj = new $lib($caller); // Set library to be available within a class via "$this->$libraryName" $caller->$name = $libObj; // Set library to also be available via "$this->load->$libraryName" // This is so this library will be available within View files as $libraryName. if ($exposeToView) $caller->setData($name, $libObj); } }
php
{ "resource": "" }
q252508
Load.view
validation
public function view($pathname = '', $data = false, $return = false) { if (is_array($data) || is_object($data)) { foreach ($data as $key => $value) { $$key = $value; } } // If no pathname specified, grab template name. if ($pathname == '') { $pathname = $this->config['template']; } $fullPath = $this->config['pathToViews'] . $this->getPath($pathname); $path = $this->getPath($pathname); $this->debug('Full Path: '.$fullPath); $fileName = $this->config['viewsPrefix'] . $this->getName($pathname) . $this->config['viewsPostfix'] . '.php'; // Determine full filepath to View //$filePath = $fullPath . $fileName; $filePath = $this->_getFilePath($pathname, $fileName); // Debug $this->debug(''); $this->debug( 'Searching for View: '); $this->debug( 'View Name: ' . $this->getName($pathname) ); $this->debug( 'View Path: ' . $this->getPath($pathname) ); $this->debug( 'File Path: ' . $filePath); $this->debug(''); // Either return the view for storage in a variable, or output to browser. if ($return || $this->neverOutput) { ob_start(); $inc = include($filePath); // If in dev mode and the include failed, throw an exception. if ($inc == false && $this->config['mode'] == 'development') { throw new \Exception("Can't find file '$fileName' using path '$filePath'"); } return ob_get_clean(); } else { $inc = include($filePath); // If in dev mode and the include failed, throw an exception. if ($inc == false && $this->config['mode'] == 'development') { throw new \Exception("Can't find file '$fileName' using path '$filePath'"); } } }
php
{ "resource": "" }
q252509
Creator.new
validation
public static function new( string $type = 'default', string $path = Migrate::DEFAULT_PATH, $notify = NotifyInterface::LOGGER ): Creator { $fs = new Filesystem(new Local($path)); $note = NotifyFactory::create($notify); return new static(CreatorFactory::create($type, $note), $fs, $note); }
php
{ "resource": "" }
q252510
Neuron_GameServer_Map_Pathfinder.getPath
validation
public function getPath ( Neuron_GameServer_Map_Location $start, Neuron_GameServer_Map_Location $end ) { // Start here :-) $x1 = $start[0]; $y1 = $start[1]; $x2 = $end[0]; $y2 = $end[1]; if (!$this->isPassable ($x2, $y2)) { return false; } $astar = $this->astar ($start, $end); //var_dump ($astar); //exit; return $astar; }
php
{ "resource": "" }
q252511
Engine.display
validation
public function display($template, array $vars = array()) { if (null === ($path = $this->locator->locate($template))) { throw TemplateNotFoundException::format( 'The template "%s" does not exist.', $template ); } $this->renderInScope( $path, array_replace($this->getArrayCopy(), $vars) ); }
php
{ "resource": "" }
q252512
Engine.render
validation
public function render($template, array $vars = array()) { ob_start(); try { $this->display($template, $vars); } catch (Exception $exception) { ob_end_clean(); throw $exception; } return ob_get_clean(); }
php
{ "resource": "" }
q252513
Caller.handleResponseContent
validation
protected function handleResponseContent(ResponseInterface $response, $contentType = null) { $contents = $response->getBody()->getContents(); if (!$contentType) { $contentTypeHeaderLine = $response->getHeaderLine('Content-Type'); if (stripos($contentTypeHeaderLine, 'application/json') !== false) { $contentType = 'json'; } elseif (stripos($contentTypeHeaderLine, 'application/xml') !== false) { $contentType = 'xml'; } } if ($contentType) { return Parser::data($contents)->from($contentType)->toArray(); } return $contents; }
php
{ "resource": "" }
q252514
HttpMethodsClient.sendRequest
validation
public function sendRequest(RequestInterface $request) { $this->lastOperation = new Operation($request); $response = parent::sendRequest($request); $this->lastOperation->setResponse($response); return $response; }
php
{ "resource": "" }
q252515
Migrate.install
validation
public function install(): Migrate { Whois::print($this->getNotify()); // Create a migration table in the // database if it does not exist. $this->exists() || $this->migrationRepository->createRepository(); return $this; }
php
{ "resource": "" }
q252516
ExtDirectResponse.buildResponse
validation
protected function buildResponse() { $res = array(); $res['type'] = $this->getParameters()->getType(); $res['tid'] = $this->getParameters()->getTid(); $res['action'] = $this->getParameters()->getAction(); $res['method'] = $this->getParameters()->getMethod(); $res['result'] = $this->getResult(); return $res; }
php
{ "resource": "" }
q252517
PurchaseResponse.getMessage
validation
public function getMessage() { $response = []; if ($messages = $this->data->query('/Message/Body/Errors')->array()) { foreach ($messages as $message) { $response[] = $message->textContent; } } return count($response) ? implode(', ', $response) : null; }
php
{ "resource": "" }
q252518
MigrationCreator.getStubs
validation
protected function getStubs(?string $table = null, bool $create = false): iterable { if (is_null($table)) { yield M::TYPE_UP => $this->stubs->read('blank.sql.stub'); yield M::TYPE_DOWN => $this->stubs->read('blank.sql.stub'); return; } $first = [M::TYPE_UP => 'create.sql.stub', M::TYPE_DOWN => 'down.sql.stub']; $second = [M::TYPE_UP => 'update.sql.stub', M::TYPE_DOWN => 'update.sql.stub']; $stubs = $create ? $first : $second; foreach ($stubs as $type => $stub) { yield $type => $this->stubs->read($stub); } }
php
{ "resource": "" }
q252519
MigrationCreator.populateStub
validation
protected function populateStub(string $filename, string $stub, ?string $table = null): string { $search = ['{name}', '{table}']; $replace = [$filename, $table ?: 'dummy_table']; return str_replace($search, $replace, $stub); }
php
{ "resource": "" }
q252520
EmailUtilities.applyDataToView
validation
public static function applyDataToView($view, $data) { // do placeholder replacement, currently {xxx} if (!empty($data)) { foreach ($data as $name => $value) { if (is_string($value)) { // replace {xxx} in subject $view = str_replace('{' . $name . '}', $value, $view); } } } return $view; }
php
{ "resource": "" }
q252521
PhpErrorUtil.getErrorString
validation
public static function getErrorString( int $errno ) { $errno = intval($errno); $errors = array( E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', E_NOTICE => 'E_NOTICE', E_CORE_ERROR => 'E_CORE_ERROR', E_CORE_WARNING => 'E_CORE_WARNING', E_COMPILE_ERROR => 'E_COMPILE_ERROR', E_COMPILE_WARNING => 'E_COMPILE_WARNING', E_USER_ERROR => 'E_USER_ERROR', E_USER_NOTICE => 'E_USER_NOTICE', E_STRICT => 'E_STRICT', E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', ); $errors[8192] = 'E_DEPRECATED'; // PHP 5.3.0 $errors[16384] = 'E_USER_DEPRECATED'; // PHP 5.3.0 $errors_desc = array(); foreach( $errors as $key => $value ){ if ( ($errno & $key) != 0 ){ $errors_desc[] = $value; } } return implode( '|', $errors_desc ); }
php
{ "resource": "" }
q252522
NumberGenerator.getFloat
validation
public function getFloat($min, $max) { if ($min > $max) { throw new InvalidArgumentException('Min cannot be greater than max'); } $random01 = \mt_rand() / \mt_getrandmax(); // [0, 1] -> [min, max]: // y = (max - min) * x + min return ($max - $min) * $random01 + $min; }
php
{ "resource": "" }
q252523
Model._populate
validation
public function _populate($record = null, $db = false, $loadMap = false) { // In order to stop unnecessary recursive issetExtended() checks while doing initial hydrating of model. $this->model_hydrating = true; // If this model is having a custom DB object passed into it, // then we'll use that for any dynamic fetching instead of // the connection defined on the model. // This is to facilitate using a Test database when running tests. if ($db) { $this->model_db = $db; } if($record) { // Populate model related data. $this->_populateAttributes($record); // Populate non-model related data. $this->_populateNonModelData($record); } // Populate data as mapped if ($this->model_loadMapsEnabled) { $this->_populateLoadMap($record, $loadMap); } // Call onLoad method $this->onLoad(); // If a custom onLoad function was given as part of a loadMap // Also call that if ($loadMap instanceof \Cora\Adm\LoadMap && $func = $loadMap->getOnLoadFunction()) { // Fetch any array of args passed along with the LoadMap $args = $loadMap->getOnLoadArgs(); // Add a reference to this model as the first argument array_unshift($args, $this); // Call user provided onLoad closure call_user_func_array($func, $args); } $this->model_hydrating = false; return $this; }
php
{ "resource": "" }
q252524
Model._populateAttributes
validation
protected function _populateAttributes($record) { foreach ($this->model_attributes as $key => $def) { // If the data is present in the DB, assign to model. // Otherwise ignore any data returned from the DB that isn't defined in the model. if (isset($record[$this->getFieldName($key)])) { $fieldName = $this->getFieldName($key); if (\Cora\Gateway::is_serialized($record[$fieldName])) { $value = unserialize($record[$fieldName]); } else if (isset($def['type']) && ($def['type'] == 'date' || $def['type'] == 'datetime')) { $value = new \DateTime($record[$fieldName]); } else { $value = $record[$fieldName]; } $this->beforeSet($key, $value); // Lifecycle callback $this->model_data[$key] = $value; $this->afterSet($key, $value); // Lifecycle callback } else if (isset($def['models']) || (isset($def['model']) && isset($def['usesRefTable']))) { if (!isset($this->model_data[$key])) $this->model_data[$key] = 1; } } }
php
{ "resource": "" }
q252525
Model._populateNonModelData
validation
protected function _populateNonModelData($record) { $nonObjectData = array_diff_key($record, $this->model_attributes); if (count($nonObjectData) > 0) { foreach ($nonObjectData as $key => $value) { // Note that if the model is using custom field names, this will result in a piece of data // getting set to both the official attribute and as non-model data. // I.E. If 'field' is set to 'last_modified' and the attribute name is 'lastModified', // the returned value from the Gateway will get assigned to the attribute in the code above like so: // $model->lastModified = $value // However because it's not worth doing a backwards lookup of the form $this->getAttributeFromField($recordKey) // (such a method would have to loop through all the attributes to find a match) // The data will also end up getting assigned here like so: // $model->last_modified = $value // An extra loop per custom field didn't seem worth the savings of a small amount of model memory size/clutter. $this->$key = $value; } } }
php
{ "resource": "" }
q252526
Model.isPlaceholder
validation
public function isPlaceholder($attributeName) { // Ref this model's attributes in a shorter variable. $def = $this->model_attributes[$attributeName]; if (isset($def['models']) || (isset($def['model']) && isset($def['usesRefTable']))) { return true; } return false; }
php
{ "resource": "" }
q252527
Model._getQueryObjectForRelation
validation
protected function _getQueryObjectForRelation($attribute) { // Setup $def = $this->model_attributes[$attribute]; // If not a model relationship, just return an adaptor for this model if (!isset($def['model']) && !isset($def['models'])) { return $this->getDbAdaptor(); } // Get DB adaptor to use for model relationships $relatedObj = isset($def['models']) ? $this->fetchRelatedObj($def['models']) : $this->fetchRelatedObj($def['model']); $query = $relatedObj->getDbAdaptor(); // If the relationship is many-to-many and uses a relation table. // OR if the relationship is one-to-many and no 'owner' type column is set, // meaning there needs to be a relation table. // If 'via' or 'using' is not set, then it's assumed the relation utilizes a relation table. if (!isset($def['via']) && !isset($def['using'])) { // Grab relation table name $relTable = $this->getRelationTableName($relatedObj, $attribute, $this->model_attributes[$attribute]); // In situations where multiple DBs are being used and there's a relation table // between data on different DBs, we can't be sure which DB holds the relation table. // First try the DB the related object is on. If that doesn't contain the relation table, // then try the current object's DB. if (!$query->tableExists($relTable)) { $query = $this->getDbAdaptor(); } } return $query; }
php
{ "resource": "" }
q252528
Model._getCustomValue
validation
protected function _getCustomValue($attributeName, $query, $loadMap = false) { $def = $this->model_attributes[$attributeName]; $result = $this->_getRelation($attributeName, $query, $loadMap); //$this->_getAttributeData($attributeName, $query, $loadMap); if (!$result) { $result = $query->fetch(); } return $result; }
php
{ "resource": "" }
q252529
Model._getRelation
validation
protected function _getRelation($attributeName, $query = false, $loadMap = false, $record = false) { // Grab attribute definition $def = $this->model_attributes[$attributeName]; $result = false; if (isset($def['models'])) { $result = $this->_getModels($attributeName, $def['models'], $query, $loadMap, $record); } else if (isset($def['model'])) { $result = $this->_getModel($attributeName, $def['model'], $query, $loadMap, $record); } return $result; }
php
{ "resource": "" }
q252530
Model._getModel
validation
protected function _getModel($attributeName, $relatedObjName = false, $query = false, $loadMap = false, $record = false) { $def = $this->model_attributes[$attributeName]; $result = null; if ($relatedObjName) { // If a LoadMap is present, and explicit fetching of the data isn't enabled, and some data was passed in, // then use the data given. if ($loadMap instanceof \Cora\Adm\LoadMap && !$loadMap->fetchData() && $record !== false) { // Create a blank object of desired type and populate it with the results of the data passed in $relatedObj = $this->fetchRelatedObj($def['model']); $result = $relatedObj->_populate($record, $query, $loadMap); } // If fetching via a defined column on a table. else if (isset($def['via'])) { $result = $this->_getModelFromTableColumn($attributeName, $def['model'], $def['via'], $query, $loadMap); } // If custom defined relationship for this single model else if (isset($def['using'])) { $result = $this->getModelFromCustomRelationship($attributeName, $def['model'], $query, $loadMap); } // In the rare case that we need to fetch a single related object, and the developer choose // to use a relation table to represent the relationship. // It's abstract in the sense that there's nothing on the current model's table // leading to it. We need to grab it using our method to grab data from a relation table. else if (isset($def['usesRefTable'])) { $result = $this->_getModelFromRelationTable($attributeName, $def['model'], $query, $loadMap); } // In the more common case of fetching a single object, where the related object's // ID is stored in a column on the parent object. // Under this scenario, the value stored in $this->$name is the ID of the related // object that was already fetched. So we can use that ID to populate a blank // object and then rely on it's dynamic loading to fetch any additional needed info. else { // Create a blank object of desired type $relatedObj = $this->fetchRelatedObj($def['model']); // If a custom query was passed in, execute it // Then populate a model with the data result if ($query && $query->isCustom()) { $data = $query->fetch(); $result = $relatedObj->_populate($data); } else { // If the Identifier is not already loaded from table, then get the ID so we can use it to // fetch the model. if (!isset($this->model_data[$attributeName])) { $this->model_data[$attributeName] = $this->_fetchData($attributeName); } // Fetch related object in whole (The model_data we have on it should be an ID reference) if (!is_object($this->model_data[$attributeName])) { $relObjRepo = $relatedObj->getRepository(true); $result = $relObjRepo->find($this->model_data[$attributeName]); } // Unless we already have an object (maybe it was added to the model from the main app) // Then just use what we have else { $result = $this->model_data[$attributeName]; } // Incase there's loadMap info that needs to be passed in, call populate if ($result) { $result->_populate([], false, $loadMap); } } } } return $result; }
php
{ "resource": "" }
q252531
Model._getModels
validation
protected function _getModels($attributeName, $relatedObjName = false, $query = false, $loadMap = false) { $def = $this->model_attributes[$attributeName]; $result = []; if ($relatedObjName) { // If the relationship is one-to-many. if (isset($def['via'])) { $result = $this->_getModelsFromTableColumn($attributeName, $relatedObjName, $def['via'], $query, $loadMap); } else if (isset($def['using'])) { $result = $this->getModelsFromCustomRelationship($attributeName, $relatedObjName, $query, $loadMap); } // If the relationship is many-to-many. // OR if the relationship is one-to-many and no 'owner' type column is set, // meaning there needs to be a relation table. else { $result = $this->_getModelsFromRelationTable($attributeName, $relatedObjName, $query, $loadMap); } } // If there is no data to return, return an empty collection if ($result == null) { $this->$attributeName = new \Cora\Collection(); $result = $this->model_data[$attributeName]; } return $result; }
php
{ "resource": "" }
q252532
Model._getAttributeDataWhenSet
validation
protected function _getAttributeDataWhenSet($attributeName, $query = false, $loadMap = false, $record = false) { // Check if the stored data is numeric. // If it's not, then we don't need to worry about it being a // class reference that we need to fetch. if (is_numeric($this->model_data[$attributeName])) { // If the attribute is defined as a model relationship, then the number is // a placeholder or ID and needs to be converted into a model. if ($this->_isRelation($attributeName) && !isset($this->model_dynamicOff)) { $this->$attributeName = $this->_getRelation($attributeName, $query, $loadMap, $record); } } $this->beforeGet($attributeName); // Lifecycle callback $returnValue = $this->model_data[$attributeName]; $this->afterGet($attributeName, $returnValue); // Lifecycle callback return $returnValue; }
php
{ "resource": "" }
q252533
Model._getAttributeDataWhenUnset
validation
protected function _getAttributeDataWhenUnset($attributeName, $query = false, $loadMap = false, $record = false) { // If the attribute isn't the primary key of our current model, do dynamic fetch. if ($attributeName != $this->getPrimaryKey()) { // If the attribute is defined as a model relationship, grab the model(s). if ($this->_isRelation($attributeName) && !isset($this->model_dynamicOff)) { $this->$attributeName = $this->_getRelation($attributeName, $query, $loadMap, $record); } // If the data is NOT a model and is located on this model's table and needs to be fetched else { $this->$attributeName = $this->_fetchData($attributeName); } } // If the data isn't set, and it IS the primary key, then need to set data to null // This is necessary to make sure that an entry exists in model_data for the field. else { $this->$attributeName = null; } $this->beforeGet($attributeName); // Lifecycle callback $returnValue = $this->model_data[$attributeName]; $this->afterGet($attributeName, $returnValue); // Lifecycle callback return $returnValue; }
php
{ "resource": "" }
q252534
Model._getAttributeData
validation
protected function _getAttributeData($name, $query = false, $loadMap = false, $record = false) { /////////////////////////////////////////////////////////////////////// // ------------------------------------- // If the model DB data is already set. // ------------------------------------- // ADM allows fetching of only part of a model's data when fetching // a record. So we have to check if the data in question has been fetched // from the DB already or not. If it has been fetched, we have to check // if it's a placeholder for a related model (related models can be set // to boolean true, meaning we have to dynamically fetch the model) /////////////////////////////////////////////////////////////////////// if (isset($this->model_data[$name])) { return $this->_getAttributeDataWhenSet($name, $query, $loadMap, $record); } /////////////////////////////////////////////////////////////////////// // If the model DB data is defined, but not grabbed from the database, // then we need to dynamically fetch it. // OR, we need to return an empty collection or NULL // in the case of the attribute pointing to models. /////////////////////////////////////////////////////////////////////// if (isset($this->model_attributes[$name]) && !isset($this->model_dynamicOff)) { return $this->_getAttributeDataWhenUnset($name, $query, $loadMap, $record); } /////////////////////////////////////////////////////////////////////// // If there is a defined DATA property (non-DB related), return the data. /////////////////////////////////////////////////////////////////////// if (isset($this->data->{$name})) { $this->beforeGet($name); // Lifecycle callback $returnValue = $this->data->{$name}; $this->afterGet($name, $returnValue); // Lifecycle callback return $returnValue; } /////////////////////////////////////////////////////////////////////// // If there is a defined property (non-DB related), return the data. /////////////////////////////////////////////////////////////////////// $class = get_class($this); if (property_exists($class, $name)) { $this->beforeGet($name); // Lifecycle callback $returnValue = $this->{$name}; $this->afterGet($name, $returnValue); // Lifecycle callback return $returnValue; } /////////////////////////////////////////////////////////////////////// // IF NONE OF THE ABOVE WORKED BECAUSE TRANSLATION FROM 'ID' TO A CUSTOM ID NAME // NEEDS TO BE DONE: // If your DB id's aren't 'id', but instead something like "note_id", // but you always want to be able to refer to 'id' within a class. /////////////////////////////////////////////////////////////////////// if ($name == 'id' && property_exists($class, 'id_name')) { $this->beforeGet($this->id_name); // Lifecycle callback if (isset($this->model_data[$this->id_name])) { $returnValue = $this->model_data[$this->id_name]; } else { $returnValue = $this->{$this->id_name}; } $this->afterGet($this->id_name, $returnValue); // Lifecycle callback return $returnValue; } /////////////////////////////////////////////////////////////////////// // If this model extends another, and the data is present on the parent, return the data. /////////////////////////////////////////////////////////////////////// if (substr($name, 0, 6 ) != "model_" && $this->issetExtended($name)) { $this->beforeGet($name); // Lifecycle callback $returnValue = $this->getExtendedAttribute($name); $this->afterGet($name, $returnValue); // Lifecycle callback return $returnValue; } /////////////////////////////////////////////////////////////////////// // No matching property was found! Normally this will return null. // However, just-in-case the object has something special setup // in the beforeGet() callback, we need to double check that the property // still isn't set after that is called. /////////////////////////////////////////////////////////////////////// $this->beforeGet($name); // Lifecycle callback if (isset($this->{$name})) { $returnValue = $this->{$name}; } else { $returnValue = null; } $this->afterGet($name, $returnValue); // Lifecycle callback return $returnValue; }
php
{ "resource": "" }
q252535
Model.getDataAttributes
validation
public function getDataAttributes($excludeExtended = false) { $attributes = new \Cora\Collection(); foreach ($this->model_attributes as $key => $def) { if (!isset($def['model']) && !isset($def['models'])) { $attributes->add($key); } } if (isset($this->model_extends) && isset($this->model_attributes[$this->model_extends])) { $extendedModel = $this->{$this->model_extends}; if ($extendedModel) { $attributes->merge($extendedModel->getDataAttributes()); } } return array_unique($attributes->toArray()); }
php
{ "resource": "" }
q252536
Model.getAttributeValue
validation
public function getAttributeValue($name, $convertDates = true) { if (isset($this->model_data[$name])) { $result = $this->model_data[$name]; if ($result instanceof \DateTime && $convertDates == true) { $result = $result->format('Y-m-d H:i:s'); } return $result; } if (isset($this->data->{$name})) { return $this->data->{$name}; } return null; }
php
{ "resource": "" }
q252537
Model.getAttributeValueExtended
validation
public function getAttributeValueExtended($name, $convertDates = true) { if (isset($this->model_data[$name])) { $result = $this->model_data[$name]; if ($result instanceof \DateTime && $convertDates == true) { $result = $result->format('Y-m-d H:i:s'); } return $result; } if (isset($this->data->{$name})) { return $this->data->{$name}; } else if (isset($this->model_extends) && isset($this->model_attributes[$this->model_extends])) { $extendedModel = $this->{$this->model_extends}; if ($extendedModel && $result = $extendedModel->getAttributeValue($name)) { return $result; } } return null; }
php
{ "resource": "" }
q252538
Model._getModelsFromTableColumn
validation
protected function _getModelsFromTableColumn($attributeName, $objName, $relationColumnName, $query = false, $loadMap = false) { // Figure out the unique identifying field of the model we want to grab. $relatedObj = $this->fetchRelatedObj($objName); $idField = $relatedObj->getPrimaryKey(); //$relatedClassName = strtolower((new \ReflectionClass($relatedObj))->getShortName()); $repo = \Cora\RepositoryFactory::make($objName, false, false, false, $this->model_db); // If no query object was passed in, then grab an appropriate one. if (!$query) $query = $this->_getQueryObjectForRelation($attributeName); // Set association condition $query->where($relationColumnName, $this->{$this->getPrimaryKey()}); return $repo->findAll($query, false, $loadMap); }
php
{ "resource": "" }
q252539
Model.getModelsFromCustomRelationship
validation
public function getModelsFromCustomRelationship($attributeName, $objName, $query = false, $loadMap = false) { // Create a repository for the related object. $repo = \Cora\RepositoryFactory::make($objName, false, false, false, $this->model_db); // Grab a Query Builder object for the connection this related model uses. // If no query object was passed in, then grab an appropriate one. if (!$query) $query = $this->_getQueryObjectForRelation($attributeName); // Grab the name of the method that defines the relationship $definingFunctionName = $this->model_attributes[$attributeName]['using']; // Pass query to the defining function $query = $this->$definingFunctionName($query); return $repo->findAll($query, false, $loadMap); }
php
{ "resource": "" }
q252540
Model.getFullClassName
validation
function getFullClassName($class = false) { if ($class == false) { $class = $this; } $className = get_class($class); if ($pos = strpos($className, '\\')) return substr($className, $pos + 1); return $className; }
php
{ "resource": "" }
q252541
Model._fetchData
validation
protected function _fetchData($name) { $gateway = new \Cora\Gateway($this->getDbAdaptor(), $this->getTableName(), $this->getPrimaryKey()); return $gateway->fetchData($this->getFieldName($name), $this); }
php
{ "resource": "" }
q252542
Model.getFieldName
validation
public function getFieldName($attributeName) { if (isset($this->model_attributes[$attributeName]['field'])) { return $this->model_attributes[$attributeName]['field']; } return $attributeName; }
php
{ "resource": "" }
q252543
Model.loadAll
validation
public function loadAll() { $this->data->id = $this->id; foreach ($this->model_attributes as $key => $value) { $temp = $this->$key; } }
php
{ "resource": "" }
q252544
ReaderAbstract.checkPath
validation
protected static function checkPath(/*# string */ $path) { if (!file_exists($path)) { throw new NotFoundException( Message::get(Message::MSG_PATH_NOTFOUND, $path), Message::MSG_PATH_NOTFOUND ); } if (!is_readable($path)) { throw new RuntimeException( Message::get(Message::MSG_PATH_NONREADABLE, $path), Message::MSG_PATH_NONREADABLE ); } }
php
{ "resource": "" }
q252545
Sanitizer.name
validation
public static function name($string = null) { if (!$string) return null; // Convert to lowercase, set UTF-8 character encoding, trim and return CamelCased string return trim(ucwords(mb_strtolower(trim($string), "UTF-8"))); }
php
{ "resource": "" }
q252546
Sanitizer.email
validation
public static function email($email = null, $errorMsg = null) { if (!$email) return null; // Convert to lowercase and set UTF-8 character encoding $email = trim(mb_strtolower(trim($email), "UTF-8")); // Validate email address if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return null; } // Return email address return $email; }
php
{ "resource": "" }
q252547
Neuron_GameServer_Mappers_PlayerMapper.getDataFromId
validation
public static function getDataFromId ($id) { $db = Neuron_Core_Database::__getInstance (); $id = intval ($id); $r = $db->getDataFromQuery ($db->customQuery (" SELECT * FROM n_players WHERE n_players.plid = '".$id."' ")); if (count ($r) == 1) { return $r[0]; } return null; }
php
{ "resource": "" }
q252548
ApiClient.sendMessage
validation
public function sendMessage( $chatId, $text, $disableWebPagePreview = null, $replyToMessageId = null, $replyMarkup = null ) { $response = $this->apiRequest("sendMessage", [ "chat_id" => $chatId, "text" => $text, "disable_web_page_preview" => $disableWebPagePreview, "reply_to_message_id" => $replyToMessageId, "reply_markup" => $replyMarkup ? $replyMarkup->toArray() : null, ]); return $this->entityFromBody($response->getBody(), new Message()); }
php
{ "resource": "" }
q252549
ApiClient.entityFromBody
validation
public function entityFromBody($body, $entity) { $json = $this->decodeJson($body); return $entity->populate($json); }
php
{ "resource": "" }
q252550
SeedCreator.populateStub
validation
protected function populateStub(string $stub, ?string $class = null): string { return str_replace('{class}', $this->getName($class), $stub); }
php
{ "resource": "" }
q252551
MappingTrait.setMappings
validation
public static function setMappings( array $messages, /*# bool */ $manual = true ) { $class = get_called_class(); if ($manual) { // set default static::$messages = $messages; // status changed self::setStatus(); } else { // set cache self::$mappings[$class] = array_replace( $class::getMappings(), $messages ); } }
php
{ "resource": "" }
q252552
MappingTrait.getMessage
validation
protected static function getMessage(/*# int */ $code)/*# : string */ { $mapping = static::getMappings(); if (isset($mapping[$code])) { return $mapping[$code]; } return (string) $code; }
php
{ "resource": "" }
q252553
Consumer.buildAuthString
validation
public static function buildAuthString(array $data) { $str = array(); foreach ($data as $k => $v) { $str[] = self::urlEncode($k) . '="' . self::urlEncode($v) . '"'; } return implode(', ', $str); }
php
{ "resource": "" }
q252554
Consumer.buildBasestring
validation
public static function buildBasestring($method, Url $url, array $data) { $base = array(); $base[] = self::urlEncode(self::getNormalizedMethod($method)); $base[] = self::urlEncode(self::getNormalizedUrl($url)); $base[] = self::urlEncode(self::getNormalizedParameters($data)); return implode('&', $base); }
php
{ "resource": "" }
q252555
Consumer.getNormalizedUrl
validation
public static function getNormalizedUrl(Url $url) { $scheme = $url->getScheme(); $host = $url->getHost(); $port = $url->getPort(); $path = $url->getPath(); // no port for 80 (http) and 443 (https) if ((($port == 80 || empty($port)) && strcasecmp($scheme, 'http') == 0) || (($port == 443 || empty($port)) && strcasecmp($scheme, 'https') == 0)) { $normalizedUrl = $scheme . '://' . $host . $path; } else { if (!empty($port)) { $normalizedUrl = $scheme . '://' . $host . ':' . $port . $path; } else { throw new RuntimeException('No port specified'); } } return strtolower($normalizedUrl); }
php
{ "resource": "" }
q252556
Consumer.getNormalizedParameters
validation
public static function getNormalizedParameters(array $data) { $params = array(); $keys = array_map('PSX\Oauth\Consumer::urlEncode', array_keys($data)); $values = array_map('PSX\Oauth\Consumer::urlEncode', array_values($data)); $data = array_combine($keys, $values); uksort($data, 'strnatcmp'); foreach ($data as $k => $v) { if ($k != 'oauth_signature') { $params[] = $k . '=' . $v; } } return implode('&', $params); }
php
{ "resource": "" }
q252557
Neuron_GameServer_Credits.handleUseRequest
validation
public function handleUseRequest ($data, $transactionId, $transactionKey) { if (!$this->objCredits) { return null; } if (isset ($_POST['transaction_id']) && isset ($_POST['transaction_secret'])) { $valid = $this->objCredits->isRequestValid ($_POST['transaction_id'], $_POST['transaction_secret']); if ($valid) { $amount = $_POST['transaction_amount']; $this->objUser->useCredit ($amount, $data); return true; } else { $this->error = 'This request was not valid or already executed. Ignore.'; } } else { $this->error = 'No post data received.'; } return false; }
php
{ "resource": "" }
q252558
NotifyLogger.note
validation
public function note(string $message): void { $this->logger->log($this->level, strip_tags($message)); }
php
{ "resource": "" }
q252559
AbstractRequest.getBaseData
validation
public function getBaseData() { $data = new FluidXml(false); $message = $data->addChild('Message', ['version' => $this->getApiVersion()], true); $header = $message->addChild('Header', true); $header->addChild('Time', $this->getTime()); $itentity = $header->addChild('Identity', true); $itentity->addChild('UserID', $this->getUserId()); $body = $message->addChild('Body', ['type' => 'GetInvoice', 'live' => $this->getLive()], true); $order = $body->addChild('Order', ['paymentMethod' => $this->getPaymentMethod()], true); $order->addChild('MerchantID', $this->getMerchantId()); $order->addChild('SiteAddress', $this->getSiteAddress()); $order->addChild('PostbackURL', $this->getNotifyUrl()); $order->addChild('SuccessURL', $this->getReturnUrl()); $order->addChild('FailureURL', $this->getCancelUrl()); return $message; }
php
{ "resource": "" }
q252560
Neuron_Auth_MySQLConnection.query
validation
function query($sql, $params = array()) { $db = Neuron_DB_Database::getInstance (); $sql = $this->printf ($sql, $params); if ($this->debug) { echo $sql . "<br><br>"; } try { //echo $sql . "<br><br>"; $data = $db->query ($sql); if ($this->debug) { echo '<pre>'; var_dump ($data); echo "</pre><br><br>"; } $this->error = false; return $data; } catch (Exception $e) { $this->error = true; echo 'error'; } }
php
{ "resource": "" }
q252561
Neuron_Auth_MySQLConnection.getOne
validation
function getOne($sql, $params = array()) { //echo 'get one --- '; $data = $this->query ($sql, $params); if (count ($data) > 0) { $data = array_values ($data[0]); return $data[0]; } return false; }
php
{ "resource": "" }
q252562
Neuron_Auth_MySQLConnection.getRow
validation
function getRow($sql, $params = array()) { //echo 'get row --- '; $data = $this->query ($sql, $params); $row = false; if (count ($data) > 0) { $row = $data[0]; } //var_dump ($row); //echo '<br><br>'; return $row; }
php
{ "resource": "" }
q252563
ExtDirectRequest.getAnnotationClassForAction
validation
protected function getAnnotationClassForAction($requestAction) { /** @var array $actions */ $actions = $this->getActions(); /** @var ClassInterface $action */ foreach ($actions as $action) { if ($action->getAnnotatedName() === $requestAction) { return $action; } } throw new ExtDirectException("extjs direct name '{$requestAction}' does not exist'"); }
php
{ "resource": "" }
q252564
ExtDirectRequest.getAnnotationMethodForMethod
validation
protected function getAnnotationMethodForMethod(ClassInterface $class, $requestMethod) { /** @var MethodInterface $method */ foreach ($class->getMethods() as $method) { if ($method->getAnnotatedName() === $requestMethod) { return $method; } } throw new ExtDirectException("extjs method name '{$requestMethod}' does not exist'"); }
php
{ "resource": "" }
q252565
ConversionTrait.convertCase
validation
public static function convertCase( /*# string */ $string, /*# string */ $toCase )/*# string */ { // break into lower case words $str = strtolower(ltrim( preg_replace(['/[A-Z]/', '/[_]/'], [' $0', ' '], $string) )); switch (strtoupper($toCase)) { case 'PASCAL': return str_replace(' ', '', ucwords($str)); case 'CAMEL' : return lcfirst(str_replace(' ', '', ucwords($str))); default: // SNAKE return str_replace(' ', '_', $str); } }
php
{ "resource": "" }
q252566
ConversionTrait.hasSuffix
validation
public static function hasSuffix( /*# string */ $string, /*# string */ $suffix )/*# : bool */ { $len = strlen($suffix); if ($len && substr($string, - $len) === $suffix) { return true; } return false; }
php
{ "resource": "" }
q252567
ConversionTrait.removeSuffix
validation
public static function removeSuffix( /*# string */ $string, /*# string */ $suffix )/*# string */ { if (static::hasSuffix($string, $suffix)) { return substr($string, 0, - strlen($suffix)); } return $string; }
php
{ "resource": "" }
q252568
Base.getLocations
validation
public function getLocations() { if (is_null($this->_locations)) { $this->_locations = $this->determineLocations(); } return $this->_locations; }
php
{ "resource": "" }
q252569
Base.setFormField
validation
public function setFormField($value) { if (is_array($value)) { if (is_null($this->formFieldClass)) { throw new Exception("DB Field incorrectly set up. What is the form class?"); } if (is_null($this->_formField)) { $config = $value; $config['class'] = $this->formFieldClass; $config['modelField'] = $this; $value = Yii::createObject($config); } else { $settings = $value; $value = $this->_formField; unset($settings['class']); Yii::configure($value, $settings); } } $this->_formField = $value; return true; }
php
{ "resource": "" }
q252570
Base.getHuman
validation
public function getHuman() { if (is_null($this->_human)) { $this->_human = HumanFieldDetector::test($this->fieldSchema); } return $this->_human; }
php
{ "resource": "" }
q252571
Base.getMultiline
validation
public function getMultiline() { if (is_null($this->_multiline)) { $this->_multiline = MultilineDetector::test($this->fieldSchema); } return $this->_multiline; }
php
{ "resource": "" }
q252572
Base.setModel
validation
public function setModel($value) { $this->_model = $value; if (is_object($value) && $this->_attributes) { $this->_model->attributes = $this->_attributes; } return true; }
php
{ "resource": "" }
q252573
Base.setAttributes
validation
public function setAttributes($value) { $this->_attributes = $value; if ($this->model) { $this->_model->attributes = $value; } }
php
{ "resource": "" }
q252574
Base.setFormat
validation
public function setFormat($value) { if (is_array($value)) { if (!isset($value['class'])) { $value['class'] = $this->determineFormatClass(); } $value['field'] = $this; $value = Yii::createObject($value); } $this->_format = $value; }
php
{ "resource": "" }
q252575
Base.getFormattedValue
validation
public function getFormattedValue() { if ($this->format instanceof BaseFormat) { $formattedValue = $this->format->get(); } elseif (is_callable($this->format) || (is_array($this->format) && !empty($this->format[0]) && is_object($this->format[0]))) { $formattedValue = $this->evaluateExpression($this->format, [$this->value]); } else { $formattedValue = $this->value; } if (is_object($formattedValue)) { $formattedValue = $formattedValue->viewLink; } return $formattedValue; }
php
{ "resource": "" }
q252576
Base.getFormValue
validation
public function getFormValue() { if ($this->format instanceof BaseFormat) { $formValue = $this->format->getFormValue(); } elseif (is_callable($this->format) || (is_array($this->format) && !empty($this->format[0]) && is_object($this->format[0]))) { $formValue = $this->evaluateExpression($this->format, [$this->value]); } else { $formValue = $this->value; } return $formValue; }
php
{ "resource": "" }
q252577
Generator.getBaseNamespace
validation
public function getBaseNamespace() { if (!empty($this->moduleSet) && isset(Yii::$app->extensions[$this->moduleSet])) { $bsClass = Yii::$app->extensions[$this->moduleSet]['bootstrap']; $bsReflector = new \ReflectionClass(new $bsClass()); return $bsReflector->getNamespaceName(); } return 'cascade\modules'; }
php
{ "resource": "" }
q252578
Generator.getMigrationClassName
validation
public function getMigrationClassName() { $postfix = '_initial_' . $this->tableName; if (is_dir($this->migrationDirectory)) { $searchExisting = FileHelper::findFiles($this->migrationDirectory, ['only' => [$postfix . '.php']]); if (!empty($searchExisting)) { return strstr(basename($searchExisting[0]), '.php', true); } } return 'm' . gmdate('ymd_His', $this->migrationTimestamp) . $postfix; }
php
{ "resource": "" }
q252579
Generator.getPrimaryKeyLocation
validation
public function getPrimaryKeyLocation($table) { // if multiple, put the primary key in the indicies section $count = 0; foreach ($table->columns as $column) { if ($column->isPrimaryKey) { $count++; } if ($count > 1) { return 'index'; } } return 'table_build'; }
php
{ "resource": "" }
q252580
Generator.getModuleSetModules
validation
public function getModuleSetModules() { if (empty($this->moduleSet) || !isset(Yii::$app->extensions[$this->moduleSet])) { return ''; } $bsClass = Yii::$app->extensions[$this->moduleSet]['bootstrap']; $p = []; $bs = new $bsClass(); $modules = $bs->getModules(); $modules[$this->moduleID] = ['class' => $this->moduleClass]; foreach ($modules as $id => $module) { $e = '$m[\'' . $id . '\'] = ['; if (!is_array($module)) { $module = ['class' => $module]; } $n = 0; foreach ($module as $k => $v) { $e .= "\n\t\t\t'{$k}' => "; if (is_string($v)) { $e .= "'" . addslashes($v) . "'"; } elseif (is_numeric($v)) { $e .= $v; } $n++; if ($n !== count($module)) { $e .= ','; } } $e .= "\n\t\t];"; $p[] = $e; } return implode("\n\t\t", $p); }
php
{ "resource": "" }
q252581
Generator.generateRules
validation
public function generateRules($table) { $types = []; $lengths = []; foreach ($table->columns as $column) { if ($column->autoIncrement) { continue; } if (!$column->allowNull && $column->defaultValue === null && !$column->isPrimaryKey) { $types['required'][] = $column->name; } switch ($column->type) { case Schema::TYPE_SMALLINT: case Schema::TYPE_INTEGER: case Schema::TYPE_BIGINT: $types['integer'][] = $column->name; break; case Schema::TYPE_BOOLEAN: $types['boolean'][] = $column->name; break; case Schema::TYPE_FLOAT: case Schema::TYPE_DECIMAL: case Schema::TYPE_MONEY: $types['number'][] = $column->name; break; case Schema::TYPE_DATE: case Schema::TYPE_TIME: case Schema::TYPE_DATETIME: case Schema::TYPE_TIMESTAMP: if (!in_array($column->name, ['created', 'deleted', 'modified'])) { $types['safe'][] = $column->name; } break; default: // strings if ($column->size > 0) { $lengths[$column->size][] = $column->name; } else { $types['string'][] = $column->name; } } } $rules = []; foreach ($types as $type => $columns) { $rules[] = "[['" . implode("', '", $columns) . "'], '$type']"; } foreach ($lengths as $length => $columns) { $rules[] = "[['" . implode("', '", $columns) . "'], 'string', 'max' => $length]"; } return $rules; }
php
{ "resource": "" }
q252582
Generator.getModelMap
validation
public function getModelMap() { $m = []; $search = []; foreach ($this->searchModels as $path => $namespace) { $files = FileHelper::findFiles(Yii::getAlias($path), ['only' => ['.php']]); foreach ($files as $file) { $baseName = strstr(basename($file), '.php', true); $className = $namespace . '\\' . $baseName; if (class_exists($className)) { $reflector = new \ReflectionClass($className); if ($reflector->isSubclassOf('yii\base\Model')) { $m[$baseName] = $className; } } } } return $m; }
php
{ "resource": "" }
q252583
FormBuilder.setDesigner
validation
public function setDesigner(Designer $designer){ $this->designer=$designer; $this->designer->build($this); }
php
{ "resource": "" }
q252584
FormBuilder.addField
validation
public function addField(FormField $field){ $this->fields[]=$field; if($field->getName()==null){ $field->setName('name_'.count($this->fields)); } if($field->getId()==null){ $field->setId('id_'.count($this->fields)); } if($field instanceof FileField){ $this->formTags['enctype']='multipart/form-data'; } }
php
{ "resource": "" }
q252585
FormBuilder.removeField
validation
public function removeField($name){ for($i=0; $i<count($this->fields); $i++){ if($this->fields[$i]->getName()==$name){ array_splice($this->fields,$i,1); break; } } }
php
{ "resource": "" }
q252586
FormBuilder.render
validation
public function render(){ $html=$this->formatter->renderFormBegin($this->formTags); foreach($this->fields as $field){ $html.=$this->formatter->renderField($field); } $html.=$this->renderSubmit(); $html.=$this->renderEnd(); return $html; }
php
{ "resource": "" }
q252587
FormBuilder.renderFields
validation
public function renderFields(){ $html=''; foreach($this->fields as $field){ $html.=$this->formatter->renderField($field); } return $html; }
php
{ "resource": "" }
q252588
FormBuilder.renderField
validation
public function renderField($name){ $html=''; $field=$this->getField($name); $html.=$this->formatter->renderField($field); return $html; }
php
{ "resource": "" }
q252589
FormBuilder.getField
validation
public function getField($name){ foreach($this->fields as $field){ if($field->getName()==$name) return $field; } throw new FieldNotFoundException($name); }
php
{ "resource": "" }
q252590
FormBuilder.setData
validation
public function setData($data){ $data=$this->transformer->encode($data); foreach($this->fields as $field){ if(isset($data[$field->getName()])){ $field->setData($data[$field->getName()]); } } }
php
{ "resource": "" }
q252591
FormBuilder.getData
validation
public function getData(){ $data=[]; foreach($this->fields as $field){ if(preg_match('/^(.*?)(\[.*\])$/',$field->getName(),$result)){ if($result[2]==''){ //FIXME autoincrement field } else{ if(!preg_match_all("/\[(.*?)\]/", $result[2], $resultDeep)){ throw new \Exception('Invalid field name.');//FIXME dedicate exception } $storage=&$data[$result[1]]; foreach($resultDeep[1] as $deep){ if(!isset($storage[$deep])){ $storage[$deep]=[]; } $storage=&$storage[$deep]; } $storage=$field->getData(); } } else{ $data[$field->getName()]=$field->getData(); } } return $this->transformer->decode($data); }
php
{ "resource": "" }
q252592
FormBuilder.submit
validation
public function submit(Request $request){ $this->isConfirmed=false; if($this->formTags['method']=='post' && $request->getType()=='POST'){ $this->isConfirmed=true; } $query=$request->getQuery(); if(count($this->fields)>0 && $this->formTags['method']=='get' && isset($query[$this->fields[0]->getName()])){ $this->isConfirmed=true; } if(!$this->isConfirmed) return; if($this->formTags['method']=='post'){ $storage=$request->getData(); } else{ $storage=$request->getQuery(); } //set field data $result=[]; foreach($this->fields as $field){ if(isset($storage[$field->getName()])){ $field->setData($storage[$field->getName()]); } else if($field instanceof FileField){ try{ $field->setData($request->getFile($field->getName())); } catch(FileNotUploadedException $e){ $field->setData(''); } } else if(preg_match('/^(.*?)(\[.*\])$/',$field->getName(),$result) && isset($storage[$result[1]])){//array if(!preg_match_all("/\[(.*?)\]/", $result[2], $resultDeep)){ throw new \Exception('Invalid field name.');//FIXME dedicate exception } $value=$storage[$result[1]]; foreach($resultDeep[1] as $deep){ if(!isset($value[$deep])){ $value=null; break; } $value=$value[$deep]; } if($result[2]==''){ //FIXME autoincrement field } else{ $field->setData($value); } } else{//for checkbox or disabled field $field->setData(null); } } //validate if($request->isFullUploadedData()){ foreach($this->fields as $field){ if($field->getValidator()){ if($error=$field->getValidator()->validate($field->getData())){ $field->setError($error); } } } } else{ foreach($this->fields as $field){ $field->setError('Request data is too large.'); } } }
php
{ "resource": "" }
q252593
FormBuilder.getErrors
validation
public function getErrors(){ $errors=[]; foreach($this->fields as $field){ if(!$field->isValid()){ $errors[]=['field'=>$field->getLabel(),'message'=>$field->getError()]; } } return $errors; }
php
{ "resource": "" }
q252594
Phase1.compress
validation
private function compress($dwnlSnap, $pv, $calcId) { $in = new \Praxigento\Core\Data(); $in->set(PPhase1::IN_DWNL_PLAIN, $dwnlSnap); $in->set(PPhase1::IN_PV, $pv); $in->set(PPhase1::IN_CALC_ID, $calcId); $in->set(PPhase1::IN_KEY_CALC_ID, EBonDwnl::A_CALC_REF); $in->set(PPhase1::IN_KEY_CUST_ID, QBSnap::A_CUST_ID); $in->set(PPhase1::IN_KEY_PARENT_ID, QBSnap::A_PARENT_ID); $in->set(PPhase1::IN_KEY_DEPTH, QBSnap::A_DEPTH); $in->set(PPhase1::IN_KEY_PATH, QBSnap::A_PATH); $in->set(PPhase1::IN_KEY_PV, EBonDwnl::A_PV); $out = $this->procPhase1->exec($in); $updates = $out->get(PPhase1::OUT_COMPRESSED); $pvTransfers = $out->get(PPhase1::OUT_PV_TRANSFERS); $result = [$updates, $pvTransfers]; return $result; }
php
{ "resource": "" }
q252595
LazyObjectsFactory.generateProxy
validation
private function generateProxy($className) { if (isset($this->checkedClasses[$className])) { return $this->checkedClasses[$className]; } $proxyParameters = array( 'className' => $className, 'factory' => get_class($this), 'proxyManagerVersion' => Version::VERSION ); $proxyClassName = $this ->configuration ->getClassNameInflector() ->getProxyClassName($className, $proxyParameters); $this->generateProxyClass($proxyClassName, $className, $proxyParameters); $this ->configuration ->getSignatureChecker() ->checkSignature(new ReflectionClass($proxyClassName), $proxyParameters); return $this->checkedClasses[$className] = $proxyClassName; }
php
{ "resource": "" }
q252596
Form.getValue
validation
public function getValue($name = null) { if ($this->has($name)) { return $this->get($name)->getValue(); } return parent::getValue(); }
php
{ "resource": "" }
q252597
Form.getInputFilter
validation
public function getInputFilter() { if ($this->filter) { return $this->filter; } $specifications = []; if ($this->object && $this->object instanceof InputFilterProviderInterface) { $specifications = $this->object->getInputFilterSpecification(); } if ($this instanceof InputFilterProviderInterface) { $specifications = ArrayUtils::merge($specifications, $this->getInputFilterSpecification()); } $this->addRequiredAttributeToFields($specifications); /** @noinspection IsEmptyFunctionUsageInspection */ if (!empty($specifications) && null === $this->baseFieldset) { $formFactory = $this->getFormFactory(); $inputFactory = $formFactory->getInputFilterFactory(); if (!($this->filter instanceof InputFilterInterface)) { $this->filter = new InputFilter(); $this->filter->setFactory($inputFactory); } foreach ($specifications as $name => $specification) { $input = $inputFactory->createInput($specification); $this->filter->add($input, $name); } } return parent::getInputFilter(); }
php
{ "resource": "" }
q252598
PermalinkManager.add
validation
public function add($blockFile, $blockContent) { $this->removeBlock($blockFile); $blockPermalinks = $this->fetchPermalinksFromBlock($blockContent, $blockFile); if (!empty($blockPermalinks)) { $this->permalinks = array_merge_recursive($this->permalinks, $blockPermalinks); } return $this; }
php
{ "resource": "" }
q252599
PermalinkManager.removeBlock
validation
public function removeBlock($blockFile) { foreach ($this->permalinks as $permalink => $associatedBlocks) { $tmp = array_flip($associatedBlocks); unset($tmp[$blockFile]); if (empty($tmp)) { unset($this->permalinks[$permalink]); continue; } $this->permalinks[$permalink] = array_flip($tmp); } return $this; }
php
{ "resource": "" }