_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q9800
Source.bailIfConstructArguments
train
private function bailIfConstructArguments(string $source, int $width, int $height): void { if ($width <= 0) { throw new InvalidArgumentException('Width cannot be less or equal than zero.'); } if ($height <= 0) { throw new InvalidArgumentException('Height cannot be les...
php
{ "resource": "" }
q9801
TokenFactory.buildFromHtml
train
public static function buildFromHtml(string $html, Token $parent = null, bool $throwOnError = true) { $matchCriteria = array( 'Php' => "/^\s*<\?(php)?\s/i", 'Comment' => "/^\s*<!--/", 'CData' => "/^\s*<!\[CDATA\[/", 'DocType' => "/^\s*<!DOCTYPE /i", ...
php
{ "resource": "" }
q9802
PoolTask.cloneStructure
train
private function cloneStructure(array & $struct): void { foreach ($struct as & $v) { if (is_object($v)) { $v = clone $v; } elseif (is_array($v)) { $this->cloneStructure($v); } } }
php
{ "resource": "" }
q9803
PictureEffect.restore
train
public function restore(array $settings = array()) { $settings = array_values($settings); $reflection = new ReflectionMethod(get_class($this), '__construct'); $alreadySet = $reflection->getNumberOfParameters(); $index = 0; foreach($this->settings as &$setting) { ...
php
{ "resource": "" }
q9804
PictureEffect.hex2rgb
train
public function hex2rgb($hex, $returnString = FALSE) { $hex = str_replace('#', '', $hex); if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)...
php
{ "resource": "" }
q9805
MemberExtension.setCart
train
public function setCart(ShoppingCart $cart) { $curr = $this->getOwner()->getCart(); $contact = $this->getOwner()->Contact(); if (isset($curr) && $curr->ID != $cart->ID) { $curr->delete(); } $cart->CustomerID = $contact->ID; return $this; }
php
{ "resource": "" }
q9806
CookieButton.renderButton
train
private function renderButton() { $this->params = Json::encode([ 'btnName' => $this->options['id'], 'cookieName' => $this->cookie['name'], 'cookieValue' => addslashes($this->getHashedCookieValue($this->cookie['value'])), 'cookieOptions' => isset($this->cookie[...
php
{ "resource": "" }
q9807
CookieButton.renderButtonGroup
train
private function renderButtonGroup() { $this->params = Json::encode([ 'btnName' => $this->options['id'], 'cookieName' => $this->cookie['name'], 'cookieValue' => addslashes($this->getHashedCookieValue($this->cookie['value'])), 'cookieOptions' => isset($this->co...
php
{ "resource": "" }
q9808
CookieButton.cookie
train
private function cookie($name, $value = null, $expire = 0, $domain = '', $path = '/', $secure = false) { if($value === false) { \Yii::$app->response->cookies->remove($name); } elseif($value === null) { return \Yii::$app->request->cookies->getValue($name); } /...
php
{ "resource": "" }
q9809
Factory.instantiate
train
private static function instantiate(array $declaration) { $fieldType = array_shift($declaration); $class = "\\Zerg\\Field\\" . ucfirst(strtolower($fieldType)); if (class_exists($class)) { $reflection = new \ReflectionClass($class); return $reflection->newInstanceArgs...
php
{ "resource": "" }
q9810
Configuration.getApplicationNode
train
private function getApplicationNode(): NodeDefinition { $treeBuilder = new TreeBuilder('application'); return $treeBuilder ->getRootNode() ->addDefaultsIfNotSet() ->children() ->arrayNode('version') ->addDefaultsIfNotSet() ...
php
{ "resource": "" }
q9811
Configuration.getFormNode
train
private function getFormNode(): NodeDefinition { $treeBuilder = new TreeBuilder('form'); return $treeBuilder ->getRootNode() ->addDefaultsIfNotSet() ->children() ->scalarNode('novalidate') ->info('Information if HTML5 inline va...
php
{ "resource": "" }
q9812
Configuration.getDateNode
train
private function getDateNode(): NodeDefinition { $treeBuilder = new TreeBuilder('date'); return $treeBuilder ->getRootNode() ->addDefaultsIfNotSet() ->children() ->arrayNode('format') ->addDefaultsIfNotSet() ...
php
{ "resource": "" }
q9813
Assert.empty
train
public static function empty(...$values): bool { self::handleInvalidArguments($values); foreach ($values as $value) { if (empty($value) === false) { return false; } } return true; }
php
{ "resource": "" }
q9814
Assert.typeOf
train
public static function typeOf($types, ...$values): bool { if (is_string($types)) { $types = [$types]; } if (is_array($types) === false) { throw new InvalidArgumentException(sprintf(static::MSG_TYPE_MISMATCH, gettype($types))); } foreach ($values as $...
php
{ "resource": "" }
q9815
Runtime.unregisterHelper
train
public static function unregisterHelper($name) { //Argument 1 must be a string Argument::i()->test(1, 'string'); if (isset(self::$helpers[$name])) { unset(self::$helpers[$name]); } }
php
{ "resource": "" }
q9816
Runtime.unregisterPartial
train
public static function unregisterPartial($name) { //Argument 1 must be a string Argument::i()->test(1, 'string'); if (isset(self::$partials[$name])) { unset(self::$partials[$name]); } }
php
{ "resource": "" }
q9817
Text.addItem
train
private function addItem() { $args = func_get_args(); $this->items[$args[0]] = implode(':', array_slice($args, 1)); return $this; }
php
{ "resource": "" }
q9818
Text.render
train
private function render() { $parts = []; if (!empty($this->items)) { $parts[] = implode(',', $this->items); } $parts[] = isset($this->items['base64']) ? self::base64Encode($this->text) : urlencode($this->text); return implode(':', $parts); }
php
{ "resource": "" }
q9819
FirewallService.index
train
public function index($params = [], $optParams = []) { if ($optParams instanceof IndexParams) { $optParams = $optParams->toArray(true); } return $this->sendRequest([], [ 'restAction' => 'index', 'params' => $params, 'getParams' => $optParams, ...
php
{ "resource": "" }
q9820
FirewallService.create
train
public function create($params, $optParams = []) { if (!$params instanceof Firewall) { throw new InvalidParamException(Firewall::class.' is required!'); } return $this->sendRequest([], [ 'restAction' => 'create', 'postParams' => $params->toArray(), ...
php
{ "resource": "" }
q9821
FirewallService.view
train
public function view($params, $optParams = []) { if ($params instanceof Firewall) { $params = $params->id; } return $this->sendRequest([], [ 'restAction' => 'view', 'restId' => $params, 'getParams' => $optParams, ], function ($response...
php
{ "resource": "" }
q9822
Address.mergeWith
train
public function mergeWith(Address $address): self { return new static(...\array_merge($this->ipv4, $address->ipv4), ...\array_merge($this->ipv6, $address->ipv6)); }
php
{ "resource": "" }
q9823
CompositeHealthIndicator.health
train
public function health() { $healths = []; foreach ($this->indicators as $key => $indicator) { $healths[$key] = $indicator->health(); } return $this->healthAggregator->aggregate($healths); }
php
{ "resource": "" }
q9824
Filesystem.purge
train
public function purge($dir) { if (!is_dir($dir)) { return; } $files = scandir($dir); if ($files !== false) { foreach ($files as $file) { if ($file === '.' || $file === '..') { continue; } $...
php
{ "resource": "" }
q9825
Filesystem.copy
train
public function copy($src, $dest) { if (is_dir($src)) { $this->ensureDir($dest); $files = scandir($src); foreach ($files as $file) { if ($file !== '.' && $file !== '..') { $this->copy($src . '/' . $file, $dest . '/' . $file); ...
php
{ "resource": "" }
q9826
ConfigServiceProvider.configMerge
train
public static function configMerge() { $result = array(); $args = func_get_args(); foreach ($args as $arg) { if (!is_array($arg)) { continue; } foreach ($arg as $key => $value) { if (is_numeric($key)) { // Re...
php
{ "resource": "" }
q9827
DoctrineActivationRepository.completed
train
public function completed(UserInterface $user) { $queryBuilder = $this->createQueryBuilder('a'); $queryBuilder ->where('a.user = :user') ->andWhere('a.completed = :completed'); $queryBuilder ->setParameters([ 'user' => $user, ...
php
{ "resource": "" }
q9828
Executor.submit
train
public function submit(Context $context, $work, int $priority = 0): Promise { $job = new class($context) extends Placeholder { public $priority; public $generator; }; $job->priority = $priority; $job->generator = ($work instanceof \Generator) ? $wor...
php
{ "resource": "" }
q9829
Executor.executeNextJob
train
protected function executeNextJob(): void { while ($this->jobs) { $job = \array_pop($this->jobs); if ($job->state & AbstractPromise::PENDING) { $done = false; (new Coroutine($job->context, $job->generator))->when(function ...
php
{ "resource": "" }
q9830
FeatureFeatureType.setFeature
train
public function setFeature(ChildFeature $v = null) { if ($v === null) { $this->setFeatureId(NULL); } else { $this->setFeatureId($v->getId()); } $this->aFeature = $v; // Add binding for other direction of this n:n relationship. // If this obje...
php
{ "resource": "" }
q9831
FeatureFeatureType.getFeature
train
public function getFeature(ConnectionInterface $con = null) { if ($this->aFeature === null && ($this->feature_id !== null)) { $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); /* The following can be used additionally to guarantee the related ...
php
{ "resource": "" }
q9832
FeatureFeatureType.initFeatureTypeAvMetas
train
public function initFeatureTypeAvMetas($overrideExisting = true) { if (null !== $this->collFeatureTypeAvMetas && !$overrideExisting) { return; } $this->collFeatureTypeAvMetas = new ObjectCollection(); $this->collFeatureTypeAvMetas->setModel('\FeatureType\Model\FeatureType...
php
{ "resource": "" }
q9833
FeatureFeatureType.getFeatureTypeAvMetas
train
public function getFeatureTypeAvMetas($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureTypeAvMetasPartial && !$this->isNew(); if (null === $this->collFeatureTypeAvMetas || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatur...
php
{ "resource": "" }
q9834
FeatureFeatureType.countFeatureTypeAvMetas
train
public function countFeatureTypeAvMetas(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureTypeAvMetasPartial && !$this->isNew(); if (null === $this->collFeatureTypeAvMetas || null !== $criteria || $partial) { if ($this->isNew() ...
php
{ "resource": "" }
q9835
FeatureFeatureType.addFeatureTypeAvMeta
train
public function addFeatureTypeAvMeta(ChildFeatureTypeAvMeta $l) { if ($this->collFeatureTypeAvMetas === null) { $this->initFeatureTypeAvMetas(); $this->collFeatureTypeAvMetasPartial = true; } if (!in_array($l, $this->collFeatureTypeAvMetas->getArrayCopy(), true)) { /...
php
{ "resource": "" }
q9836
FeatureFeatureType.getFeatureTypeAvMetasJoinFeatureAv
train
public function getFeatureTypeAvMetasJoinFeatureAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildFeatureTypeAvMetaQuery::create(null, $criteria); $query->joinWith('FeatureAv', $joinBehavior); return $this->getFeatureTypeAvMetas($query, $con); }
php
{ "resource": "" }
q9837
XTreeDB.Put
train
function Put($key, $value) { // check the file description if (!$this->fd || $this->mode != 'w') { trigger_error("XDB::Put(), null db handler or readonly.", E_USER_WARNING); return false; } // check the length $klen = strlen($key); $vlen = strlen($value); if (!$klen || $klen > XDB_MAXKLEN) re...
php
{ "resource": "" }
q9838
XTreeDB.Draw
train
function Draw($i = -1) { if ($i < 0 || $i >= $this->hash_prime) { $i = 0; $j = $this->hash_prime; } else { $j = $i + 1; } echo "Draw the XDB data [$i ~ $j]. (" . trim($this->Version()) . ")\n\n"; while ($i < $j) { $poff = $i * 8 + 32; fseek($this->fd, $poff, SEEK_SET); $buf = fread...
php
{ "resource": "" }
q9839
XTreeDB.Version
train
function Version() { $ver = (is_null($this) ? XDB_VERSION : $this->version); $str = sprintf("%s/%d.%d", XDB_TAGNAME, ($ver >> 5), ($ver & 0x1f)); if (!is_null($this)) $str .= " <base={$this->hash_base}, prime={$this->hash_prime}>"; return $str; }
php
{ "resource": "" }
q9840
XTreeDB.Close
train
function Close() { if (!$this->fd) return; if ($this->mode == 'w') { $buf = pack('I', $this->fsize); fseek($this->fd, 12, SEEK_SET); fwrite($this->fd, $buf, 4); flock($this->fd, LOCK_UN); } fclose($this->fd); $this->fd = false; }
php
{ "resource": "" }
q9841
XTreeDB.Optimize
train
function Optimize($i = -1) { // check the file description if (!$this->fd || $this->mode != 'w') { trigger_error("XDB::Optimize(), null db handler or readonly.", E_USER_WARNING); return false; } // get the index zone: if ($i < 0 || $i >= $this->hash_prime) { $i = 0; $j = $this->hash_prime; ...
php
{ "resource": "" }
q9842
XTreeDB._optimize_index
train
function _optimize_index($index) { static $cmp = false; $poff = $index * 8 + 32; // save all nodes into array() $this->_sync_nodes = array(); $this->_load_tree_nodes($poff); $count = count($this->_sync_nodes); if ($count < 3) return; // sync the nodes, sort by key first if ($cmp == false) $cmp = c...
php
{ "resource": "" }
q9843
XTreeDB._load_tree_nodes
train
function _load_tree_nodes($poff) { fseek($this->fd, $poff, SEEK_SET); $buf = fread($this->fd, 8); if (strlen($buf) != 8) return; $tmp = unpack('Ioff/Ilen', $buf); if ($tmp['len'] == 0) return; fseek($this->fd, $tmp['off'], SEEK_SET); $rlen = XDB_MAXKLEN + 17; if ($rlen > $tmp['len']) $rlen = $tmp['le...
php
{ "resource": "" }
q9844
XTreeDB._reset_tree_nodes
train
function _reset_tree_nodes($poff, $low, $high) { if ($low <= $high) { $mid = ($low+$high)>>1; $node = $this->_sync_nodes[$mid]; $buf = pack('II', $node['off'], $node['len']); // left $this->_reset_tree_nodes($node['off'], $low, $mid - 1); // right $this->_reset_tree_nodes($node['off'] + 8, $m...
php
{ "resource": "" }
q9845
XTreeDB._check_header
train
function _check_header($fd) { fseek($fd, 0, SEEK_SET); $buf = fread($fd, 32); if (strlen($buf) !== 32) return false; $hdr = unpack('a3tag/Cver/Ibase/Iprime/Ifsize/fcheck/a12reversed', $buf); if ($hdr['tag'] != XDB_TAGNAME) return false; // check the fsize $fstat = fstat($fd); if ($fstat['size'] != $hd...
php
{ "resource": "" }
q9846
XTreeDB._write_header
train
function _write_header($fd) { $buf = pack('a3CiiIfa12', XDB_TAGNAME, $this->version, $this->hash_base, $this->hash_prime, 0, XDB_FLOAT_CHECK, ''); fseek($fd, 0, SEEK_SET); fwrite($fd, $buf, 32); }
php
{ "resource": "" }
q9847
XTreeDB._get_record
train
function _get_record($key) { $this->_io_times = 1; $index = ($this->hash_prime > 1 ? $this->_get_index($key) : 0); $poff = $index * 8 + 32; fseek($this->fd, $poff, SEEK_SET); $buf = fread($this->fd, 8); if (strlen($buf) == 8) $tmp = unpack('Ioff/Ilen', $buf); else $tmp = array('off' => 0, 'len' => 0); ...
php
{ "resource": "" }
q9848
XTreeDB._tree_get_record
train
function _tree_get_record($off, $len, $poff = 0, $key = '') { if ($len == 0) return (array('poff' => $poff)); $this->_io_times++; // get the data & compare the key data fseek($this->fd, $off, SEEK_SET); $rlen = XDB_MAXKLEN + 17; if ($rlen > $len) $rlen = $len; $buf = fread($this->fd, $rlen); $rec...
php
{ "resource": "" }
q9849
ReadSection.read
train
public function read( ReadOptionsInterface $options, SectionConfig $sectionConfig = null ): \ArrayIterator { $sectionData = new \ArrayIterator(); $this->dispatcher->dispatch( SectionBeforeRead::NAME, new SectionBeforeRead($sectionData, $options, $sectionConfi...
php
{ "resource": "" }
q9850
NativeLoop.nextTimeout
train
private function nextTimeout(): ?int { $time = \microtime(true); while (!$this->scheduler->isEmpty()) { list ($watcher, $scheduled) = $this->scheduler->top(); if ($watcher->enabled && $watcher->scheduled === $scheduled) { return (int) \ma...
php
{ "resource": "" }
q9851
NativeLoop.notifyPolls
train
private function notifyPolls(array $selected, array & $watchers): void { foreach ($selected as $k => $stream) { $k = $k ?: (int) $stream; if (isset($watchers[$k])) { foreach ($watchers[$k] as $watcher) { if (isset($watchers[$k][$watche...
php
{ "resource": "" }
q9852
AbstractView.addToContext
train
public function addToContext( string $key, $value, string $behavior ): View { switch ($behavior) { case View::REPLACE: $this->_context_[$key] = $value; return $this; case View::MERGE: if(array_key_exists($key, $this->_context_)) { ...
php
{ "resource": "" }
q9853
AbstractView.assimilateContext
train
protected function assimilateContext(array $context = []) { $this->_context_ = $context; foreach ($context as $key => $value) { $this->$key = $value; } }
php
{ "resource": "" }
q9854
FeatureTypeI18nTableMap.doDelete
train
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(FeatureTypeI18nTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity ...
php
{ "resource": "" }
q9855
LazyLoader.load
train
public function load($object) { if (get_class($object) !== $this->objectClass) { throw new \LogicException(sprintf('Invalid object type. Expected "%s" but got "%s".', $this->objectClass, get_class($object))); } $hydrator = $this->objectManager->getHydratorFor($this->objectClass)...
php
{ "resource": "" }
q9856
LazyLoader.loadProperty
train
public function loadProperty($object, $propertyName) { if (get_class($object) !== $this->objectClass) { throw new \LogicException(sprintf('Invalid object type. Expected "%s" but got "%s".', $this->objectClass, get_class($object))); } if ($this->objectManager->isPropertyLoaded($o...
php
{ "resource": "" }
q9857
Client.defer
train
public function defer($enable) { $this->deferred = $enable; if (!$this->deferred && isset($this->request)) { return $this->doSend(); } }
php
{ "resource": "" }
q9858
Client.doSend
train
private function doSend() { try { if (!empty($this->sentContentIds) && count($this->sentContentIds) > $this->batchLimit) { throw new InvalidCallException(sprintf("Request limit reached! Max %d requests per batch is accepted!", $this->batchLimit)); } $respo...
php
{ "resource": "" }
q9859
FeatureFeatureTypeQuery.create
train
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \FeatureType\Model\FeatureFeatureTypeQuery) { return $criteria; } $query = new \FeatureType\Model\FeatureFeatureTypeQuery(); if (null !== $modelAlias) { $query->setM...
php
{ "resource": "" }
q9860
FeatureFeatureTypeQuery.filterByFeatureId
train
public function filterByFeatureId($featureId = null, $comparison = null) { if (is_array($featureId)) { $useMinMax = false; if (isset($featureId['min'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); ...
php
{ "resource": "" }
q9861
FeatureFeatureTypeQuery.filterByFeatureTypeId
train
public function filterByFeatureTypeId($featureTypeId = null, $comparison = null) { if (is_array($featureTypeId)) { $useMinMax = false; if (isset($featureTypeId['min'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_TYPE_ID, $featureTypeId['min'], Criteria...
php
{ "resource": "" }
q9862
FeatureFeatureTypeQuery.filterByFeature
train
public function filterByFeature($feature, $comparison = null) { if ($feature instanceof \Thelia\Model\Feature) { return $this ->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $feature->getId(), $comparison); } elseif ($feature instanceof ObjectCollection) { ...
php
{ "resource": "" }
q9863
FeatureFeatureTypeQuery.useFeatureQuery
train
public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFeature($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery'); }
php
{ "resource": "" }
q9864
FeatureFeatureTypeQuery.filterByFeatureTypeAvMeta
train
public function filterByFeatureTypeAvMeta($featureTypeAvMeta, $comparison = null) { if ($featureTypeAvMeta instanceof \FeatureType\Model\FeatureTypeAvMeta) { return $this ->addUsingAlias(FeatureFeatureTypeTableMap::ID, $featureTypeAvMeta->getFeatureFeatureTypeId(), $comparison); ...
php
{ "resource": "" }
q9865
FeatureFeatureTypeQuery.useFeatureTypeAvMetaQuery
train
public function useFeatureTypeAvMetaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFeatureTypeAvMeta($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FeatureTypeAvMeta', '\FeatureType\Model\FeatureTypeAvMetaQuery'); }
php
{ "resource": "" }
q9866
Router.map
train
public function map($method, string $route, string $action, string $controller) { // alias $proxy = $this->proxy_factory; if (!\is_array($method)) { $method = [(string)$method]; } // whitelist http methods \array_walk($method, function ($v) { ...
php
{ "resource": "" }
q9867
Router.dispatch
train
public function dispatch(Request $request, ControllerFactory $actual_factory) { $this->proxy_factory ->replace($actual_factory) ->close(); $this->klein->dispatch($request); }
php
{ "resource": "" }
q9868
SecurityContext.add
train
public function add(SecurityContextConfiguration $configuration) { $this->contexts[$configuration->getName()] = $configuration; $this->updateMappings( $configuration, $this->container->make(EntityManagerInterface::class) ); }
php
{ "resource": "" }
q9869
SecurityContext.bindContext
train
public function bindContext($context, Request $request) { $security = $this->getSecurity($context); $this->container->instance(SecurityApi::class, $security); $this->container->bind(UrlGeneratorContract::class, function() use ($security){ return $security->url(); }); ...
php
{ "resource": "" }
q9870
SecurityContext.getSecurity
train
public function getSecurity($context) { if (array_key_exists($context, $this->instances)) { return $this->instances[$context]; } $configuration = $this->getConfigurationFor($context); $this->addPermissionsFactoryListener($context); return $this->instance...
php
{ "resource": "" }
q9871
ExampleGroup.runHooks
train
public function runHooks($name, AbstractContext $context, $reverse = false) { $parent = $this->getParent(); $hooks = $this->hooks[$name]; if ($reverse) { foreach (array_reverse($hooks) as $hook) { $hook->run($context); } if ($parent) { ...
php
{ "resource": "" }
q9872
ExampleGroup.total
train
public function total() { $total = array_reduce($this->examples, function($x, $e) { $x += $e instanceof Example ? 1 : $e->total(); return $x; }, 0); return $total; }
php
{ "resource": "" }
q9873
ExampleGroup.setErrorHandler
train
public function setErrorHandler() { set_error_handler(function ($errno, $errstr, $errfile, $errline ) { throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }); }
php
{ "resource": "" }
q9874
PSCWS4._rule_get
train
function _rule_get($str) { if (!isset($this->_rd[$str])) return false; return $this->_rd[$str]; }
php
{ "resource": "" }
q9875
PSCWS4._rule_checkbit
train
function _rule_checkbit($str, $bit) { if (!isset($this->_rd[$str])) return false; $bit2 = $this->_rd[$str]['bit']; return ($bit & $bit2 ? true : false); }
php
{ "resource": "" }
q9876
PSCWS4._rule_check
train
function _rule_check($rule, $str) { if (($rule['flag'] & PSCWS4_ZRULE_INCLUDE) && !$this->_rule_checkbit($str, $rule['bit'])) return false; if (($rule['flag'] & PSCWS4_ZRULE_EXCLUDE) && $this->_rule_checkbit($str, $rule['bit'])) return false; return true; }
php
{ "resource": "" }
q9877
PSCWS4._dict_query
train
function _dict_query($word) { if (!$this->_xd) return false; $value = $this->_xd->Get($word); if (!$value) return false; $tmp = unpack('ftf/fidf/Cflag/a3attr', $value); return $tmp; }
php
{ "resource": "" }
q9878
PSCWS4._get_zs
train
function _get_zs($i, $j = -1) { if ($j == -1) $j = $i; return substr($this->_txt, $this->_zmap[$i]['start'], $this->_zmap[$j]['end'] - $this->_zmap[$i]['start']); }
php
{ "resource": "" }
q9879
FosUser.setSalt
train
public function setSalt( $value ) { if( (string) $value !== $this->getSalt() ) { $this->values['salt'] = (string) $value; $this->setModified(); } return $this; }
php
{ "resource": "" }
q9880
ResponseParser.parse
train
public function parse(Context $context, ?Request $request = null): \Generator { $header = \unpack('nid/nflags/nqc/nac/nauth/nadd', yield $this->stream->readBuffer($context, 12)); $this->offset += 12; $response = new Response($header['id']); $response->setFlags($header['flags...
php
{ "resource": "" }
q9881
ResponseParser.parseQuestion
train
protected function parseQuestion(Context $context, Response $response): \Generator { $host = yield from $this->readLabel($context); $question = \unpack('ntype/nclass', yield $this->stream->readBuffer($context, 4)); $this->offset += 4; $response->addQuestion($host, $...
php
{ "resource": "" }
q9882
ResponseParser.parseAnswer
train
protected function parseAnswer(Context $context, Response $response): \Generator { $host = yield from $this->readLabel($context); $answer = \unpack('ntype/nclass/Nttl/nlen', yield $this->stream->readBuffer($context, 10)); $this->offset += 10; $ttl = $answer['ttl']; ...
php
{ "resource": "" }
q9883
State.nextOutdent
train
public function nextOutdent() { $oldLevel = $this->getIndentLevel(); $expected = $this->getLevel(); if ($expected < $oldLevel) { $newLevel = $this->outdent(); if ($newLevel < $expected) { $this->throwException( 'Inconsistent indent...
php
{ "resource": "" }
q9884
State.indent
train
public function indent($level = null) { $level = $level ?: $this->getLevel(); array_push($this->indentStack, $level); return $level; }
php
{ "resource": "" }
q9885
State.scan
train
public function scan($scanners) { $scanners = $this->filterScanners($scanners); foreach ($scanners as $key => $scanner) { /** @var ScannerInterface $scanner */ $success = false; foreach ($scanner->scan($this) as $token) { if (!($token instanceof ...
php
{ "resource": "" }
q9886
State.loopScan
train
public function loopScan($scanners, $required = false) { while ($this->reader->hasLength()) { $success = false; foreach ($this->scan($scanners) as $token) { $success = true; yield $token; } if (!$success) { brea...
php
{ "resource": "" }
q9887
State.createToken
train
public function createToken($className) { if (!is_subclass_of($className, TokenInterface::class)) { $this->throwException( "$className is not a valid token sub-class" ); } return new $className( $this->createCurrentSourceLocation(), ...
php
{ "resource": "" }
q9888
State.scanToken
train
public function scanToken($className, $pattern, $modifiers = null) { if (!$this->reader->match($pattern, $modifiers)) { return; } $data = $this->reader->getMatchData(); $token = $this->createToken($className); $this->reader->consume(); foreach ($data as ...
php
{ "resource": "" }
q9889
State.filterScanners
train
private function filterScanners($scanners) { $scannerInstances = []; $scanners = is_array($scanners) ? $scanners : [$scanners]; foreach ($scanners as $key => $scanner) { if (!is_a($scanner, ScannerInterface::class, true)) { throw new \InvalidArgumentException( ...
php
{ "resource": "" }
q9890
ResponseService.getRedirectResponse
train
public function getRedirectResponse(string $routeName, array $routeParameters = []): RedirectResponse { $url = $this->router->generate($routeName, $routeParameters); return new RedirectResponse($url); }
php
{ "resource": "" }
q9891
CategorizeServiceProvider.registerCategoryProvider
train
protected function registerCategoryProvider() { $this->app['categorize.category'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categories.model'); return new CategoryProvider($model); }); }
php
{ "resource": "" }
q9892
CategorizeServiceProvider.registerCategoryHierarchyProvider
train
protected function registerCategoryHierarchyProvider() { $this->app['categorize.categoryHierarchy'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categoryHierarchy.model'); return new CategoryHierarchyProvider($model); }); }
php
{ "resource": "" }
q9893
CategorizeServiceProvider.registerCategoryRelateProvider
train
protected function registerCategoryRelateProvider() { $this->app['categorize.categoryRelate'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categoryRelates.model'); return new CategoryRelateProvider($model); }); }
php
{ "resource": "" }
q9894
SitemapService.configureRobotsFile
train
protected function configureRobotsFile(RobotsFileInterface $robots) { $robots->setCrawlDelay($this->robots['crawl_delay']); foreach ($this->robots['allow'] as $path => $userAgent) { if (strpos($path, '/') === false) { $path = $this->router->generate($path); } ...
php
{ "resource": "" }
q9895
DoctrineThrottleRepository.bulkSave
train
protected function bulkSave(array $throttles) { $entityManager = $this->getEntityManager(); foreach ($throttles as $throttle) { $entityManager->persist($throttle); } $entityManager->flush(); }
php
{ "resource": "" }
q9896
sfWidgetFormSelect2PropelChoiceSortable.configure
train
protected function configure($options = array(), $attributes = array()) { $this->addOption('culture', sfContext::getInstance()->getUser()->getCulture()); $this->addOption('width', sfConfig::get('sf_sfSelect2Widgets_width')); $this->addRequiredOption('model'); $this->addOption('add_em...
php
{ "resource": "" }
q9897
DoctrinePersistenceRepository.findUserByPersistenceCode
train
public function findUserByPersistenceCode($code) { $persistence = $this->findByPersistenceCode($code); if ($persistence) { return $persistence->getUser(); } return false; }
php
{ "resource": "" }
q9898
DoctrinePersistenceRepository.persist
train
public function persist(PersistableInterface $persistable, $remember = false) { try { if ($this->single) { $this->flush($persistable); } $code = $persistable->generatePersistenceCode(); $this->session->put($code); ...
php
{ "resource": "" }
q9899
DoctrinePersistenceRepository.remove
train
public function remove($code) { $entityManager = $this->getEntityManager(); $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder ->delete($this->entityName(), 'p') ->where('p.code = :code') ->setParameter('code', $code); return $qu...
php
{ "resource": "" }