_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q253600
Api.decodeHashId
validation
public static function decodeHashId($idHashed) { if (! config('odin.hashid.active')) { return $idHashed; } $hashids = App::make('Hashids'); $hashId = $hashids->decode($idHashed); return (count($hashId) > 0) ? $hashId[0] : ''; }
php
{ "resource": "" }
q253601
Api.encodeHashId
validation
public static function encodeHashId($id) { if (! config('odin.hashid.active')) { return $id; } $hashids = App::make('Hashids'); return $hashids->encode($id, date('d')); }
php
{ "resource": "" }
q253602
HeaderPublisherLocator.getPublisherForMessage
validation
public function getPublisherForMessage(Message $message) { $attributes = $message->getAttributes(); if (!isset($attributes['headers']) || !isset($attributes['headers'][$this->headerName])) { throw MissingPublisherException::noHeaderInMessage($message, $this->headerName); } $value = $attributes['headers'][$this->headerName]; foreach ($this->valueMap as $hash => $values) { if (!in_array($value, $values, true)) { continue; } return $this->publishers[$hash]; } throw MissingPublisherException::noKnownPublisherFor($message); }
php
{ "resource": "" }
q253603
Client.database
validation
public function database($db) { $connection = $this->connection; $connection->db = $db; $this->constructConnections = $connection; $connection = class_exists("Clusterpoint\Connection") ? new Connection($this->constructConnections) : new StandartConnection($this->constructConnections); return new Service($connection); }
php
{ "resource": "" }
q253604
SqliteDialect.initialize
validation
public function initialize() { parent::initialize(); $this->addClauses([ self::DEFERRABLE => 'DEFERRABLE %s', self::EITHER => 'OR %s', self::MATCH => 'MATCH %s', self::NOT_DEFERRABLE => 'NOT DEFERRABLE %s', self::UNIQUE_KEY => 'UNIQUE (%2$s)' ]); $this->addKeywords([ self::ABORT => 'ABORT', self::BINARY => 'BINARY', self::AUTO_INCREMENT => 'AUTOINCREMENT', self::FAIL => 'FAIL', self::IGNORE => 'IGNORE', self::INIT_DEFERRED => 'INITIALLY DEFERRED', self::INIT_IMMEDIATE => 'INITIALLY IMMEDIATE', self::NOCASE => 'NOCASE', self::PRIMARY_KEY => 'PRIMARY KEY', self::REPLACE => 'REPLACE', self::ROLLBACK => 'ROLLBACK', self::RTRIM => 'RTRIM', self::UNIQUE => 'UNIQUE' ]); $this->addStatements([ Query::INSERT => new Statement('INSERT {or} INTO {table} {fields} VALUES {values}'), Query::SELECT => new Statement('SELECT {distinct} {fields} FROM {table} {joins} {where} {groupBy} {having} {compounds} {orderBy} {limit}'), Query::UPDATE => new Statement('UPDATE {or} {table} SET {fields} {where}'), Query::DELETE => new Statement('DELETE FROM {table} {where}'), Query::CREATE_TABLE => new Statement("CREATE {temporary} TABLE IF NOT EXISTS {table} (\n{columns}{keys}\n)"), Query::CREATE_INDEX => new Statement('CREATE {type} INDEX IF NOT EXISTS {index} ON {table} ({fields})'), Query::DROP_TABLE => new Statement('DROP TABLE IF EXISTS {table}'), Query::DROP_INDEX => new Statement('DROP INDEX IF EXISTS {index}') ]); // SQLite doesn't support TRUNCATE unset($this->_statements[Query::TRUNCATE]); }
php
{ "resource": "" }
q253605
ExtendableBlock.updateSource
validation
public function updateSource() { $source = array( "value" => $this->value, "tags" => $this->tags, "type" => $this->type, ); $this->source = Yaml::dump($source, 100, 2); }
php
{ "resource": "" }
q253606
SDIS62_Controller_Action_OauthConsumer.init
validation
public function init() { // Récupération du fichier de config $config = new Zend_Config_Ini( $this->config_path == null ? APPLICATION_PATH . DS . "configs" . DS . "secret.ini" : $config_path, APPLICATION_ENV ); // Initialisation du consumer $this->setConsumer(new Zend_Oauth_Consumer(array( 'callbackUrl' => $config->oauth->callback, 'siteUrl' => $config->oauth->siteurl, 'consumerKey' => $config->oauth->consumerkey, 'consumerSecret' => $config->oauth->consumersecret ))); }
php
{ "resource": "" }
q253607
VideoRepository.getNextVideoToConvert
validation
public function getNextVideoToConvert() { $query = $this->createQueryBuilder('v'); $this->onlyUploaded($query); return $query->getQuery()->getOneOrNullResult(); }
php
{ "resource": "" }
q253608
ValidatorAbstract.getOption
validation
protected function getOption($name){ if(!isset($this->options[$name])){ throw new ValueNotFoundException($name); } return $this->options[$name]; }
php
{ "resource": "" }
q253609
Headers.set
validation
public function set(string $name, string $value = null) : Headers { if ($value !== null) { header($name . ': ' . $value); } else { header($name); } return $this; }
php
{ "resource": "" }
q253610
Client.authenticate
validation
public function authenticate($accountKey, $uniqueUserId, $authMethod = null) { if (null === $authMethod) { $authMethod = self::AUTH_HTTP_TOKEN; } $this->getHttpClient()->authenticate($accountKey, $uniqueUserId, $authMethod); }
php
{ "resource": "" }
q253611
Validator.getArrayItemByPointSeparatedKey
validation
public static function getArrayItemByPointSeparatedKey(array& $data, string $key) { if (strpos($key, '.') !== false) { preg_match('/([a-zA-Z0-9_\-]+)\.([a-zA-Z0-9_\-\.]+)/', $key, $keys); if (!isset($data[$keys[1]])) { throw new Exception('Undefined index: '.$keys[1]); } if (!is_array($data[$keys[1]])) { throw new Exception("The element indexed {$keys[1]} isn't an array."); } return self::getArrayItemByPointSeparatedKey( $data[$keys[1]], $keys[2] ); } elseif (isset($data[$key])) { return $data[$key]; } else { throw new Exception('Undefined index: '.$key); } }
php
{ "resource": "" }
q253612
Validator.addItem
validation
public function addItem(array $item): self { if (count($item) < 2) { throw new Exception('Invalid count of item elements.'); } $this->items[] = $item; return $this; }
php
{ "resource": "" }
q253613
Validator.addRule
validation
public function addRule(string $name, callable $func, $errorMsg = null): self { $this->rules[$name] = array($func, $errorMsg); return $this; }
php
{ "resource": "" }
q253614
Validator.applyRuleToField
validation
private function applyRuleToField( string $fieldName, string $ruleName, array $options = [] ): void { if (!isset($this->rules[$ruleName])) { throw new Exception('Undefined rule name.'); } $func = $this->rules[$ruleName][0]; if (!$func($fieldName, $options)) { if (isset($this->rules[$ruleName][1])) { if (is_callable($this->rules[$ruleName][1])) { // If message entity is function $funcMsg = $this->rules[$ruleName][1]; $this->addError($funcMsg($fieldName, $options)); } else { // If message entity is string $this->addError((string) $this->rules[$ruleName][1]); } } else { // If message entity isn't set $this->addDefaultError($fieldName); } } }
php
{ "resource": "" }
q253615
Validator.run
validation
public function run(): void { if (!$this->isRan) { $this->isRan = true; foreach ($this->items as $item) { $options = $item[2] ?? []; $ruleName = $item[1]; foreach (is_array($item[0]) ? $item[0] : [$item[0]] as $fieldName) { self::applyRuleToField($fieldName, $ruleName, $options); } } } }
php
{ "resource": "" }
q253616
EqualsBuilder.append
validation
public function append($a, $b = true, $comparatorCallback = null) { $this->comparisonList[] = array($a, $b, $comparatorCallback); return $this; }
php
{ "resource": "" }
q253617
EqualsBuilder.equals
validation
public function equals() { foreach ($this->comparisonList as $valuePair) { $a = $valuePair[0]; $b = $valuePair[1]; $callback = $valuePair[2]; if (! is_null($callback)) { if (! is_callable($callback)) { throw new \InvalidArgumentException( sprintf( 'Provided callback of type %s is not callable!', is_object($callback)? get_class($callback) : gettype($callback) ) ); } if (is_array($a) && is_array($b) && $this->isList($a) && $this->isList($b)) { $result = $this->compareListsWithCallback($a, $b, $callback); } else { $result = call_user_func($callback, $a, $b); } if (! is_bool($result)) { throw new \RuntimeException( sprintf( 'Provided callback of type %s does not return a boolean value!', is_object($callback)? get_class($callback) : gettype($callback) ) ); } return $result; } if (! (($this->strict)? $a === $b : $a == $b) ) { return false; } } return true; }
php
{ "resource": "" }
q253618
Install.superadmin
validation
public function superadmin(User $account, Container $application, Database $database){ //@TODO create master user account //1. Load the model $config = $this->config; //$database = \Library\Database::getInstance(); //2. Prevalidate passwords and other stuff; $username = $application->input->getString("user_first_name", "","post", FALSE, array()); $usernameid = $application->input->getString("user_name_id", "","post",FALSE, array()); $userpass = $application->input->getString("user_password", "", "post", FALSE, array()); $userpass2 = $application->input->getString("user_password_2", "", "post", FALSE, array()); $useremail = $application->input->getString("user_email", "", "post", FALSE, array()); //3. Encrypt validated password if new users! //4. If not new user, check user has update permission on this user //5. MailOut if(empty($userpass)||empty($username)||empty($usernameid)||empty($useremail)){ //Display a message telling them what can't be empty throw new Exception(t('Please provide at least a Name, Username, E-mail and Password') ); return false; } //Validate the passwords if($userpass <> $userpass2){ throw new Exception(t('The user passwords do not match') ); return false; } //6. Store the user if(!$account->store( $application->input->data("post") , true)){ //Display a message telling them what can't be empty throw new Exception( t('Could not store the admin user account') ); return false; } //Add this user to the superadministrators group! //$adminObject = $account->getObjectByURI( $usernameid ); $adminAuthority = $this->config->get( "setup.site.superadmin-authority", NULL); //Default Permission Group? if(!empty($adminAuthority)){ $query = "INSERT INTO ?objects_authority( authority_id, object_id ) SELECT {$database->quote((int)$adminAuthority)}, object_id FROM ?objects WHERE object_uri={$database->quote($usernameid)}"; $database->exec($query); } //@TODO Empty the setup/sessions folder // \Library\Folder::deleteContents( APPPATH."setup".DS."sessions" ); //No need to through an error //Completes installation //set session handler to database if database is connectable $config->set("setup.session.store", "database"); $config->set("setup.database.installed", TRUE ); if(!$config->saveParams() ){ throw new Exception("could not save config"); return false; } return true; }
php
{ "resource": "" }
q253619
Install.database
validation
public function database(Container $application){ $config = $this->config; //Stores all user information in the database; $dbName = $application->input->getString("dbname", "", "post"); $dbPass = $application->input->getString("dbpassword", "", "post"); $dbHost = $application->input->getString("dbhost", "", "post"); $dbPref = $application->input->getString("dbtableprefix", "", "post"); $dbUser = $application->input->getString("dbusername", "", "post"); $dbDriver = $application->input->getString("dbdriver","MySQLi", "post"); $dbPort = $application->input->getInt("dbport","", "post"); if(empty($dbName)){ throw new \Exception(t("Database Name is required to proceed.")); return false; } if(empty($dbDriver)){ throw new \Exception(t("Database Driver Type is required to proceed.")); return false; } if(empty($dbUser)){ throw new \Exception(t("Database username is required to proceed")); return false; } if(empty($dbHost)){ throw new \Exception(t("Please provide a link to your database host. If using SQLite, provide a path to the SQLite database as host")); return false; } $config->set("setup.database.host", $dbHost ); $config->set("setup.database.prefix", $dbPref ); $config->set("setup.database.user", $dbUser ); $config->set("setup.database.password", $dbPass ); $config->set("setup.database.name", $dbName ); $config->set("setup.database.driver", strtolower($dbDriver ) ); $config->set("setup.database.port", intval($dbPort) ); //Try connect to the database with these details? try{ $application->createInstance("database", [ $application->config->get("setup.database.driver"), //get the database driver $application->config->get("setup.database") //get all the database options and pass to the driver ] ); } catch (Exception $exception) { //@TODO do something with this exception; return false; } //@TODO run the install.sql script on the connected database $schema = new Schema(); //print_r($schema::$database); if(!$schema->createTables( $application->database )){ echo "wtf"; return false; } //generate encryption key $encryptor = $this->encryptor; $encryptKey = $encryptor->generateKey( time().getRandomString(5) ); $config->set("setup.encrypt.key", $encryptKey ); if(!$config->saveParams() ){ throw new Exception("could not save config"); return false; } return true; }
php
{ "resource": "" }
q253620
Help.handle
validation
public function handle(): void { /* Help Guide Header */ $help = " -----------------------------------------------------------------\n"; $help .= " | Command Line Interface\n"; $help .= " | See more in https://github.com/senhungwong/command-line-interface\n"; $help .= " -------------------------------------------------------------------\n"; /* Get All Commands */ $commands = CommandEntry::getCommands(); /* See Specific Function's Description */ if ($command = $this->getArgument('function-name')) { $command = new $commands[$command]; $help .= " - " . $command->getCommand() . ": "; $help .= $command->getDescription() . "\n"; } /* List All Commands */ else { foreach ($commands as $command) { $command = new $command; $help .= " - "; $help .= $command->getCommand() . ": "; $help .= $command->getDescription() . "\n"; } } echo $help; }
php
{ "resource": "" }
q253621
UnresolvableArgumentException.fromReflectionParam
validation
public static function fromReflectionParam( ReflectionParameter $param, ReflectionFunctionAbstract $func = null, Exception $previous = null, $afterMessage = null ) { $message = static::makeMessage($param, $func); if ($previous) { $message .= ' - '.$previous->getMessage(); } if ($afterMessage) { $message .= ' - '.$afterMessage; } return new static($message, 0, $previous); }
php
{ "resource": "" }
q253622
Logger.interval
validation
public static function interval($startDate, $endDate){ $hits = DB::table('views')->select('id', 'ip', 'created_at')->whereBetween('created_at', [$startDate, $endDate])->groupBy('ip')->get(); return count($hits); }
php
{ "resource": "" }
q253623
Logger.lastMonth
validation
public static function lastMonth() { $hits_count = self::interval(Carbon::now()->subMonth()->firstOfMonth(), Carbon::now()->subMonth()->lastOfMonth()); return $hits_count; }
php
{ "resource": "" }
q253624
Logger.perMonth
validation
public static function perMonth($months = 1, $date_format = "Y-m") { $hits_per_month = []; for ($i = 1; $i <= $months; $i++) { $hits_count = self::interval(Carbon::now()->subMonths($i)->firstOfMonth(), Carbon::now()->subMonths($i)->lastOfMonth()); $hits_per_month[Carbon::now()->subMonths($i)->format($date_format)] = $hits_count; } return $hits_per_month; }
php
{ "resource": "" }
q253625
Logger.perDay
validation
public static function perDay($days = 1, $date_format = "m-d") { $hits_per_day = []; for ($i = 1; $i <= $days; $i++) { $hits_count = self::interval(Carbon::now()->subDays($i), Carbon::now()->subDays($i - 1)); $hits_per_day[Carbon::now()->subDays($i)->format($date_format)] = $hits_count; } return $hits_per_day; }
php
{ "resource": "" }
q253626
PagesCollectionParser.permalinksByLanguage
validation
public function permalinksByLanguage($language = null) { $result = array(); if (null === $language) { $language = $this->currentLanguage; } foreach ($this->pages as $page) { foreach ($page["seo"] as $pageAttribute) { if ($pageAttribute["language"] != $language) { continue; } $result[] = $pageAttribute["permalink"]; } } return $result; }
php
{ "resource": "" }
q253627
PagesCollectionParser.parse
validation
public function parse() { $finder = new Finder(); $pages = $finder->directories()->depth(0)->sortByName()->in($this->pagesDir); $languages = $this->configurationHandler->languages(); $homepage = $this->configurationHandler->homepage(); foreach ($pages as $page) { $pageDir = (string)$page; $pageName = basename($pageDir); $pageDefinitionFile = $pageDir . '/' . $this->pageFile; if (!file_exists($pageDefinitionFile)) { continue; } $seoDefinition = $this->fetchSeoDefinition($this->pagesDir . '/' . $pageName, $this->seoFile, $languages); $pageDefinition = json_decode(file_get_contents($pageDefinitionFile), true); $pageDefinition["seo"] = $seoDefinition; $pageDefinition["isHome"] = $homepage == $pageName; $this->pages[$pageName] = $pageDefinition; } return $this; }
php
{ "resource": "" }
q253628
ExceptionManager.showErrors
validation
private static function showErrors() { if (count(static::$errors) > 0) { $errorsList = ''; foreach (static::$errors as $error) { $errorsList .= 'Tipo: ' . $error['type'] . '<br>'; $errorsList .= 'Mensaje: ' . $error['message'] . '<br>'; $errorsList .= 'Archivo: ' . $error['file'] . '<br>'; $errorsList .= 'Line: ' . $error['line'] . '<br><br>'; } static::viewException(1, $errorsList); } }
php
{ "resource": "" }
q253629
DefaultAdapter.logout
validation
public function logout(AdapterChainEvent $e) { $session = new Container($this->getStorage()->getNameSpace()); $session->getManager()->forgetMe(); $session->getManager()->destroy(); }
php
{ "resource": "" }
q253630
DefaultAdapter.updateCredentialHash
validation
protected function updateCredentialHash(PasswordableInterface $identityObject, $password) { $cryptoService = $this->getMapper()->getPasswordService(); if (!$cryptoService instanceof Bcrypt) { return $this; } $hash = explode('$', $identityObject->getPassword()); if ($hash[2] === $cryptoService->getCost()) { return $this; } $identityObject->setPassword($cryptoService->create($password)); return $this; }
php
{ "resource": "" }
q253631
NamespaceOptions.setEntityPrototype
validation
public function setEntityPrototype($entityPrototype) { if (!is_object($entityPrototype)) { throw new Exception\InvalidArgumentException( sprintf( '%s expects parameter 1 to be an object, %s provided instead', __METHOD__, is_object($entityPrototype) ? get_class($entityPrototype) : gettype($entityPrototype) ) ); } $this->entityPrototype = $entityPrototype; return $this; }
php
{ "resource": "" }
q253632
NamespaceOptions.setHydrator
validation
public function setHydrator($hydrator) { if (!is_string($hydrator) && !$hydrator instanceof HydratorInterface) { throw new Exception\InvalidArgumentException( sprintf( '%s expects parameter 1 to be an object of instance Zend\Stdlib\Hydrator\HydratorInterface or string, %s provided instead', __METHOD__, is_object($hydrator) ? get_class($hydrator) : gettype($hydrator) ) ); } $this->hydrator = $hydrator; return $this; }
php
{ "resource": "" }
q253633
GithubPaginator.getPages
validation
public function getPages($startPage, $endPage, $urlStub) { $pages = []; //TODO yield this array - after upgrading to php 5.5 for($x=$startPage ; $x<=$endPage ; $x++) { $pages[] = $urlStub.$x; } return $pages; }
php
{ "resource": "" }
q253634
SiteSavedListener.onSiteSaved
validation
public function onSiteSaved(SiteSavedEvent $event) { $fs = new Filesystem(); $fs->mirror( $this->configurationHandler->uploadAssetsDir(), $this->configurationHandler->uploadAssetsDirProduction() ); }
php
{ "resource": "" }
q253635
Job.fill
validation
protected function fill(array $data) { $this->uuid = $data["uuid"] ?: ""; $this->status = $data["status"] ?: ""; $this->code = $data["code"] ?: ""; $this->modules = $data["modules"] ?: []; $this->vars = $data["vars"] ?: []; $this->error = $data["error"] ?: ""; $this->logs = $data["logs"] ?: []; $this->results = $data["results"] ?: []; $this->duration = $data["duration"] ?: 0; $this->createdAt = $this->parseDate($data["created_at"]); $this->startedAt = $this->parseDate($data["started_at"]); $this->finishedAt = $this->parseDate($data["finished_at"]); }
php
{ "resource": "" }
q253636
Builder.listWords
validation
abstract public function __construct(ConnectionInterface $connection); public function listWords($word, $field = null) { $this->where('word','==',$word); if (!is_null($field)){ $this->scope->listWordsField = $field; } else { $this->scope->listWordsField = ''; } return $this; }
php
{ "resource": "" }
q253637
Builder.where
validation
public function where($field, $operator = null, $value = null, $logical = '&&') { if ($field instanceof Closure) { $this->scope->where .= $this->scope->where=='' ? ' (' : $logical.' ('; call_user_func($field, $this); $this->scope->where .= ') '; } else { $logical = (strlen($this->scope->where) <=1 || substr($this->scope->where, -1)=='(') ? '' : $logical; $this->scope->where .= Parser::where($field, $operator, $value, $logical); } return $this; }
php
{ "resource": "" }
q253638
Builder.orWhere
validation
public function orWhere($field, $operator = null, $value = null) { return $this->where($field, $operator, $value, '||'); }
php
{ "resource": "" }
q253639
Builder.select
validation
public function select($select = null) { $this->scope->select = Parser::select($select); return $this; }
php
{ "resource": "" }
q253640
Builder.orderBy
validation
public function orderBy($field, $order = null) { $this->scope->orderBy[] = Parser::orderBy($field, $order); return $this; }
php
{ "resource": "" }
q253641
Builder.first
validation
public function first() { $this->scope->limit = 1; $this->scope->offset = 0; return $this->get(null); }
php
{ "resource": "" }
q253642
Builder.get
validation
public function get($multiple = true) { $scope = $this->scope; return Parser::get($scope, $this->connection, $multiple); }
php
{ "resource": "" }
q253643
Builder.update
validation
public function update($id, $document = null) { return Parser::update($id, $document, $this->connection); }
php
{ "resource": "" }
q253644
Builder.replace
validation
public function replace($id, $document = null) { return Parser::replace($id, $document, $this->connection); }
php
{ "resource": "" }
q253645
Builder.transaction
validation
public function transaction() { $transaction_id = Parser::beginTransaction($this->connection); $connection = clone $this->connection; $connection->transactionId = $transaction_id; return new Service($connection); }
php
{ "resource": "" }
q253646
ApprovePageController.approveAction
validation
public function approveAction(Request $request, Application $app) { $options = array( "request" => $request, "page_manager" => $app["red_kite_cms.page_manager"], "username" => $this->fetchUsername($app["security"], $app["red_kite_cms.configuration_handler"]), ); return parent::approve($options); }
php
{ "resource": "" }
q253647
FileCache.exists
validation
public function exists($key) { $filenameCache = $this->location . DS . $key; if (file_exists($filenameCache)) { return true; } return false; }
php
{ "resource": "" }
q253648
FileCache.set
validation
public function set($key, $value) { try { $filenameCache = $this->location . DS . $key; // Escribe el archivo en cache file_put_contents($filenameCache, $value); } catch (\Exception $e) { return false; } return true; }
php
{ "resource": "" }
q253649
YamlConfigurationProvider.load
validation
protected function load() { $this->config = array(); if (file_exists($this->filePath)) { $this->config = Yaml::parse($this->filePath); } }
php
{ "resource": "" }
q253650
YamlConfigurationProvider.save
validation
protected function save() { $yaml = Yaml::dump($this->config, 2); file_put_contents($this->filePath, $yaml); }
php
{ "resource": "" }
q253651
Group.delete
validation
public function delete($groupId) { $params = [ 'group_id' => intval($groupId), ]; return $this->parseJSON('json', [self::API_DELETE, $params]); }
php
{ "resource": "" }
q253652
Group.lists
validation
public function lists($begin, $count) { $params = [ 'begin' => intval($begin), 'count' => intval($count), ]; return $this->parseJSON('json', [self::API_GET_LIST, $params]); }
php
{ "resource": "" }
q253653
Group.getDetails
validation
public function getDetails($groupId, $begin, $count) { $params = [ 'group_id' => intval($groupId), 'begin' => intval($begin), 'count' => intval($count), ]; return $this->parseJSON('json', [self::API_GET_DETAIL, $params]); }
php
{ "resource": "" }
q253654
Group.addDevice
validation
public function addDevice($groupId, array $deviceIdentifiers) { $params = [ 'group_id' => intval($groupId), 'device_identifiers' => $deviceIdentifiers, ]; return $this->parseJSON('json', [self::API_ADD_DEVICE, $params]); }
php
{ "resource": "" }
q253655
Group.removeDevice
validation
public function removeDevice($groupId, array $deviceIdentifiers) { $params = [ 'group_id' => intval($groupId), 'device_identifiers' => $deviceIdentifiers, ]; return $this->parseJSON('json', [self::API_DELETE_DEVICE, $params]); }
php
{ "resource": "" }
q253656
WingCommander.init
validation
public static function init ($options = array()) { Flight::map("render", function($template, $data, $toVar = false){ Flight::view()->render($template, $data, $toVar); }); Flight::register('view', get_called_class(), $options); }
php
{ "resource": "" }
q253657
ReportTasks.run_coding_style_report
validation
static function run_coding_style_report( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = self::getReportDir( $opts ) . '/' . $opts['extension']['name']; $phpcs = self::getTool( 'phpcs', $opts, true ); // in case we use the standard rule set, try to install it (after composer has downloaded it) // nb: this could become a task of its own... $rulesDir = self::getVendorDir() . '/squizlabs/php_codesniffer/Codesniffer/Standards/' . $opts['tools']['phpcs']['rules'] ; if ( !is_dir( $rulesDir ) ) { if ( $opts['tools']['phpcs']['rules'] == 'ezcs' ) { $sourceDir = self::getVendorDir() . '/ezsystems/ezcs/php/ezcs'; if ( is_dir( $sourceDir ) ) { pake_symlink( $sourceDir, $rulesDir ); } } } // phpcs will exit with a non-0 value as soon as there is any violation (which generates an exception in pake_sh), // but we do not consider this a fatal error, as we are only generating reports try { $out = pake_sh( "$phpcs --standard=" . escapeshellarg( $opts['tools']['phpcs']['rules'] ) . " " . "--report=" . escapeshellarg( $opts['tools']['phpcs']['format'] ) . " " . // if we do not filter on php files, phpcs can go in a loop trying to parse tpl files "--extensions=php " . /*"--encoding=utf8 " .*/ escapeshellarg( self::getBuildDir( $opts ) . '/' . $opts['extension']['name'] ) ); } catch ( pakeException $e ) { $out = preg_replace( '/^Problem executing command/', '', $e->getMessage() ); } pake_mkdirs( $destdir ); pake_write_file( $destdir . '/phpcs.txt', $out, true ); SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); }
php
{ "resource": "" }
q253658
ReportTasks.run_copy_paste_report
validation
static function run_copy_paste_report( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = self::getReportDir( $opts ) . '/' . $opts['extension']['name']; $phpcpd = self::getTool( 'phpcpd', $opts, true ); // phpcpd will exit with a non-0 value as soon as there is any violation (which generates an exception in pake_sh), // but we do not consider this a fatal error, as we are only generating reports try { $out = pake_sh( "$phpcpd " . escapeshellarg( self::getBuildDir( $opts ) . '/' . $opts['extension']['name'] ) ); } catch ( pakeException $e ) { $out = preg_replace( '/^Problem executing command/', '', $e->getMessage() ); } pake_mkdirs( $destdir ); pake_write_file( $destdir . '/phpcpd.txt', $out, true ); SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); }
php
{ "resource": "" }
q253659
ReportTasks.run_php_loc_report
validation
static function run_php_loc_report( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = self::getReportDir( $opts ) . '/' . $opts['extension']['name']; $phploc = self::getTool( 'phploc', $opts, true ); $out = pake_sh( "$phploc -n " . escapeshellarg( self::getBuildDir( $opts ) . '/' . $opts['extension']['name'] ) ); pake_mkdirs( $destdir ); pake_write_file( $destdir . '/phploc.txt', $out, true ); SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); }
php
{ "resource": "" }
q253660
ReportTasks.run_php_pdepend_report
validation
static function run_php_pdepend_report( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = self::getReportDir( $opts ) . '/' . $opts['extension']['name']; $pdepend = self::getTool( 'pdepend', $opts, true ); pake_mkdirs( $destdir ); $out = pake_sh( $pdepend . " --jdepend-chart=" . escapeshellarg( self::getReportDir( $opts ) . '/' . $opts['extension']['name'] . '/jdependchart.svg' ) . " --overview-pyramid=" . escapeshellarg( self::getReportDir( $opts ) . '/' . $opts['extension']['name'] . '/overview-pyramid.svg' ) . " --summary-xml=" . escapeshellarg( self::getReportDir( $opts ) . '/' . $opts['extension']['name'] . '/summary.xml' ) . " " . escapeshellarg( self::getBuildDir( $opts ) . '/' . $opts['extension']['name'] ) ); SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); }
php
{ "resource": "" }
q253661
Zend2.dt
validation
public function dt( $domain, $singular ) { $singular = (string) $singular; try { $locale = $this->getLocale(); foreach( $this->getTranslations( $domain ) as $object ) { if( ( $string = $object->translate( $singular, $domain, $locale ) ) != $singular ) { return $string; } } } catch( \Exception $e ) { ; } // Discard errors, return original string instead return (string) $singular; }
php
{ "resource": "" }
q253662
Zend2.dn
validation
public function dn( $domain, $singular, $plural, $number ) { $singular = (string) $singular; $plural = (string) $plural; $number = (int) $number; try { $locale = $this->getLocale(); foreach( $this->getTranslations( $domain ) as $object ) { if( ( $string = $object->translatePlural( $singular, $plural, $number, $domain, $locale ) ) != $singular ) { return $string; } } } catch( \Exception $e ) { ; } // Discard errors, return original string instead if( $this->getPluralIndex( $number, $this->getLocale() ) > 0 ) { return (string) $plural; } return (string) $singular; }
php
{ "resource": "" }
q253663
Zend2.getAll
validation
public function getAll( $domain ) { $messages = []; $locale = $this->getLocale(); foreach( $this->getTranslations( $domain ) as $object ) { $messages = $messages + (array) $object->getMessages( $domain, $locale ); } return $messages; }
php
{ "resource": "" }
q253664
Zend2.getTranslations
validation
protected function getTranslations( $domain ) { if( !isset( $this->translations[$domain] ) ) { if ( !isset( $this->translationSources[$domain] ) ) { $msg = sprintf( 'No translation directory for domain "%1$s" available', $domain ); throw new \Aimeos\MW\Translation\Exception( $msg ); } $locale = $this->getLocale(); // Reverse locations so the former gets not overwritten by the later $locations = array_reverse( $this->getTranslationFileLocations( $this->translationSources[$domain], $locale ) ); foreach( $locations as $location ) { $translator = \Zend\I18n\Translator\MwTranslator::factory( $this->options ); $translator->addTranslationFile( $this->adapter, $location, $domain, $locale ); $this->translations[$domain][$location] = $translator; } } return ( isset( $this->translations[$domain] ) ? $this->translations[$domain] : [] ); }
php
{ "resource": "" }
q253665
BaseApi.getAuthorizationInfo
validation
public function getAuthorizationInfo($authCode = null) { $params = [ 'component_appid' => $this->getAppId(), 'authorization_code' => $authCode ?: $this->request->get('auth_code'), ]; return $this->parseJSON('json', [self::GET_AUTH_INFO, $params]); }
php
{ "resource": "" }
q253666
BaseApi.getAuthorizerToken
validation
public function getAuthorizerToken($appId, $refreshToken) { $params = [ 'component_appid' => $this->getAppId(), 'authorizer_appid' => $appId, 'authorizer_refresh_token' => $refreshToken, ]; return $this->parseJSON('json', [self::GET_AUTHORIZER_TOKEN, $params]); }
php
{ "resource": "" }
q253667
BaseApi.getAuthorizerInfo
validation
public function getAuthorizerInfo($authorizerAppId) { $params = [ 'component_appid' => $this->getAppId(), 'authorizer_appid' => $authorizerAppId, ]; return $this->parseJSON('json', [self::GET_AUTHORIZER_INFO, $params]); }
php
{ "resource": "" }
q253668
BaseApi.getAuthorizerOption
validation
public function getAuthorizerOption($authorizerAppId, $optionName) { $params = [ 'component_appid' => $this->getAppId(), 'authorizer_appid' => $authorizerAppId, 'option_name' => $optionName, ]; return $this->parseJSON('json', [self::GET_AUTHORIZER_OPTION, $params]); }
php
{ "resource": "" }
q253669
BaseApi.setAuthorizerOption
validation
public function setAuthorizerOption($authorizerAppId, $optionName, $optionValue) { $params = [ 'component_appid' => $this->getAppId(), 'authorizer_appid' => $authorizerAppId, 'option_name' => $optionName, 'option_value' => $optionValue, ]; return $this->parseJSON('json', [self::SET_AUTHORIZER_OPTION, $params]); }
php
{ "resource": "" }
q253670
BaseApi.getAuthorizerList
validation
public function getAuthorizerList($offset = 0, $count = 500) { $params = [ 'component_appid' => $this->getAppId(), 'offset' => $offset, 'count' => $count, ]; return $this->parseJSON('json', [self::GET_AUTHORIZER_LIST, $params]); }
php
{ "resource": "" }
q253671
ForwardsToCriteria.sort
validation
public function sort($key, $order=Sortable::ASC) { $this->criteria->sort($key, $order); return $this; }
php
{ "resource": "" }
q253672
ContentRepository.generateContentTypeFilter
validation
protected function generateContentTypeFilter($contentType) { $filter = null; if (!is_null($contentType) && '' != $contentType) { $filter = array('contentType' => $contentType); } return $filter; }
php
{ "resource": "" }
q253673
PermalinksController.listPermalinksAction
validation
public function listPermalinksAction(Request $request, Application $app) { $options = array( "request" => $request, "pages_collection_parser" => $app["red_kite_cms.pages_collection_parser"], "username" => $this->fetchUsername($app["security"], $app["red_kite_cms.configuration_handler"]), ); return parent::listPermalinks($options); }
php
{ "resource": "" }
q253674
Calc.getMaxPercentForInfinityBonus
validation
private function getMaxPercentForInfinityBonus($cfgParams, $scheme) { $result = 0; $params = $cfgParams[$scheme]; /** @var ECfgParam $item */ foreach ($params as $item) { $percent = $item->getInfinity(); if ($percent > $result) { $result = $percent; } } return $result; }
php
{ "resource": "" }
q253675
Calc.shouldInterruptInfinityBonus
validation
private function shouldInterruptInfinityBonus($percent, $percentParent) { $result = false; if ( ($percentParent > 0) && ($percentParent <= $percent) ) { $result = true; } return $result; }
php
{ "resource": "" }
q253676
Form.add
validation
public function add($id, IFormField $field) { $field->setId($id); return $this->addFormField($field); }
php
{ "resource": "" }
q253677
Form.addExtra
validation
public function addExtra($id, IFormField $formField) { $formField->setId($id); return $this->addFormField($formField, true); }
php
{ "resource": "" }
q253678
Form.addFormField
validation
public function addFormField(IFormField $field, $isExtra = false) { $fieldId = $field->getId(); if (empty($fieldId)) { throw new \LogicException('The access path of a form field must not be empty'); } // setup the field and remember it $field->setParent($this); $this->children[$fieldId] = $field; // non-extra fields are tracked and automatically mapped from and to the subject if ($isExtra === false) { // setup the mapping context, remember it $mappingContext = new MappingContext($this, $field, $this->accessorChain); $this->mappingContexts[$fieldId] = $mappingContext; } return $field; }
php
{ "resource": "" }
q253679
Form.get
validation
public function get($id) { if (isset($this->children[$id])) { return $this->children[$id]; } throw new FormalException( "Unknown form field '$id' on form '" . get_called_class() . "'. Available fields are: " . implode(', ', array_keys($this->children)) ); }
php
{ "resource": "" }
q253680
Chameleon.render
validation
public function render($template, $data) { $tplReady = ''; $this->template = $template; $this->data = $data; if ($this->loadTemplate()) { $tplReady = $this->dataRender; } // Se verifica si hay que minificar el resultado if (Settings::getInstance()->get('minifyTemplate') && !Settings::getInstance()->inDebug()) { $tplReady = $this->minify($tplReady); } $this->release(); return $tplReady; }
php
{ "resource": "" }
q253681
Container.get
validation
public function get($key) { if (!isset($this->instances[$key])) { throw new \LogicException('No instance for given key! (key: ' . $key . ')'); } return $this->instances[$key]; }
php
{ "resource": "" }
q253682
Container.attach
validation
public function attach($key, $instance, $type = self::OBJECT) { switch ($type) { case self::OBJECT: case self::CACHE: if (!is_object($instance)) { throw new \LogicException('Instance is not an object!'); } break; case self::DATABASE: if (!($instance instanceof \PDO)) { throw new \LogicException(); } break; } if (isset($this->instances[$key])) { return $this; } $this->instances[$key] = $instance; return $this; }
php
{ "resource": "" }
q253683
Container.detach
validation
public function detach($key) { if (isset($this->instances[$key])) { unset($this->instances[$key]); } return $this; }
php
{ "resource": "" }
q253684
TaskQueue.add
validation
public function add(InvokerInterface $invoker, $taskArgs = []) { $taskArgs = (is_array($taskArgs) ? $taskArgs : array_slice(func_get_args(), 1)); array_unshift($this->tasks, compact('invoker', 'taskArgs')); return $this; }
php
{ "resource": "" }
q253685
GD_Resize.run
validation
public static function run($source, $destination, $width, $height = "") { // Get the image's MIME $mime = exif_imagetype($source); // Check if the MIME is supported switch ($mime) { case IMAGETYPE_JPEG : $source = imagecreatefromjpeg($source); break; case IMAGETYPE_PNG : $source = imagecreatefrompng($source); break; case IMAGETYPE_GIF : $source = imagecreatefromgif($source); break; default : return; // No support } // Get the width and height of the source $width_src = imagesx($source); $height_src = imagesy($source); // Initialize the height and width of image destination $width_dest = 0; $height_dest= 0; // If the height is not provided, keep the proportions if (!$height) { // Get the ratio $ratio = ($width * 100) / $width_src; // Need resize ? if ($ratio>100) { imagejpeg($source, $destination, 70); imagedestroy($source); return; } // height and width of image resized $width_dest = $width; $height_dest = $height_src * $ratio/100; } else { if ($height_src >= $width_src) { $height_dest = ($height_src * $width ) / $width_src; $width_dest = $width; } elseif ($height_src < $width_src) { $width_dest = ($width_src * $height ) / $height_src; $height_dest = $height; } } // Build the image resized $emptyPicture = imagecreatetruecolor($width, ($height)?$height:$height_dest); imagecopyresampled($emptyPicture, $source, 0, 0, 0, 0, $width_dest, $height_dest, $width_src, $height_src); // Save image imagejpeg($emptyPicture, $destination, 70); // Destruct tmp images imagedestroy($source); imagedestroy($emptyPicture); return; }
php
{ "resource": "" }
q253686
GetPlainData.getPlainCalcId
validation
private function getPlainCalcId($period) { if ($period) { $dsMax = $this->hlpPeriod->getPeriodLastDate($period); } else { $dsMax = Cfg::DEF_MAX_DATESTAMP; } /* prepare query */ $query = $this->qbCalcGetLast->build(); $bind = [ QBCalcGetLast::BND_CODE => Cfg::CODE_TYPE_CALC_FORECAST_PLAIN, QBCalcGetLast::BND_DATE => $dsMax, QBCalcGetLast::BND_STATE => Cfg::CALC_STATE_COMPLETE ]; /* fetch & parse data */ $conn = $query->getConnection(); $rs = $conn->fetchRow($query, $bind); $result = $rs[QBCalcGetLast::A_CALC_ID]; return $result; }
php
{ "resource": "" }
q253687
ContainerAwareTrait._setContainer
validation
protected function _setContainer($container) { if (!is_null($container) && !($container instanceof BaseContainerInterface)) { throw $this->_createInvalidArgumentException($this->__('Not a valid container'), 0, null, $container); } $this->container = $container; return $this; }
php
{ "resource": "" }
q253688
BuildTasks.run_build_dependencies
validation
static function run_build_dependencies( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); $current = $opts['extension']['name']; foreach( $opts['dependencies']['extensions'] as $ext => $source ) { // avoid loops if ( $ext != $current ) { // create a temporary config file to drive the init task // this could be done better in memory... foreach( $source as $type => $def ) { break; } $tempconf = array( 'extension' => array( 'name' => $ext ), 'version' => array( 'major' => 0, 'minor' => 0, 'release' => 0 ), $type => $def ); $tempconffile = self::getOptionsDir() . "/options-tmp_$ext.yaml"; pakeYaml::emitfile( $tempconf, $tempconffile ); // download remote extension // nb: we can not run the init task here via invoke() because of already_invoked status, // so we use execute(). NB: this is fine as long as init has no prerequisites $task = pakeTask::get( 'init' ); $task->execute( array( "tmp_$ext" ), array_merge( $cliopts, array( 'skip-init' => false, 'skip-init-fetch' => false, 'skip-init-clean' => true ) ) ); // copy config file from ext dir to current config dir if ( is_file( self::getBuildDir( $opts ) . "/$ext/pake/options-$ext.yaml" ) ) { pake_copy( self::getBuildDir( $opts ) . "/$ext/pake/options-$ext.yaml", self::getOptionsDir() . "/options-$ext.yaml" ); } else { throw new pakeException( "Missing pake/options.yaml extension in dependent extension $ext" ); } // finish the init-task $task->execute( array( "tmp_$ext" ), array_merge( $cliopts, array( 'skip-init' => false, 'skip-init-fetch' => true, 'skip-init-clean' => false ) ) ); pake_remove( $tempconffile, '' ); // and build it. Here again we cannot use 'invoke', but we know 'build' has prerequisites // so we execute them one by one $task = pakeTask::get( 'build' ); foreach( $task->get_prerequisites() as $pretask ) { $pretask = pakeTask::get( $pretask ); $pretask->execute( array( $ext ), array_merge( $opts, array( 'skip-init' => true ) ) ); } $task->execute( array( $ext ), array_merge( $opts, array( 'skip-init' => true ) ) ); } } }
php
{ "resource": "" }
q253689
BuildTasks.run_update_ezinfo
validation
static function run_update_ezinfo( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_EX, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = self::getBuildDir( $opts ) . '/' . $opts['extension']['name']; $files = pakeFinder::type( 'file' )->name( 'ezinfo.php' )->maxdepth( 0 ); /// @todo use a real php parser instead pake_replace_regexp( $files, $destdir, array( '/^([\s]{1,25}\x27Version\x27[\s]+=>[\s]+[\x27\x22])(.*)([\x27\x22],?\r?\n?)/m' => '${1}' . $opts['version']['alias'] . $opts['releasenr']['separator'] . $opts['version']['release'] . '$3', '/^([\s]{1,25}\x27License\x27[\s]+=>[\s]+[\x27\x22])(.*)([\x27\x22],?\r?\n?)/m' => '${1}' . $opts['version']['license'] . '$3' ), 1 ); $files = pakeFinder::type( 'file' )->maxdepth( 0 )->name( 'extension.xml' ); /// @todo use a real xml parser instead pake_replace_regexp( $files, $destdir, array( '#^([\s]{1,8}<version>)([^<]*)(</version>\r?\n?)#m' => '${1}' . $opts['version']['alias'] . $opts['releasenr']['separator'] . $opts['version']['release'] . '$3', /// @bug we should use a better xml escaping here '#^([\s]{1,8}<license>)([^<]*)(</license>\r?\n?)#m' => '${1}' . htmlspecialchars( $opts['version']['license'] ) . '$3', '#^([\s]{1,8}<copyright>)Copyright \(C\) 1999-[\d]{4} eZ Systems AS(</copyright>\r?\n?)#m' => '${1}' . 'Copyright (C) 1999-' . strftime( '%Y' ). ' eZ Systems AS' . '$2' ), 1 ); SharedLock::release( $opts['extension']['name'], LOCK_EX, $opts ); }
php
{ "resource": "" }
q253690
BuildTasks.run_check_gnu_files
validation
static function run_check_gnu_files( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = self::getBuildDir( $opts ) . '/' . $opts['extension']['name']; if ( $opts['files']['gnu_dir'] ) { $destdir .= '/' . $opts['files']['gnu_dir']; } $files = pakeFinder::type( 'file' )->name( array( 'README', 'LICENSE' ) )->maxdepth( 0 )->in( $destdir ); if ( count( $files ) != 2 ) { SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); throw new pakeException( "README and/or LICENSE files missing. Please fix" ); } SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); }
php
{ "resource": "" }
q253691
BuildTasks.run_check_templates
validation
static function run_check_templates( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = self::getBuildDir( $opts ) . '/' . $opts['extension']['name']; $files = pakeFinder::type( 'file' )->name( array( '*.tpl' ) )->maxdepth( 0 )->in( $destdir ); if ( count( $files ) ) { $php = self::getTool( 'php', $opts ); if ( strpos( pake_sh( $php . " -v" ), 'PHP' ) === false ) { SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); throw new pakeException( "$php does not seem to be a valid php executable" ); } $ezp = @$opts['ezublish']['install_dir_LS']; if ( $ezp == '' ) { // assume we're running inside an eZ installation $ezp = '../..'; } if ( !file_exists( $ezp . '/bin/php/eztemplatecheck.php' ) ) { SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); throw new pakeException( "$ezp does not seem to be a valid eZ Publish install" ); } // get absolute path to build dir $rootpath = pakeFinder::type( 'directory' )->name( $opts['extension']['name'] )->in( self::getBuildDir( $opts ) ); $rootpath = dirname( $rootpath[0] ); $out = pake_sh( "cd " . escapeshellarg( $ezp ) . " && " . escapeshellarg( $php ) . " bin/php/eztemplatecheck.php " . escapeshellarg( $rootpath ) ); if ( strpos( $out, 'Some templates did not validate' ) !== false ) { SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); throw new pakeException( $out ); } } SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); }
php
{ "resource": "" }
q253692
BuildTasks.run_check_php_files
validation
static function run_check_php_files( $task=null, $args=array(), $cliopts=array() ) { $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = self::getBuildDir( $opts ) . '/' . $opts['extension']['name']; $files = pakeFinder::type( 'file' )->name( array( '*.php' ) )->in( $destdir ); if ( count( $files ) ) { $php = self::getTool( 'php', $opts ); if ( strpos( pake_sh( $php . " -v" ), 'PHP' ) === false ) { SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); throw new pakeException( "$php does not seem to be a valid php executable" ); } foreach ( pakeFinder::type( 'file' )->name( array( '*.php' ) )->in( $destdir ) as $file ) { if ( strpos( pake_sh( $php . " -l " . escapeshellarg( $file ) ), 'No syntax errors detected' ) === false ) { SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); throw new pakeException( "$file does not seem to be a valid php file" ); } } } SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts ); }
php
{ "resource": "" }
q253693
BuildTasks.run_update_package_xml
validation
static function run_update_package_xml( $task=null, $args=array(), $cliopts=array() ) { /// @todo replace hostname, build time $opts = self::getOpts( @$args[0], @$args[1], $cliopts ); if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_EX, $opts ) ) throw new PakeException( "Source code locked by another process" ); $destdir = $opts['build']['dir']; $files = pakeFinder::type( 'file' )->name( 'package.xml' )->maxdepth( 0 ); if ( count( $files ) == 1 ) { // original format pake_replace_regexp( $files, $destdir, array( // <name>xxx</name> '#^( *\074name\076)(.*)(\074/name\076\r?\n?)$#m' => '${1}' . $opts['extension']['name'] . '_extension' . '$3', // <version>xxx</version> '#^( *\074version\076)(.*)(\074/version\076\r?\n?)$#m' => '${1}' . $opts['ezp']['version']['major'] . '.' . $opts['ezp']['version']['minor'] . '.' . $opts['ezp']['version']['release'] . '$3', // <named-version>xxx</named-version> '#^( *\074named-version\076)(.*)(\074/named-version\076\r?\n?)$#m' => '${1}' . $opts['ezp']['version']['major'] . '.' . $opts['ezp']['version']['minor'] . '$3', // <package version="zzzz" //'#^( *\074package +version=")(.*)("\r?\n?)$#m' => '${1}' . $opts['version']['major'] . '.' . $opts['version']['minor'] . $opts['releasenr']['separator'] . $opts['version']['release'] . '$3', // <number>xxxx</number> '#^( *\074number\076)(.*)(\074/number\076\r?\n?)$#m' => '${1}' . $opts['version']['alias'] . '$3', // <release>yyy</release> '#^( *\074release\076)(.*)(\074/release\076\r?\n?)$#m' => '${1}' . $opts['version']['release'] . '$3', '#^( *\074timestamp\076)(.*)(\074/timestamp\076\r?\n?)$#m' => '${1}' . time() . '$3', '#^( *\074host\076)(.*)(\074/host\076\r?\n?)$#m' => '${1}' . gethostname() . '$3', '#^( *\074licence\076)(.*)(\074/licence\076\r?\n?)$#m' => '${1}' . $opts['version']['license'] . '$3', ) ); // replacing a token based on its value instead of its location (text immediately before and after, // as done above) has a disadvantage: we cannot execute the substitution many // times on the same text, as the 1st substitution will remove the token's // value. This means we have to reinit the build to get a 100% updated // package file. Unfortunately hunting for xml attributes not based on // token values needs a real xml parser, simplistic regexps are not enough... pake_replace_tokens( $files, $destdir, '{', '}', array( '$name' => $opts['extension']['name'], '$version' => $opts['version']['alias'], '$ezp_version' => $opts['ezp']['version']['major'] . '.' . $opts['ezp']['version']['minor'] . '.' . $opts['ezp']['version']['release'] ) ); } SharedLock::release( $opts['extension']['name'], LOCK_EX, $opts ); }
php
{ "resource": "" }
q253694
BuildTasks.run_generate_sample_package_xml
validation
static function run_generate_sample_package_xml( $task=null, $args=array(), $cliopts=array() ) { pake_copy( self::getResourceDir() . '/package_master.xml', 'package.xml' ); // tokens not replaced here are replaced at build time // tokens in square brackets are supposed to be edited by the developer $tokens = array( '$summary' => '[Summary]', '$description' => '[Description]', '$vendor' => '', '$maintainers' => '', '$documents' => '', '$changelog' => '', '$simple-files' => '', '$state' => '[State]', '$requires' => '' ); //$files = pakeFinder::type( 'file' )->name( 'package.xml' )->maxdepth( 0 )->in( '.' ); pake_replace_tokens( 'package.xml', '.', '{', '}', $tokens ); pake_echo ( "File package.xml generated. Please replace all tokens in square brackets in it (but do not replace values in curly brackets) then commit it to sources in the top dir of the extension" ); }
php
{ "resource": "" }
q253695
FactoryAction.create
validation
public function create($entity, $action) { $type = ucfirst($entity); $actionName = ucfirst($action); $class = sprintf('RedKiteCms\Action\%s\%s%sAction', $type, $actionName, $type); if (!class_exists($class)) { return null; } $reflectionClass = new \ReflectionClass($class); return $reflectionClass->newInstance($this->app); }
php
{ "resource": "" }
q253696
Plugin.hasToolbar
validation
public function hasToolbar() { $fileSkeleton = '/Resources/views/Editor/Toolbar/_toolbar_%s_buttons.html.twig'; return file_exists($this->pluginDir . sprintf($fileSkeleton, 'left')) || file_exists($this->pluginDir . sprintf($fileSkeleton, 'right')); }
php
{ "resource": "" }
q253697
Plugin.installAssets
validation
public function installAssets($targetFolder = "web", $force = false) { $sourceDir = $this->pluginDir . '/Resources/public'; $targetDir = $this->rootDir . '/' . $targetFolder . '/plugins/' . strtolower($this->name); if (is_dir($targetDir) && !$force) { return; } $this->filesystem->symlink($sourceDir, $targetDir, true); }
php
{ "resource": "" }
q253698
Web2All_Table_Object.onSuccessLoad
validation
protected function onSuccessLoad() { if ($this->Web2All->DebugLevel>Web2All_Manager_Main::DEBUGLEVEL_MEDIUM) { $this->Web2All->debugLog('Web2All_Table_Object::loadFromTable(): loaded: '.$this->asDebugString()); } }
php
{ "resource": "" }
q253699
BlogController.createCommentForm
validation
private function createCommentForm(CommentFront $model, $entity) { $form = $this->createForm('BlogBundle\Form\CommentFrontType', $model, array( 'action' => $this->generateUrl('blog_blog_comment', array('post' => $entity->getId())), 'method' => 'POST', 'attr' => array('id' => 'comment-form','class' => 'comment-form') )); return $form; }
php
{ "resource": "" }