_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
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
php
{ "resource": "" }
q266001
Table.getPrimaryKey
test
public function getPrimaryKey() { if ($this->primary_key === null) { $pks = $this->getPrimaryKeys(); if (count($pks) > 1) { throw new
php
{ "resource": "" }
q266002
Table.getColumnsInformation
test
public function getColumnsInformation() { if ($this->column_information === null) { $this->column_information = $this->tableManager ->metadata()
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);
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");
php
{ "resource": "" }
q266005
Table.checkDataColumns
test
protected function checkDataColumns(array $data) { $diff = array_diff_key($data, $this->getColumnsInformation()); if (count($diff) > 0)
php
{ "resource": "" }
q266006
Api.parseAsArray
test
protected function parseAsArray($content) { $data = json_decode($content, true); return array( isset($data['status']) ? $data['status'] : false,
php
{ "resource": "" }
q266007
Api.parseAsObject
test
protected function parseAsObject($content) { $data = json_decode($content); return array( property_exists($data, 'status') ? $data->status : false,
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
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']); }
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']);
php
{ "resource": "" }
q266011
MoveBuilder.is
test
public function is($type) { if (null !== $this->type) {
php
{ "resource": "" }
q266012
MoveBuilder.named
test
public function named($name) { if (null !== $this->name) { throw new LogicException('Already named'); }
php
{ "resource": "" }
q266013
MoveBuilder.start
test
public function start($position) { if (null !== $this->initialPosition) { throw new LogicException('Start already defined');
php
{ "resource": "" }
q266014
MoveBuilder.deal
test
public function deal($damage) { if (null !== $this->damage) {
php
{ "resource": "" }
q266015
MoveBuilder.aim
test
public function aim($hitLevel) { if (null !== $this->hitLevel) { throw
php
{ "resource": "" }
q266016
MoveBuilder.withMeterGain
test
public function withMeterGain($value) { if (null !== $this->meterGain) { throw new LogicException('Meter gain already defined');
php
{ "resource": "" }
q266017
MoveBuilder.withInputs
test
public function withInputs($inputs) { if (0 < count($this->inputs)) { throw new LogicException('Inputs already defined'); }
php
{ "resource": "" }
q266018
MoveBuilder.addCancel
test
public function addCancel(MoveInterface $move) { foreach ($this->cancelAbilities as $cancelAbility) { if ($cancelAbility->equals($move)) { throw new LogicException(
php
{ "resource": "" }
q266019
MoveBuilder.startIn
test
public function startIn($frames) { if (null !== $this->startFrames) {
php
{ "resource": "" }
q266020
MoveBuilder.activeDuring
test
public function activeDuring($frames) { if (null !== $this->activeFrames) { throw new LogicException('Active frames already defined');
php
{ "resource": "" }
q266021
MoveBuilder.recoverIn
test
public function recoverIn($frames) { if (null !== $this->recoveryFrames) {
php
{ "resource": "" }
q266022
MoveBuilder.advantageOnHit
test
public function advantageOnHit($frames) { if (null !== $this->hitAdvantage) { throw new LogicException('Hit advantage already defined');
php
{ "resource": "" }
q266023
MoveBuilder.advantageOnGuard
test
public function advantageOnGuard($frames) { if (null !== $this->guardAdvantage) { throw new LogicException('Guard advantage already defined');
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,
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') {
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) {
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']
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); }
php
{ "resource": "" }
q266029
NativePathGenerator.findParamSegment
test
protected function findParamSegment(array $segments, string $param): ? string { $segment = null; foreach ($segments as $segment) { if
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]"))
php
{ "resource": "" }
q266031
ClassName.validate
test
private function validate($name): void { try { new ReflectionClass($name); } catch(ReflectionException $ex) { throw
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);
php
{ "resource": "" }
q266033
ImageModel.count
test
public function count() { $_new_dir = new DirectoryModel; $_new_dir->setPath( dirname($this->getPath()) );
php
{ "resource": "" }
q266034
RequestHelper.getConsolePathInfo
test
protected function getConsolePathInfo() { if (!isset($this->_route)) { $data
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];
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"
php
{ "resource": "" }
q266037
Uri.withUserInfo
test
public function withUserInfo($user, $password = null) { $uri = clone $this; $uri->user = $user;
php
{ "resource": "" }
q266038
Uri.withHost
test
public function withHost($host) { if (false) { // Invalid hostname ? throw new InvalidArgumentException('Hostname is not valid.'); }
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'
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
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.
php
{ "resource": "" }
q266042
Net_URL2.setQueryVariables
test
public function setQueryVariables(array $array) { if (!$array) { $this->_query = false; } else { $this->_query = $this->buildQuery( $array,
php
{ "resource": "" }
q266043
Net_URL2.setQueryVariable
test
public function setQueryVariable($name, $value) { $array = $this->getQueryVariables(); $array[$name] = $value;
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(),
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'),
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
php
{ "resource": "" }
q266047
Net_URL2._isFragmentOnly
test
private function _isFragmentOnly() { return ( $this->_fragment !== false && $this->_query === false && $this->_path === '' && $this->_port === 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 =
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
php
{ "resource": "" }
q266050
Net_URL2.getOption
test
public function getOption($optionName) { return isset($this->_options[$optionName])
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 {
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
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;
php
{ "resource": "" }
q266054
TranslationPromise.translate
test
public function translate($language = null) { if (isset($language)) { $this->language = $language; } else { $this->suggestLanguage(); }
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']) ||
php
{ "resource": "" }
q266056
AutomatedTrait.getNewStateList
test
private function getNewStateList(): array { $statesList = []; foreach ($this->getStatesAssertions() as $stateAssertion) { if ($stateAssertion->isValid($this)) { $statesList = \array_merge(
php
{ "resource": "" }
q266057
AutomatedTrait.filterStatesNames
test
private function filterStatesNames(array &$newStateList): AutomatedInterface { foreach ($newStateList as &$stateName) {
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
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) {
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()) {
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();
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);
php
{ "resource": "" }
q266063
Mail_mime.getParam
test
function getParam($name) { return isset($this->_build_params[$name])
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)) {
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) {
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; }
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); }
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'];
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)) {
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']))
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)
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) {
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'])
php
{ "resource": "" }
q266074
Validator.check
test
public function check($value) { if ($this->hasError($value)) { $this->error = sprintf($this->errorTpl, (string) $value);
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);
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'])) {
php
{ "resource": "" }
q266077
PhpManager.save
test
protected function save() { $promises = [ $this->saveItems(), $this->saveAssignments(),
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(
php
{ "resource": "" }
q266079
NativeJsonResponse.createJson
test
public static function createJson( string $content = '', int $status = StatusCode::OK, array $headers = [],
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)) {
php
{ "resource": "" }
q266081
NativeJsonResponse.setEncodingOptions
test
public function setEncodingOptions(int $encodingOptions): JsonResponse {
php
{ "resource": "" }
q266082
Error.getLayout
test
protected function getLayout(TemplateInterface $template) { $layout = new Template($this->layoutPath . EKA_SEP . 'Main'); $layout->setVar('content', $template->render());
php
{ "resource": "" }
q266083
Category.getWordsAsString
test
public function getWordsAsString() { $words = array(); foreach ($this->getAllCategoryWord() as
php
{ "resource": "" }
q266084
TableGateaway.update
test
public function update($sessionEntity, $data) { return $this->storageManager->update( $data, [
php
{ "resource": "" }
q266085
TableGateaway.delete
test
public function delete($sessionEntity) { return (bool) $this->storageManager->delete( [ $this->options->getIdColumn() => $this->getIdValue($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',
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');
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
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 =
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()
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();
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
php
{ "resource": "" }
q266093
Application.url
test
public function url($name, array $params = []) { $uri = $this->uri($name, $params);
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)) {
php
{ "resource": "" }
q266095
Application.html
test
public function html($content = null, $status = 200) { $r = new Response($content, $status); $r->headers->set('Content-Type',
php
{ "resource": "" }
q266096
Application.redirect
test
public function redirect($url = null, $status = 302) { $r = new RedirectResponse($url, $status);
php
{ "resource": "" }
q266097
PathSegmentsAwareTrait._setPathSegments
test
protected function _setPathSegments($segments) { /* * `PathSegmentsAwareInterface#getPathSegments()` disallows `stdClass`. */ if ($segments instanceof stdClass) { $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)) {
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();
php
{ "resource": "" }