_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q266000
Table.getPrimaryKeys
test
public function getPrimaryKeys() { if ($this->primary_keys === null) { try { $this->primary_keys = $this->tableManager->metadata()->getPrimaryKeys($this->prefixed_table); } catch (\Soluble\Schema\Exception\NoPrimaryKeyException $e) { throw new Exception\PrimaryKeyNotFoundException(__METHOD__ . ': ' . $e->getMessage()); //@codeCoverageIgnoreStart } catch (\Soluble\Schema\Exception\ExceptionInterface $e) { throw new Exception\RuntimeException(__METHOD__ . ": Cannot determine primary key on table " . $this->prefixed_table); } //@codeCoverageIgnoreEnd } return $this->primary_keys; }
php
{ "resource": "" }
q266001
Table.getPrimaryKey
test
public function getPrimaryKey() { if ($this->primary_key === null) { $pks = $this->getPrimaryKeys(); if (count($pks) > 1) { throw new Exception\MultiplePrimaryKeysFoundException(__METHOD__ . ": Error getting unique primary key on table, multiple found on table " . $this->prefixed_table); } $this->primary_key = $pks[0]; } return $this->primary_key; }
php
{ "resource": "" }
q266002
Table.getColumnsInformation
test
public function getColumnsInformation() { if ($this->column_information === null) { $this->column_information = $this->tableManager ->metadata() ->getColumnsInformation($this->prefixed_table); } return $this->column_information; }
php
{ "resource": "" }
q266003
Table.executeStatement
test
protected function executeStatement($sqlObject) { if ($sqlObject instanceof PreparableSqlInterface) { $statement = $this->sql->prepareStatementForSqlObject($sqlObject); } elseif (is_string($sqlObject)) { $statement = $this->tableManager->getDbAdapter()->createStatement($sqlObject); } else { //@codeCoverageIgnoreStart throw new Exception\InvalidArgumentException(__METHOD__ . ': expects sqlObject to be string or PreparableInterface'); //@codeCoverageIgnoreEnd } try { $result = $statement->execute(); } catch (\Exception $e) { // In ZF2, PDO_Mysql and MySQLi return different exception, // attempt to normalize by catching one exception instead // of RuntimeException and InvalidQueryException $messages = []; $ex = $e; do { $messages[] = $ex->getMessage(); } while ($ex = $ex->getPrevious()); $message = implode(', ', array_unique($messages)); $lmsg = __METHOD__ . ':' . strtolower($message) . '(code:' . $e->getCode() . ')'; if (strpos($lmsg, 'cannot be null') !== false) { // Integrity constraint violation: 1048 Column 'non_null_column' cannot be null $rex = new Exception\NotNullException(__METHOD__ . ': ' . $message, $e->getCode(), $e); throw $rex; } elseif (strpos($lmsg, 'duplicate entry') !== false) { $rex = new Exception\DuplicateEntryException(__METHOD__ . ': ' . $message, $e->getCode(), $e); throw $rex; } elseif (strpos($lmsg, 'constraint violation') !== false || strpos($lmsg, 'foreign key') !== false) { $rex = new Exception\ForeignKeyException(__METHOD__ . ': ' . $message, $e->getCode(), $e); throw $rex; } else { if ($sqlObject instanceof SqlInterface) { $sql_string = $sqlObject->getSqlString($this->sql->getAdapter()->getPlatform()); } else { $sql_string = $sqlObject; } $iqex = new Exception\RuntimeException(__METHOD__ . ': ' . $message . "[$sql_string]", $e->getCode(), $e); throw $iqex; } } return $result; }
php
{ "resource": "" }
q266004
Table.getPrimaryKeyPredicate
test
protected function getPrimaryKeyPredicate($id) { if (!is_scalar($id) && !is_array($id)) { throw new Exception\InvalidArgumentException(__METHOD__ . ": Id must be scalar or array, type " . gettype($id) . " received"); } $keys = $this->getPrimaryKeys(); if (count($keys) == 1) { $pk = $keys[0]; if (!is_scalar($id)) { $type = gettype($id); throw new Exception\InvalidArgumentException(__METHOD__ . ": invalid primary key value. Table '{$this->table}' has a single primary key '$pk'. Argument must be scalar, '$type' given"); } $predicate = [$pk => $id]; } else { if (!is_array($id)) { $pks = implode(',', $keys); $type = gettype($id); throw new Exception\InvalidArgumentException(__METHOD__ . ": invalid primary key value. Table '{$this->table}' has multiple primary keys '$pks'. Argument must be an array, '$type' given"); } $matched_keys = array_diff($id, $keys); if (count($matched_keys) == count($keys)) { $predicate = $matched_keys; } else { $pks = implode(',', $keys); $vals = implode(',', $matched_keys); throw new Exception\InvalidArgumentException(__METHOD__ . ": incomplete primary key value. Table '{$this->table}' has multiple primary keys '$pks', values received '$vals'"); } } return $predicate; }
php
{ "resource": "" }
q266005
Table.checkDataColumns
test
protected function checkDataColumns(array $data) { $diff = array_diff_key($data, $this->getColumnsInformation()); if (count($diff) > 0) { $msg = implode(',', array_keys($diff)); throw new Exception\ColumnNotFoundException(__METHOD__ . ": some specified columns '$msg' does not exists in table {$this->table}."); } }
php
{ "resource": "" }
q266006
Api.parseAsArray
test
protected function parseAsArray($content) { $data = json_decode($content, true); return array( isset($data['status']) ? $data['status'] : false, isset($data['error']) ? $data['error'] : false, $data, ); }
php
{ "resource": "" }
q266007
Api.parseAsObject
test
protected function parseAsObject($content) { $data = json_decode($content); return array( property_exists($data, 'status') ? $data->status : false, property_exists($data, 'error') ? $data->error : false, $data ); }
php
{ "resource": "" }
q266008
Api.setReturnType
test
public function setReturnType($returnType) { if (!in_array($returnType, array(static::RETURN_OBJECT, static::RETURN_ARRAY))) { throw new InvalidArgumentException(sprintf('Invalid return type "%s" given.', $returnType)); } $this->returnType = $returnType; return $this; }
php
{ "resource": "" }
q266009
Loader.run
test
public function run() { // Enqueue styles and scripts $this->action('wp_enqueue_scripts', $this->enqueue('wp')); $this->action('admin_enqueue_scripts', $this->enqueue('admin')); foreach ($this->filters as $hook) { add_filter($hook['hook'], $hook['callback'], $hook['priority'], $hook['accepted_args']); } foreach ($this->actions as $hook) { add_action($hook['hook'], $hook['callback'], $hook['priority'], $hook['accepted_args']); } }
php
{ "resource": "" }
q266010
Loader.enqueue
test
protected function enqueue($type) { $filter = function ($val) use ($type) { return in_array($val['type'], array($type, 'both')); }; return function () use ($filter) { foreach (array_filter($this->styles, $filter) as $hook) { wp_enqueue_style($hook['handle'], $hook['src'], $hook['deps'], $this->version, $hook['cond']); } foreach (array_filter($this->scripts, $filter) as $hook) { wp_enqueue_script($hook['handle'], $hook['src'], $hook['deps'], $this->version, $hook['cond']); } }; }
php
{ "resource": "" }
q266011
MoveBuilder.is
test
public function is($type) { if (null !== $this->type) { throw new LogicException('Already typed'); } $this->type = $type; return $this; }
php
{ "resource": "" }
q266012
MoveBuilder.named
test
public function named($name) { if (null !== $this->name) { throw new LogicException('Already named'); } $this->name = $name; return $this; }
php
{ "resource": "" }
q266013
MoveBuilder.start
test
public function start($position) { if (null !== $this->initialPosition) { throw new LogicException('Start already defined'); } $this->initialPosition = $position; return $this; }
php
{ "resource": "" }
q266014
MoveBuilder.deal
test
public function deal($damage) { if (null !== $this->damage) { throw new LogicException('Damage already defined'); } $this->damage = $damage; return $this; }
php
{ "resource": "" }
q266015
MoveBuilder.aim
test
public function aim($hitLevel) { if (null !== $this->hitLevel) { throw new LogicException('Hit level already defined'); } $this->hitLevel = $hitLevel; return $this; }
php
{ "resource": "" }
q266016
MoveBuilder.withMeterGain
test
public function withMeterGain($value) { if (null !== $this->meterGain) { throw new LogicException('Meter gain already defined'); } $this->meterGain = $value; return $this; }
php
{ "resource": "" }
q266017
MoveBuilder.withInputs
test
public function withInputs($inputs) { if (0 < count($this->inputs)) { throw new LogicException('Inputs already defined'); } $this->inputs = $this->parser->transforms($inputs); return $this; }
php
{ "resource": "" }
q266018
MoveBuilder.addCancel
test
public function addCancel(MoveInterface $move) { foreach ($this->cancelAbilities as $cancelAbility) { if ($cancelAbility->equals($move)) { throw new LogicException( sprintf('Cancel ability "%s" already defined', $move->getName()) ); } } $this->cancelAbilities[] = $move; return $this; }
php
{ "resource": "" }
q266019
MoveBuilder.startIn
test
public function startIn($frames) { if (null !== $this->startFrames) { throw new LogicException('Start frames already defined'); } $this->startFrames = $frames; return $this; }
php
{ "resource": "" }
q266020
MoveBuilder.activeDuring
test
public function activeDuring($frames) { if (null !== $this->activeFrames) { throw new LogicException('Active frames already defined'); } $this->activeFrames = $frames; return $this; }
php
{ "resource": "" }
q266021
MoveBuilder.recoverIn
test
public function recoverIn($frames) { if (null !== $this->recoveryFrames) { throw new LogicException('Recovery frames already defined'); } $this->recoveryFrames = $frames; return $this; }
php
{ "resource": "" }
q266022
MoveBuilder.advantageOnHit
test
public function advantageOnHit($frames) { if (null !== $this->hitAdvantage) { throw new LogicException('Hit advantage already defined'); } $this->hitAdvantage = $frames; return $this; }
php
{ "resource": "" }
q266023
MoveBuilder.advantageOnGuard
test
public function advantageOnGuard($frames) { if (null !== $this->guardAdvantage) { throw new LogicException('Guard advantage already defined'); } $this->guardAdvantage = $frames; return $this; }
php
{ "resource": "" }
q266024
MoveBuilder.build
test
public function build() { return new Move( $this->type, $this->name, $this->initialPosition, $this->inputs, $this->damage, $this->meterGain, $this->hitLevel, $this->cancelAbilities, new FrameData( $this->startFrames, $this->activeFrames, $this->recoveryFrames, $this->guardAdvantage, $this->hitAdvantage ) ); }
php
{ "resource": "" }
q266025
Notify.sendSlackMessage
test
private static function sendSlackMessage($message, $channel) { // do not send Slack messages in test mode for now // @todo Trap these for testing if (Director::isTest()) { return; } $hooksFromConfig = Config::inst()->get('Suilven\Notifier\Notify', 'slack_webhooks'); // optionally override the channel $channelOverride = Config::inst()->get('Suilven\Notifier\Notify', 'channel_override'); if (!empty($channelOverride)) { $channel = $channelOverride; } // get the appropriate webhook $url = null; if (!empty($hooksFromConfig)) { foreach($hooksFromConfig as $hook) { // stick with the default webhook but allow overriding on a per channel basis if ($hook['name'] == $channel) { $url = $hook['url']; } elseif (empty($url) && $hook['name'] == 'default') { $url = $hook['url']; } } } // Log an error if Slack config misconfigured if (empty($url)) { Injector::inst()->get(LoggerInterface::class)->error('The slack channel ' . $channel . ' has no webhook'); return; } // create job $job = new NotifyViaSlackJob(); $job->webhookURL = $url; $job->message = $message; $job->channel = $channel; // place on queue singleton(QueuedJobService::class)->queueJob($job); }
php
{ "resource": "" }
q266026
NativePathGenerator.parse
test
public function parse(array $segments, array $data = null, array $params = null): string { // If data was passed but no params if (null === $params && null !== $data) { throw new InvalidArgumentException( 'Route params are required when supplying data' ); } $path = ''; $replace = []; $replacements = []; // If there is data, parse the replacements if (null !== $data) { $this->parseData( $segments, $data, $params, $replace, $replacements ); } // Iterate through the segments foreach ($segments as $index => $segment) { // No need to do replacements if there was no data if (null !== $data) { // Replace any parameters $segment = str_replace($replace, $replacements, $segment); } // If parameters were replaced or none to begin with if (strpos($segment, '{') === false) { // Append this segment $path .= $segment; } } return $path; }
php
{ "resource": "" }
q266027
NativePathGenerator.parseData
test
protected function parseData( array $segments, array $data, array $params, array &$replace, array &$replacements ): void { // Iterate through all the data properties foreach ($data as $key => $datum) { // If the data isn't found in the params array it is not a valid // param if (! isset($params[$key])) { throw new InvalidArgumentException( "Invalid route param '{$key}'" ); } $regex = $params[$key]['regex']; $this->validateDatum($key, $datum, $regex); if (\is_array($datum)) { // Get the segment by the param key and replace the {key} // within it to get the repeatable portion of the segment $segment = $this->findParamSegment( $segments, $params[$key]['replace'] ); $deliminator = str_replace( $params[$key]['replace'] . '*', '', $segment ); // Set what to replace $replace[] = $params[$key]['replace'] . '*'; // With the data value to replace with $replacements[] = implode($deliminator, $datum); continue; } // Set what to replace $replace[] = $params[$key]['replace']; // With the data value to replace with $replacements[] = $datum; } }
php
{ "resource": "" }
q266028
NativePathGenerator.validateDatum
test
protected function validateDatum(string $key, $datum, string $regex): void { if (\is_array($datum)) { foreach ($datum as $datumItem) { $this->validateDatum($key, $datumItem, $regex); } return; } // If the value of the data doesn't match what was specified when the route was made if (preg_match('/^' . $regex . '$/', $datum) === 0) { throw new InvalidArgumentException( "Route param for {$key}, '{$datum}', does not match {$regex}" ); } }
php
{ "resource": "" }
q266029
NativePathGenerator.findParamSegment
test
protected function findParamSegment(array $segments, string $param): ? string { $segment = null; foreach ($segments as $segment) { if (strpos($segment, $param) !== false) { return $segment; } } return $segment; }
php
{ "resource": "" }
q266030
ResourceGeneratorCommand.callRepository
test
protected function callRepository($resource) { $repositoryName = $this->getRepositoryName($resource); if ($this->confirm("Do you want me to create a $repositoryName Repository? [yes|no]")) { $this->call('generate:repository', compact('repositoryName')); } }
php
{ "resource": "" }
q266031
ClassName.validate
test
private function validate($name): void { try { new ReflectionClass($name); } catch(ReflectionException $ex) { throw new InvalidArgumentException('Expected class name, but got [' . var_export($name, true) . '] instead'); } }
php
{ "resource": "" }
q266032
ImageModel.isImage
test
public function isImage( $exif=null ) { $_ext = empty($exif) ? self::$img_extensions : self::$exif_extensions; $tbl = explode('.', $this->filename); $last = end($tbl); return (bool) ($this->pathExists() && $this->exists() && in_array(strtolower($last), $_ext)); }
php
{ "resource": "" }
q266033
ImageModel.count
test
public function count() { $_new_dir = new DirectoryModel; $_new_dir->setPath( dirname($this->getPath()) ); $_new_dir->setDirname( basename($this->getPath()) ); return count($_new_dir->scanDir()); }
php
{ "resource": "" }
q266034
RequestHelper.getConsolePathInfo
test
protected function getConsolePathInfo() { if (!isset($this->_route)) { $data = $this->getConsoleRouteAndParams(); $this->_route = (string)$data[0]; } return $this->_route; }
php
{ "resource": "" }
q266035
RequestHelper.getConsoleRouteAndParamsRaw
test
protected function getConsoleRouteAndParamsRaw() { $rawParams = $this->getConsoleParamsRaw(); $endOfOptionsFound = false; if (isset($rawParams[0])) { $route = array_shift($rawParams); if ($route === '--') { $endOfOptionsFound = true; $route = array_shift($rawParams); } } else { $route = ''; } $params = []; $prevOption = null; foreach ($rawParams as $param) { if ($endOfOptionsFound) { $params[] = $param; } elseif ($param === '--') { $endOfOptionsFound = true; } elseif (preg_match('/^--([\w-]+)(?:=(.*))?$/', $param, $matches)) { $name = $matches[1]; if (is_numeric(substr($name, 0, 1))) { throw new Exception('Parameter "' . $name . '" is not valid'); } $params[$name] = isset($matches[2]) ? $matches[2] : true; $prevOption = &$params[$name]; } elseif (preg_match('/^-([\w-]+)(?:=(.*))?$/', $param, $matches)) { $name = $matches[1]; if (is_numeric($name)) { $params[] = $param; } else { $params['_aliases'][$name] = isset($matches[2]) ? $matches[2] : true; $prevOption = &$params['_aliases'][$name]; } } elseif ($prevOption === true) { // `--option value` syntax $prevOption = $param; } else { $params[] = $param; } } return [$route, $params]; }
php
{ "resource": "" }
q266036
Uri.withScheme
test
public function withScheme($scheme): UriInterface { if (!in_array(strtolower($scheme), ['', 'http', 'https'])) { throw new InvalidArgumentException('Scheme must be one of : "", "http" or "https"'); } $uri = clone $this; $uri->scheme = $scheme; return $uri; }
php
{ "resource": "" }
q266037
Uri.withUserInfo
test
public function withUserInfo($user, $password = null) { $uri = clone $this; $uri->user = $user; $uri->password = $password ?: ''; return $uri; }
php
{ "resource": "" }
q266038
Uri.withHost
test
public function withHost($host) { if (false) { // Invalid hostname ? throw new InvalidArgumentException('Hostname is not valid.'); } $uri = clone $this; $uri->host = $host; return $uri; }
php
{ "resource": "" }
q266039
Uri.withPort
test
public function withPort($port = null) { if ($port !== null && $port < 1 && $port > 65535) { throw new InvalidArgumentException( 'Port must be null or an integer between 1 and 65535' ); } $uri = clone $this; $uri->port = $port; return $uri; }
php
{ "resource": "" }
q266040
Net_URL2._queryArrayByKey
test
private function _queryArrayByKey($key, $value, array $array = array()) { if (!strlen($key)) { return $array; } $offset = $this->_queryKeyBracketOffset($key); if ($offset === false) { $name = $key; } else { $name = substr($key, 0, $offset); } if (!strlen($name)) { return $array; } if (!$offset) { // named value $array[$name] = $value; } else { // array $brackets = substr($key, $offset); if (!isset($array[$name])) { $array[$name] = null; } $array[$name] = $this->_queryArrayByBrackets( $brackets, $value, $array[$name] ); } return $array; }
php
{ "resource": "" }
q266041
Net_URL2._queryArrayByBrackets
test
private function _queryArrayByBrackets($buffer, $value, array $array = null) { $entry = &$array; for ($iteration = 0; strlen($buffer); $iteration++) { $open = $this->_queryKeyBracketOffset($buffer); if ($open !== 0) { // Opening bracket [ must exist at offset 0, if not, there is // no bracket to parse and the value dropped. // if this happens in the first iteration, this is flawed, see // as well the second exception below. if ($iteration) { break; } // @codeCoverageIgnoreStart throw new Exception( 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . 'Opening bracket [ must exist at offset 0' ); // @codeCoverageIgnoreEnd } $close = strpos($buffer, ']', 1); if (!$close) { // this error condition should never be reached as this is a // private method and bracket pairs are checked beforehand. // See as well the first exception for the opening bracket. // @codeCoverageIgnoreStart throw new Exception( 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . 'Closing bracket ] must exist, not found' ); // @codeCoverageIgnoreEnd } $index = substr($buffer, 1, $close - 1); if (strlen($index)) { $entry = &$entry[$index]; } else { if (!is_array($entry)) { $entry = array(); } $entry[] = &$new; $entry = &$new; unset($new); } $buffer = substr($buffer, $close + 1); } $entry = $value; return $array; }
php
{ "resource": "" }
q266042
Net_URL2.setQueryVariables
test
public function setQueryVariables(array $array) { if (!$array) { $this->_query = false; } else { $this->_query = $this->buildQuery( $array, $this->getOption(self::OPTION_SEPARATOR_OUTPUT) ); } return $this; }
php
{ "resource": "" }
q266043
Net_URL2.setQueryVariable
test
public function setQueryVariable($name, $value) { $array = $this->getQueryVariables(); $array[$name] = $value; $this->setQueryVariables($array); return $this; }
php
{ "resource": "" }
q266044
Net_URL2.getURL
test
public function getURL() { // See RFC 3986, section 5.3 $url = ''; if ($this->_scheme !== false) { $url .= $this->_scheme . ':'; } $url .= $this->_buildAuthorityAndPath($this->getAuthority(), $this->_path); if ($this->_query !== false) { $url .= '?' . $this->_query; } if ($this->_fragment !== false) { $url .= '#' . $this->_fragment; } return $url; }
php
{ "resource": "" }
q266045
Net_URL2.normalize
test
public function normalize() { // See RFC 3986, section 6 // Scheme is case-insensitive if ($this->_scheme) { $this->_scheme = strtolower($this->_scheme); } // Hostname is case-insensitive if ($this->_host) { $this->_host = strtolower($this->_host); } // Remove default port number for known schemes (RFC 3986, section 6.2.3) if ('' === $this->_port || $this->_port && $this->_scheme && $this->_port == getservbyname($this->_scheme, 'tcp') ) { $this->_port = false; } // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) // Normalize percentage-encoded unreserved characters (section 6.2.2.2) list($this->_userinfo, $this->_host, $this->_path) = preg_replace_callback( '((?:%[0-9a-fA-Z]{2})+)', array($this, '_normalizeCallback'), array($this->_userinfo, $this->_host, $this->_path) ); // Path segment normalization (RFC 3986, section 6.2.2.3) $this->_path = self::removeDotSegments($this->_path); // Scheme based normalization (RFC 3986, section 6.2.3) if (false !== $this->_host && '' === $this->_path) { $this->_path = '/'; } // path should start with '/' if there is authority (section 3.3.) if (strlen($this->getAuthority()) && strlen($this->_path) && $this->_path[0] !== '/' ) { $this->_path = '/' . $this->_path; } }
php
{ "resource": "" }
q266046
Net_URL2.resolve
test
public function resolve($reference) { if (!$reference instanceof Net_URL2) { $reference = new self($reference); } if (!$reference->_isFragmentOnly() && !$this->isAbsolute()) { throw new Exception( 'Base-URL must be absolute if reference is not fragment-only' ); } // A non-strict parser may ignore a scheme in the reference if it is // identical to the base URI's scheme. if (!$this->getOption(self::OPTION_STRICT) && $reference->_scheme == $this->_scheme ) { $reference->_scheme = false; } $target = new self(''); if ($reference->_scheme !== false) { $target->_scheme = $reference->_scheme; $target->setAuthority($reference->getAuthority()); $target->_path = self::removeDotSegments($reference->_path); $target->_query = $reference->_query; } else { $authority = $reference->getAuthority(); if ($authority !== false) { $target->setAuthority($authority); $target->_path = self::removeDotSegments($reference->_path); $target->_query = $reference->_query; } else { if ($reference->_path == '') { $target->_path = $this->_path; if ($reference->_query !== false) { $target->_query = $reference->_query; } else { $target->_query = $this->_query; } } else { if (substr($reference->_path, 0, 1) == '/') { $target->_path = self::removeDotSegments($reference->_path); } else { // Merge paths (RFC 3986, section 5.2.3) if ($this->_host !== false && $this->_path == '') { $target->_path = '/' . $reference->_path; } else { $i = strrpos($this->_path, '/'); if ($i !== false) { $target->_path = substr($this->_path, 0, $i + 1); } $target->_path .= $reference->_path; } $target->_path = self::removeDotSegments($target->_path); } $target->_query = $reference->_query; } $target->setAuthority($this->getAuthority()); } $target->_scheme = $this->_scheme; } $target->_fragment = $reference->_fragment; return $target; }
php
{ "resource": "" }
q266047
Net_URL2._isFragmentOnly
test
private function _isFragmentOnly() { return ( $this->_fragment !== false && $this->_query === false && $this->_path === '' && $this->_port === false && $this->_host === false && $this->_userinfo === false && $this->_scheme === false ); }
php
{ "resource": "" }
q266048
Net_URL2.getCanonical
test
public static function getCanonical() { if (!isset($_SERVER['REQUEST_METHOD'])) { // ALERT - no current URL throw new Exception('Script was not called through a webserver'); } // Begin with a relative URL $url = new self($_SERVER['PHP_SELF']); $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; $url->_host = $_SERVER['SERVER_NAME']; $port = $_SERVER['SERVER_PORT']; if ($url->_scheme == 'http' && $port != 80 || $url->_scheme == 'https' && $port != 443 ) { $url->_port = $port; } return $url; }
php
{ "resource": "" }
q266049
Net_URL2.getRequested
test
public static function getRequested() { if (!isset($_SERVER['REQUEST_METHOD'])) { // ALERT - no current URL throw new Exception('Script was not called through a webserver'); } // Begin with a relative URL $url = new self($_SERVER['REQUEST_URI']); $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; // Set host and possibly port $url->setAuthority($_SERVER['HTTP_HOST']); return $url; }
php
{ "resource": "" }
q266050
Net_URL2.getOption
test
public function getOption($optionName) { return isset($this->_options[$optionName]) ? $this->_options[$optionName] : false; }
php
{ "resource": "" }
q266051
Net_URL2.buildQuery
test
protected function buildQuery(array $data, $separator, $key = null) { $query = array(); foreach ($data as $name => $value) { if ($this->getOption(self::OPTION_ENCODE_KEYS) === true) { $name = rawurlencode($name); } if ($key !== null) { if ($this->getOption(self::OPTION_USE_BRACKETS) === true) { $name = $key . '[' . $name . ']'; } else { $name = $key; } } if (is_array($value)) { $query[] = $this->buildQuery($value, $separator, $name); } else { $query[] = $name . '=' . rawurlencode($value); } } return implode($separator, $query); }
php
{ "resource": "" }
q266052
Net_URL2.parseUrl
test
protected function parseUrl($url) { // The regular expression is copied verbatim from RFC 3986, appendix B. // The expression does not validate the URL but matches any string. preg_match( '(^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)', $url, $matches ); // "path" is always present (possibly as an empty string); the rest // are optional. $this->_scheme = !empty($matches[1]) ? $matches[2] : false; $this->setAuthority(!empty($matches[3]) ? $matches[4] : false); $this->_path = $this->_encodeData($matches[5]); $this->_query = !empty($matches[6]) ? $this->_encodeData($matches[7]) : false ; $this->_fragment = !empty($matches[8]) ? $matches[9] : false; }
php
{ "resource": "" }
q266053
Trace.display
test
public final function display(string $text, int $tab = 0, string $highlighter = "*") { $_tab = null; for ($index = 0; $index < $tab; $index++) { $_tab .= $this->tabSpace; } echo("(" . Date("Y-m-d H:i:s") . ") | {$_tab}{$highlighter} {$text}" . PHP_EOL); return null; }
php
{ "resource": "" }
q266054
TranslationPromise.translate
test
public function translate($language = null) { if (isset($language)) { $this->language = $language; } else { $this->suggestLanguage(); } return Reaction::t($this->category, $this->message, $this->params, $this->language); }
php
{ "resource": "" }
q266055
TranslationPromise.suggestLanguage
test
protected function suggestLanguage() { if (Reaction::isDebug()) { Reaction::warning(__METHOD__ . ' call. Avoid it for performance reasons.'); } $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS); $traceCount = count($trace) - 1; for ($i = $traceCount; $i >= 0; $i--) { if (!isset($trace[$i]['object']) || !$trace[$i]['object'] instanceof RequestLanguageGetterInterface) { continue; } /** @var RequestLanguageGetterInterface $object */ $object = $trace[$i]['object']; $this->language = $object->getRequestLanguage(); break; } }
php
{ "resource": "" }
q266056
AutomatedTrait.getNewStateList
test
private function getNewStateList(): array { $statesList = []; foreach ($this->getStatesAssertions() as $stateAssertion) { if ($stateAssertion->isValid($this)) { $statesList = \array_merge( $statesList, \array_flip($stateAssertion->getStatesList()) ); } } return \array_keys($statesList); }
php
{ "resource": "" }
q266057
AutomatedTrait.filterStatesNames
test
private function filterStatesNames(array &$newStateList): AutomatedInterface { foreach ($newStateList as &$stateName) { $this->validateName($stateName); } return $this; }
php
{ "resource": "" }
q266058
AutomatedTrait.switchToNewStates
test
private function switchToNewStates(array $newStateList): AutomatedInterface { $this->filterStatesNames($newStateList); $lastEnabledStates = $this->listEnabledStates(); $outgoingStates = \array_diff($lastEnabledStates, $newStateList); foreach ($outgoingStates as $stateName) { //disable older states $this->disableState($stateName); } $incomingStates = \array_diff($newStateList, $lastEnabledStates); foreach ($incomingStates as $stateName) { //enable missing states $this->enableState($stateName); } return $this; }
php
{ "resource": "" }
q266059
BudgetCategoryMapper.findAllByBudgetId
test
public function findAllByBudgetId($budgetId) { $budgetId = (int) $budgetId; $this->addWhere('budget_id', $budgetId); $list = $this->select(); $collection = array(); foreach ($list as $item) { $collection[$item->getCategoryId()] = $item; } return $collection; }
php
{ "resource": "" }
q266060
SecurityController.actionLogin
test
public function actionLogin() { if (!Yii::$app->user->isGuest) { $this->goHome(); } /** @var LoginForm $model */ $model = Yii::createObject(LoginForm::className()); $event = $this->getFormEvent($model); $this->performAjaxValidation($model); $this->trigger(self::EVENT_BEFORE_LOGIN, $event); if ($model->load(Yii::$app->getRequest()->post()) && $model->login()) { $this->trigger(self::EVENT_AFTER_LOGIN, $event); return $this->goBack(); } return $this->render('login', [ 'model' => $model, 'module' => $this->module, ]); }
php
{ "resource": "" }
q266061
SecurityController.actionLogout
test
public function actionLogout() { $event = $this->getUserEvent(Yii::$app->user->identity); $this->trigger(self::EVENT_BEFORE_LOGOUT, $event); Yii::$app->getUser()->logout(); $this->trigger(self::EVENT_AFTER_LOGOUT, $event); return $this->goHome(); }
php
{ "resource": "" }
q266062
SecurityController.connect
test
public function connect(ClientInterface $client) { /** @var Account $account */ $account = Yii::createObject(Account::className()); $event = $this->getAuthEvent($account, $client); $this->trigger(self::EVENT_BEFORE_CONNECT, $event); $account->connectWithUser($client); $this->trigger(self::EVENT_AFTER_CONNECT, $event); $this->action->successUrl = Url::to(['/user/settings/networks']); }
php
{ "resource": "" }
q266063
Mail_mime.getParam
test
function getParam($name) { return isset($this->_build_params[$name]) ? $this->_build_params[$name] : null; }
php
{ "resource": "" }
q266064
Mail_mime.setHTMLBody
test
function setHTMLBody($data, $isfile = false) { if (!$isfile) { $this->_htmlbody = $data; } else { $cont = $this->_file2str($data); if ($this->_isError($cont)) { return $cont; } $this->_htmlbody = $cont; } return true; }
php
{ "resource": "" }
q266065
Mail_mime.addHTMLImage
test
function addHTMLImage($file, $c_type='application/octet-stream', $name = '', $isfile = true, $content_id = null ) { $bodyfile = null; if ($isfile) { // Don't load file into memory if ($this->_build_params['delay_file_io']) { $filedata = null; $bodyfile = $file; } else { if ($this->_isError($filedata = $this->_file2str($file))) { return $filedata; } } $filename = ($name ? $name : $file); } else { $filedata = $file; $filename = $name; } if (!$content_id) { $content_id = preg_replace('/[^0-9a-zA-Z]/', '', uniqid(time(), true)); } $this->_html_images[] = array( 'body' => $filedata, 'body_file' => $bodyfile, 'name' => $filename, 'c_type' => $c_type, 'cid' => $content_id ); return true; }
php
{ "resource": "" }
q266066
Mail_mime.addAttachment
test
function addAttachment($file, $c_type = 'application/octet-stream', $name = '', $isfile = true, $encoding = 'base64', $disposition = 'attachment', $charset = '', $language = '', $location = '', $n_encoding = null, $f_encoding = null, $description = '', $h_charset = null, $add_headers = array() ) { $bodyfile = null; if ($isfile) { // Don't load file into memory if ($this->_build_params['delay_file_io']) { $filedata = null; $bodyfile = $file; } else { if ($this->_isError($filedata = $this->_file2str($file))) { return $filedata; } } // Force the name the user supplied, otherwise use $file $filename = ($name ? $name : $this->_basename($file)); } else { $filedata = $file; $filename = $name; } if (!strlen($filename)) { $msg = "The supplied filename for the attachment can't be empty"; return $this->_raiseError($msg); } $this->_parts[] = array( 'body' => $filedata, 'body_file' => $bodyfile, 'name' => $filename, 'c_type' => $c_type, 'charset' => $charset, 'encoding' => $encoding, 'language' => $language, 'location' => $location, 'disposition' => $disposition, 'description' => $description, 'add_headers' => $add_headers, 'name_encoding' => $n_encoding, 'filename_encoding' => $f_encoding, 'headers_charset' => $h_charset, ); return true; }
php
{ "resource": "" }
q266067
Mail_mime._file2str
test
function _file2str($file_name) { // Check state of file and raise an error properly if (!file_exists($file_name)) { return $this->_raiseError('File not found: ' . $file_name); } if (!is_file($file_name)) { return $this->_raiseError('Not a regular file: ' . $file_name); } if (!is_readable($file_name)) { return $this->_raiseError('File is not readable: ' . $file_name); } // Temporarily reset magic_quotes_runtime and read file contents if ($magic_quote_setting = get_magic_quotes_runtime()) { @ini_set('magic_quotes_runtime', 0); } $cont = file_get_contents($file_name); if ($magic_quote_setting) { @ini_set('magic_quotes_runtime', $magic_quote_setting); } return $cont; }
php
{ "resource": "" }
q266068
Mail_mime.&
test
function &_addTextPart(&$obj = null, $text = '') { $params['content_type'] = 'text/plain'; $params['encoding'] = $this->_build_params['text_encoding']; $params['charset'] = $this->_build_params['text_charset']; $params['eol'] = $this->_build_params['eol']; if (is_object($obj)) { $ret = $obj->addSubpart($text, $params); } else { $ret = new Mail_mimePart($text, $params); } return $ret; }
php
{ "resource": "" }
q266069
Mail_mime.&
test
function &_addHtmlPart(&$obj = null) { $params['content_type'] = 'text/html'; $params['encoding'] = $this->_build_params['html_encoding']; $params['charset'] = $this->_build_params['html_charset']; $params['eol'] = $this->_build_params['eol']; if (is_object($obj)) { $ret = $obj->addSubpart($this->_htmlbody, $params); } else { $ret = new Mail_mimePart($this->_htmlbody, $params); } return $ret; }
php
{ "resource": "" }
q266070
Mail_mime.&
test
function &_addHtmlImagePart(&$obj, $value) { $params['content_type'] = $value['c_type']; $params['encoding'] = 'base64'; $params['disposition'] = 'inline'; $params['filename'] = $value['name']; $params['cid'] = $value['cid']; $params['body_file'] = $value['body_file']; $params['eol'] = $this->_build_params['eol']; if (!empty($value['name_encoding'])) { $params['name_encoding'] = $value['name_encoding']; } if (!empty($value['filename_encoding'])) { $params['filename_encoding'] = $value['filename_encoding']; } $ret = $obj->addSubpart($value['body'], $params); return $ret; }
php
{ "resource": "" }
q266071
Mail_mime.&
test
function &_addAttachmentPart(&$obj, $value) { $params['eol'] = $this->_build_params['eol']; $params['filename'] = $value['name']; $params['encoding'] = $value['encoding']; $params['content_type'] = $value['c_type']; $params['body_file'] = $value['body_file']; $params['disposition'] = isset($value['disposition']) ? $value['disposition'] : 'attachment'; // content charset if (!empty($value['charset'])) { $params['charset'] = $value['charset']; } // headers charset (filename, description) if (!empty($value['headers_charset'])) { $params['headers_charset'] = $value['headers_charset']; } if (!empty($value['language'])) { $params['language'] = $value['language']; } if (!empty($value['location'])) { $params['location'] = $value['location']; } if (!empty($value['name_encoding'])) { $params['name_encoding'] = $value['name_encoding']; } if (!empty($value['filename_encoding'])) { $params['filename_encoding'] = $value['filename_encoding']; } if (!empty($value['description'])) { $params['description'] = $value['description']; } if (is_array($value['add_headers'])) { $params['headers'] = $value['add_headers']; } $ret = $obj->addSubpart($value['body'], $params); return $ret; }
php
{ "resource": "" }
q266072
Mail_mime._encodeHeaders
test
function _encodeHeaders($input, $params = array()) { $build_params = $this->_build_params; while (list($key, $value) = each($params)) { $build_params[$key] = $value; } foreach ($input as $hdr_name => $hdr_value) { if (is_array($hdr_value)) { foreach ($hdr_value as $idx => $value) { $input[$hdr_name][$idx] = $this->encodeHeader( $hdr_name, $value, $build_params['head_charset'], $build_params['head_encoding'] ); } } else { $input[$hdr_name] = $this->encodeHeader( $hdr_name, $hdr_value, $build_params['head_charset'], $build_params['head_encoding'] ); } } return $input; }
php
{ "resource": "" }
q266073
Mail_mime._checkParams
test
function _checkParams() { $encodings = array('7bit', '8bit', 'base64', 'quoted-printable'); $this->_build_params['text_encoding'] = strtolower($this->_build_params['text_encoding']); $this->_build_params['html_encoding'] = strtolower($this->_build_params['html_encoding']); if (!in_array($this->_build_params['text_encoding'], $encodings)) { $this->_build_params['text_encoding'] = '7bit'; } if (!in_array($this->_build_params['html_encoding'], $encodings)) { $this->_build_params['html_encoding'] = '7bit'; } // text body if ($this->_build_params['text_encoding'] == '7bit' && !preg_match('/ascii/i', $this->_build_params['text_charset']) && preg_match('/[^\x00-\x7F]/', $this->_txtbody) ) { $this->_build_params['text_encoding'] = 'quoted-printable'; } // html body if ($this->_build_params['html_encoding'] == '7bit' && !preg_match('/ascii/i', $this->_build_params['html_charset']) && preg_match('/[^\x00-\x7F]/', $this->_htmlbody) ) { $this->_build_params['html_encoding'] = 'quoted-printable'; } }
php
{ "resource": "" }
q266074
Validator.check
test
public function check($value) { if ($this->hasError($value)) { $this->error = sprintf($this->errorTpl, (string) $value); return false; } return true; }
php
{ "resource": "" }
q266075
PhpManager.init
test
public function init() { parent::init(); $this->itemFile = Reaction::$app->getAlias($this->itemFile); $this->assignmentFile = Reaction::$app->getAlias($this->assignmentFile); $this->ruleFile = Reaction::$app->getAlias($this->ruleFile); $this->load(); }
php
{ "resource": "" }
q266076
PhpManager.load
test
protected function load() { $this->children = []; $this->rules = []; $this->assignments = []; $this->items = []; $items = $this->loadFromFile($this->itemFile); $itemsMtime = @filemtime($this->itemFile); $assignments = $this->loadFromFile($this->assignmentFile); $assignmentsMtime = @filemtime($this->assignmentFile); $rules = $this->loadFromFile($this->ruleFile); foreach ($items as $name => $item) { $class = $item['type'] == Item::TYPE_PERMISSION ? Permission::class : Role::class; $this->items[$name] = new $class([ 'name' => $name, 'description' => isset($item['description']) ? $item['description'] : null, 'ruleName' => isset($item['ruleName']) ? $item['ruleName'] : null, 'data' => isset($item['data']) ? $item['data'] : null, 'createdAt' => $itemsMtime, 'updatedAt' => $itemsMtime, ]); } foreach ($items as $name => $item) { if (isset($item['children'])) { foreach ($item['children'] as $childName) { if (isset($this->items[$childName])) { $this->children[$name][$childName] = $this->items[$childName]; } } } } foreach ($assignments as $userId => $roles) { foreach ($roles as $role) { $this->assignments[$userId][$role] = new Assignment([ 'userId' => $userId, 'roleName' => $role, 'createdAt' => $assignmentsMtime, ]); } } foreach ($rules as $name => $ruleData) { $this->rules[$name] = unserialize($ruleData); } }
php
{ "resource": "" }
q266077
PhpManager.save
test
protected function save() { $promises = [ $this->saveItems(), $this->saveAssignments(), $this->saveRules(), ]; return all($promises); }
php
{ "resource": "" }
q266078
PhpManager.saveToFile
test
protected function saveToFile($data, $filePath) { $fileContent = "<?php\nreturn " . VarDumper::export($data) . ";\n"; $self = $this; return Reaction\Helpers\FileHelperAsc::putContents($filePath, $fileContent, 'cwt')->then( function() use ($self, $filePath) { $self->invalidateScriptCache($filePath); } ); }
php
{ "resource": "" }
q266079
NativeJsonResponse.createJson
test
public static function createJson( string $content = '', int $status = StatusCode::OK, array $headers = [], array $data = [] ): JsonResponse { return new static($content, $status, $headers, $data); }
php
{ "resource": "" }
q266080
NativeJsonResponse.setCallback
test
public function setCallback(string $callback = null): JsonResponse { if (null !== $callback) { // taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/ $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u'; $parts = explode('.', $callback); foreach ($parts as $part) { if (! preg_match($pattern, $part)) { throw new \InvalidArgumentException( 'The callback name is not valid.' ); } } } $this->callback = $callback; return $this->update(); }
php
{ "resource": "" }
q266081
NativeJsonResponse.setEncodingOptions
test
public function setEncodingOptions(int $encodingOptions): JsonResponse { $this->encodingOptions = $encodingOptions; return $this->setData(json_decode($this->data)); }
php
{ "resource": "" }
q266082
Error.getLayout
test
protected function getLayout(TemplateInterface $template) { $layout = new Template($this->layoutPath . EKA_SEP . 'Main'); $layout->setVar('content', $template->render()); $layout->setVar('meta', Config::getInstance()->get('Eureka\Meta')); return $layout; }
php
{ "resource": "" }
q266083
Category.getWordsAsString
test
public function getWordsAsString() { $words = array(); foreach ($this->getAllCategoryWord() as $word) { $words[] = $word->getName(); } return implode(', ', $words); }
php
{ "resource": "" }
q266084
TableGateaway.update
test
public function update($sessionEntity, $data) { return $this->storageManager->update( $data, [ $this->options->getIdColumn() => $this->getIdValue($sessionEntity), $this->options->getNameColumn() => $this->getNameValue($sessionEntity) ] ); }
php
{ "resource": "" }
q266085
TableGateaway.delete
test
public function delete($sessionEntity) { return (bool) $this->storageManager->delete( [ $this->options->getIdColumn() => $this->getIdValue($sessionEntity), $this->options->getNameColumn() => $this->getNameValue($sessionEntity) ] ); }
php
{ "resource": "" }
q266086
ConfigPmTrait.configurePMOptions
test
protected function configurePMOptions(Command $command) { $iniMemLimit = ceil($this->getIniMemoryLimit() * 0.9); $command ->addOption('bridge', null, InputOption::VALUE_REQUIRED, 'Bridge for converting React Psr7 requests to target framework.', 'ReactionBridge') ->addOption('host', null, InputOption::VALUE_REQUIRED, 'Load-Balancer host. Default is 127.0.0.1', '127.0.0.1') ->addOption('port', null, InputOption::VALUE_REQUIRED, 'Load-Balancer port. Default is 8080', 8080) ->addOption('workers', null, InputOption::VALUE_REQUIRED, 'Worker count. Default is 8. Should be minimum equal to the number of CPU cores.', 8) ->addOption('app-env', null, InputOption::VALUE_REQUIRED, 'The environment that your application will use to bootstrap (if any)', 'dev') ->addOption('debug', null, InputOption::VALUE_REQUIRED, 'Enable/Disable debugging so that your application is more verbose, enables also hot-code reloading. 1|0', 0) ->addOption('logging', null, InputOption::VALUE_REQUIRED, 'Enable/Disable http logging to stdout. 1|0', 1) ->addOption('static-directory', null, InputOption::VALUE_REQUIRED, 'Static files root directory, if not provided static files will not be served', '') ->addOption('max-requests', null, InputOption::VALUE_REQUIRED, 'Max requests per worker until it will be restarted', 1000) ->addOption('ttl', null, InputOption::VALUE_REQUIRED, 'Time to live for a worker until it will be restarted', null) ->addOption('populate-server-var', null, InputOption::VALUE_REQUIRED, 'If a worker application uses $_SERVER var it needs to be populated by request data 1|0', 1) ->addOption('bootstrap', null, InputOption::VALUE_REQUIRED, 'Class responsible for bootstrapping the application', 'Reaction\PM\Bootstraps\ReactionBootstrap') ->addOption('cli-path', null, InputOption::VALUE_REQUIRED, 'Full path to the php-cli executable', false) ->addOption('socket-path', null, InputOption::VALUE_REQUIRED, 'Path to a folder where socket files will be placed. Relative to working-directory or cwd()', '.pm/run/') ->addOption('pidfile', null, InputOption::VALUE_REQUIRED, 'Path to a file where the pid of the master process is going to be stored', '.pm/pm.pid') ->addOption('reload-timeout', null, InputOption::VALUE_REQUIRED, 'The number of seconds to wait before force closing a worker during a reload, or -1 to disable. Default: 30', 30) ->addOption('max-memory-usage', null, InputOption::VALUE_REQUIRED, 'The number of slave memory usage in bytes until it will be restarted, or 0 to disable.', $iniMemLimit) ->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Path to config file', ''); }
php
{ "resource": "" }
q266087
ConfigPmTrait.loadPmConfig
test
protected function loadPmConfig(InputInterface $input, OutputInterface $output) { $config = []; if ($path = $this->getPmConfigPath($input)) { $content = file_get_contents($path); $config = json_decode($content, true); } $config['bridge'] = $this->optionOrConfigValue($input, $config, 'bridge'); $config['host'] = $this->optionOrConfigValue($input, $config, 'host'); $config['port'] = (int)$this->optionOrConfigValue($input, $config, 'port'); $config['workers'] = (int)$this->optionOrConfigValue($input, $config, 'workers'); $config['app-env'] = $this->optionOrConfigValue($input, $config, 'app-env'); $config['debug'] = $this->optionOrConfigValue($input, $config, 'debug'); $config['logging'] = $this->optionOrConfigValue($input, $config, 'logging'); $config['static-directory'] = $this->optionOrConfigValue($input, $config, 'static-directory'); $config['bootstrap'] = $this->optionOrConfigValue($input, $config, 'bootstrap'); $config['max-requests'] = (int)$this->optionOrConfigValue($input, $config, 'max-requests'); $config['ttl'] = (int)$this->optionOrConfigValue($input, $config, 'ttl'); $config['populate-server-var'] = (boolean)$this->optionOrConfigValue($input, $config, 'populate-server-var'); $config['socket-path'] = $this->optionOrConfigValue($input, $config, 'socket-path'); $config['pidfile'] = $this->optionOrConfigValue($input, $config, 'pidfile'); $config['reload-timeout'] = $this->optionOrConfigValue($input, $config, 'reload-timeout'); $config['max-memory-usage'] = $this->optionOrConfigValue($input, $config, 'max-memory-usage'); $config['cli-path'] = $this->optionOrConfigValue($input, $config, 'cli-path'); if (false === $config['cli-path']) { //not set in config nor in command options -> autodetect path $executableFinder = new PhpExecutableFinder(); $binary = $executableFinder->find(); $config['cli-path'] = $binary; if (false === $config['cli-path']) { $output->writeln('<error>PPM could find a php-cli path. Please specify by --cli-path=</error>'); exit(1); } } return $config; }
php
{ "resource": "" }
q266088
ConfigPmTrait.getIniMemoryLimit
test
private function getIniMemoryLimit() { $iniMemLimit = ini_get('memory_limit'); if (!is_numeric($iniMemLimit)) { $iniSuffix = strtoupper(substr($iniMemLimit, -1)); $iniMemLimit = substr($iniMemLimit, 0, -1); $iniMultiplier = 1024; //K $iniMultiplier = $iniSuffix === 'M' ? $iniMultiplier * 1024 : $iniMultiplier * 1024 * 1024; //M || G $iniMemLimit *= $iniMultiplier; } return (int)$iniMemLimit; }
php
{ "resource": "" }
q266089
ModelBoundLeaf.onModelCreated
test
protected function onModelCreated() { parent::onModelCreated(); if ($this->incomingRestModel instanceof Model){ $this->setRestModel($this->incomingRestModel); } elseif ($this->incomingRestModel instanceof Collection){ $this->setRestCollection($this->incomingRestModel); } $this->model->createSubLeafFromNameEvent->attachHandler(function($leafName){ if (!$this->hasRestModelOrCollection) { return null; } $restModel = $this->model->restModel; if ($restModel) { $class = $restModel->getModelName(); $schema = $restModel->getSchema(); } else { $restCollection = $this->model->restCollection; $class = $restCollection->getModelClassName(); $schema = $restCollection->getModelSchema(); } $leaf = $this->createLeafForLeafName($leafName); if ($leaf){ return $leaf; } // See if the model has a relationship with this name. $relationships = SolutionSchema::getAllOneToOneRelationshipsForModelBySourceColumnName($class); $columnRelationships = false; if (isset($relationships[$leafName])) { $columnRelationships = $relationships[$leafName]; } else { if ($leafName == $schema->uniqueIdentifierColumnName) { if (isset($relationships[""])) { $columnRelationships = $relationships[""]; } } } if ($columnRelationships) { $relationship = $relationships[$leafName]; $collection = $relationship->getCollection(); $dropDown = new DropDown($leafName); $dropDown->setSelectionItems( [ ["", "Please Select"], $collection ] ); $dropDown->setLabel(StringTools::wordifyStringByUpperCase($relationship->getNavigationPropertyName())); return $dropDown; } $columns = $schema->getColumns(); if (!isset($columns[$leafName])) { return null; } $column = $columns[$leafName]; return $this->createLeafFromColumn($column, $leafName); }); }
php
{ "resource": "" }
q266090
AbstractTool.render
test
public function render() { $args = $this->buildViewParams(); if (isset($args['output'])) $this->output = $args['output']; if (!empty($this->view)) { return FrontController::getInstance() ->view( DirectoryHelper::slashDirname($this->views_dir).$this->view, $args ); } elseif (isset($this->output)) { return $this->output; } else { throw new RuntimeException("Tool '".get_class($this)."' do not render anything !"); } }
php
{ "resource": "" }
q266091
Application.addPlugin
test
public function addPlugin(IPlugin $plugin, $autoExecute = false) { if (isset($this[$plugin->getPluginName()])) { return $this; } $plugin->setApplication($this); $plugin->initPlugin(); if ($autoExecute) { $this->{$plugin->getPluginName()}; } return $this; }
php
{ "resource": "" }
q266092
Application.config
test
public function config($key) { $keys = explode('.', $key); $config = func_num_args() === 1 ? $this['config'] : func_get_arg(1); while (($k = array_shift($keys)) !== null) { if (array_key_exists($k, $config)) { return count($keys) > 0 ? $this->config(implode('.', $keys), $config[$k]) : $config[$k]; } else { return null; } } }
php
{ "resource": "" }
q266093
Application.url
test
public function url($name, array $params = []) { $uri = $this->uri($name, $params); return sprintf('//%s/%s', $this->request()->getHttpHost(), ltrim($uri)); }
php
{ "resource": "" }
q266094
Application.get
test
public function get($route, $callable, $name = null, array $events = null) { $this['router']->map('GET', $route, $callable, $name); if ($name && is_array($events)) { $this->routeEvents[$name] = $events; } return $this; }
php
{ "resource": "" }
q266095
Application.html
test
public function html($content = null, $status = 200) { $r = new Response($content, $status); $r->headers->set('Content-Type', 'text/html; charset=utf-8'); $r->setCharset('UTF-8'); return $r; }
php
{ "resource": "" }
q266096
Application.redirect
test
public function redirect($url = null, $status = 302) { $r = new RedirectResponse($url, $status); $r->setCharset('UTF-8'); return $r; }
php
{ "resource": "" }
q266097
PathSegmentsAwareTrait._setPathSegments
test
protected function _setPathSegments($segments) { /* * `PathSegmentsAwareInterface#getPathSegments()` disallows `stdClass`. */ if ($segments instanceof stdClass) { $segments = (array) $segments; } $segments = $this->_normalizeIterable($segments); $this->pathSegments = $segments; }
php
{ "resource": "" }
q266098
ProxyBuilder.getProxy
test
public function getProxy() { include_once(__DIR__ . '/Generator.php'); $proxyClass = Generator::generate( $this->className, $this->methods, $this->properties, $this->proxyClassName, $this->autoload ); $classname = $proxyClass['proxyClassName']; if (!empty($proxyClass['namespaceName'])) { $classname = $proxyClass['namespaceName'] . '\\' . $proxyClass['proxyClassName']; } if (!class_exists($classname, false)) { eval($proxyClass['code']); } if ($this->invokeOriginalConstructor && !interface_exists($this->className, $this->autoload)) { if (empty($this->constructorArgs)) { return new $classname(); } $proxy = new \ReflectionClass($classname); return $proxy->newInstanceArgs($this->constructorArgs); } return $this->getInstanceOf($classname); }
php
{ "resource": "" }
q266099
ProxyBuilder.getInstanceOf
test
protected function getInstanceOf($classname) { // As of PHP5.4 the reflection api provides a way to get an instance // of a class without invoking the constructor. if (method_exists('ReflectionClass', 'newInstanceWithoutConstructor')) { $reflectedClass = new \ReflectionClass($classname); return $reflectedClass->newInstanceWithoutConstructor(); } // Use a trick to create a new object of a class // without invoking its constructor. return unserialize( sprintf( 'O:%d:"%s":0:{}', strlen($classname), $classname ) ); }
php
{ "resource": "" }