_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q239000
ServiceContainer.boot
train
public function boot(): void { if(count($this->queue) !== 0) { throw new ServiceDependenciesNotRegisteredException($this->queue); } foreach($this->services as $service) { $service->boot(); } }
php
{ "resource": "" }
q239001
Auth.handleLogin
train
public function handleLogin(array $request = []) { $validator = new \Valitron\Validator($request); $validator->rule('required', ['username', 'password']); $validator->rule(function ($field, $value, array $params, array $fields) { return is_string($value); }, ['username', ...
php
{ "resource": "" }
q239002
Auth.handleRegister
train
public function handleRegister(array $request = []) { $validator = new \Valitron\Validator($request); $validator->rule('required', ['username', 'password', 'confirm_password']); $validator->rule(function ($field, $value, array $params, array $fields) { return is_string($value); ...
php
{ "resource": "" }
q239003
Auth.handleForgot
train
public function handleForgot(array $request = []) { $validator = new \Valitron\Validator($request); $validator->rule('required', 'email'); $validator->rule('email', 'email'); if ($validator->validate() === false) { if (headers_sent() === false) { header('X...
php
{ "resource": "" }
q239004
Auth.showReset
train
public function showReset(string $reset_code = null) { if ($reset_code === null) { if (isset($_GET['template']) === false) { return redirect($this->router->generate('login-page') . "?m=3"); } else { return 'Redirect: ' . $this->router->generate('login-...
php
{ "resource": "" }
q239005
DBObject.executeUpdate
train
protected function executeUpdate($sql,$bindparams=NULL) { $result = $this->db->handle->prepare($sql); $result->execute($bindparams); if ($result->errorCode() == '00000') { return true; } $this->logStatementError($result->errorInfo(),$sql); return false; }
php
{ "resource": "" }
q239006
DBObject.queryWithIndex
train
protected function queryWithIndex($sql,$index,$findex=NULL,$bindparams=NULL) { if ($result = $this->executeQuery($sql,$bindparams)) { $temp = array(); if ($findex) { foreach ($result as $row) { $temp[$row[$findex]][$row[$index]] = $row; } } else { foreach ($result as $row) { $temp[$row[...
php
{ "resource": "" }
q239007
DBObject.buildIn
train
protected function buildIn($ar,&$bindparams,$varprefix = 'v') { $x=1; foreach ($ar as $value) { $sql .= ":{$varprefix}{$x},"; $bindparams[":{$varprefix}{$x}"] = $value; $x++; } return 'IN ('.rtrim($sql,',').')'; }
php
{ "resource": "" }
q239008
DBObject.buildInsertStatement
train
protected function buildInsertStatement($data,$table=null) { if (!$table) { $table = $this->primaryTable; } $bindparams = array(); $sql_fields = NULL; $sql_values = NULL; foreach ($data as $field=>$value) { $sql_fields .= "{$field},"; $sql_values .= ":{$field},"; $bindparams[":{$field}"] = $valu...
php
{ "resource": "" }
q239009
DBObject.buildMultiRowInsertStatement
train
protected function buildMultiRowInsertStatement($rows,$table=null) { if (!$table) { $table = $this->primaryTable; } $bindparams = array(); $sqlRows = NULL; $sqlFields = implode(',',array_keys(current($rows))); $x = 1; foreach ($rows as $data) { $sqlValues = NULL; foreach ($data as $field=>$value)...
php
{ "resource": "" }
q239010
DBObject.buildUpdateStatement
train
protected function buildUpdateStatement($id,$data,$table=null) { if (!$table) { $table = $this->primaryTable; } $sql = "UPDATE {$table} SET "; foreach ($data as $field=>$value) { $sql .= "{$field}=:{$field},"; $bindparams[":{$field}"] = $value; } $sql = rtrim($sql,',')." WHERE id=:id"; $bindpa...
php
{ "resource": "" }
q239011
DBObject.logStatementError
train
protected function logStatementError($error,$sql=null) { if (!empty($GLOBALS['config']['DB_DEBUG'])) { $message = "Error with query - CODE: {$error[1]}"; if ($sql) { $message .= " QUERY: {$sql}"; } $this->getLogger()->error($message); } }
php
{ "resource": "" }
q239012
AbstractResponse.setCookieValue
train
public function setCookieValue(string $name, string $value, ?\DateTimeInterface $expiry = null, ?UrlPathInterface $path = null, ?HostInterface $domain = null, bool $isSecure = false, bool $isHttpOnly = false): void { $this->cookies->set($name, new ResponseCookie($value, $expiry, $path, $domain, $isSecure, $...
php
{ "resource": "" }
q239013
AbstractResponse.setExpiry
train
public function setExpiry(?\DateTimeImmutable $expiry = null): void { $date = new \DateTimeImmutable(); $expiry = $expiry ?: $date; $this->setHeader('Date', $date->setTimezone(new \DateTimeZone('UTC'))->format('D, d M Y H:i:s \G\M\T')); $this->setHeader('Expires', $expiry->setTimezo...
php
{ "resource": "" }
q239014
Buffer.readUntil
train
public function readUntil($end) { if (empty($end)) { throw new ResourceException("Empty string given to Reader::readUntil()"); } fseek($this->resource, $this->readPosition); // Reading the first character (maybe blocking) $buffer = stream_get_contents($this->resou...
php
{ "resource": "" }
q239015
Buffer.write
train
public function write($content) { fseek($this->resource, $this->writePosition); if(false === fwrite($this->resource, $content)) throw new ResourceException("Unable to write content to resource"); $this->writePosition = ftell($this->resource); return $this; }
php
{ "resource": "" }
q239016
Publisher.initialiseMonitoring
train
protected function initialiseMonitoring() { for ($i = 0; $i < count($this->entries); $i++) { $this->monitor->monitor($this->entries[$i]['entry']); } }
php
{ "resource": "" }
q239017
Publisher.publishEntry
train
protected function publishEntry( string $entryId, array $parameters, array $content ) { $entry = $this->entryFactory->getEntry($entryId, $parameters); $entry->setBody($content); $response = $this->publish($entry); $t...
php
{ "resource": "" }
q239018
PluginOptions.update
train
public function update( $options = [] ) { if ( is_null( $this->row ) ) { return $this->reset(); } $mergeOptions = array_replace_recursive( $this->_value, $options ); $result = WpOption::updateOrCreate( ['option_name' => $this->optionsName], ['op...
php
{ "resource": "" }
q239019
PluginOptions.delta
train
public function delta() { $mergeOptions = $this->__delta( $this->optionsData, $this->_value ); $result = WpOption::updateOrCreate( ['option_name' => $this->optionsName], ['option_value' => json_encode( $mergeOptions )] ); $this->_value = (array) $mergeOpt...
php
{ "resource": "" }
q239020
PayloadContainerTrait.set
train
public function set(string $name, $item): void { $this->payloadContainerItems->set($name, $item); }
php
{ "resource": "" }
q239021
AbstractWordRequest.checkResponseErrors
train
protected function checkResponseErrors(ResponseInterface $response) { $status = intval($response->getStatusCode()); if ($status === 200) return; switch ($status) { case 401: throw new AuthorizationException($response); default: throw new RequestException($response); } }
php
{ "resource": "" }
q239022
LoggerFactory.getDafaultLogger
train
public function getDafaultLogger () { if (null === $this->root) { $this->root = new HierarchialLogger(null); } return $this->root; }
php
{ "resource": "" }
q239023
LoggerFactory.newLogger
train
protected function newLogger ($name, LoggerInterface $parent) { $logger = $parent; if ($parent instanceof HierarchialLogger) { $logger = new HierarchialLogger($name); $logger->setParent($parent); } return $logger; }
php
{ "resource": "" }
q239024
MList.removeOne
train
public function removeOne($value): bool { if ($this->isValidType($value) === false) { throw new MWrongTypeException("\$value", $this->getType(), $value); } $result = array_search($value, $this->list); if ($result === false) { throw new \OutOfBoundsException(...
php
{ "resource": "" }
q239025
MList.startsWith
train
public function startsWith($value): bool { if ($this->isValidType($value) === false) { throw new MWrongTypeException("\$value", $this->getType(), $value); } if ($this->count() <= 0) { return false; } $lastValue = $this->list[0]; return ($las...
php
{ "resource": "" }
q239026
MList.offsetExists
train
public function offsetExists($offset): bool { MDataType::mustBe(array(MDataType::INT)); return (array_key_exists($offset, $this->list) === true); }
php
{ "resource": "" }
q239027
Gdn_Pluggable.FireAs
train
public function FireAs($Options) { if (!is_array($Options)) $Options = array('FireClass' => $Options); if (array_key_exists('FireClass', $Options)) $this->FireAs = GetValue('FireClass', $Options); return $this; }
php
{ "resource": "" }
q239028
Generic.flip
train
public function flip() { $this->counter++; unset($this->isLucky); $this->currentSide = $this->isLucky()? $this->expectedSide : $this->getOppositeSide($this->expectedSide); return $this->currentSide; }
php
{ "resource": "" }
q239029
Generic.isLucky
train
public function isLucky() { if (isset($this->isLucky)) { return $this->isLucky; } $this->isLucky = $this->checkLuck(); return $this->isLucky; }
php
{ "resource": "" }
q239030
Analytics.createCookie
train
private function createCookie() { $rand_id = rand(10000000, 99999999); $random = rand(1000000000, 2147483647); $var = '-'; $time = time(); $cookie = ''; $cookie .= '__utma=' . $rand_id . '.' . $random . '.' . $time . '.' . $time . '.' . $time . '.2;+'; $cookie...
php
{ "resource": "" }
q239031
Analytics.createGif
train
public function createGif() { $data = array(); foreach ($this->data as $key => $item) { if ($item !== null) { $data[$key] = $item; } } return $this->tracking = self::GA_URL . '?' . http_build_query($data); }
php
{ "resource": "" }
q239032
Analytics.remoteCall
train
private function remoteCall() { if (function_exists( 'wp_remote_head' )) { // Check if this is being used with WordPress, if so use it's excellent HTTP class $response = wp_remote_head($this->tracking); return $response; } elseif (function_exists('curl_...
php
{ "resource": "" }
q239033
Analytics.sendTransaction
train
public function sendTransaction($transaction_id, $affiliation, $total, $tax, $shipping, $city, $region, $country) { $this->data['utmvw'] = '5.6.4dc'; $this->data['utms'] = ++self::$RequestsForThisSession; $this->data['utmt'] = 'tran'; $this->data['utmtid'] = $transaction_id; ...
php
{ "resource": "" }
q239034
Text.truncate
train
public static function truncate( $value, $length = 80, $terminator = "\n", $preserve = false ) { $length = $preserve ? static::preserveBreakpoint($value, $length) : $length; if (mb_strlen($value) > $length) { $value = rtrim(mb_substr($value, 0, $length)). ...
php
{ "resource": "" }
q239035
Text.preserveBreakpoint
train
private static function preserveBreakpoint($value, $length) { if (strlen($value) <= $length) { return $length; } $breakpoint = mb_strpos($value, ' ', $length); $length = $breakpoint; if (false === $breakpoint) { $length = mb_strlen($value); } ...
php
{ "resource": "" }
q239036
Validator.validate
train
protected function validate() { if (!empty($this->errors)) { // already validated return; } $this->errors = []; foreach ($this->rules as $field => $rules) { $value = $this->getValue($field); foreach ($this->provider->getRules($rules...
php
{ "resource": "" }
q239037
TaggedServicesPass.getDefinitionForServiceId
train
private function getDefinitionForServiceId($serviceId, ServiceConfig $serviceConfig) { if ($serviceConfig->has(ServiceConfig::LAZY) && !$serviceConfig->get(ServiceConfig::LAZY)) { return new Reference($serviceId); } else { return new Definition($this->invokeClass, array(new ...
php
{ "resource": "" }
q239038
Template.load
train
protected function load($filename, $data = array(), $return = false) { $template = $this->createSubTemplate(); try { return $template->renderTemplate($filename, $data, $return); } catch (\Exception $exception) { if (!empty($this->log)) { $...
php
{ "resource": "" }
q239039
Template.parseTemplate
train
private function parseTemplate($filename, $data) { if (is_array($data)) { $this->_templateData = $data; } else if (is_object($data)) { if (method_exists($data, 'getTemplateData')) { $this->_templateData = $data->getTemplateData(); } else { ...
php
{ "resource": "" }
q239040
Template.locateViewFile
train
public function locateViewFile($filename, $requiredNamespace = '') { foreach ($this->templateSearchDirectories as $namespace => $location) { if (!empty($requiredNamespace) && ($namespace != $requiredNamespace)) { continue; } $fullFilename = $location . DI...
php
{ "resource": "" }
q239041
Common.humanize
train
public function humanize(){ $this->stream->setCompression(Stream::COMPRESS_OFF); $this->stream->setEncryption(Stream::CRYPT_OFF); $this->setEncoding(Common::ENC_XML); return $this; }
php
{ "resource": "" }
q239042
ResponseFactory.getResponse
train
public function getResponse($code = ResponseCode::NO_CONTENT, $content = null, $headers = []) { $response = clone $this->baseResponse; if ($code !== false) { $response->setStatus($code); } if ($content !== false) { $response->setBody($content); } ...
php
{ "resource": "" }
q239043
PackageManifest.providers
train
public function providers() { return collect($this->getManifest())->flatMap(function ($configuration) { return (array) ($configuration['providers'] ? $configuration['providers'] : []); })->filter()->all(); }
php
{ "resource": "" }
q239044
PackageManifest.aliases
train
public function aliases() { return collect($this->getManifest())->flatMap(function ($configuration) { return (array) ($configuration['aliases'] ? $configuration['aliases'] : []); })->filter()->all(); }
php
{ "resource": "" }
q239045
PackageManifest.build
train
public function build() { $packages = []; if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) { $packages = json_decode($this->files->get($path), true); } $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); $this->write(...
php
{ "resource": "" }
q239046
iauTaitt.Taitt
train
public static function Taitt($tai1, $tai2, &$tt1, &$tt2) { /* TT minus TAI (days). */ $dtat = TTMTAI / DAYSEC; /* Result, safeguarding precision. */ if ($tai1 > $tai2) { $tt1 = $tai1; $tt2 = $tai2 + $dtat; } else { $tt1 = $tai1 + $dtat; $tt2 = $tai2; } /* Status...
php
{ "resource": "" }
q239047
Maestrano_Api_Util.convertToMaestranoObject
train
public static function convertToMaestranoObject($resp, $preset) { $types = array( 'account_bill' => 'Maestrano_Account_Bill', 'account_recurring_bill' => 'Maestrano_Account_RecurringBill', 'account_group' => 'Maestrano_Account_Group', 'account_user' => 'Maestrano_Account_User', 'acco...
php
{ "resource": "" }
q239048
ItemMetaDataFactory.doLoad
train
protected function doLoad($itemClass) { $itemMetaData = $this->newItemMetaDataInstance($itemClass); $entityDefinitions = $this->annotationDriver->loadEntityDefinitions($itemClass); $itemMetaData->mapEntities($entityDefinitions); $hitDefinitions = $this->annotationDriver->loadHitDefinitions($itemClass); $item...
php
{ "resource": "" }
q239049
Email.forge
train
public static function forge($setup = null, array $config = array()) { empty($setup) and $setup = \Config::get('email.default_setup', 'default'); is_string($setup) and $setup = \Config::get('email.setups.'.$setup, array()); $setup = \Arr::merge(static::$_defaults, $setup); $config = \Arr::merge($setup, $confi...
php
{ "resource": "" }
q239050
SettingHelper.get
train
public function get($key) { if (!$this->has($key)) { return null; } return (new SettingModel) ->cached() ->where('key', $key) ->first() ->value; }
php
{ "resource": "" }
q239051
SettingHelper.put
train
public function put($key, $value) { // if key exits then override if ($this::has($key)) { $setting = (new SettingModel) ->cached() ->where('key', $key) ->first(); $setting->value = $value; return $setting->save(); ...
php
{ "resource": "" }
q239052
SettingHelper.forget
train
public function forget($key) { $isDeleted = SettingModel::where('key', $key) ->delete(); // if delete record then delete cache if ($isDeleted) { Cache::forget('Klaravel\Settings\Setting'); } return $isDeleted; }
php
{ "resource": "" }
q239053
ElasticaAwareCommand.getClient
train
protected function getClient($clientName) { $clientName = $clientName ?: 'gbprod.elastica_extra.default_client'; $client = $this->getContainer() ->get( $clientName, ContainerInterface::NULL_ON_INVALID_REFERENCE ) ; $this->vali...
php
{ "resource": "" }
q239054
ClassFinder.find
train
public static function find(string $source): ?string { $class = false; $namespace = false; $tokens = token_get_all($source); if (1 === count($tokens) && T_INLINE_HTML === $tokens[0][0]) { return null; } for ($i = 0; isset($tokens[$i]); ++$i) { ...
php
{ "resource": "" }
q239055
Templating.shutdown
train
public static function shutdown() { global $PPHP; $req = grab('request'); if (!$req['binary']) { $body = ob_get_contents(); ob_end_clean(); try { array_merge_assoc( self::$_stash, array( ...
php
{ "resource": "" }
q239056
Templating.gettext
train
function gettext($string) { global $PPHP; $req = grab('request'); $default = $PPHP['config']['global']['default_lang']; $current = $req['lang']; $res = $string; try { if (self::$_gettext !== null) { $res = self::$_gettext->gettext($string...
php
{ "resource": "" }
q239057
Templating.title
train
public static function title($prepend, $sep = ' - ') { self::$_stash['title'] = $prepend . ( isset(self::$_stash['title']) ? ($sep . self::$_stash['title']) : '' ); }
php
{ "resource": "" }
q239058
Templating.renderBlocks
train
public static function renderBlocks($name, $args = array()) { global $PPHP, $_SESSION; array_merge_assoc( self::$_stash, $args, array( 'config' => $PPHP['config'], 'session' => $_SESSION, 'req' => grab('request') ...
php
{ "resource": "" }
q239059
CommentRepository.convertAndReturn
train
protected function convertAndReturn($comments) { // Create the return value $retval = false; if ($comments && is_array($comments) && count($comments)) { // Create the array $retval = array(); foreach ($comments as $theComment) { // Create a...
php
{ "resource": "" }
q239060
Strings.concat
train
public static function concat() { $args = func_get_arg(); $string = ''; foreach ($args as $arg) { $string .= $arg; } return $string; }
php
{ "resource": "" }
q239061
Strings.compare
train
public static function compare($str1, $str2, $ignoreCase = true) { if ($ignoreCase) { if (strcasecmp($str1, $str2) == 0) { return true; } } else { if (strcmp($str1, $str2) == 0) { return true; } } return...
php
{ "resource": "" }
q239062
Strings.join
train
public static function join($strings, $separator, $start = 0, $count = -1) { $string = ''; $end = $count == -1 ? Collection::count($strings) : $count; for ($i = $start; $i < $end; $i++) { $string .= $strings[$i].$separator; if ($i == ($end - 1)) { $...
php
{ "resource": "" }
q239063
Strings.at
train
public static function at($string, $index) { if (self::length($string) >= ($index + 1)) { return $string[$index]; } exception(StringOutIndexException::class); }
php
{ "resource": "" }
q239064
Strings.insert
train
public static function insert($string, $substring, $index) { exception_if(!self::checkIndex($string, $index), StringOutIndexException::class); $str = ''; for ($i = 0; $i < static::length($string); $i++) { if ($i == $index) { $str .= $substring; } ...
php
{ "resource": "" }
q239065
Strings.trim
train
public static function trim($string, $side = self::TRIM_BOTH, $chars = null) { if ($side == self::TRIM_START) { return ltrim($string, $chars); } elseif ($side == self::TRIM_END) { return rtrim($string, $chars); } elseif ($side == self::TRIM_BOTH) { return ...
php
{ "resource": "" }
q239066
Strings.startsWith
train
public static function startsWith($string, $substrings) { if (is_array($substrings)) { foreach ((array) $substrings as $substring) { if ($substring != '' && mb_strpos($string, $substring) === 0) { return true; } } } elseif (...
php
{ "resource": "" }
q239067
Strings.endsWith
train
public static function endsWith($string, $substrings) { if (is_array($substrings)) { foreach ((array) $substrings as $substring) { if ((string) $substring === static::subString($string, -static::length($substring))) { return true; } ...
php
{ "resource": "" }
q239068
SiteMapService.getSiteMap
train
public function getSiteMap() { $sitemap = $this->getCacheItem('site-map'); if (null === $sitemap) { /* @var $menuService MenuService */ $menuService = $this->getService(MenuService::class); $navigation = $menuService->getPages(); $argv = $this->prep...
php
{ "resource": "" }
q239069
ConfigUtil.includeConfigFile
train
private static function includeConfigFile(array &$config, $config_file, File $base_dir, ConfigReader $reader) { // try relative path $file = new File($config_file, $base_dir); if ( $file->exists() ){ $included = self::loadConfigFileByFormat( $file, $reader ); ...
php
{ "resource": "" }
q239070
HTMLCompressor.replaceAbsoluteUrls
train
public function replaceAbsoluteUrls($currentHost = true) { $hosts = array(); if ($currentHost === true) { $hosts[] = $_SERVER["HTTP_HOST"]; } elseif (is_array($currentHost)) { foreach ($currentHost as $h) { $hosts[]...
php
{ "resource": "" }
q239071
Scope.hasScope
train
public function hasScope(Scope $scope) { foreach ($scope->toArray() as $scopeToken) { if (!$this->hasScopeToken($scopeToken)) { return false; } } return true; }
php
{ "resource": "" }
q239072
PollController.indexAction
train
public function indexAction(Request $request) { $messages = []; $data = []; foreach ($this->get('phlexible_dashboard.portlets') as $portlet) { $data[$portlet->getId()] = $portlet->getData(); } $message = new \stdClass(); $message->type = 'start'; ...
php
{ "resource": "" }
q239073
SubcategoryController.indexAction
train
public function indexAction($categoryId) { $em = $this->getDoctrine()->getManager(); /** @var Category $entity */ $entity = $em->getRepository('EcommerceBundle:Category')->find($categoryId); if (!$entity) { throw $this->createNotFoundException('Unable to find Category e...
php
{ "resource": "" }
q239074
SubcategoryController.createAction
train
public function createAction(Request $request, $categoryId) { $em = $this->getDoctrine()->getManager(); /** @var Category $category */ $category = $em->getRepository('EcommerceBundle:Category')->find($categoryId); if (!$category) { throw $this->createNotFoundException('...
php
{ "resource": "" }
q239075
LifestreamFactory.createLifestream
train
public function createLifestream($serviceName, array $arguments = array(), array $filters = array(), array $formatters = array()) { if (!array_key_exists($serviceName, $this->services)) { throw new \InvalidArgumentException(sprintf( 'Service "%s" not Found. Services supported: "%...
php
{ "resource": "" }
q239076
FileFilter.finderWrapperInject
train
protected function finderWrapperInject($finder) { foreach ($this->wrappedMethodHistory as $row) { call_user_func_array(array($finder, $row['method']), $row['args']); } }
php
{ "resource": "" }
q239077
Zend_Http_Client_Adapter_Socket.setConfig
train
public function setConfig($config = array()) { if ($config instanceof Zend_Config) { $config = $config->toArray(); } elseif (! is_array($config)) { throw new Zend_Http_Client_Adapter_Exception( 'Array or Zend_Config object expected, got ' . gettype($config) ...
php
{ "resource": "" }
q239078
Zend_Http_Client_Adapter_Socket.setStreamContext
train
public function setStreamContext($context) { if (is_resource($context) && get_resource_type($context) == 'stream-context') { $this->_context = $context; } elseif (is_array($context)) { $this->_context = stream_context_create($context); } else { // Invali...
php
{ "resource": "" }
q239079
Zend_Http_Client_Adapter_Socket._checkSocketReadTimeout
train
protected function _checkSocketReadTimeout() { if ($this->socket) { $info = stream_get_meta_data($this->socket); $timedout = $info['timed_out']; if ($timedout) { $this->close(); throw new Zend_Http_Client_Adapter_Exception( ...
php
{ "resource": "" }
q239080
ButtonGroup.&
train
public function &createButton($button_class='Bootstrap\Button\Button') { $button = $this->factory->create($button_class); $this->addButton($button); return $button; }
php
{ "resource": "" }
q239081
AuthenticatedUserController.create
train
public function create($data) { $authService = $this->options->getAuthenticationService(); if ($authService->hasIdentity()) { $authService->logout(); } $result = $authService->login( $data[$this->options->getDataUsernameKey()], $data[$this->optio...
php
{ "resource": "" }
q239082
Composer.setComposerFile
train
protected function setComposerFile($file) { if (null != $file && !is_file($file)) { throw new FileNotFoundException( "The file {$file} was not found." ); } $this->composerFile = $file; }
php
{ "resource": "" }
q239083
Composer.getComposerData
train
protected function getComposerData() { if (null == $this->composerData) { $json = file_get_contents($this->getComposerFile()); $this->composerData = json_decode($json); if (null === $this->composerData) { throw new ComposerParseException( ...
php
{ "resource": "" }
q239084
Composer.getAuthor
train
protected function getAuthor() { if ( !isset($this->getComposerData()->authors) || count($this->getComposerData()->authors) != 1 ) { return $this->requestAuthor(); } return [ 'authorName' => $this->getComposerData()->authors[0]->name, ...
php
{ "resource": "" }
q239085
Composer.requestAuthor
train
protected function requestAuthor() { if (!empty($this->getComposerData()->authors)) { return $this->selectAuthors(); } $nameQuestion = new Question('Please enter your name: '); $emailQuestion = new Question('Please enter your e-mail address: '); $this->getOutput(...
php
{ "resource": "" }
q239086
Composer.selectAuthors
train
protected function selectAuthors() { $options = $this->getAuthorsAsOptions(); $this->getOutput()->writeln(''); $this->getOutput()->writeln( '<info>Multiple authors found on ' . 'project\'s composer.json file.</info>' ); $question = new ChoiceQuestion( ...
php
{ "resource": "" }
q239087
Passthru.run
train
public function run(RunnableInterface $command, callable $func = null) { if ($func) { throw new \Exception('You cannot process passthru with a callable. Use another Runner instead.'); } $command = (string) $command->getCommandAssembler(); passthru($command, $status); ...
php
{ "resource": "" }
q239088
JsonRpcServer.processApiMethod
train
private function processApiMethod(SfRequest $request) { // Try parse JSON $content = $request->getContent(); if (!$content) { throw new MissingHttpContentException('Missing HTTP content.'); } $query = @json_decode($content, true); if (false === $query) ...
php
{ "resource": "" }
q239089
JsonRpcServer.processApiQuery
train
private function processApiQuery(array $query) { $query += array( 'params' => array(), 'id' => null ); if (empty($query['method'])) { throw new MissingMethodException('Missing "method" parameter in query.'); } if ($query['id'] !== null &&...
php
{ "resource": "" }
q239090
JsonRpcServer.createErrorResponse
train
private function createErrorResponse($code, $message = null, array $data = []) { if (!$message) { $messages = $this->handler->getErrors()->getErrors(); $message = isset($messages[$code]) ? $messages[$code] : 'Error'; } $json = [ 'jsonrpc' => self::JSON_RP...
php
{ "resource": "" }
q239091
JsonRpcServer.createViolationErrorResponse
train
public function createViolationErrorResponse(ViolationListException $exception) { $errorData = []; /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */ foreach ($exception->getViolationList() as $violation) { $errorData[$violation->getPropertyPath()] ...
php
{ "resource": "" }
q239092
RequestHelper.head
train
public function head($uri = null, $expectedStatus = null) { $this->setMethod('HEAD'); $this->setUri($uri); if (!is_null($expectedStatus)) { $this->expectingStatusCode($expectedStatus); } return $this; }
php
{ "resource": "" }
q239093
ArticleList.InitCategoryArticles
train
private function InitCategoryArticles() { $tblArticle = Article::Schema()->Table(); $sql = Access::SqlBuilder(); $orderBy = $sql->OrderList($sql->OrderDesc($tblArticle->Field('Created'))); $this->articles = Article::Schema()->FetchByCategory(false, $this->category, $orderBy, null, $t...
php
{ "resource": "" }
q239094
ArticleList.RemovalObject
train
protected function RemovalObject() { $id = Request::PostData('delete'); return $id ? Article::Schema()->ByID($id) : null; }
php
{ "resource": "" }
q239095
ArticleList.BackLink
train
protected function BackLink() { if ($this->category) { return BackendRouter::ModuleUrl(new CategoryList(), array('archive'=>$this->archive->GetID())); } else { return BackendRouter::ModuleUrl(new ArchiveList()); } }
php
{ "resource": "" }
q239096
AbstractFilesystem.setNewDirectoryMode
train
public static function setNewDirectoryMode(string $mode = '740'): void { static::init(); static::$newDirectoryMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740; }
php
{ "resource": "" }
q239097
AbstractFilesystem.setNewFileMode
train
public static function setNewFileMode(string $mode = '740'): void { static::init(); static::$newFileMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740; }
php
{ "resource": "" }
q239098
AbstractFilesystem.setNewSymbolicLinkMode
train
public static function setNewSymbolicLinkMode(string $mode = '740'): void { static::init(); static::$newSymlinkMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740; }
php
{ "resource": "" }
q239099
Formatter.createDefaultStyles
train
protected function createDefaultStyles() : styles\Map { return new styles\Map([ 'error' => new Style('white', 'red'), 'info' => new Style('green'), 'comment' => new Style('cyan'), 'important' => new Style('red'), 'header' => new Style...
php
{ "resource": "" }