repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
wa0x6e/php-resque-ex-scheduler
lib/ResqueScheduler/ResqueScheduler.php
ResqueScheduler.enqueueIn
public static function enqueueIn($in, $queue, $class, array $args = array(), $trackStatus = false) { return self::enqueueAt(time() + $in, $queue, $class, $args, $trackStatus); }
php
public static function enqueueIn($in, $queue, $class, array $args = array(), $trackStatus = false) { return self::enqueueAt(time() + $in, $queue, $class, $args, $trackStatus); }
[ "public", "static", "function", "enqueueIn", "(", "$", "in", ",", "$", "queue", ",", "$", "class", ",", "array", "$", "args", "=", "array", "(", ")", ",", "$", "trackStatus", "=", "false", ")", "{", "return", "self", "::", "enqueueAt", "(", "time", ...
Enqueue a job in a given number of seconds from now. Identical to Resque::enqueue, however the first argument is the number of seconds before the job should be executed. @param int $in Number of seconds from now when the job should be executed. @param string $queue The name of the queue to place the job in. @param string $class The name of the class that contains the code to execute the job. @param array $args Any optional arguments that should be passed when the job is executed. @param boolean $trackStatus Set to true to be able to monitor the status of a job. @return string Job ID
[ "Enqueue", "a", "job", "in", "a", "given", "number", "of", "seconds", "from", "now", "." ]
train
https://github.com/wa0x6e/php-resque-ex-scheduler/blob/aebd32014e44d2a1037392961dede2875b525f6f/lib/ResqueScheduler/ResqueScheduler.php#L32-L35
wa0x6e/php-resque-ex-scheduler
lib/ResqueScheduler/ResqueScheduler.php
ResqueScheduler.enqueueAt
public static function enqueueAt($at, $queue, $class, $args = array(), $trackStatus = false) { self::validateJob($class, $queue); $args['id'] = md5(uniqid('', true)); $args['s_time'] = time(); $job = self::jobToHash($queue, $class, $args, $trackStatus); self::delayedPush($at, $job); if ($trackStatus) { \Resque_Job_Status::create($args['id'], Job\Status::STATUS_SCHEDULED); } \Resque_Event::trigger( 'afterSchedule', array( 'at' => $at, 'queue' => $queue, 'class' => $class, 'args' => $args, ) ); return $args['id']; }
php
public static function enqueueAt($at, $queue, $class, $args = array(), $trackStatus = false) { self::validateJob($class, $queue); $args['id'] = md5(uniqid('', true)); $args['s_time'] = time(); $job = self::jobToHash($queue, $class, $args, $trackStatus); self::delayedPush($at, $job); if ($trackStatus) { \Resque_Job_Status::create($args['id'], Job\Status::STATUS_SCHEDULED); } \Resque_Event::trigger( 'afterSchedule', array( 'at' => $at, 'queue' => $queue, 'class' => $class, 'args' => $args, ) ); return $args['id']; }
[ "public", "static", "function", "enqueueAt", "(", "$", "at", ",", "$", "queue", ",", "$", "class", ",", "$", "args", "=", "array", "(", ")", ",", "$", "trackStatus", "=", "false", ")", "{", "self", "::", "validateJob", "(", "$", "class", ",", "$", ...
Enqueue a job for execution at a given timestamp. Identical to Resque::enqueue, however the first argument is a timestamp (either UNIX timestamp in integer format or an instance of the DateTime class in PHP). @param DateTime|int $at Instance of PHP DateTime object or int of UNIX timestamp. @param string $queue The name of the queue to place the job in. @param string $class The name of the class that contains the code to execute the job. @param array $args Any optional arguments that should be passed when the job is executed. @param boolean $trackStatus Set to true to be able to monitor the status of a job. @return string Job ID
[ "Enqueue", "a", "job", "for", "execution", "at", "a", "given", "timestamp", "." ]
train
https://github.com/wa0x6e/php-resque-ex-scheduler/blob/aebd32014e44d2a1037392961dede2875b525f6f/lib/ResqueScheduler/ResqueScheduler.php#L51-L75
wa0x6e/php-resque-ex-scheduler
lib/ResqueScheduler/ResqueScheduler.php
ResqueScheduler.delayedPush
public static function delayedPush($timestamp, $item) { $timestamp = self::getTimestamp($timestamp); $redis = \Resque::redis(); $redis->rpush(self::QUEUE_NAME . ':' . $timestamp, json_encode($item)); $redis->zadd(self::QUEUE_NAME, $timestamp, $timestamp); }
php
public static function delayedPush($timestamp, $item) { $timestamp = self::getTimestamp($timestamp); $redis = \Resque::redis(); $redis->rpush(self::QUEUE_NAME . ':' . $timestamp, json_encode($item)); $redis->zadd(self::QUEUE_NAME, $timestamp, $timestamp); }
[ "public", "static", "function", "delayedPush", "(", "$", "timestamp", ",", "$", "item", ")", "{", "$", "timestamp", "=", "self", "::", "getTimestamp", "(", "$", "timestamp", ")", ";", "$", "redis", "=", "\\", "Resque", "::", "redis", "(", ")", ";", "...
Directly append an item to the delayed queue schedule. @param DateTime|int $timestamp Timestamp job is scheduled to be run at. @param array $item Hash of item to be pushed to schedule.
[ "Directly", "append", "an", "item", "to", "the", "delayed", "queue", "schedule", "." ]
train
https://github.com/wa0x6e/php-resque-ex-scheduler/blob/aebd32014e44d2a1037392961dede2875b525f6f/lib/ResqueScheduler/ResqueScheduler.php#L83-L90
wa0x6e/php-resque-ex-scheduler
lib/ResqueScheduler/ResqueScheduler.php
ResqueScheduler.getDelayedTimestampSize
public static function getDelayedTimestampSize($timestamp) { $timestamp = self::getTimestamp($timestamp); return \Resque::redis()->llen(self::QUEUE_NAME . ':' . $timestamp, $timestamp); }
php
public static function getDelayedTimestampSize($timestamp) { $timestamp = self::getTimestamp($timestamp); return \Resque::redis()->llen(self::QUEUE_NAME . ':' . $timestamp, $timestamp); }
[ "public", "static", "function", "getDelayedTimestampSize", "(", "$", "timestamp", ")", "{", "$", "timestamp", "=", "self", "::", "getTimestamp", "(", "$", "timestamp", ")", ";", "return", "\\", "Resque", "::", "redis", "(", ")", "->", "llen", "(", "self", ...
Get the number of jobs for a given timestamp in the delayed schedule. @param DateTime|int $timestamp Timestamp @return int Number of scheduled jobs.
[ "Get", "the", "number", "of", "jobs", "for", "a", "given", "timestamp", "in", "the", "delayed", "schedule", "." ]
train
https://github.com/wa0x6e/php-resque-ex-scheduler/blob/aebd32014e44d2a1037392961dede2875b525f6f/lib/ResqueScheduler/ResqueScheduler.php#L108-L113
wa0x6e/php-resque-ex-scheduler
lib/ResqueScheduler/ResqueScheduler.php
ResqueScheduler.getTimestamp
private static function getTimestamp($timestamp) { if ($timestamp instanceof \DateTime) { $timestamp = $timestamp->getTimestamp(); } if ((int) $timestamp != $timestamp) { throw new ResqueScheduler\InvalidTimestampException( 'The supplied timestamp value could not be converted to an integer.' ); } return (int) $timestamp; }
php
private static function getTimestamp($timestamp) { if ($timestamp instanceof \DateTime) { $timestamp = $timestamp->getTimestamp(); } if ((int) $timestamp != $timestamp) { throw new ResqueScheduler\InvalidTimestampException( 'The supplied timestamp value could not be converted to an integer.' ); } return (int) $timestamp; }
[ "private", "static", "function", "getTimestamp", "(", "$", "timestamp", ")", "{", "if", "(", "$", "timestamp", "instanceof", "\\", "DateTime", ")", "{", "$", "timestamp", "=", "$", "timestamp", "->", "getTimestamp", "(", ")", ";", "}", "if", "(", "(", ...
Convert a timestamp in some format in to a unix timestamp as an integer. @param DateTime|int $timestamp Instance of DateTime or UNIX timestamp. @return int Timestamp @throws ResqueScheduler_InvalidTimestampException
[ "Convert", "a", "timestamp", "in", "some", "format", "in", "to", "a", "unix", "timestamp", "as", "an", "integer", "." ]
train
https://github.com/wa0x6e/php-resque-ex-scheduler/blob/aebd32014e44d2a1037392961dede2875b525f6f/lib/ResqueScheduler/ResqueScheduler.php#L213-L226
wa0x6e/php-resque-ex-scheduler
lib/ResqueScheduler/ResqueScheduler.php
ResqueScheduler.nextDelayedTimestamp
public static function nextDelayedTimestamp($at = null) { if ($at === null) { $at = time(); } else { $at = self::getTimestamp($at); } $items = \Resque::redis()->zrangebyscore(self::QUEUE_NAME, '-inf', $at, array('limit', 0, 1)); if (!empty($items)) { return $items[0]; } return false; }
php
public static function nextDelayedTimestamp($at = null) { if ($at === null) { $at = time(); } else { $at = self::getTimestamp($at); } $items = \Resque::redis()->zrangebyscore(self::QUEUE_NAME, '-inf', $at, array('limit', 0, 1)); if (!empty($items)) { return $items[0]; } return false; }
[ "public", "static", "function", "nextDelayedTimestamp", "(", "$", "at", "=", "null", ")", "{", "if", "(", "$", "at", "===", "null", ")", "{", "$", "at", "=", "time", "(", ")", ";", "}", "else", "{", "$", "at", "=", "self", "::", "getTimestamp", "...
Find the first timestamp in the delayed schedule before/including the timestamp. Will find and return the first timestamp upto and including the given timestamp. This is the heart of the ResqueScheduler that will make sure that any jobs scheduled for the past when the worker wasn't running are also queued up. @param DateTime|int $timestamp Instance of DateTime or UNIX timestamp. Defaults to now. @return int|false UNIX timestamp, or false if nothing to run.
[ "Find", "the", "first", "timestamp", "in", "the", "delayed", "schedule", "before", "/", "including", "the", "timestamp", "." ]
train
https://github.com/wa0x6e/php-resque-ex-scheduler/blob/aebd32014e44d2a1037392961dede2875b525f6f/lib/ResqueScheduler/ResqueScheduler.php#L240-L254
wa0x6e/php-resque-ex-scheduler
lib/ResqueScheduler/ResqueScheduler.php
ResqueScheduler.nextItemForTimestamp
public static function nextItemForTimestamp($timestamp) { $timestamp = self::getTimestamp($timestamp); $key = self::QUEUE_NAME . ':' . $timestamp; $item = json_decode(\Resque::redis()->lpop($key), true); self::cleanupTimestamp($key, $timestamp); return $item; }
php
public static function nextItemForTimestamp($timestamp) { $timestamp = self::getTimestamp($timestamp); $key = self::QUEUE_NAME . ':' . $timestamp; $item = json_decode(\Resque::redis()->lpop($key), true); self::cleanupTimestamp($key, $timestamp); return $item; }
[ "public", "static", "function", "nextItemForTimestamp", "(", "$", "timestamp", ")", "{", "$", "timestamp", "=", "self", "::", "getTimestamp", "(", "$", "timestamp", ")", ";", "$", "key", "=", "self", "::", "QUEUE_NAME", ".", "':'", ".", "$", "timestamp", ...
Pop a job off the delayed queue for a given timestamp. @param DateTime|int $timestamp Instance of DateTime or UNIX timestamp. @return array Matching job at timestamp.
[ "Pop", "a", "job", "off", "the", "delayed", "queue", "for", "a", "given", "timestamp", "." ]
train
https://github.com/wa0x6e/php-resque-ex-scheduler/blob/aebd32014e44d2a1037392961dede2875b525f6f/lib/ResqueScheduler/ResqueScheduler.php#L262-L272
baleen/migrations
src/Migration/Repository/AggregateMigrationRepository.php
AggregateMigrationRepository.addRepositories
public function addRepositories($repositories) { if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) { throw new InvalidArgumentException(sprintf( 'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' . ' "%s" given', is_object($repositories) ? get_class($repositories) : gettype($repositories) )); } foreach ($repositories as $repo) { $this->addRepository($repo); } }
php
public function addRepositories($repositories) { if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) { throw new InvalidArgumentException(sprintf( 'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' . ' "%s" given', is_object($repositories) ? get_class($repositories) : gettype($repositories) )); } foreach ($repositories as $repo) { $this->addRepository($repo); } }
[ "public", "function", "addRepositories", "(", "$", "repositories", ")", "{", "if", "(", "!", "is_array", "(", "$", "repositories", ")", "&&", "(", "!", "is_object", "(", "$", "repositories", ")", "||", "!", "$", "repositories", "instanceof", "\\", "Travers...
Adds a set of repositories to the stack @param $repositories @throws InvalidArgumentException
[ "Adds", "a", "set", "of", "repositories", "to", "the", "stack" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Repository/AggregateMigrationRepository.php#L60-L72
baleen/migrations
src/Migration/Repository/AggregateMigrationRepository.php
AggregateMigrationRepository.setRepositories
public function setRepositories($repositories) { if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) { throw new InvalidArgumentException(sprintf( 'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' . ' "%s" given', is_object($repositories) ? get_class($repositories) : gettype($repositories) )); } $this->stack = new \SplStack(); $this->addRepositories($repositories); }
php
public function setRepositories($repositories) { if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) { throw new InvalidArgumentException(sprintf( 'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' . ' "%s" given', is_object($repositories) ? get_class($repositories) : gettype($repositories) )); } $this->stack = new \SplStack(); $this->addRepositories($repositories); }
[ "public", "function", "setRepositories", "(", "$", "repositories", ")", "{", "if", "(", "!", "is_array", "(", "$", "repositories", ")", "&&", "(", "!", "is_object", "(", "$", "repositories", ")", "||", "!", "$", "repositories", "instanceof", "\\", "Travers...
Resets the stack to the specified repositories @param array|\Traversable $repositories @throws InvalidArgumentException
[ "Resets", "the", "stack", "to", "the", "specified", "repositories" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Repository/AggregateMigrationRepository.php#L90-L101
baleen/migrations
src/Migration/Repository/AggregateMigrationRepository.php
AggregateMigrationRepository.fetchAll
public function fetchAll() { $collection = new Collection(); foreach ($this->getRepositories() as $repo) { /** @var MigrationRepositoryInterface $repo */ $versions = $repo->fetchAll(); $collection->merge($versions); } return $collection; }
php
public function fetchAll() { $collection = new Collection(); foreach ($this->getRepositories() as $repo) { /** @var MigrationRepositoryInterface $repo */ $versions = $repo->fetchAll(); $collection->merge($versions); } return $collection; }
[ "public", "function", "fetchAll", "(", ")", "{", "$", "collection", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "this", "->", "getRepositories", "(", ")", "as", "$", "repo", ")", "{", "/** @var MigrationRepositoryInterface $repo */", "$", "...
Fetches all versions available to all repositories in the stack and returns them as a Linked collection. The returned collection contains versions groups sequentially into groups that correspond to each sub-repository. Each of those groups is sorted with the repository's own comparator. Therefore, its strongly recommended not to sort or modify the resulting collection. @return Collection
[ "Fetches", "all", "versions", "available", "to", "all", "repositories", "in", "the", "stack", "and", "returns", "them", "as", "a", "Linked", "collection", "." ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Repository/AggregateMigrationRepository.php#L112-L122
baleen/migrations
src/Migration/Repository/AggregateMigrationRepository.php
AggregateMigrationRepository.setMigrationFactory
public function setMigrationFactory(FactoryInterface $factory) { foreach ($this->getRepositories() as $repo) { $repo->setMigrationFactory($factory); } }
php
public function setMigrationFactory(FactoryInterface $factory) { foreach ($this->getRepositories() as $repo) { $repo->setMigrationFactory($factory); } }
[ "public", "function", "setMigrationFactory", "(", "FactoryInterface", "$", "factory", ")", "{", "foreach", "(", "$", "this", "->", "getRepositories", "(", ")", "as", "$", "repo", ")", "{", "$", "repo", "->", "setMigrationFactory", "(", "$", "factory", ")", ...
Sets the migration factory for ALL repositories in the stack. @param FactoryInterface $factory
[ "Sets", "the", "migration", "factory", "for", "ALL", "repositories", "in", "the", "stack", "." ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Repository/AggregateMigrationRepository.php#L129-L134
kaliop-uk/kueueingbundle
Helper/Watchdog.php
Watchdog.startProcess
public function startProcess($command) { $process = new Process($command); $process->start(); // give the OS some time to abort invalid commands sleep(1); if (!$process->isRunning()) { throw new RuntimeException("Process terminated immediately"); } // while at it, emit a message if ($this->dispatcher) { $event = new ProcessStartedEvent($process->getPid(), $command); $this->dispatcher->dispatch(EventsList::PROCESS_STARTED, $event); } return $process->getPid(); }
php
public function startProcess($command) { $process = new Process($command); $process->start(); // give the OS some time to abort invalid commands sleep(1); if (!$process->isRunning()) { throw new RuntimeException("Process terminated immediately"); } // while at it, emit a message if ($this->dispatcher) { $event = new ProcessStartedEvent($process->getPid(), $command); $this->dispatcher->dispatch(EventsList::PROCESS_STARTED, $event); } return $process->getPid(); }
[ "public", "function", "startProcess", "(", "$", "command", ")", "{", "$", "process", "=", "new", "Process", "(", "$", "command", ")", ";", "$", "process", "->", "start", "(", ")", ";", "// give the OS some time to abort invalid commands", "sleep", "(", "1", ...
Starts a process in the background - waits for 1 second to check that the process did not die prematurely (it is supposed to be a long-running task) @param string $command @return int the pid of the created process @throws \Symfony\Component\Process\Exception\RuntimeException when process could not start / terminated immediately
[ "Starts", "a", "process", "in", "the", "background", "-", "waits", "for", "1", "second", "to", "check", "that", "the", "process", "did", "not", "die", "prematurely", "(", "it", "is", "supposed", "to", "be", "a", "long", "-", "running", "task", ")", "@p...
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Helper/Watchdog.php#L31-L48
kaliop-uk/kueueingbundle
Helper/Watchdog.php
Watchdog.getProcessPidByCommand
public function getProcessPidByCommand($command) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { throw new \Exception("Windows not supported yet"); } else { exec( // gotta love escaping single quotes in shell "ps -eo pid,args | fgrep '" . str_replace("'", "'\''", $command) . "' | grep -v grep", $output, $retCode); if ($retCode != 0) { return array(); } $pids = array(); foreach ($output as $line) { $line = explode(' ', trim($line), 2); $pids[$line[0]] = $line[1]; } return $pids; } }
php
public function getProcessPidByCommand($command) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { throw new \Exception("Windows not supported yet"); } else { exec( // gotta love escaping single quotes in shell "ps -eo pid,args | fgrep '" . str_replace("'", "'\''", $command) . "' | grep -v grep", $output, $retCode); if ($retCode != 0) { return array(); } $pids = array(); foreach ($output as $line) { $line = explode(' ', trim($line), 2); $pids[$line[0]] = $line[1]; } return $pids; } }
[ "public", "function", "getProcessPidByCommand", "(", "$", "command", ")", "{", "if", "(", "strtoupper", "(", "substr", "(", "PHP_OS", ",", "0", ",", "3", ")", ")", "===", "'WIN'", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Windows not supported y...
Checks if a command is still executing, by looking at its exact command-line in the process list NB: it is based on the ps command which, (on linux) removes most quotes in its output, compared to what is passed on the shell for execution. For a non-exhaustive list of ways to express options, try using 'ps' and grep for the following: php sleep.php -a='b' -c="d" -e='f g' --h="i j" k 'l' "m" 'n''' "o\"" "p'" 'q"' -r=\' -s=\'\' -t='u'\''v' @param string $command @return array (key: pid, value: command) @throws \Exception @todo windows support: use "tasklist /v"
[ "Checks", "if", "a", "command", "is", "still", "executing", "by", "looking", "at", "its", "exact", "command", "-", "line", "in", "the", "process", "list", "NB", ":", "it", "is", "based", "on", "the", "ps", "command", "which", "(", "on", "linux", ")", ...
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Helper/Watchdog.php#L87-L109
cevou/BehatScreenshotCompareExtension
src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/ScreenshotCompareExtension.php
ScreenshotCompareExtension.load
public function load(ContainerBuilder $container, array $config) { $container->setParameter('screenshot_compare.parameters', $config); $this->loadAdaptersAndCreateFilesystem($container, $config); $this->loadContextInitializer($container); }
php
public function load(ContainerBuilder $container, array $config) { $container->setParameter('screenshot_compare.parameters', $config); $this->loadAdaptersAndCreateFilesystem($container, $config); $this->loadContextInitializer($container); }
[ "public", "function", "load", "(", "ContainerBuilder", "$", "container", ",", "array", "$", "config", ")", "{", "$", "container", "->", "setParameter", "(", "'screenshot_compare.parameters'", ",", "$", "config", ")", ";", "$", "this", "->", "loadAdaptersAndCreat...
{@inheritdoc}
[ "{" ]
train
https://github.com/cevou/BehatScreenshotCompareExtension/blob/b10465b0c69d237f8608c78e829bc6f10c31455a/src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/ScreenshotCompareExtension.php#L48-L54
cevou/BehatScreenshotCompareExtension
src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/ScreenshotCompareExtension.php
ScreenshotCompareExtension.configure
public function configure(ArrayNodeDefinition $builder) { $builder ->addDefaultsIfNotSet() ->children() ->scalarNode('screenshot_dir')->defaultValue('%paths.base%/features/screenshots')->end() ->end() ->end(); $adapterNodeBuilder = $builder ->children() ->arrayNode('adapters') ->useAttributeAsKey('name') ->prototype('array') ->performNoDeepMerging() ->children() ; foreach ($this->adapterFactories as $name => $factory) { $factoryNode = $adapterNodeBuilder->arrayNode($name)->canBeUnset(); $factory->addConfiguration($factoryNode); } $builder ->children() ->arrayNode('sessions') ->useAttributeAsKey('name') ->prototype('array') ->children() ->scalarNode('adapter')->defaultValue('default')->end() ->arrayNode('crop') ->children() ->integerNode('left')->defaultValue(0)->min(0)->end() ->integerNode('right')->defaultValue(0)->min(0)->end() ->integerNode('top')->defaultValue(0)->min(0)->end() ->integerNode('bottom')->defaultValue(0)->min(0)->end(); }
php
public function configure(ArrayNodeDefinition $builder) { $builder ->addDefaultsIfNotSet() ->children() ->scalarNode('screenshot_dir')->defaultValue('%paths.base%/features/screenshots')->end() ->end() ->end(); $adapterNodeBuilder = $builder ->children() ->arrayNode('adapters') ->useAttributeAsKey('name') ->prototype('array') ->performNoDeepMerging() ->children() ; foreach ($this->adapterFactories as $name => $factory) { $factoryNode = $adapterNodeBuilder->arrayNode($name)->canBeUnset(); $factory->addConfiguration($factoryNode); } $builder ->children() ->arrayNode('sessions') ->useAttributeAsKey('name') ->prototype('array') ->children() ->scalarNode('adapter')->defaultValue('default')->end() ->arrayNode('crop') ->children() ->integerNode('left')->defaultValue(0)->min(0)->end() ->integerNode('right')->defaultValue(0)->min(0)->end() ->integerNode('top')->defaultValue(0)->min(0)->end() ->integerNode('bottom')->defaultValue(0)->min(0)->end(); }
[ "public", "function", "configure", "(", "ArrayNodeDefinition", "$", "builder", ")", "{", "$", "builder", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'screenshot_dir'", ")", "->", "defaultValue", "(", "'%paths.base...
{@inheritdoc}
[ "{" ]
train
https://github.com/cevou/BehatScreenshotCompareExtension/blob/b10465b0c69d237f8608c78e829bc6f10c31455a/src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/ScreenshotCompareExtension.php#L59-L96
matrozov/yii2-couchbase
src/Query.php
Query.createCommand
public function createCommand($db = null) { if ($db === null) { $db = Yii::$app->get('couchbase'); } list($sql, $params) = $db->getQueryBuilder()->build($this); $bucketName = is_array($this->from) ? reset($this->from) : $this->from; return $db->createCommand($sql, $params)->setBucketName($bucketName); }
php
public function createCommand($db = null) { if ($db === null) { $db = Yii::$app->get('couchbase'); } list($sql, $params) = $db->getQueryBuilder()->build($this); $bucketName = is_array($this->from) ? reset($this->from) : $this->from; return $db->createCommand($sql, $params)->setBucketName($bucketName); }
[ "public", "function", "createCommand", "(", "$", "db", "=", "null", ")", "{", "if", "(", "$", "db", "===", "null", ")", "{", "$", "db", "=", "Yii", "::", "$", "app", "->", "get", "(", "'couchbase'", ")", ";", "}", "list", "(", "$", "sql", ",", ...
Creates a DB command that can be used to execute this query. @param Connection $db the database connection used to generate the SQL statement. If this parameter is not given, the `db` application component will be used. @return Command the created DB command instance. @throws Exception @throws \yii\base\InvalidConfigException
[ "Creates", "a", "DB", "command", "that", "can", "be", "used", "to", "execute", "this", "query", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Query.php#L40-L51
budde377/Part
lib/view/template/SiteContentTwigTokenParserImpl.php
SiteContentTwigTokenParserImpl.parse
public function parse(Twig_Token $token) { $stream = $this->parser->getStream(); if($stream->getCurrent()->getType() == Twig_Token::BLOCK_END_TYPE){ $stream->expect(Twig_Token::BLOCK_END_TYPE); return new SiteContentTwigNodeImpl($token->getLine(), $this->getTag()); } $name = $this->parser->getExpressionParser()->parseExpression(); //$stream->expect(Twig_Token::NAME_TYPE)->getValue(); $stream->expect(Twig_Token::BLOCK_END_TYPE); return new SiteContentTwigNodeImpl( $token->getLine(), $this->getTag(), $name); }
php
public function parse(Twig_Token $token) { $stream = $this->parser->getStream(); if($stream->getCurrent()->getType() == Twig_Token::BLOCK_END_TYPE){ $stream->expect(Twig_Token::BLOCK_END_TYPE); return new SiteContentTwigNodeImpl($token->getLine(), $this->getTag()); } $name = $this->parser->getExpressionParser()->parseExpression(); //$stream->expect(Twig_Token::NAME_TYPE)->getValue(); $stream->expect(Twig_Token::BLOCK_END_TYPE); return new SiteContentTwigNodeImpl( $token->getLine(), $this->getTag(), $name); }
[ "public", "function", "parse", "(", "Twig_Token", "$", "token", ")", "{", "$", "stream", "=", "$", "this", "->", "parser", "->", "getStream", "(", ")", ";", "if", "(", "$", "stream", "->", "getCurrent", "(", ")", "->", "getType", "(", ")", "==", "T...
Parses a token and returns a node. @param Twig_Token $token A Twig_Token instance @return Twig_Node A Twig_NodeInterface instance
[ "Parses", "a", "token", "and", "returns", "a", "node", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/view/template/SiteContentTwigTokenParserImpl.php#L24-L36
budde377/Part
lib/model/page/DefaultPageLibraryImpl.php
DefaultPageLibraryImpl.getPage
public function getPage($id) { return isset($this->pages[$id])?$this->pages[$id]:null; }
php
public function getPage($id) { return isset($this->pages[$id])?$this->pages[$id]:null; }
[ "public", "function", "getPage", "(", "$", "id", ")", "{", "return", "isset", "(", "$", "this", "->", "pages", "[", "$", "id", "]", ")", "?", "$", "this", "->", "pages", "[", "$", "id", "]", ":", "null", ";", "}" ]
Will return a default page given an ID @param string $id The id @return Page | null Instance matching the ID or NULL on no such page
[ "Will", "return", "a", "default", "page", "given", "an", "ID" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/DefaultPageLibraryImpl.php#L112-L115
scherersoftware/cake-model-history
src/Model/Transform/Transform.php
Transform.get
public static function get(string $type): Transform { $namespace = '\\ModelHistory\\Model\\Transform\\'; $transformClass = $namespace . Inflector::camelize($type) . 'Transform'; if (class_exists($transformClass)) { return new $transformClass(); } throw new InvalidArgumentException('Transform ' . $transformClass . ' not found!'); }
php
public static function get(string $type): Transform { $namespace = '\\ModelHistory\\Model\\Transform\\'; $transformClass = $namespace . Inflector::camelize($type) . 'Transform'; if (class_exists($transformClass)) { return new $transformClass(); } throw new InvalidArgumentException('Transform ' . $transformClass . ' not found!'); }
[ "public", "static", "function", "get", "(", "string", "$", "type", ")", ":", "Transform", "{", "$", "namespace", "=", "'\\\\ModelHistory\\\\Model\\\\Transform\\\\'", ";", "$", "transformClass", "=", "$", "namespace", ".", "Inflector", "::", "camelize", "(", "$",...
Transform factory @param string $type Transform type @return Transform
[ "Transform", "factory" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Transform/Transform.php#L39-L47
yeephp/yeephp
Yee/Middleware/SessionCookie.php
SessionCookie.loadSession
protected function loadSession() { if (session_id() === '') { session_start(); } $value = $this->app->getCookie($this->settings['name']); if ($value) { try { $_SESSION = unserialize($value); } catch (\Exception $e) { $this->app->getLog()->error('Error unserializing session cookie value! ' . $e->getMessage()); } } else { $_SESSION = array(); } }
php
protected function loadSession() { if (session_id() === '') { session_start(); } $value = $this->app->getCookie($this->settings['name']); if ($value) { try { $_SESSION = unserialize($value); } catch (\Exception $e) { $this->app->getLog()->error('Error unserializing session cookie value! ' . $e->getMessage()); } } else { $_SESSION = array(); } }
[ "protected", "function", "loadSession", "(", ")", "{", "if", "(", "session_id", "(", ")", "===", "''", ")", "{", "session_start", "(", ")", ";", "}", "$", "value", "=", "$", "this", "->", "app", "->", "getCookie", "(", "$", "this", "->", "settings", ...
Load session
[ "Load", "session" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Middleware/SessionCookie.php#L117-L134
yeephp/yeephp
Yee/Middleware/SessionCookie.php
SessionCookie.saveSession
protected function saveSession() { $value = serialize($_SESSION); if (strlen($value) > 4096) { $this->app->getLog()->error('WARNING! Yee\Middleware\SessionCookie data size is larger than 4KB. Content save failed.'); } else { $this->app->setCookie( $this->settings['name'], $value, $this->settings['expires'], $this->settings['path'], $this->settings['domain'], $this->settings['secure'], $this->settings['httponly'] ); } // session_destroy(); }
php
protected function saveSession() { $value = serialize($_SESSION); if (strlen($value) > 4096) { $this->app->getLog()->error('WARNING! Yee\Middleware\SessionCookie data size is larger than 4KB. Content save failed.'); } else { $this->app->setCookie( $this->settings['name'], $value, $this->settings['expires'], $this->settings['path'], $this->settings['domain'], $this->settings['secure'], $this->settings['httponly'] ); } // session_destroy(); }
[ "protected", "function", "saveSession", "(", ")", "{", "$", "value", "=", "serialize", "(", "$", "_SESSION", ")", ";", "if", "(", "strlen", "(", "$", "value", ")", ">", "4096", ")", "{", "$", "this", "->", "app", "->", "getLog", "(", ")", "->", "...
Save session
[ "Save", "session" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Middleware/SessionCookie.php#L139-L157
fab2s/NodalFlow
src/Interrupter.php
Interrupter.setType
public function setType($type) { if (!isset($this->types[$type])) { throw new InvalidArgumentException('type must be one of:' . implode(', ', array_keys($this->types))); } $this->type = $type; return $this; }
php
public function setType($type) { if (!isset($this->types[$type])) { throw new InvalidArgumentException('type must be one of:' . implode(', ', array_keys($this->types))); } $this->type = $type; return $this; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "types", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'type must be one of:'", ".", "implode", "(", ...
@param string $type @throws InvalidArgumentException @return $this
[ "@param", "string", "$type" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Interrupter.php#L79-L88
fab2s/NodalFlow
src/Interrupter.php
Interrupter.propagate
public function propagate(FlowInterface $flow) { // evacuate edge cases if ($this->isEdgeInterruptCase($flow)) { // if anything had to be done, it was done first hand already // just make sure we propagate the eventual nodeTarget return $flow->setInterruptNodeId($this->nodeTarget); } $InterrupterFlowId = $flow->getId(); if (!$this->type) { throw new NodalFlowException('No interrupt type set', 1, null, [ 'InterrupterFlowId' => $InterrupterFlowId, ]); } do { $lastFlowId = $flow->getId(); if ($this->flowTarget === $lastFlowId) { // interrupting $flow return $flow->setInterruptNodeId($this->nodeTarget)->interruptFlow($this->type); } // Set interruptNodeId to true in order to make sure // we do not match any nodes in this flow (as it is not the target) $flow->setInterruptNodeId(true)->interruptFlow($this->type); } while ($flow = $flow->getParent()); if ($this->flowTarget !== InterrupterInterface::TARGET_TOP) { throw new NodalFlowException('Interruption target missed', 1, null, [ 'interruptAt' => $this->flowTarget, 'InterrupterFlowId' => $InterrupterFlowId, 'lastFlowId' => $lastFlowId, ]); } return $flow; }
php
public function propagate(FlowInterface $flow) { // evacuate edge cases if ($this->isEdgeInterruptCase($flow)) { // if anything had to be done, it was done first hand already // just make sure we propagate the eventual nodeTarget return $flow->setInterruptNodeId($this->nodeTarget); } $InterrupterFlowId = $flow->getId(); if (!$this->type) { throw new NodalFlowException('No interrupt type set', 1, null, [ 'InterrupterFlowId' => $InterrupterFlowId, ]); } do { $lastFlowId = $flow->getId(); if ($this->flowTarget === $lastFlowId) { // interrupting $flow return $flow->setInterruptNodeId($this->nodeTarget)->interruptFlow($this->type); } // Set interruptNodeId to true in order to make sure // we do not match any nodes in this flow (as it is not the target) $flow->setInterruptNodeId(true)->interruptFlow($this->type); } while ($flow = $flow->getParent()); if ($this->flowTarget !== InterrupterInterface::TARGET_TOP) { throw new NodalFlowException('Interruption target missed', 1, null, [ 'interruptAt' => $this->flowTarget, 'InterrupterFlowId' => $InterrupterFlowId, 'lastFlowId' => $lastFlowId, ]); } return $flow; }
[ "public", "function", "propagate", "(", "FlowInterface", "$", "flow", ")", "{", "// evacuate edge cases", "if", "(", "$", "this", "->", "isEdgeInterruptCase", "(", "$", "flow", ")", ")", "{", "// if anything had to be done, it was done first hand already", "// just make...
Trigger the Interrupt of each ancestor Flows up to a specific one, the root one or none if : - No FlowInterrupt is set - FlowInterrupt is set at InterrupterInterface::TARGET_SELF - FlowInterrupt is set at this Flow's Id - FlowInterrupt is set as InterrupterInterface::TARGET_TOP and this has no parent Throw an exception if we reach the top after bubbling and FlowInterrupt != InterrupterInterface::TARGET_TOP @param FlowInterface $flow @throws NodalFlowException @return FlowInterface
[ "Trigger", "the", "Interrupt", "of", "each", "ancestor", "Flows", "up", "to", "a", "specific", "one", "the", "root", "one", "or", "none", "if", ":", "-", "No", "FlowInterrupt", "is", "set", "-", "FlowInterrupt", "is", "set", "at", "InterrupterInterface", "...
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Interrupter.php#L106-L143
fab2s/NodalFlow
src/Interrupter.php
Interrupter.interruptNode
public function interruptNode(NodeInterface $node = null) { return $node ? $this->nodeTarget === $node->getId() : false; }
php
public function interruptNode(NodeInterface $node = null) { return $node ? $this->nodeTarget === $node->getId() : false; }
[ "public", "function", "interruptNode", "(", "NodeInterface", "$", "node", "=", "null", ")", "{", "return", "$", "node", "?", "$", "this", "->", "nodeTarget", "===", "$", "node", "->", "getId", "(", ")", ":", "false", ";", "}" ]
@param NodeInterface|null $node @return bool
[ "@param", "NodeInterface|null", "$node" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Interrupter.php#L150-L153
fab2s/NodalFlow
src/Interrupter.php
Interrupter.isEdgeInterruptCase
protected function isEdgeInterruptCase(FlowInterface $flow) { return !$this->flowTarget || ( // asked to stop right here $this->flowTarget === InterrupterInterface::TARGET_SELF || $this->flowTarget === $flow->getId() || ( // target root when this Flow is root already $this->flowTarget === InterrupterInterface::TARGET_TOP && !$flow->hasParent() ) ); }
php
protected function isEdgeInterruptCase(FlowInterface $flow) { return !$this->flowTarget || ( // asked to stop right here $this->flowTarget === InterrupterInterface::TARGET_SELF || $this->flowTarget === $flow->getId() || ( // target root when this Flow is root already $this->flowTarget === InterrupterInterface::TARGET_TOP && !$flow->hasParent() ) ); }
[ "protected", "function", "isEdgeInterruptCase", "(", "FlowInterface", "$", "flow", ")", "{", "return", "!", "$", "this", "->", "flowTarget", "||", "(", "// asked to stop right here", "$", "this", "->", "flowTarget", "===", "InterrupterInterface", "::", "TARGET_SELF"...
@param FlowInterface $flow @return bool
[ "@param", "FlowInterface", "$flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Interrupter.php#L160-L173
budde377/Part
lib/log/LoggerImpl.php
LoggerImpl.log
public function log($level, $message, array $context = array()) { if($context != []){ /** @var DumpFile $dumpFile */ $dumpFile = true; $t = $this->logFile->log($message, $level, $dumpFile); $dumpFile->writeSerialized($context); } else { $t = $this->logFile->log($message, $level); } return $t; }
php
public function log($level, $message, array $context = array()) { if($context != []){ /** @var DumpFile $dumpFile */ $dumpFile = true; $t = $this->logFile->log($message, $level, $dumpFile); $dumpFile->writeSerialized($context); } else { $t = $this->logFile->log($message, $level); } return $t; }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "if", "(", "$", "context", "!=", "[", "]", ")", "{", "/** @var DumpFile $dumpFile */", "$", "dumpFile", "=", "true", ...
Logs with an arbitrary level. @param mixed $level @param string $message @param array $context @return int
[ "Logs", "with", "an", "arbitrary", "level", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/log/LoggerImpl.php#L142-L156
budde377/Part
lib/log/LoggerImpl.php
LoggerImpl.listLog
public function listLog($level = Logger::LOG_LEVEL_ALL, $includeContext = true, $time = 0) { $list = $this->logFile->listLog($level, $time); $result = []; foreach ($list as $entry) { if (isset($entry['dumpfile'])) { if ($includeContext) { /** @var DumpFile $dumpFile */ $dumpFile = $entry['dumpfile']; $entry['context'] = $dumpFile->getUnSerializedContent()[0]; } unset($entry['dumpfile']); } $result[] = $entry; } return $result; }
php
public function listLog($level = Logger::LOG_LEVEL_ALL, $includeContext = true, $time = 0) { $list = $this->logFile->listLog($level, $time); $result = []; foreach ($list as $entry) { if (isset($entry['dumpfile'])) { if ($includeContext) { /** @var DumpFile $dumpFile */ $dumpFile = $entry['dumpfile']; $entry['context'] = $dumpFile->getUnSerializedContent()[0]; } unset($entry['dumpfile']); } $result[] = $entry; } return $result; }
[ "public", "function", "listLog", "(", "$", "level", "=", "Logger", "::", "LOG_LEVEL_ALL", ",", "$", "includeContext", "=", "true", ",", "$", "time", "=", "0", ")", "{", "$", "list", "=", "$", "this", "->", "logFile", "->", "listLog", "(", "$", "level...
Use boolean or to combine which loglevels you whish to list. @param int $level @param bool $includeContext If false context will not be included in result. @param int $time The earliest returned entry will be after this value @return mixed
[ "Use", "boolean", "or", "to", "combine", "which", "loglevels", "you", "whish", "to", "list", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/log/LoggerImpl.php#L165-L188
budde377/Part
lib/log/LoggerImpl.php
LoggerImpl.getContextAt
public function getContextAt($time) { $l = $this->listLog(Logger::LOG_LEVEL_ALL, true, $time); if(!count($l) || $l[0]["time"] != $time){ return null; } return $l[0]["context"]; }
php
public function getContextAt($time) { $l = $this->listLog(Logger::LOG_LEVEL_ALL, true, $time); if(!count($l) || $l[0]["time"] != $time){ return null; } return $l[0]["context"]; }
[ "public", "function", "getContextAt", "(", "$", "time", ")", "{", "$", "l", "=", "$", "this", "->", "listLog", "(", "Logger", "::", "LOG_LEVEL_ALL", ",", "true", ",", "$", "time", ")", ";", "if", "(", "!", "count", "(", "$", "l", ")", "||", "$", ...
Returns the context corresponding to the line given. @param int $time @return array
[ "Returns", "the", "context", "corresponding", "to", "the", "line", "given", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/log/LoggerImpl.php#L195-L204
yeephp/yeephp
Yee/Http/Request.php
Request.isAjax
public function isAjax() { if ($this->params('isajax')) { return true; } elseif (isset($this->headers['X_REQUESTED_WITH']) && $this->headers['X_REQUESTED_WITH'] === 'XMLHttpRequest') { return true; } else { return false; } }
php
public function isAjax() { if ($this->params('isajax')) { return true; } elseif (isset($this->headers['X_REQUESTED_WITH']) && $this->headers['X_REQUESTED_WITH'] === 'XMLHttpRequest') { return true; } else { return false; } }
[ "public", "function", "isAjax", "(", ")", "{", "if", "(", "$", "this", "->", "params", "(", "'isajax'", ")", ")", "{", "return", "true", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "headers", "[", "'X_REQUESTED_WITH'", "]", ")", "&&", ...
Is this an AJAX request? @return bool
[ "Is", "this", "an", "AJAX", "request?" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Request.php#L166-L175
yeephp/yeephp
Yee/Http/Request.php
Request.get
public function get($key = null, $default = null) { if (!isset($this->env['yee.request.query_hash'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['yee.tests.ignore_multibyte'])) { mb_parse_str($this->env['QUERY_STRING'], $output); } else { parse_str($this->env['QUERY_STRING'], $output); } $this->env['yee.request.query_hash'] = Util::stripSlashesIfMagicQuotes($output); } if ($key) { if (isset($this->env['yee.request.query_hash'][$key])) { return $this->env['yee.request.query_hash'][$key]; } else { return $default; } } else { return $this->env['yee.request.query_hash']; } }
php
public function get($key = null, $default = null) { if (!isset($this->env['yee.request.query_hash'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['yee.tests.ignore_multibyte'])) { mb_parse_str($this->env['QUERY_STRING'], $output); } else { parse_str($this->env['QUERY_STRING'], $output); } $this->env['yee.request.query_hash'] = Util::stripSlashesIfMagicQuotes($output); } if ($key) { if (isset($this->env['yee.request.query_hash'][$key])) { return $this->env['yee.request.query_hash'][$key]; } else { return $default; } } else { return $this->env['yee.request.query_hash']; } }
[ "public", "function", "get", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "env", "[", "'yee.request.query_hash'", "]", ")", ")", "{", "$", "output", "=", "array", "(", ...
Fetch GET data This method returns a key-value array of data sent in the HTTP request query string, or the value of the array key if requested; if the array key does not exist, NULL is returned. @param string $key @param mixed $default Default return value when key does not exist @return array|mixed|null
[ "Fetch", "GET", "data" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Request.php#L217-L237
yeephp/yeephp
Yee/Http/Request.php
Request.post
public function post($key = null, $default = null) { if (!isset($this->env['yee.input'])) { throw new \RuntimeException('Missing Yee.input in environment variables'); } if (!isset($this->env['yee.request.form_hash'])) { $this->env['yee.request.form_hash'] = array(); if ($this->isFormData() && is_string($this->env['yee.input'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['yee.tests.ignore_multibyte'])) { mb_parse_str($this->env['yee.input'], $output); } else { parse_str($this->env['yee.input'], $output); } $this->env['yee.request.form_hash'] = Util::stripSlashesIfMagicQuotes($output); } else { $this->env['yee.request.form_hash'] = Util::stripSlashesIfMagicQuotes($_POST); } } if ($key) { if (isset($this->env['yee.request.form_hash'][$key])) { return $this->env['yee.request.form_hash'][$key]; } else { return $default; } } else { return $this->env['yee.request.form_hash']; } }
php
public function post($key = null, $default = null) { if (!isset($this->env['yee.input'])) { throw new \RuntimeException('Missing Yee.input in environment variables'); } if (!isset($this->env['yee.request.form_hash'])) { $this->env['yee.request.form_hash'] = array(); if ($this->isFormData() && is_string($this->env['yee.input'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['yee.tests.ignore_multibyte'])) { mb_parse_str($this->env['yee.input'], $output); } else { parse_str($this->env['yee.input'], $output); } $this->env['yee.request.form_hash'] = Util::stripSlashesIfMagicQuotes($output); } else { $this->env['yee.request.form_hash'] = Util::stripSlashesIfMagicQuotes($_POST); } } if ($key) { if (isset($this->env['yee.request.form_hash'][$key])) { return $this->env['yee.request.form_hash'][$key]; } else { return $default; } } else { return $this->env['yee.request.form_hash']; } }
[ "public", "function", "post", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "env", "[", "'yee.input'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", ...
Fetch POST data This method returns a key-value array of data sent in the HTTP request body, or the value of a hash key if requested; if the array key does not exist, NULL is returned. @param string $key @param mixed $default Default return value when key does not exist @return array|mixed|null @throws \RuntimeException If environment input is not available
[ "Fetch", "POST", "data" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Request.php#L250-L278
yeephp/yeephp
Yee/Http/Request.php
Request.cookies
public function cookies($key = null) { if ($key) { return $this->cookies->get($key); } return $this->cookies; }
php
public function cookies($key = null) { if ($key) { return $this->cookies->get($key); } return $this->cookies; }
[ "public", "function", "cookies", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", ")", "{", "return", "$", "this", "->", "cookies", "->", "get", "(", "$", "key", ")", ";", "}", "return", "$", "this", "->", "cookies", ";", "}" ]
Fetch COOKIE data This method returns a key-value array of Cookie data sent in the HTTP request, or the value of a array key if requested; if the array key does not exist, NULL is returned. @param string $key @return array|string|null
[ "Fetch", "COOKIE", "data" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Request.php#L322-L330
yeephp/yeephp
Yee/Http/Request.php
Request.getIp
public function getIp() { $keys = array('X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR'); foreach ($keys as $key) { if (isset($this->env[$key])) { return $this->env[$key]; } } return $this->env['REMOTE_ADDR']; }
php
public function getIp() { $keys = array('X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR'); foreach ($keys as $key) { if (isset($this->env[$key])) { return $this->env[$key]; } } return $this->env['REMOTE_ADDR']; }
[ "public", "function", "getIp", "(", ")", "{", "$", "keys", "=", "array", "(", "'X_FORWARDED_FOR'", ",", "'HTTP_X_FORWARDED_FOR'", ",", "'CLIENT_IP'", ",", "'REMOTE_ADDR'", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "iss...
Get IP @return string
[ "Get", "IP" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Request.php#L567-L577
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/Api/PostController.php
PostController.store
public function store() { $messages = $this->posts->validForCreation(Input::get('title'), Input::get('slug')); if (count($messages) > 0) { return Response::json($messages->all(), 400); } $date = (Input::get('publish_date') == "") ? "Now" : Input::get('publish_date'); $post = $this->posts->create( Input::get('title'), Input::get('content'), Input::get('slug'), explode(',', Input::get('tags')), (bool) Input::get('active'), Input::get('user_id', $this->auth->user()->id), Carbon::createFromTimestamp(strtotime($date)) ); return (string) $this->posts->find($post->id); }
php
public function store() { $messages = $this->posts->validForCreation(Input::get('title'), Input::get('slug')); if (count($messages) > 0) { return Response::json($messages->all(), 400); } $date = (Input::get('publish_date') == "") ? "Now" : Input::get('publish_date'); $post = $this->posts->create( Input::get('title'), Input::get('content'), Input::get('slug'), explode(',', Input::get('tags')), (bool) Input::get('active'), Input::get('user_id', $this->auth->user()->id), Carbon::createFromTimestamp(strtotime($date)) ); return (string) $this->posts->find($post->id); }
[ "public", "function", "store", "(", ")", "{", "$", "messages", "=", "$", "this", "->", "posts", "->", "validForCreation", "(", "Input", "::", "get", "(", "'title'", ")", ",", "Input", "::", "get", "(", "'slug'", ")", ")", ";", "if", "(", "count", "...
Store a newly created resource in storage. @return Response
[ "Store", "a", "newly", "created", "resource", "in", "storage", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/Api/PostController.php#L49-L71
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/Api/PostController.php
PostController.update
public function update($id) { $messages = $this->posts->validForUpdate($id, Input::get('title'), Input::get('slug')); if (count($messages) > 0) { return Response::json($messages->all(), 400); } $post = $this->posts->update( $id, Input::get('title'), Input::get('content'), Input::get('slug'), explode(',', Input::get('tags')), (bool) Input::get('active'), (int) Input::get('user_id'), Carbon::createFromTimestamp(strtotime(Input::get('publish_date'))) ); return (string) $this->posts->find($id); }
php
public function update($id) { $messages = $this->posts->validForUpdate($id, Input::get('title'), Input::get('slug')); if (count($messages) > 0) { return Response::json($messages->all(), 400); } $post = $this->posts->update( $id, Input::get('title'), Input::get('content'), Input::get('slug'), explode(',', Input::get('tags')), (bool) Input::get('active'), (int) Input::get('user_id'), Carbon::createFromTimestamp(strtotime(Input::get('publish_date'))) ); return (string) $this->posts->find($id); }
[ "public", "function", "update", "(", "$", "id", ")", "{", "$", "messages", "=", "$", "this", "->", "posts", "->", "validForUpdate", "(", "$", "id", ",", "Input", "::", "get", "(", "'title'", ")", ",", "Input", "::", "get", "(", "'slug'", ")", ")", ...
Update the specified resource in storage. @param int $id @return Response
[ "Update", "the", "specified", "resource", "in", "storage", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/Api/PostController.php#L101-L122
reliv/swagger-expressive
src/Options.php
Options.get
public static function get( array $options, string $key, $default = null ) { if (array_key_exists($key, $options)) { return $options[$key]; } return $default; }
php
public static function get( array $options, string $key, $default = null ) { if (array_key_exists($key, $options)) { return $options[$key]; } return $default; }
[ "public", "static", "function", "get", "(", "array", "$", "options", ",", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "options", ")", ")", "{", "return", "$", "options", ...
@param array $options @param string $key @param null $default @return mixed|null
[ "@param", "array", "$options", "@param", "string", "$key", "@param", "null", "$default" ]
train
https://github.com/reliv/swagger-expressive/blob/65f94262f1709c0d6ed8723938aac618b63d8fd9/src/Options.php#L17-L27
reliv/swagger-expressive
src/Options.php
Options.getString
public static function getString( array $options, string $key, $default = null ) { if (array_key_exists($key, $options)) { return (string)$options[$key]; } return $default; }
php
public static function getString( array $options, string $key, $default = null ) { if (array_key_exists($key, $options)) { return (string)$options[$key]; } return $default; }
[ "public", "static", "function", "getString", "(", "array", "$", "options", ",", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "options", ")", ")", "{", "return", "(", "stri...
@param array $options @param string $key @param null $default @return string|null
[ "@param", "array", "$options", "@param", "string", "$key", "@param", "null", "$default" ]
train
https://github.com/reliv/swagger-expressive/blob/65f94262f1709c0d6ed8723938aac618b63d8fd9/src/Options.php#L36-L46
reliv/swagger-expressive
src/Options.php
Options.getArray
public static function getArray( array $options, string $key, $default = null ) { if (array_key_exists($key, $options)) { return (array)$options[$key]; } return $default; }
php
public static function getArray( array $options, string $key, $default = null ) { if (array_key_exists($key, $options)) { return (array)$options[$key]; } return $default; }
[ "public", "static", "function", "getArray", "(", "array", "$", "options", ",", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "options", ")", ")", "{", "return", "(", "array...
@param array $options @param string $key @param null $default @return array|null
[ "@param", "array", "$options", "@param", "string", "$key", "@param", "null", "$default" ]
train
https://github.com/reliv/swagger-expressive/blob/65f94262f1709c0d6ed8723938aac618b63d8fd9/src/Options.php#L55-L65
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.addRootPrivileges
public function addRootPrivileges() { if ($this->addRootPrivilegeStatement == null) { $this->addRootPrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,1,0,NULL)"); } $this->addRootPrivilegeStatement->execute(array($this->user->getUsername())); $this->rootPrivilege = 1; }
php
public function addRootPrivileges() { if ($this->addRootPrivilegeStatement == null) { $this->addRootPrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,1,0,NULL)"); } $this->addRootPrivilegeStatement->execute(array($this->user->getUsername())); $this->rootPrivilege = 1; }
[ "public", "function", "addRootPrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "addRootPrivilegeStatement", "==", "null", ")", "{", "$", "this", "->", "addRootPrivilegeStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"\n ...
Will add root privileges @return void
[ "Will", "add", "root", "privileges" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L49-L57
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.addSitePrivileges
public function addSitePrivileges() { if ($this->addSitePrivilegeStatement == null) { $this->addSitePrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,0,1,NULL)"); } $this->addSitePrivilegeStatement->execute(array($this->user->getUsername())); $this->sitePrivilege = 1; }
php
public function addSitePrivileges() { if ($this->addSitePrivilegeStatement == null) { $this->addSitePrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,0,1,NULL)"); } $this->addSitePrivilegeStatement->execute(array($this->user->getUsername())); $this->sitePrivilege = 1; }
[ "public", "function", "addSitePrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "addSitePrivilegeStatement", "==", "null", ")", "{", "$", "this", "->", "addSitePrivilegeStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"\n ...
Will add Site privileges @return void
[ "Will", "add", "Site", "privileges" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L63-L71
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.addPagePrivileges
public function addPagePrivileges(Page $page) { if ($this->addPagePrivilegeStatement == null) { $this->addPagePrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,0,0,?)"); } $success = true; try { $this->addPagePrivilegeStatement->execute(array($this->user->getUsername(), $page->getID())); } catch (PDOException $e) { $success = false; } if ($success) { $this->pagePrivilege[$page->getID()] = 1; } }
php
public function addPagePrivileges(Page $page) { if ($this->addPagePrivilegeStatement == null) { $this->addPagePrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,0,0,?)"); } $success = true; try { $this->addPagePrivilegeStatement->execute(array($this->user->getUsername(), $page->getID())); } catch (PDOException $e) { $success = false; } if ($success) { $this->pagePrivilege[$page->getID()] = 1; } }
[ "public", "function", "addPagePrivileges", "(", "Page", "$", "page", ")", "{", "if", "(", "$", "this", "->", "addPagePrivilegeStatement", "==", "null", ")", "{", "$", "this", "->", "addPagePrivilegeStatement", "=", "$", "this", "->", "connection", "->", "pre...
Will add privileges to given page @param Page $page @return void
[ "Will", "add", "privileges", "to", "given", "page" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L78-L93
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.revokeRootPrivileges
public function revokeRootPrivileges() { if ($this->revokeRootStatement == null) { $this->revokeRootStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND rootPrivileges = 1"); $u = $this->user->getUsername(); $this->revokeRootStatement->bindParam(1, $u); } $this->revokeRootStatement->execute(); $this->rootPrivilege = false; }
php
public function revokeRootPrivileges() { if ($this->revokeRootStatement == null) { $this->revokeRootStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND rootPrivileges = 1"); $u = $this->user->getUsername(); $this->revokeRootStatement->bindParam(1, $u); } $this->revokeRootStatement->execute(); $this->rootPrivilege = false; }
[ "public", "function", "revokeRootPrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "revokeRootStatement", "==", "null", ")", "{", "$", "this", "->", "revokeRootStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"DELETE FROM UserP...
Will revoke Root privileges @return void
[ "Will", "revoke", "Root", "privileges" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L127-L137
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.revokeSitePrivileges
public function revokeSitePrivileges() { if ($this->revokeSiteStatement == null) { $this->revokeSiteStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND sitePrivileges = 1"); $u = $this->user->getUsername(); $this->revokeSiteStatement->bindParam(1, $u); } $this->revokeSiteStatement->execute(); $this->sitePrivilege = 0; }
php
public function revokeSitePrivileges() { if ($this->revokeSiteStatement == null) { $this->revokeSiteStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND sitePrivileges = 1"); $u = $this->user->getUsername(); $this->revokeSiteStatement->bindParam(1, $u); } $this->revokeSiteStatement->execute(); $this->sitePrivilege = 0; }
[ "public", "function", "revokeSitePrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "revokeSiteStatement", "==", "null", ")", "{", "$", "this", "->", "revokeSiteStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"DELETE FROM UserP...
Will revoke Site privileges @return void
[ "Will", "revoke", "Site", "privileges" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L143-L153
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.revokePagePrivileges
public function revokePagePrivileges(Page $page) { if ($this->revokePageStatement == null) { $this->revokePageStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND pageId = ?"); } $this->revokePageStatement->execute(array($this->user->getUsername(), $page->getID())); unset($this->pagePrivilege[$page->getID()]); }
php
public function revokePagePrivileges(Page $page) { if ($this->revokePageStatement == null) { $this->revokePageStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND pageId = ?"); } $this->revokePageStatement->execute(array($this->user->getUsername(), $page->getID())); unset($this->pagePrivilege[$page->getID()]); }
[ "public", "function", "revokePagePrivileges", "(", "Page", "$", "page", ")", "{", "if", "(", "$", "this", "->", "revokePageStatement", "==", "null", ")", "{", "$", "this", "->", "revokePageStatement", "=", "$", "this", "->", "connection", "->", "prepare", ...
Will revoke privileges from given Page @param Page $page @return void
[ "Will", "revoke", "privileges", "from", "given", "Page" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L160-L168
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.revokeAllPrivileges
public function revokeAllPrivileges() { if ($this->revokeAllStatement == null) { $this->revokeAllStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ?"); $u = $this->user->getUsername(); $this->revokeAllStatement->bindParam(1, $u); } $this->revokeAllStatement->execute(); $this->rootPrivilege = $this->sitePrivilege = 0; $this->pagePrivilege = array(); }
php
public function revokeAllPrivileges() { if ($this->revokeAllStatement == null) { $this->revokeAllStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ?"); $u = $this->user->getUsername(); $this->revokeAllStatement->bindParam(1, $u); } $this->revokeAllStatement->execute(); $this->rootPrivilege = $this->sitePrivilege = 0; $this->pagePrivilege = array(); }
[ "public", "function", "revokeAllPrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "revokeAllStatement", "==", "null", ")", "{", "$", "this", "->", "revokeAllStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"DELETE FROM UserPriv...
This will revoke all privileges @return void
[ "This", "will", "revoke", "all", "privileges" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L174-L185
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.listPagePrivileges
public function listPagePrivileges(PageOrder $pageOrder = null) { $this->initialize(); if ($this->hasRootPrivileges() || $this->hasSitePrivileges()) { return array(); } $returnArray = array(); foreach ($this->pagePrivilege as $key => $val) { if ($pageOrder instanceof PageOrder) { $returnArray[] = $pageOrder->getPage($key); } else { $returnArray[] = $key; } } return $returnArray; }
php
public function listPagePrivileges(PageOrder $pageOrder = null) { $this->initialize(); if ($this->hasRootPrivileges() || $this->hasSitePrivileges()) { return array(); } $returnArray = array(); foreach ($this->pagePrivilege as $key => $val) { if ($pageOrder instanceof PageOrder) { $returnArray[] = $pageOrder->getPage($key); } else { $returnArray[] = $key; } } return $returnArray; }
[ "public", "function", "listPagePrivileges", "(", "PageOrder", "$", "pageOrder", "=", "null", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "if", "(", "$", "this", "->", "hasRootPrivileges", "(", ")", "||", "$", "this", "->", "hasSitePrivileges"...
Will return an array of strings containing the sites that are under the users control. If the user has site or root privileges an empty array is returned. If the user has no privileges an empty array is returned. @param PageOrder $pageOrder If order is given it will return array containing instances from the PageOrder @return array
[ "Will", "return", "an", "array", "of", "strings", "containing", "the", "sites", "that", "are", "under", "the", "users", "control", ".", "If", "the", "user", "has", "site", "or", "root", "privileges", "an", "empty", "array", "is", "returned", ".", "If", "...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L212-L228
bigwhoop/sentence-breaker
src/SentenceBuilder.php
SentenceBuilder.build
public function build(array $tokenProbabilities, $threshold = 50) { $sentences = ['']; foreach ($tokenProbabilities as $idx => $tokenProbability) { $token = $tokenProbability->getToken(); $sentenceIdx = count($sentences) - 1; $sentences[$sentenceIdx] .= $token->getPrintableValue(); $meetsThreshold = $tokenProbability->getProbability() >= $threshold; $currentSentenceIsEmpty = empty(trim($sentences[$sentenceIdx])); if ($meetsThreshold && !$currentSentenceIsEmpty) { $sentences[] = ''; } } if ('' === $sentences[count($sentences) - 1]) { unset($sentences[count($sentences) - 1]); } $sentences = array_map('ltrim', $sentences); return $sentences; }
php
public function build(array $tokenProbabilities, $threshold = 50) { $sentences = ['']; foreach ($tokenProbabilities as $idx => $tokenProbability) { $token = $tokenProbability->getToken(); $sentenceIdx = count($sentences) - 1; $sentences[$sentenceIdx] .= $token->getPrintableValue(); $meetsThreshold = $tokenProbability->getProbability() >= $threshold; $currentSentenceIsEmpty = empty(trim($sentences[$sentenceIdx])); if ($meetsThreshold && !$currentSentenceIsEmpty) { $sentences[] = ''; } } if ('' === $sentences[count($sentences) - 1]) { unset($sentences[count($sentences) - 1]); } $sentences = array_map('ltrim', $sentences); return $sentences; }
[ "public", "function", "build", "(", "array", "$", "tokenProbabilities", ",", "$", "threshold", "=", "50", ")", "{", "$", "sentences", "=", "[", "''", "]", ";", "foreach", "(", "$", "tokenProbabilities", "as", "$", "idx", "=>", "$", "tokenProbability", ")...
@param TokenProbability[] $tokenProbabilities @param int $threshold @return array
[ "@param", "TokenProbability", "[]", "$tokenProbabilities", "@param", "int", "$threshold" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/SentenceBuilder.php#L21-L46
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.add
public function add(NodeInterface $node) { if ($node instanceof BranchNodeInterface) { // this node is a branch $childFlow = $node->getPayload(); $this->branchFlowCheck($childFlow); $childFlow->setParent($this); } $node->setCarrier($this); $this->flowMap->register($node, $this->nodeIdx); $this->nodes[$this->nodeIdx] = $node; ++$this->nodeIdx; return $this; }
php
public function add(NodeInterface $node) { if ($node instanceof BranchNodeInterface) { // this node is a branch $childFlow = $node->getPayload(); $this->branchFlowCheck($childFlow); $childFlow->setParent($this); } $node->setCarrier($this); $this->flowMap->register($node, $this->nodeIdx); $this->nodes[$this->nodeIdx] = $node; ++$this->nodeIdx; return $this; }
[ "public", "function", "add", "(", "NodeInterface", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "BranchNodeInterface", ")", "{", "// this node is a branch", "$", "childFlow", "=", "$", "node", "->", "getPayload", "(", ")", ";", "$", "this", ...
Adds a Node to the flow @param NodeInterface $node @throws NodalFlowException @return $this
[ "Adds", "a", "Node", "to", "the", "flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L61-L78
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.addPayload
public function addPayload(callable $payload, $isAReturningVal, $isATraversable = false) { $node = PayloadNodeFactory::create($payload, $isAReturningVal, $isATraversable); $this->add($node); return $this; }
php
public function addPayload(callable $payload, $isAReturningVal, $isATraversable = false) { $node = PayloadNodeFactory::create($payload, $isAReturningVal, $isATraversable); $this->add($node); return $this; }
[ "public", "function", "addPayload", "(", "callable", "$", "payload", ",", "$", "isAReturningVal", ",", "$", "isATraversable", "=", "false", ")", "{", "$", "node", "=", "PayloadNodeFactory", "::", "create", "(", "$", "payload", ",", "$", "isAReturningVal", ",...
Adds a Payload Node to the Flow @param callable $payload @param mixed $isAReturningVal @param mixed $isATraversable @throws NodalFlowException @return $this
[ "Adds", "a", "Payload", "Node", "to", "the", "Flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L91-L98
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.replace
public function replace($nodeIdx, NodeInterface $node) { if (!isset($this->nodes[$nodeIdx])) { throw new NodalFlowException('Argument 1 should be a valid index in nodes', 1, null, [ 'nodeIdx' => $nodeIdx, 'node' => get_class($node), ]); } $node->setCarrier($this); $this->nodes[$nodeIdx] = $node; $this->flowMap->register($node, $nodeIdx, true); return $this; }
php
public function replace($nodeIdx, NodeInterface $node) { if (!isset($this->nodes[$nodeIdx])) { throw new NodalFlowException('Argument 1 should be a valid index in nodes', 1, null, [ 'nodeIdx' => $nodeIdx, 'node' => get_class($node), ]); } $node->setCarrier($this); $this->nodes[$nodeIdx] = $node; $this->flowMap->register($node, $nodeIdx, true); return $this; }
[ "public", "function", "replace", "(", "$", "nodeIdx", ",", "NodeInterface", "$", "node", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "nodes", "[", "$", "nodeIdx", "]", ")", ")", "{", "throw", "new", "NodalFlowException", "(", "'Argument ...
Replaces a node with another one @param int $nodeIdx @param NodeInterface $node @throws NodalFlowException @return $this
[ "Replaces", "a", "node", "with", "another", "one" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L110-L124
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.sendTo
public function sendTo($nodeId = null, $param = null) { $nodeIndex = 0; if ($nodeId !== null) { if (!($nodeIndex = $this->flowMap->getNodeIndex($nodeId))) { throw new NodalFlowException('Cannot sendTo without valid Node target', 1, null, [ 'flowId' => $this->getId(), 'nodeId' => $nodeId, ]); } } return $this->rewind()->recurse($param, $nodeIndex); }
php
public function sendTo($nodeId = null, $param = null) { $nodeIndex = 0; if ($nodeId !== null) { if (!($nodeIndex = $this->flowMap->getNodeIndex($nodeId))) { throw new NodalFlowException('Cannot sendTo without valid Node target', 1, null, [ 'flowId' => $this->getId(), 'nodeId' => $nodeId, ]); } } return $this->rewind()->recurse($param, $nodeIndex); }
[ "public", "function", "sendTo", "(", "$", "nodeId", "=", "null", ",", "$", "param", "=", "null", ")", "{", "$", "nodeIndex", "=", "0", ";", "if", "(", "$", "nodeId", "!==", "null", ")", "{", "if", "(", "!", "(", "$", "nodeIndex", "=", "$", "thi...
@param string|null $nodeId @param mixed|null $param @throws NodalFlowException @return mixed
[ "@param", "string|null", "$nodeId", "@param", "mixed|null", "$param" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L134-L147
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.exec
public function exec($param = null) { try { $result = $this->rewind() ->flowStart() ->recurse($param); // set flowStatus to make sure that we have the proper // value in flowEnd even when overridden without (or when // improperly) calling parent if ($this->flowStatus->isRunning()) { $this->flowStatus = new FlowStatus(FlowStatus::FLOW_CLEAN); } $this->flowEnd(); return $result; } catch (\Exception $e) { $this->flowStatus = new FlowStatus(FlowStatus::FLOW_EXCEPTION, $e); $this->flowEnd(); if ($e instanceof NodalFlowException) { throw $e; } throw new NodalFlowException('Flow execution failed', 0, $e, [ 'nodeMap' => $this->getNodeMap(), ]); } }
php
public function exec($param = null) { try { $result = $this->rewind() ->flowStart() ->recurse($param); // set flowStatus to make sure that we have the proper // value in flowEnd even when overridden without (or when // improperly) calling parent if ($this->flowStatus->isRunning()) { $this->flowStatus = new FlowStatus(FlowStatus::FLOW_CLEAN); } $this->flowEnd(); return $result; } catch (\Exception $e) { $this->flowStatus = new FlowStatus(FlowStatus::FLOW_EXCEPTION, $e); $this->flowEnd(); if ($e instanceof NodalFlowException) { throw $e; } throw new NodalFlowException('Flow execution failed', 0, $e, [ 'nodeMap' => $this->getNodeMap(), ]); } }
[ "public", "function", "exec", "(", "$", "param", "=", "null", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "rewind", "(", ")", "->", "flowStart", "(", ")", "->", "recurse", "(", "$", "param", ")", ";", "// set flowStatus to make sure th...
Execute the flow @param null|mixed $param The eventual init argument to the first node or, in case of a branch, the last relevant argument from upstream Flow @throws NodalFlowException @return mixed the last result of the last returning value node
[ "Execute", "the", "flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L161-L189
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.rewind
public function rewind() { $this->nodeCount = count($this->nodes); $this->lastIdx = $this->nodeCount - 1; $this->break = false; $this->continue = false; $this->interruptNodeId = null; return $this; }
php
public function rewind() { $this->nodeCount = count($this->nodes); $this->lastIdx = $this->nodeCount - 1; $this->break = false; $this->continue = false; $this->interruptNodeId = null; return $this; }
[ "public", "function", "rewind", "(", ")", "{", "$", "this", "->", "nodeCount", "=", "count", "(", "$", "this", "->", "nodes", ")", ";", "$", "this", "->", "lastIdx", "=", "$", "this", "->", "nodeCount", "-", "1", ";", "$", "this", "->", "break", ...
Rewinds the Flow @return $this
[ "Rewinds", "the", "Flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L196-L205
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.branchFlowCheck
protected function branchFlowCheck(FlowInterface $flow) { if ( // this flow has parent already $flow->hasParent() || // adding root flow in itself $this->getRootFlow($flow)->getId() === $this->getRootFlow($this)->getId() ) { throw new NodalFlowException('Cannot reuse Flow within Branches', 1, null, [ 'flowId' => $this->getId(), 'BranchFlowId' => $flow->getId(), 'BranchFlowParentId' => $flow->hasParent() ? $flow->getParent()->getId() : null, ]); } }
php
protected function branchFlowCheck(FlowInterface $flow) { if ( // this flow has parent already $flow->hasParent() || // adding root flow in itself $this->getRootFlow($flow)->getId() === $this->getRootFlow($this)->getId() ) { throw new NodalFlowException('Cannot reuse Flow within Branches', 1, null, [ 'flowId' => $this->getId(), 'BranchFlowId' => $flow->getId(), 'BranchFlowParentId' => $flow->hasParent() ? $flow->getParent()->getId() : null, ]); } }
[ "protected", "function", "branchFlowCheck", "(", "FlowInterface", "$", "flow", ")", "{", "if", "(", "// this flow has parent already", "$", "flow", "->", "hasParent", "(", ")", "||", "// adding root flow in itself", "$", "this", "->", "getRootFlow", "(", "$", "flo...
@param FlowInterface $flow @throws NodalFlowException
[ "@param", "FlowInterface", "$flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L212-L226
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.flowStart
protected function flowStart() { $this->flowMap->incrementFlow('num_exec')->flowStart(); $this->listActiveEvent(!$this->hasParent())->triggerEvent(FlowEvent::FLOW_START); // flow started status kicks in after Event start to hint eventual children // this way, root flow is only running when a record hits a branch // and triggers a child flow flowStart() call $this->flowStatus = new FlowStatus(FlowStatus::FLOW_RUNNING); return $this; }
php
protected function flowStart() { $this->flowMap->incrementFlow('num_exec')->flowStart(); $this->listActiveEvent(!$this->hasParent())->triggerEvent(FlowEvent::FLOW_START); // flow started status kicks in after Event start to hint eventual children // this way, root flow is only running when a record hits a branch // and triggers a child flow flowStart() call $this->flowStatus = new FlowStatus(FlowStatus::FLOW_RUNNING); return $this; }
[ "protected", "function", "flowStart", "(", ")", "{", "$", "this", "->", "flowMap", "->", "incrementFlow", "(", "'num_exec'", ")", "->", "flowStart", "(", ")", ";", "$", "this", "->", "listActiveEvent", "(", "!", "$", "this", "->", "hasParent", "(", ")", ...
Triggered just before the flow starts @throws NodalFlowException @return $this
[ "Triggered", "just", "before", "the", "flow", "starts" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L235-L245
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.flowEnd
protected function flowEnd() { $this->flowMap->flowEnd(); $eventName = FlowEvent::FLOW_SUCCESS; $node = null; if ($this->flowStatus->isException()) { $eventName = FlowEvent::FLOW_FAIL; $node = $this->nodes[$this->nodeIdx]; } // restore nodeIdx $this->nodeIdx = $this->lastIdx + 1; $this->triggerEvent($eventName, $node); return $this; }
php
protected function flowEnd() { $this->flowMap->flowEnd(); $eventName = FlowEvent::FLOW_SUCCESS; $node = null; if ($this->flowStatus->isException()) { $eventName = FlowEvent::FLOW_FAIL; $node = $this->nodes[$this->nodeIdx]; } // restore nodeIdx $this->nodeIdx = $this->lastIdx + 1; $this->triggerEvent($eventName, $node); return $this; }
[ "protected", "function", "flowEnd", "(", ")", "{", "$", "this", "->", "flowMap", "->", "flowEnd", "(", ")", ";", "$", "eventName", "=", "FlowEvent", "::", "FLOW_SUCCESS", ";", "$", "node", "=", "null", ";", "if", "(", "$", "this", "->", "flowStatus", ...
Triggered right after the flow stops @return $this
[ "Triggered", "right", "after", "the", "flow", "stops" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L252-L267
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.recurse
protected function recurse($param = null, $nodeIdx = 0) { while ($nodeIdx <= $this->lastIdx) { $node = $this->nodes[$nodeIdx]; $this->nodeIdx = $nodeIdx; $nodeStats = &$this->flowMap->getNodeStat($node->getId()); $returnVal = $node->isReturningVal(); if ($node->isTraversable()) { /** @var TraversableNodeInterface $node */ foreach ($node->getTraversable($param) as $value) { if ($returnVal) { // pass current $value as next param $param = $value; } ++$nodeStats['num_iterate']; if (!($nodeStats['num_iterate'] % $this->progressMod)) { $this->triggerEvent(FlowEvent::FLOW_PROGRESS, $node); } $param = $this->recurse($param, $nodeIdx + 1); if ($this->continue) { if ($this->continue = $this->interruptNode($node)) { // since we want to bubble the continue upstream // we break here waiting for next $param if any ++$nodeStats['num_break']; break; } // we drop one iteration ++$nodeStats['num_continue']; continue; } if ($this->break) { // we drop all subsequent iterations ++$nodeStats['num_break']; $this->break = $this->interruptNode($node); break; } } // we reached the end of this Traversable and executed all its downstream Nodes ++$nodeStats['num_exec']; return $param; } /** @var ExecNodeInterface $node */ $value = $node->exec($param); ++$nodeStats['num_exec']; if ($this->continue) { ++$nodeStats['num_continue']; // a continue does not need to bubble up unless // it specifically targets a node in this flow // or targets an upstream flow $this->continue = $this->interruptNode($node); return $param; } if ($this->break) { ++$nodeStats['num_break']; // a break always need to bubble up to the first upstream Traversable if any return $param; } if ($returnVal) { // pass current $value as next param $param = $value; } ++$nodeIdx; } // we reached the end of this recursion return $param; }
php
protected function recurse($param = null, $nodeIdx = 0) { while ($nodeIdx <= $this->lastIdx) { $node = $this->nodes[$nodeIdx]; $this->nodeIdx = $nodeIdx; $nodeStats = &$this->flowMap->getNodeStat($node->getId()); $returnVal = $node->isReturningVal(); if ($node->isTraversable()) { /** @var TraversableNodeInterface $node */ foreach ($node->getTraversable($param) as $value) { if ($returnVal) { // pass current $value as next param $param = $value; } ++$nodeStats['num_iterate']; if (!($nodeStats['num_iterate'] % $this->progressMod)) { $this->triggerEvent(FlowEvent::FLOW_PROGRESS, $node); } $param = $this->recurse($param, $nodeIdx + 1); if ($this->continue) { if ($this->continue = $this->interruptNode($node)) { // since we want to bubble the continue upstream // we break here waiting for next $param if any ++$nodeStats['num_break']; break; } // we drop one iteration ++$nodeStats['num_continue']; continue; } if ($this->break) { // we drop all subsequent iterations ++$nodeStats['num_break']; $this->break = $this->interruptNode($node); break; } } // we reached the end of this Traversable and executed all its downstream Nodes ++$nodeStats['num_exec']; return $param; } /** @var ExecNodeInterface $node */ $value = $node->exec($param); ++$nodeStats['num_exec']; if ($this->continue) { ++$nodeStats['num_continue']; // a continue does not need to bubble up unless // it specifically targets a node in this flow // or targets an upstream flow $this->continue = $this->interruptNode($node); return $param; } if ($this->break) { ++$nodeStats['num_break']; // a break always need to bubble up to the first upstream Traversable if any return $param; } if ($returnVal) { // pass current $value as next param $param = $value; } ++$nodeIdx; } // we reached the end of this recursion return $param; }
[ "protected", "function", "recurse", "(", "$", "param", "=", "null", ",", "$", "nodeIdx", "=", "0", ")", "{", "while", "(", "$", "nodeIdx", "<=", "$", "this", "->", "lastIdx", ")", "{", "$", "node", "=", "$", "this", "->", "nodes", "[", "$", "node...
Recurse over nodes which may as well be Flows and Traversable ... Welcome to the abysses of recursion or iter-recursion ^^ `recurse` perform kind of an hybrid recursion as the Flow is effectively iterating and recurring over its Nodes, which may as well be seen as over itself Iterating tends to limit the amount of recursion levels: recursion is only triggered when executing a Traversable Node's downstream Nodes while every consecutive exec Nodes are executed within the while loop. The size of the recursion context is kept to a minimum as pretty much everything is done by the iterating instance @param mixed $param @param int $nodeIdx @return mixed the last value returned by the last returning value Node in the flow
[ "Recurse", "over", "nodes", "which", "may", "as", "well", "be", "Flows", "and", "Traversable", "...", "Welcome", "to", "the", "abysses", "of", "recursion", "or", "iter", "-", "recursion", "^^" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L290-L369
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.create
public static function create() { switch (func_num_args()) { case 0: return new File(); case 1: return new File(func_get_arg(0)); case 2: return new File(func_get_arg(0), func_get_arg(1)); case 3: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new File(); case 1: return new File(func_get_arg(0)); case 2: return new File(func_get_arg(0), func_get_arg(1)); case 3: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "File", "(", ")", ";", "case", "1", ":", "return", "new", "File", "(", "func_get_arg", "(", "0", ")", ")...
Creates new instance of \Google\Protobuf\Compiler\CodeGeneratorResponse\File @throws \InvalidArgumentException @return File
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L59-L83
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.reset
public static function reset($object) { if (!($object instanceof File)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse\File.'); } $object->name = NULL; $object->insertionPoint = NULL; $object->content = NULL; }
php
public static function reset($object) { if (!($object instanceof File)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse\File.'); } $object->name = NULL; $object->insertionPoint = NULL; $object->content = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "File", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\Compiler\\Code...
Resets properties of \Google\Protobuf\Compiler\CodeGeneratorResponse\File to default values @param File $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L96-L104
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->insertionPoint)) { hash_update($ctx, 'insertionPoint'); hash_update($ctx, (string)$object->insertionPoint); } if (isset($object->content)) { hash_update($ctx, 'content'); hash_update($ctx, (string)$object->content); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->insertionPoint)) { hash_update($ctx, 'insertionPoint'); hash_update($ctx, (string)$object->insertionPoint); } if (isset($object->content)) { hash_update($ctx, 'content'); hash_update($ctx, (string)$object->content); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Google\Protobuf\Compiler\CodeGeneratorResponse\File @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L116-L144
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new File(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->name = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->insertionPoint = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 15: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->content = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new File(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->name = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->insertionPoint = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 15: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->content = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\Compiler\CodeGeneratorResponse\File object from serialized Protocol Buffers message. @param string $input @param File $object @param int $start @param int $end @throws \Exception @return File
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L159-L240
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->insertionPoint) && ($filter === null || isset($filter['insertionPoint']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->insertionPoint)); $output .= $object->insertionPoint; } if (isset($object->content) && ($filter === null || isset($filter['content']))) { $output .= "\x7a"; $output .= Binary::encodeVarint(strlen($object->content)); $output .= $object->content; } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->insertionPoint) && ($filter === null || isset($filter['insertionPoint']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->insertionPoint)); $output .= $object->insertionPoint; } if (isset($object->content) && ($filter === null || isset($filter['content']))) { $output .= "\x7a"; $output .= Binary::encodeVarint(strlen($object->content)); $output .= $object->content; } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "name", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\Compiler\CodeGeneratorResponse\File to Protocol Buffers message. @param File $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L253-L276
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php
FileDescriptorProtoMeta.create
public static function create() { switch (func_num_args()) { case 0: return new FileDescriptorProto(); case 1: return new FileDescriptorProto(func_get_arg(0)); case 2: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new FileDescriptorProto(); case 1: return new FileDescriptorProto(func_get_arg(0)); case 2: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "FileDescriptorProto", "(", ")", ";", "case", "1", ":", "return", "new", "FileDescriptorProto", "(", "func_get_a...
Creates new instance of \Google\Protobuf\FileDescriptorProto @throws \InvalidArgumentException @return FileDescriptorProto
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php#L68-L92
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php
FileDescriptorProtoMeta.reset
public static function reset($object) { if (!($object instanceof FileDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FileDescriptorProto.'); } $object->name = NULL; $object->package = NULL; $object->dependency = NULL; $object->publicDependency = NULL; $object->weakDependency = NULL; $object->messageType = NULL; $object->enumType = NULL; $object->service = NULL; $object->extension = NULL; $object->options = NULL; $object->sourceCodeInfo = NULL; $object->syntax = NULL; }
php
public static function reset($object) { if (!($object instanceof FileDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FileDescriptorProto.'); } $object->name = NULL; $object->package = NULL; $object->dependency = NULL; $object->publicDependency = NULL; $object->weakDependency = NULL; $object->messageType = NULL; $object->enumType = NULL; $object->service = NULL; $object->extension = NULL; $object->options = NULL; $object->sourceCodeInfo = NULL; $object->syntax = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "FileDescriptorProto", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\...
Resets properties of \Google\Protobuf\FileDescriptorProto to default values @param FileDescriptorProto $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorProto", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php#L105-L122
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php
FileDescriptorProtoMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->package)) { hash_update($ctx, 'package'); hash_update($ctx, (string)$object->package); } if (isset($object->dependency)) { hash_update($ctx, 'dependency'); foreach ($object->dependency instanceof \Traversable ? $object->dependency : (array)$object->dependency as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->publicDependency)) { hash_update($ctx, 'publicDependency'); foreach ($object->publicDependency instanceof \Traversable ? $object->publicDependency : (array)$object->publicDependency as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->weakDependency)) { hash_update($ctx, 'weakDependency'); foreach ($object->weakDependency instanceof \Traversable ? $object->weakDependency : (array)$object->weakDependency as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->messageType)) { hash_update($ctx, 'messageType'); foreach ($object->messageType instanceof \Traversable ? $object->messageType : (array)$object->messageType as $v0) { DescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->enumType)) { hash_update($ctx, 'enumType'); foreach ($object->enumType instanceof \Traversable ? $object->enumType : (array)$object->enumType as $v0) { EnumDescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->service)) { hash_update($ctx, 'service'); foreach ($object->service instanceof \Traversable ? $object->service : (array)$object->service as $v0) { ServiceDescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->extension)) { hash_update($ctx, 'extension'); foreach ($object->extension instanceof \Traversable ? $object->extension : (array)$object->extension as $v0) { FieldDescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->options)) { hash_update($ctx, 'options'); FileOptionsMeta::hash($object->options, $ctx); } if (isset($object->sourceCodeInfo)) { hash_update($ctx, 'sourceCodeInfo'); SourceCodeInfoMeta::hash($object->sourceCodeInfo, $ctx); } if (isset($object->syntax)) { hash_update($ctx, 'syntax'); hash_update($ctx, (string)$object->syntax); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->package)) { hash_update($ctx, 'package'); hash_update($ctx, (string)$object->package); } if (isset($object->dependency)) { hash_update($ctx, 'dependency'); foreach ($object->dependency instanceof \Traversable ? $object->dependency : (array)$object->dependency as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->publicDependency)) { hash_update($ctx, 'publicDependency'); foreach ($object->publicDependency instanceof \Traversable ? $object->publicDependency : (array)$object->publicDependency as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->weakDependency)) { hash_update($ctx, 'weakDependency'); foreach ($object->weakDependency instanceof \Traversable ? $object->weakDependency : (array)$object->weakDependency as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->messageType)) { hash_update($ctx, 'messageType'); foreach ($object->messageType instanceof \Traversable ? $object->messageType : (array)$object->messageType as $v0) { DescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->enumType)) { hash_update($ctx, 'enumType'); foreach ($object->enumType instanceof \Traversable ? $object->enumType : (array)$object->enumType as $v0) { EnumDescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->service)) { hash_update($ctx, 'service'); foreach ($object->service instanceof \Traversable ? $object->service : (array)$object->service as $v0) { ServiceDescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->extension)) { hash_update($ctx, 'extension'); foreach ($object->extension instanceof \Traversable ? $object->extension : (array)$object->extension as $v0) { FieldDescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->options)) { hash_update($ctx, 'options'); FileOptionsMeta::hash($object->options, $ctx); } if (isset($object->sourceCodeInfo)) { hash_update($ctx, 'sourceCodeInfo'); SourceCodeInfoMeta::hash($object->sourceCodeInfo, $ctx); } if (isset($object->syntax)) { hash_update($ctx, 'syntax'); hash_update($ctx, (string)$object->syntax); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Google\Protobuf\FileDescriptorProto @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php#L134-L221
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php
FileDescriptorProtoMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FileDescriptorProto(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->name = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->package = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 3: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->dependency) && is_array($object->dependency))) { $object->dependency = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->dependency[] = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 10: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } if (!(isset($object->publicDependency) && is_array($object->publicDependency))) { $object->publicDependency = array(); } $object->publicDependency[] = Binary::decodeVarint($input, $start); break; case 11: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } if (!(isset($object->weakDependency) && is_array($object->weakDependency))) { $object->weakDependency = array(); } $object->weakDependency[] = Binary::decodeVarint($input, $start); break; case 4: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->messageType) && is_array($object->messageType))) { $object->messageType = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->messageType[] = DescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 5: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->enumType) && is_array($object->enumType))) { $object->enumType = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->enumType[] = EnumDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 6: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->service) && is_array($object->service))) { $object->service = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->service[] = ServiceDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 7: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->extension) && is_array($object->extension))) { $object->extension = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->extension[] = FieldDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 8: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->options = FileOptionsMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 9: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->sourceCodeInfo = SourceCodeInfoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 12: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->syntax = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FileDescriptorProto(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->name = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->package = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 3: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->dependency) && is_array($object->dependency))) { $object->dependency = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->dependency[] = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 10: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } if (!(isset($object->publicDependency) && is_array($object->publicDependency))) { $object->publicDependency = array(); } $object->publicDependency[] = Binary::decodeVarint($input, $start); break; case 11: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } if (!(isset($object->weakDependency) && is_array($object->weakDependency))) { $object->weakDependency = array(); } $object->weakDependency[] = Binary::decodeVarint($input, $start); break; case 4: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->messageType) && is_array($object->messageType))) { $object->messageType = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->messageType[] = DescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 5: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->enumType) && is_array($object->enumType))) { $object->enumType = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->enumType[] = EnumDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 6: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->service) && is_array($object->service))) { $object->service = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->service[] = ServiceDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 7: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->extension) && is_array($object->extension))) { $object->extension = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->extension[] = FieldDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 8: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->options = FileOptionsMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 9: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->sourceCodeInfo = SourceCodeInfoMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 12: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->syntax = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\FileDescriptorProto object from serialized Protocol Buffers message. @param string $input @param FileDescriptorProto $object @param int $start @param int $end @throws \Exception @return FileDescriptorProto
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorProto", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php#L236-L449
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php
FileDescriptorProtoMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->package) && ($filter === null || isset($filter['package']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->package)); $output .= $object->package; } if (isset($object->dependency) && ($filter === null || isset($filter['dependency']))) { foreach ($object->dependency instanceof \Traversable ? $object->dependency : (array)$object->dependency as $k => $v) { $output .= "\x1a"; $output .= Binary::encodeVarint(strlen($v)); $output .= $v; } } if (isset($object->publicDependency) && ($filter === null || isset($filter['publicDependency']))) { foreach ($object->publicDependency instanceof \Traversable ? $object->publicDependency : (array)$object->publicDependency as $k => $v) { $output .= "\x50"; $output .= Binary::encodeVarint($v); } } if (isset($object->weakDependency) && ($filter === null || isset($filter['weakDependency']))) { foreach ($object->weakDependency instanceof \Traversable ? $object->weakDependency : (array)$object->weakDependency as $k => $v) { $output .= "\x58"; $output .= Binary::encodeVarint($v); } } if (isset($object->messageType) && ($filter === null || isset($filter['messageType']))) { foreach ($object->messageType instanceof \Traversable ? $object->messageType : (array)$object->messageType as $k => $v) { $output .= "\x22"; $buffer = DescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['messageType']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->enumType) && ($filter === null || isset($filter['enumType']))) { foreach ($object->enumType instanceof \Traversable ? $object->enumType : (array)$object->enumType as $k => $v) { $output .= "\x2a"; $buffer = EnumDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['enumType']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->service) && ($filter === null || isset($filter['service']))) { foreach ($object->service instanceof \Traversable ? $object->service : (array)$object->service as $k => $v) { $output .= "\x32"; $buffer = ServiceDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['service']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->extension) && ($filter === null || isset($filter['extension']))) { foreach ($object->extension instanceof \Traversable ? $object->extension : (array)$object->extension as $k => $v) { $output .= "\x3a"; $buffer = FieldDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['extension']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x42"; $buffer = FileOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } if (isset($object->sourceCodeInfo) && ($filter === null || isset($filter['sourceCodeInfo']))) { $output .= "\x4a"; $buffer = SourceCodeInfoMeta::toProtobuf($object->sourceCodeInfo, $filter === null ? null : $filter['sourceCodeInfo']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } if (isset($object->syntax) && ($filter === null || isset($filter['syntax']))) { $output .= "\x62"; $output .= Binary::encodeVarint(strlen($object->syntax)); $output .= $object->syntax; } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->package) && ($filter === null || isset($filter['package']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->package)); $output .= $object->package; } if (isset($object->dependency) && ($filter === null || isset($filter['dependency']))) { foreach ($object->dependency instanceof \Traversable ? $object->dependency : (array)$object->dependency as $k => $v) { $output .= "\x1a"; $output .= Binary::encodeVarint(strlen($v)); $output .= $v; } } if (isset($object->publicDependency) && ($filter === null || isset($filter['publicDependency']))) { foreach ($object->publicDependency instanceof \Traversable ? $object->publicDependency : (array)$object->publicDependency as $k => $v) { $output .= "\x50"; $output .= Binary::encodeVarint($v); } } if (isset($object->weakDependency) && ($filter === null || isset($filter['weakDependency']))) { foreach ($object->weakDependency instanceof \Traversable ? $object->weakDependency : (array)$object->weakDependency as $k => $v) { $output .= "\x58"; $output .= Binary::encodeVarint($v); } } if (isset($object->messageType) && ($filter === null || isset($filter['messageType']))) { foreach ($object->messageType instanceof \Traversable ? $object->messageType : (array)$object->messageType as $k => $v) { $output .= "\x22"; $buffer = DescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['messageType']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->enumType) && ($filter === null || isset($filter['enumType']))) { foreach ($object->enumType instanceof \Traversable ? $object->enumType : (array)$object->enumType as $k => $v) { $output .= "\x2a"; $buffer = EnumDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['enumType']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->service) && ($filter === null || isset($filter['service']))) { foreach ($object->service instanceof \Traversable ? $object->service : (array)$object->service as $k => $v) { $output .= "\x32"; $buffer = ServiceDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['service']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->extension) && ($filter === null || isset($filter['extension']))) { foreach ($object->extension instanceof \Traversable ? $object->extension : (array)$object->extension as $k => $v) { $output .= "\x3a"; $buffer = FieldDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['extension']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x42"; $buffer = FileOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } if (isset($object->sourceCodeInfo) && ($filter === null || isset($filter['sourceCodeInfo']))) { $output .= "\x4a"; $buffer = SourceCodeInfoMeta::toProtobuf($object->sourceCodeInfo, $filter === null ? null : $filter['sourceCodeInfo']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } if (isset($object->syntax) && ($filter === null || isset($filter['syntax']))) { $output .= "\x62"; $output .= Binary::encodeVarint(strlen($object->syntax)); $output .= $object->syntax; } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "name", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\FileDescriptorProto to Protocol Buffers message. @param FileDescriptorProto $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorProto", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php#L462-L557
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.setValueType
final public function setValueType(&$value, $type) { if ( empty($value) || !in_array(strtolower($type), array("base64", "datetime", "cdata")) ) throw new XmlrpcException("Invalid value type"); $this->special_types[$value] = strtolower($type); return $this; }
php
final public function setValueType(&$value, $type) { if ( empty($value) || !in_array(strtolower($type), array("base64", "datetime", "cdata")) ) throw new XmlrpcException("Invalid value type"); $this->special_types[$value] = strtolower($type); return $this; }
[ "final", "public", "function", "setValueType", "(", "&", "$", "value", ",", "$", "type", ")", "{", "if", "(", "empty", "(", "$", "value", ")", "||", "!", "in_array", "(", "strtolower", "(", "$", "type", ")", ",", "array", "(", "\"base64\"", ",", "\...
Handle base64 and datetime values @param mixed $value The referenced value @param string $type The type of value @return \Comodojo\Xmlrpc\XmlrpcEncoder
[ "Handle", "base64", "and", "datetime", "values" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L96-L104
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeResponse
public function encodeResponse($data) { $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(false); $xml->startDocument('1.0', $this->encoding); $xml->startElement("methodResponse"); $xml->startElement("params"); $xml->startElement("param"); $xml->startElement("value"); try { $this->encodeValue($xml, $data); } catch (XmlrpcException $xe) { throw $xe; } catch (Exception $e) { throw $e; } $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endDocument(); return trim($xml->outputMemory()); }
php
public function encodeResponse($data) { $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(false); $xml->startDocument('1.0', $this->encoding); $xml->startElement("methodResponse"); $xml->startElement("params"); $xml->startElement("param"); $xml->startElement("value"); try { $this->encodeValue($xml, $data); } catch (XmlrpcException $xe) { throw $xe; } catch (Exception $e) { throw $e; } $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endDocument(); return trim($xml->outputMemory()); }
[ "public", "function", "encodeResponse", "(", "$", "data", ")", "{", "$", "xml", "=", "new", "XMLWriter", "(", ")", ";", "$", "xml", "->", "openMemory", "(", ")", ";", "$", "xml", "->", "setIndent", "(", "false", ")", ";", "$", "xml", "->", "startDo...
Encode an xmlrpc response It expects a scalar, array or NULL as $data and will try to encode it as a valid xmlrpc response. @param mixed $data @return string xmlrpc formatted response @throws \Comodojo\Exception\XmlrpcException @throws \Exception
[ "Encode", "an", "xmlrpc", "response" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L133-L177
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeCall
public function encodeCall($method, $data = array()) { $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(false); $xml->startDocument('1.0', $this->encoding); $xml->startElement("methodCall"); $xml->writeElement("methodName", trim($method)); $xml->startElement("params"); try { foreach ( $data as $d ) { $xml->startElement("param"); $xml->startElement("value"); $this->encodeValue($xml, $d); $xml->endElement(); $xml->endElement(); } } catch (XmlrpcException $xe) { throw $xe; } $xml->endElement(); $xml->endElement(); $xml->endDocument(); return trim($xml->outputMemory()); }
php
public function encodeCall($method, $data = array()) { $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(false); $xml->startDocument('1.0', $this->encoding); $xml->startElement("methodCall"); $xml->writeElement("methodName", trim($method)); $xml->startElement("params"); try { foreach ( $data as $d ) { $xml->startElement("param"); $xml->startElement("value"); $this->encodeValue($xml, $d); $xml->endElement(); $xml->endElement(); } } catch (XmlrpcException $xe) { throw $xe; } $xml->endElement(); $xml->endElement(); $xml->endDocument(); return trim($xml->outputMemory()); }
[ "public", "function", "encodeCall", "(", "$", "method", ",", "$", "data", "=", "array", "(", ")", ")", "{", "$", "xml", "=", "new", "XMLWriter", "(", ")", ";", "$", "xml", "->", "openMemory", "(", ")", ";", "$", "xml", "->", "setIndent", "(", "fa...
Encode an xmlrpc call It expects an array of values as $data and will try to encode it as a valid xmlrpc call. @param string $method @param array $data @return string xmlrpc formatted call @throws \Comodojo\Exception\XmlrpcException @throws \Exception
[ "Encode", "an", "xmlrpc", "call" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L192-L238
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeMulticall
public function encodeMulticall($data) { $packed_requests = array(); foreach ( $data as $methodName => $params ) { if ( is_int($methodName) && count($params) == 2 ) { array_push($packed_requests, array( "methodName" => $params[0], "params" => $params[1] )); } else { array_push($packed_requests, array( "methodName" => $methodName, "params" => $params )); } } return $this->encodeCall("system.multicall", array($packed_requests)); }
php
public function encodeMulticall($data) { $packed_requests = array(); foreach ( $data as $methodName => $params ) { if ( is_int($methodName) && count($params) == 2 ) { array_push($packed_requests, array( "methodName" => $params[0], "params" => $params[1] )); } else { array_push($packed_requests, array( "methodName" => $methodName, "params" => $params )); } } return $this->encodeCall("system.multicall", array($packed_requests)); }
[ "public", "function", "encodeMulticall", "(", "$", "data", ")", "{", "$", "packed_requests", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "methodName", "=>", "$", "params", ")", "{", "if", "(", "is_int", "(", "$", "methodName", ...
Encode an xmlrpc multicall It expects in input a key->val array where key represent the method and val the parameters. @param array $data @return string xmlrpc formatted call @throws \Comodojo\Exception\XmlrpcException @throws \Exception
[ "Encode", "an", "xmlrpc", "multicall" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L253-L279
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeError
public function encodeError($error_code, $error_message) { $payload = '<?xml version="1.0" encoding="'.$this->encoding.'"?>'; $payload .= "<methodResponse>"; $payload .= $this->encodeFault($error_code, $error_message); $payload .= "</methodResponse>"; return $payload; }
php
public function encodeError($error_code, $error_message) { $payload = '<?xml version="1.0" encoding="'.$this->encoding.'"?>'; $payload .= "<methodResponse>"; $payload .= $this->encodeFault($error_code, $error_message); $payload .= "</methodResponse>"; return $payload; }
[ "public", "function", "encodeError", "(", "$", "error_code", ",", "$", "error_message", ")", "{", "$", "payload", "=", "'<?xml version=\"1.0\" encoding=\"'", ".", "$", "this", "->", "encoding", ".", "'\"?>'", ";", "$", "payload", ".=", "\"<methodResponse>\"", ";...
Encode an xmlrpc error @param int $error_code @param string $error_message @return string xmlrpc formatted error
[ "Encode", "an", "xmlrpc", "error" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L289-L298
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeFault
private function encodeFault($error_code, $error_message) { $value = htmlentities($error_message, ENT_QUOTES, $this->encoding, false); $string = preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/S', 'self::numericEntities', $value); $payload = "<fault>"; $payload .= "<value>"; $payload .= "<struct>"; $payload .= "<member>"; $payload .= "<name>faultCode</name>"; $payload .= "<value><int>".$error_code."</int></value>"; $payload .= "</member>"; $payload .= "<member>"; $payload .= "<name>faultString</name>"; $payload .= "<value><string>".$string."</string></value>"; $payload .= "</member>"; $payload .= "</struct>"; $payload .= "</value>"; $payload .= "</fault>"; return $payload; }
php
private function encodeFault($error_code, $error_message) { $value = htmlentities($error_message, ENT_QUOTES, $this->encoding, false); $string = preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/S', 'self::numericEntities', $value); $payload = "<fault>"; $payload .= "<value>"; $payload .= "<struct>"; $payload .= "<member>"; $payload .= "<name>faultCode</name>"; $payload .= "<value><int>".$error_code."</int></value>"; $payload .= "</member>"; $payload .= "<member>"; $payload .= "<name>faultString</name>"; $payload .= "<value><string>".$string."</string></value>"; $payload .= "</member>"; $payload .= "</struct>"; $payload .= "</value>"; $payload .= "</fault>"; return $payload; }
[ "private", "function", "encodeFault", "(", "$", "error_code", ",", "$", "error_message", ")", "{", "$", "value", "=", "htmlentities", "(", "$", "error_message", ",", "ENT_QUOTES", ",", "$", "this", "->", "encoding", ",", "false", ")", ";", "$", "string", ...
Encode an xmlrpc fault (without full xml document body) @param int $error_code @param string $error_message @return string xmlrpc formatted error
[ "Encode", "an", "xmlrpc", "fault", "(", "without", "full", "xml", "document", "body", ")" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L308-L331
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeValue
private function encodeValue(XMLWriter $xml, $value) { if ( $value === null ) $xml->writeRaw($this->use_ex_nil === true ? '<ex:nil />' : '<nil />'); else if ( is_array($value) ) { if ( !self::catchStruct($value) ) $this->encodeArray($xml, $value); else $this->encodeStruct($xml, $value); } else if ( @array_key_exists($value, $this->special_types) ) { switch ( $this->special_types[$value] ) { case 'base64': $xml->writeElement("base64", $value); break; case 'datetime': $xml->writeElement("dateTime.iso8601", self::timestampToIso8601Time($value)); break; case 'cdata': $xml->writeCData($value); break; } } else if ( is_bool($value) ) { $xml->writeElement("boolean", $value ? 1 : 0); } else if ( is_double($value) ) { $xml->writeElement("double", $value); } else if ( is_integer($value) ) { $xml->writeElement("int", $value); } else if ( is_object($value) ) { $this->encodeObject($xml, $value); } else if ( is_string($value) ) { $value = htmlentities($value, ENT_QUOTES, $this->encoding, false); $string = preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/S', 'self::numericEntities', $value); $xml->writeRaw("<string>".$string."</string>"); } else throw new XmlrpcException("Unknown type for encoding"); }
php
private function encodeValue(XMLWriter $xml, $value) { if ( $value === null ) $xml->writeRaw($this->use_ex_nil === true ? '<ex:nil />' : '<nil />'); else if ( is_array($value) ) { if ( !self::catchStruct($value) ) $this->encodeArray($xml, $value); else $this->encodeStruct($xml, $value); } else if ( @array_key_exists($value, $this->special_types) ) { switch ( $this->special_types[$value] ) { case 'base64': $xml->writeElement("base64", $value); break; case 'datetime': $xml->writeElement("dateTime.iso8601", self::timestampToIso8601Time($value)); break; case 'cdata': $xml->writeCData($value); break; } } else if ( is_bool($value) ) { $xml->writeElement("boolean", $value ? 1 : 0); } else if ( is_double($value) ) { $xml->writeElement("double", $value); } else if ( is_integer($value) ) { $xml->writeElement("int", $value); } else if ( is_object($value) ) { $this->encodeObject($xml, $value); } else if ( is_string($value) ) { $value = htmlentities($value, ENT_QUOTES, $this->encoding, false); $string = preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/S', 'self::numericEntities', $value); $xml->writeRaw("<string>".$string."</string>"); } else throw new XmlrpcException("Unknown type for encoding"); }
[ "private", "function", "encodeValue", "(", "XMLWriter", "$", "xml", ",", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "$", "xml", "->", "writeRaw", "(", "$", "this", "->", "use_ex_nil", "===", "true", "?", "'<ex:nil />'", ":", ...
Encode a value using XMLWriter object $xml @param XMLWriter $xml @param mixed $value @throws \Comodojo\Exception\XmlrpcException
[ "Encode", "a", "value", "using", "XMLWriter", "object", "$xml" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L341-L401
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeArray
private function encodeArray(XMLWriter $xml, $value) { $xml->startElement("array"); $xml->startElement("data"); foreach ( $value as $entry ) { $xml->startElement("value"); $this->encodeValue($xml, $entry); $xml->endElement(); } $xml->endElement(); $xml->endElement(); }
php
private function encodeArray(XMLWriter $xml, $value) { $xml->startElement("array"); $xml->startElement("data"); foreach ( $value as $entry ) { $xml->startElement("value"); $this->encodeValue($xml, $entry); $xml->endElement(); } $xml->endElement(); $xml->endElement(); }
[ "private", "function", "encodeArray", "(", "XMLWriter", "$", "xml", ",", "$", "value", ")", "{", "$", "xml", "->", "startElement", "(", "\"array\"", ")", ";", "$", "xml", "->", "startElement", "(", "\"data\"", ")", ";", "foreach", "(", "$", "value", "a...
Encode an array using XMLWriter object $xml @param XMLWriter $xml @param mixed $value
[ "Encode", "an", "array", "using", "XMLWriter", "object", "$xml" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L409-L429
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeObject
private function encodeObject(XMLWriter $xml, $value) { if ( $value instanceof \DateTime ) $xml->writeElement("dateTime.iso8601", self::timestampToIso8601Time($value->format('U'))); else throw new XmlrpcException("Unknown type for encoding"); }
php
private function encodeObject(XMLWriter $xml, $value) { if ( $value instanceof \DateTime ) $xml->writeElement("dateTime.iso8601", self::timestampToIso8601Time($value->format('U'))); else throw new XmlrpcException("Unknown type for encoding"); }
[ "private", "function", "encodeObject", "(", "XMLWriter", "$", "xml", ",", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "$", "xml", "->", "writeElement", "(", "\"dateTime.iso8601\"", ",", "self", "::", "timestampToIso8...
Encode an object using XMLWriter object $xml @param XMLWriter $xml @param mixed $value @throws \Comodojo\Exception\XmlrpcException
[ "Encode", "an", "object", "using", "XMLWriter", "object", "$xml" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L439-L445
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeStruct
private function encodeStruct(XMLWriter $xml, $value) { $xml->startElement("struct"); foreach ( $value as $k => $v ) { $xml->startElement("member"); $xml->writeElement("name", $k); $xml->startElement("value"); $this->encodeValue($xml, $v); $xml->endElement(); $xml->endElement(); } $xml->endElement(); }
php
private function encodeStruct(XMLWriter $xml, $value) { $xml->startElement("struct"); foreach ( $value as $k => $v ) { $xml->startElement("member"); $xml->writeElement("name", $k); $xml->startElement("value"); $this->encodeValue($xml, $v); $xml->endElement(); $xml->endElement(); } $xml->endElement(); }
[ "private", "function", "encodeStruct", "(", "XMLWriter", "$", "xml", ",", "$", "value", ")", "{", "$", "xml", "->", "startElement", "(", "\"struct\"", ")", ";", "foreach", "(", "$", "value", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "xml", "->...
Encode a struct using XMLWriter object $xml @param XMLWriter $xml @param mixed $value @throws \Comodojo\Exception\XmlrpcException
[ "Encode", "a", "struct", "using", "XMLWriter", "object", "$xml" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L455-L477
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.catchStruct
private static function catchStruct($value) { $values = count($value); for ( $i = 0; $i < $values; $i++ ) if ( !array_key_exists($i, $value) ) return true; return false; }
php
private static function catchStruct($value) { $values = count($value); for ( $i = 0; $i < $values; $i++ ) if ( !array_key_exists($i, $value) ) return true; return false; }
[ "private", "static", "function", "catchStruct", "(", "$", "value", ")", "{", "$", "values", "=", "count", "(", "$", "value", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "values", ";", "$", "i", "++", ")", "if", "(", "!"...
Return true if $value is a struct, false otherwise @param mixed $value @return bool
[ "Return", "true", "if", "$value", "is", "a", "struct", "false", "otherwise" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L486-L494
budde377/Part
lib/view/page_element/PageElementFactoryImpl.php
PageElementFactoryImpl.getPageElement
public function getPageElement($name, $cached = true) { if($cached && isset($this->cache[$name])){ return $this->cache[$name]; } $element = $this->config->getPageElement($name); if($element === null){ if(!class_exists($name)){ return null; } $className = $name; } else { if(isset($element['link'])){ if (!file_exists($element['link'])) { throw new FileNotFoundException($element['link'], 'PageElement'); } /** @noinspection PhpIncludeInspection */ require_once $element['link']; } if (!class_exists($element['className'])) { throw new ClassNotDefinedException($element['className']); } $className = $element['className']; } $elementObject = new $className($this->backendSingletonFactory); if (!($elementObject instanceof view\page_element\PageElement)) { throw new ClassNotInstanceOfException($className, 'PageElement'); } return $this->cache[$name] = $elementObject; }
php
public function getPageElement($name, $cached = true) { if($cached && isset($this->cache[$name])){ return $this->cache[$name]; } $element = $this->config->getPageElement($name); if($element === null){ if(!class_exists($name)){ return null; } $className = $name; } else { if(isset($element['link'])){ if (!file_exists($element['link'])) { throw new FileNotFoundException($element['link'], 'PageElement'); } /** @noinspection PhpIncludeInspection */ require_once $element['link']; } if (!class_exists($element['className'])) { throw new ClassNotDefinedException($element['className']); } $className = $element['className']; } $elementObject = new $className($this->backendSingletonFactory); if (!($elementObject instanceof view\page_element\PageElement)) { throw new ClassNotInstanceOfException($className, 'PageElement'); } return $this->cache[$name] = $elementObject; }
[ "public", "function", "getPageElement", "(", "$", "name", ",", "$", "cached", "=", "true", ")", "{", "if", "(", "$", "cached", "&&", "isset", "(", "$", "this", "->", "cache", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "cac...
{@inheritdoc}
[ "{" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/view/page_element/PageElementFactoryImpl.php#L31-L71
MW-Peachy/Peachy
Plugins/RPED.php
RPED.insertOrDeleteArray
public function insertOrDeleteArray( $command, $pageArray, $maxURLLength = 0 ) { if( $command != 'insert' && $command != 'delete' ) { die( 'Something tried to call insertOrDeleteArray without' . 'specifying an insert or delete command.' ); } if( $maxURLLength == 0 ) { $maxURLLength = $this->defaultMaxURLLength; } $line = ''; foreach( $pageArray as $page ){ if( $line != '' ) { $line .= '|'; } if( strlen( $line ) + strlen( $page ) > $maxURLLength ) { if( $command == 'delete' ) { $this->delete( $line ); } else { $this->insert( $line ); } $line = ''; } $line .= $page; } if( $command == 'delete' ) { $this->delete( $line ); } else { $this->insert( $line ); } }
php
public function insertOrDeleteArray( $command, $pageArray, $maxURLLength = 0 ) { if( $command != 'insert' && $command != 'delete' ) { die( 'Something tried to call insertOrDeleteArray without' . 'specifying an insert or delete command.' ); } if( $maxURLLength == 0 ) { $maxURLLength = $this->defaultMaxURLLength; } $line = ''; foreach( $pageArray as $page ){ if( $line != '' ) { $line .= '|'; } if( strlen( $line ) + strlen( $page ) > $maxURLLength ) { if( $command == 'delete' ) { $this->delete( $line ); } else { $this->insert( $line ); } $line = ''; } $line .= $page; } if( $command == 'delete' ) { $this->delete( $line ); } else { $this->insert( $line ); } }
[ "public", "function", "insertOrDeleteArray", "(", "$", "command", ",", "$", "pageArray", ",", "$", "maxURLLength", "=", "0", ")", "{", "if", "(", "$", "command", "!=", "'insert'", "&&", "$", "command", "!=", "'delete'", ")", "{", "die", "(", "'Something ...
Insert/delete an array of page titles into/from the rped_page table @static @access public @param string $command Either 'insert' or 'delete' @param array $pageArray The array of page title to insert @param int $maxURLLength The maximum length of the url to be POSTed @return void
[ "Insert", "/", "delete", "an", "array", "of", "page", "titles", "into", "/", "from", "the", "rped_page", "table" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/RPED.php#L95-L123
letyii/yii2-tinymce
Tinymce.php
Tinymce.run
public function run() { $this->options['id'] = Html::getInputId($this->model, $this->attribute); $this->configs['selector'] = 'textarea#' . $this->options['id']; $configsEncode = Json::encode($this->configs); $configsEncode = rtrim($configsEncode, '}'); $this->addConfigString = str_replace('{{id}}', $this->options['id'], $this->addConfigString); $configsEncode .= ','. $this->addConfigString .'}'; $this->getView()->registerJs('tinymce.init('. $configsEncode .');'); echo Html::activeTextarea($this->model, $this->attribute, $this->options); }
php
public function run() { $this->options['id'] = Html::getInputId($this->model, $this->attribute); $this->configs['selector'] = 'textarea#' . $this->options['id']; $configsEncode = Json::encode($this->configs); $configsEncode = rtrim($configsEncode, '}'); $this->addConfigString = str_replace('{{id}}', $this->options['id'], $this->addConfigString); $configsEncode .= ','. $this->addConfigString .'}'; $this->getView()->registerJs('tinymce.init('. $configsEncode .');'); echo Html::activeTextarea($this->model, $this->attribute, $this->options); }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "options", "[", "'id'", "]", "=", "Html", "::", "getInputId", "(", "$", "this", "->", "model", ",", "$", "this", "->", "attribute", ")", ";", "$", "this", "->", "configs", "[", "'select...
Renders the widget.
[ "Renders", "the", "widget", "." ]
train
https://github.com/letyii/yii2-tinymce/blob/861873f30d9e16f76239ae827f2848879f66f78f/Tinymce.php#L38-L50
matrozov/yii2-couchbase
src/ActiveRecord.php
ActiveRecord.attributes
public function attributes() { $rules = $this->rules(); if (empty($rules)) { throw new InvalidConfigException('The attributes() method of Couchbase ActiveRecord has to be implemented by child classes.'); } $attributes = []; $attributes['_id'] = true; foreach ($rules as $rule) { if (is_array($rule[0])) { foreach ($rule[0] as $field) { $attributes[$field] = true; } } else { $attributes[$rule[0]] = true; } } return array_keys($attributes); }
php
public function attributes() { $rules = $this->rules(); if (empty($rules)) { throw new InvalidConfigException('The attributes() method of Couchbase ActiveRecord has to be implemented by child classes.'); } $attributes = []; $attributes['_id'] = true; foreach ($rules as $rule) { if (is_array($rule[0])) { foreach ($rule[0] as $field) { $attributes[$field] = true; } } else { $attributes[$rule[0]] = true; } } return array_keys($attributes); }
[ "public", "function", "attributes", "(", ")", "{", "$", "rules", "=", "$", "this", "->", "rules", "(", ")", ";", "if", "(", "empty", "(", "$", "rules", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "'The attributes() method of Couchbase Activ...
Returns the list of all attribute names of the model. This method must be overridden by child classes to define available attributes. Note: primary key attribute "_id" should be always present in returned array. For example: ```php public function attributes() { return ['_id', 'name', 'address', 'status']; } ``` @throws \yii\base\InvalidConfigException if not implemented @return array list of attribute names.
[ "Returns", "the", "list", "of", "all", "attribute", "names", "of", "the", "model", ".", "This", "method", "must", "be", "overridden", "by", "child", "classes", "to", "define", "available", "attributes", ".", "Note", ":", "primary", "key", "attribute", "_id",...
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/ActiveRecord.php#L173-L196
matrozov/yii2-couchbase
src/ActiveRecord.php
ActiveRecord.updateInternal
protected function updateInternal($attributes = null) { if (!$this->beforeSave(false)) { return false; } $values = $this->getDirtyAttributes($attributes); if (empty($values)) { $this->afterSave(false, $values); return 0; } $condition = $this->getOldPrimaryKey(true); $lock = $this->optimisticLock(); if ($lock !== null) { if (!isset($values[$lock])) { $values[$lock] = $this->$lock + 1; } $condition[$lock] = $this->$lock; } // We do not check the return value of update() because it's possible // that it doesn't change anything and thus returns 0. $rows = static::getBucket()->update($values, $condition); if ($lock !== null && !$rows) { throw new StaleObjectException('The object being updated is outdated.'); } if (isset($values[$lock])) { $this->$lock = $values[$lock]; } $changedAttributes = []; foreach ($values as $name => $value) { $changedAttributes[$name] = $this->getOldAttribute($name); $this->setOldAttribute($name, $value); } $this->afterSave(false, $changedAttributes); return $rows; }
php
protected function updateInternal($attributes = null) { if (!$this->beforeSave(false)) { return false; } $values = $this->getDirtyAttributes($attributes); if (empty($values)) { $this->afterSave(false, $values); return 0; } $condition = $this->getOldPrimaryKey(true); $lock = $this->optimisticLock(); if ($lock !== null) { if (!isset($values[$lock])) { $values[$lock] = $this->$lock + 1; } $condition[$lock] = $this->$lock; } // We do not check the return value of update() because it's possible // that it doesn't change anything and thus returns 0. $rows = static::getBucket()->update($values, $condition); if ($lock !== null && !$rows) { throw new StaleObjectException('The object being updated is outdated.'); } if (isset($values[$lock])) { $this->$lock = $values[$lock]; } $changedAttributes = []; foreach ($values as $name => $value) { $changedAttributes[$name] = $this->getOldAttribute($name); $this->setOldAttribute($name, $value); } $this->afterSave(false, $changedAttributes); return $rows; }
[ "protected", "function", "updateInternal", "(", "$", "attributes", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "beforeSave", "(", "false", ")", ")", "{", "return", "false", ";", "}", "$", "values", "=", "$", "this", "->", "getDirtyAttribu...
@see ActiveRecord::update() @param null $attributes @return bool|int @throws Exception @throws InvalidConfigException @throws StaleObjectException
[ "@see", "ActiveRecord", "::", "update", "()" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/ActiveRecord.php#L306-L353
matrozov/yii2-couchbase
src/ActiveRecord.php
ActiveRecord.equals
public function equals($record) { if ($this->isNewRecord || $record->isNewRecord) { return false; } return $this->bucketName() === $record->bucketName() && (string) $this->getPrimaryKey() === (string) $record->getPrimaryKey(); }
php
public function equals($record) { if ($this->isNewRecord || $record->isNewRecord) { return false; } return $this->bucketName() === $record->bucketName() && (string) $this->getPrimaryKey() === (string) $record->getPrimaryKey(); }
[ "public", "function", "equals", "(", "$", "record", ")", "{", "if", "(", "$", "this", "->", "isNewRecord", "||", "$", "record", "->", "isNewRecord", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "bucketName", "(", ")", "===", "$...
Returns a value indicating whether the given active record is the same as the current one. The comparison is made by comparing the bucket names and the primary key values of the two active records. If one of the records [[isNewRecord|is new]] they are also considered not equal. @param ActiveRecord $record record to compare to @return bool whether the two active records refer to the same row in the same Couchbase bucket.
[ "Returns", "a", "value", "indicating", "whether", "the", "given", "active", "record", "is", "the", "same", "as", "the", "current", "one", ".", "The", "comparison", "is", "made", "by", "comparing", "the", "bucket", "names", "and", "the", "primary", "key", "...
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/ActiveRecord.php#L424-L431
matrozov/yii2-couchbase
src/ActiveRecord.php
ActiveRecord.toArrayInternal
private function toArrayInternal($data) { if (is_array($data)) { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->toArrayInternal($value); } if (is_object($value)) { $data[$key] = ArrayHelper::toArray($value); } } return $data; } elseif (is_object($data)) { return ArrayHelper::toArray($data); } else { return [$data]; } }
php
private function toArrayInternal($data) { if (is_array($data)) { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->toArrayInternal($value); } if (is_object($value)) { $data[$key] = ArrayHelper::toArray($value); } } return $data; } elseif (is_object($data)) { return ArrayHelper::toArray($data); } else { return [$data]; } }
[ "private", "function", "toArrayInternal", "(", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", "...
Converts data to array recursively, converting Couchbase JSON objects to readable values. @param mixed $data the data to be converted into an array. @return array the array representation of the data.
[ "Converts", "data", "to", "array", "recursively", "converting", "Couchbase", "JSON", "objects", "to", "readable", "values", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/ActiveRecord.php#L478-L499
Fuhrmann/larageo-plugin
src/Fuhrmann/LarageoPlugin/LarageoPlugin.php
LarageoPlugin.getInfo
public function getInfo($ip = null) { if ($ip == null) { $ip = $this->getIpAdress(); } $url = str_replace('{IP}', $ip, $this->api_adress); $hex = $this->ipToHex($ip); $me = $this; // Check if the IP is in the cache if (Cache::has($hex)) { $this->isCached = true; } // Use the IP info stored in cache or store it $ipInfo = Cache::remember($hex, 10080, function () use ($me, $url) { return $me->fetchInfo($url); }); $ipInfo->geoplugin_cached = $this->isCached; return $ipInfo; }
php
public function getInfo($ip = null) { if ($ip == null) { $ip = $this->getIpAdress(); } $url = str_replace('{IP}', $ip, $this->api_adress); $hex = $this->ipToHex($ip); $me = $this; // Check if the IP is in the cache if (Cache::has($hex)) { $this->isCached = true; } // Use the IP info stored in cache or store it $ipInfo = Cache::remember($hex, 10080, function () use ($me, $url) { return $me->fetchInfo($url); }); $ipInfo->geoplugin_cached = $this->isCached; return $ipInfo; }
[ "public", "function", "getInfo", "(", "$", "ip", "=", "null", ")", "{", "if", "(", "$", "ip", "==", "null", ")", "{", "$", "ip", "=", "$", "this", "->", "getIpAdress", "(", ")", ";", "}", "$", "url", "=", "str_replace", "(", "'{IP}'", ",", "$",...
Return all the information in an array. @param $ip IP to search for @return array Info from the IP parameter
[ "Return", "all", "the", "information", "in", "an", "array", "." ]
train
https://github.com/Fuhrmann/larageo-plugin/blob/b45374b971253aa553b4b4429581bba886237671/src/Fuhrmann/LarageoPlugin/LarageoPlugin.php#L29-L51
Fuhrmann/larageo-plugin
src/Fuhrmann/LarageoPlugin/LarageoPlugin.php
LarageoPlugin.getIpAdress
public function getIpAdress() { $ip_keys = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR']; foreach ($ip_keys as $key) { if (array_key_exists($key, $_SERVER) === true) { foreach (explode(',', $_SERVER[$key]) as $ip) { $ip = trim($ip); if ($this->validateIp($ip)) { return $ip; } } } } return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : false; }
php
public function getIpAdress() { $ip_keys = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR']; foreach ($ip_keys as $key) { if (array_key_exists($key, $_SERVER) === true) { foreach (explode(',', $_SERVER[$key]) as $ip) { $ip = trim($ip); if ($this->validateIp($ip)) { return $ip; } } } } return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : false; }
[ "public", "function", "getIpAdress", "(", ")", "{", "$", "ip_keys", "=", "[", "'HTTP_CLIENT_IP'", ",", "'HTTP_X_FORWARDED_FOR'", ",", "'HTTP_X_FORWARDED'", ",", "'HTTP_X_CLUSTER_CLIENT_IP'", ",", "'HTTP_FORWARDED_FOR'", ",", "'HTTP_FORWARDED'", ",", "'REMOTE_ADDR'", "]"...
Get the IP adress. @link https://gist.github.com/cballou/2201933 @return bool|string
[ "Get", "the", "IP", "adress", "." ]
train
https://github.com/Fuhrmann/larageo-plugin/blob/b45374b971253aa553b4b4429581bba886237671/src/Fuhrmann/LarageoPlugin/LarageoPlugin.php#L60-L75
Fuhrmann/larageo-plugin
src/Fuhrmann/LarageoPlugin/LarageoPlugin.php
LarageoPlugin.validateIp
protected function validateIp($ip) { if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_IPV6) === false) { return false; } return true; }
php
protected function validateIp($ip) { if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_IPV6) === false) { return false; } return true; }
[ "protected", "function", "validateIp", "(", "$", "ip", ")", "{", "if", "(", "filter_var", "(", "$", "ip", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV4", "|", "FILTER_FLAG_NO_PRIV_RANGE", "|", "FILTER_FLAG_NO_RES_RANGE", "|", "FILTER_FLAG_IPV6", ")", "===", "f...
Ensures an ip address is both a valid IP and does not fall within a private network range.
[ "Ensures", "an", "ip", "address", "is", "both", "a", "valid", "IP", "and", "does", "not", "fall", "within", "a", "private", "network", "range", "." ]
train
https://github.com/Fuhrmann/larageo-plugin/blob/b45374b971253aa553b4b4429581bba886237671/src/Fuhrmann/LarageoPlugin/LarageoPlugin.php#L81-L88
Fuhrmann/larageo-plugin
src/Fuhrmann/LarageoPlugin/LarageoPlugin.php
LarageoPlugin.fetchInfo
public function fetchInfo($url) { $response = null; if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'LarageoPlugin Package v1.0'); $response = curl_exec($ch); curl_close($ch); } elseif (ini_get('allow_url_fopen')) { $response = file_get_contents($url, 'r'); } else { throw new \Exception('LarageoPlugin requires the CURL PHP extension or allow_url_fopen set to 1!'); } $response = json_decode($response); if (empty($response)) { throw new \Exception('Ops! The data is empty! Is '.$url.' acessible?'); } if (isset($response->geoplugin_status) && $response->geoplugin_status == 404) { throw new \Exception('Ops! Your request returned a 404 error! Is '.$url.' acessible?'); } return $response; }
php
public function fetchInfo($url) { $response = null; if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'LarageoPlugin Package v1.0'); $response = curl_exec($ch); curl_close($ch); } elseif (ini_get('allow_url_fopen')) { $response = file_get_contents($url, 'r'); } else { throw new \Exception('LarageoPlugin requires the CURL PHP extension or allow_url_fopen set to 1!'); } $response = json_decode($response); if (empty($response)) { throw new \Exception('Ops! The data is empty! Is '.$url.' acessible?'); } if (isset($response->geoplugin_status) && $response->geoplugin_status == 404) { throw new \Exception('Ops! Your request returned a 404 error! Is '.$url.' acessible?'); } return $response; }
[ "public", "function", "fetchInfo", "(", "$", "url", ")", "{", "$", "response", "=", "null", ";", "if", "(", "function_exists", "(", "'curl_init'", ")", ")", "{", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT...
Fetch the info from IP using CURL or file_get_contents. @param $url @throws \Exception @return mixed
[ "Fetch", "the", "info", "from", "IP", "using", "CURL", "or", "file_get_contents", "." ]
train
https://github.com/Fuhrmann/larageo-plugin/blob/b45374b971253aa553b4b4429581bba886237671/src/Fuhrmann/LarageoPlugin/LarageoPlugin.php#L99-L128
Fuhrmann/larageo-plugin
src/Fuhrmann/LarageoPlugin/LarageoPlugin.php
LarageoPlugin.ipToHex
public function ipToHex($ipAddress) { $hex = ''; if (strpos($ipAddress, ',') !== false) { $splitIp = explode(',', $ipAddress); $ipAddress = trim($splitIp[0]); } $isIpV6 = false; $isIpV4 = false; if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { $isIpV6 = true; } elseif (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) { $isIpV4 = true; } if (!$isIpV4 && !$isIpV6) { return false; } // IPv4 format if ($isIpV4) { $parts = explode('.', $ipAddress); for ($i = 0; $i < 4; $i++) { $parts[ $i ] = str_pad(dechex($parts[ $i ]), 2, '0', STR_PAD_LEFT); } $ipAddress = '::'.$parts[0].$parts[1].':'.$parts[2].$parts[3]; $hex = implode('', $parts); } // IPv6 format else { $parts = explode(':', $ipAddress); // If this is mixed IPv6/IPv4, convert end to IPv6 value if (filter_var($parts[ count($parts) - 1 ], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) { $partsV4 = explode('.', $parts[ count($parts) - 1 ]); for ($i = 0; $i < 4; $i++) { $partsV4[ $i ] = str_pad(dechex($partsV4[ $i ]), 2, '0', STR_PAD_LEFT); } $parts[ count($parts) - 1 ] = $partsV4[0].$partsV4[1]; $parts[] = $partsV4[2].$partsV4[3]; } $numMissing = 8 - count($parts); $expandedParts = []; $expansionDone = false; foreach ($parts as $part) { if (!$expansionDone && $part == '') { for ($i = 0; $i <= $numMissing; $i++) { $expandedParts[] = '0000'; } $expansionDone = true; } else { $expandedParts[] = $part; } } foreach ($expandedParts as &$part) { $part = str_pad($part, 4, '0', STR_PAD_LEFT); } $ipAddress = implode(':', $expandedParts); $hex = implode('', $expandedParts); } // Validate the final IP if (!filter_var($ipAddress, FILTER_VALIDATE_IP)) { return false; } return strtolower(str_pad($hex, 32, '0', STR_PAD_LEFT)); }
php
public function ipToHex($ipAddress) { $hex = ''; if (strpos($ipAddress, ',') !== false) { $splitIp = explode(',', $ipAddress); $ipAddress = trim($splitIp[0]); } $isIpV6 = false; $isIpV4 = false; if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { $isIpV6 = true; } elseif (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) { $isIpV4 = true; } if (!$isIpV4 && !$isIpV6) { return false; } // IPv4 format if ($isIpV4) { $parts = explode('.', $ipAddress); for ($i = 0; $i < 4; $i++) { $parts[ $i ] = str_pad(dechex($parts[ $i ]), 2, '0', STR_PAD_LEFT); } $ipAddress = '::'.$parts[0].$parts[1].':'.$parts[2].$parts[3]; $hex = implode('', $parts); } // IPv6 format else { $parts = explode(':', $ipAddress); // If this is mixed IPv6/IPv4, convert end to IPv6 value if (filter_var($parts[ count($parts) - 1 ], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) { $partsV4 = explode('.', $parts[ count($parts) - 1 ]); for ($i = 0; $i < 4; $i++) { $partsV4[ $i ] = str_pad(dechex($partsV4[ $i ]), 2, '0', STR_PAD_LEFT); } $parts[ count($parts) - 1 ] = $partsV4[0].$partsV4[1]; $parts[] = $partsV4[2].$partsV4[3]; } $numMissing = 8 - count($parts); $expandedParts = []; $expansionDone = false; foreach ($parts as $part) { if (!$expansionDone && $part == '') { for ($i = 0; $i <= $numMissing; $i++) { $expandedParts[] = '0000'; } $expansionDone = true; } else { $expandedParts[] = $part; } } foreach ($expandedParts as &$part) { $part = str_pad($part, 4, '0', STR_PAD_LEFT); } $ipAddress = implode(':', $expandedParts); $hex = implode('', $expandedParts); } // Validate the final IP if (!filter_var($ipAddress, FILTER_VALIDATE_IP)) { return false; } return strtolower(str_pad($hex, 32, '0', STR_PAD_LEFT)); }
[ "public", "function", "ipToHex", "(", "$", "ipAddress", ")", "{", "$", "hex", "=", "''", ";", "if", "(", "strpos", "(", "$", "ipAddress", ",", "','", ")", "!==", "false", ")", "{", "$", "splitIp", "=", "explode", "(", "','", ",", "$", "ipAddress", ...
Return a hex string of the current IP. Used as the key for cache storage. @param $ipAddress @return bool|string
[ "Return", "a", "hex", "string", "of", "the", "current", "IP", ".", "Used", "as", "the", "key", "for", "cache", "storage", "." ]
train
https://github.com/Fuhrmann/larageo-plugin/blob/b45374b971253aa553b4b4429581bba886237671/src/Fuhrmann/LarageoPlugin/LarageoPlugin.php#L137-L199
vcarreira/wordsapi
src/Word.php
Word.make
private function make($verb, $fetchDetails = null) { if (isset($this->cache[$verb])) { return $this->cache[$verb]; } $data = $this->service->fetch( $this->word, $verb, is_null($fetchDetails) ? $this->prefetchDetails : (bool) $fetchDetails ); if ($data === false) { return false; } $this->cache = array_merge($this->cache, $data); return $this->cache[$verb]; }
php
private function make($verb, $fetchDetails = null) { if (isset($this->cache[$verb])) { return $this->cache[$verb]; } $data = $this->service->fetch( $this->word, $verb, is_null($fetchDetails) ? $this->prefetchDetails : (bool) $fetchDetails ); if ($data === false) { return false; } $this->cache = array_merge($this->cache, $data); return $this->cache[$verb]; }
[ "private", "function", "make", "(", "$", "verb", ",", "$", "fetchDetails", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "verb", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "verb", ...
Checks if the result is cached. Otherwise it invokes the service method to retrieve the results. Results are cached on a word basis to optimize the number of API calls.
[ "Checks", "if", "the", "result", "is", "cached", ".", "Otherwise", "it", "invokes", "the", "service", "method", "to", "retrieve", "the", "results", ".", "Results", "are", "cached", "on", "a", "word", "basis", "to", "optimize", "the", "number", "of", "API",...
train
https://github.com/vcarreira/wordsapi/blob/60ca55823ffdf8c422e6bbed614161dc8d6af394/src/Word.php#L326-L344
louvian/pururin-crawler
src/Pururin/PururinCrawler.php
PururinCrawler.getCover
private function getCover() { $get = new Cover($this); $get->action(); $get->build(); $this->buildContext($this->result = $get->get(), "cover"); $this->tmpContainer['content_crawler'] = new Content($this); $this->tmpContainer['content_crawler']->setOffsetPoint($this->offset); }
php
private function getCover() { $get = new Cover($this); $get->action(); $get->build(); $this->buildContext($this->result = $get->get(), "cover"); $this->tmpContainer['content_crawler'] = new Content($this); $this->tmpContainer['content_crawler']->setOffsetPoint($this->offset); }
[ "private", "function", "getCover", "(", ")", "{", "$", "get", "=", "new", "Cover", "(", "$", "this", ")", ";", "$", "get", "->", "action", "(", ")", ";", "$", "get", "->", "build", "(", ")", ";", "$", "this", "->", "buildContext", "(", "$", "th...
Get gallery cover.
[ "Get", "gallery", "cover", "." ]
train
https://github.com/louvian/pururin-crawler/blob/1a8e5d606fc9e0f494aaceaf192d08265e8b8d26/src/Pururin/PururinCrawler.php#L141-L149
louvian/pururin-crawler
src/Pururin/PururinCrawler.php
PururinCrawler.getContent
private function getContent() { $action = $this->tmpContainer['content_crawler']->action(); if ($action) { $this->buildContext( $this->tmpContainer['content_crawler']->get(), "content" ); } return $action; }
php
private function getContent() { $action = $this->tmpContainer['content_crawler']->action(); if ($action) { $this->buildContext( $this->tmpContainer['content_crawler']->get(), "content" ); } return $action; }
[ "private", "function", "getContent", "(", ")", "{", "$", "action", "=", "$", "this", "->", "tmpContainer", "[", "'content_crawler'", "]", "->", "action", "(", ")", ";", "if", "(", "$", "action", ")", "{", "$", "this", "->", "buildContext", "(", "$", ...
Get content
[ "Get", "content" ]
train
https://github.com/louvian/pururin-crawler/blob/1a8e5d606fc9e0f494aaceaf192d08265e8b8d26/src/Pururin/PururinCrawler.php#L154-L164
Cocolabs-SAS/CocoricoSwiftReaderBundle
Controller/MessageController.php
MessageController.indexAction
public function indexAction() { $this->get('profiler')->disable(); $messageListDTO = $this->get('cocorico.swift_reader.message_manager') ->getMessageListDTO(); return $this->render( 'CocoricoSwiftReaderBundle:Message:index.html.twig', array( 'messages' => $messageListDTO->messages ) ); }
php
public function indexAction() { $this->get('profiler')->disable(); $messageListDTO = $this->get('cocorico.swift_reader.message_manager') ->getMessageListDTO(); return $this->render( 'CocoricoSwiftReaderBundle:Message:index.html.twig', array( 'messages' => $messageListDTO->messages ) ); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "this", "->", "get", "(", "'profiler'", ")", "->", "disable", "(", ")", ";", "$", "messageListDTO", "=", "$", "this", "->", "get", "(", "'cocorico.swift_reader.message_manager'", ")", "->", "getMessage...
@Route("/", name="cocorico_swift_reader_message_index") @Method("GET") @return \Symfony\Component\HttpFoundation\Response
[ "@Route", "(", "/", "name", "=", "cocorico_swift_reader_message_index", ")", "@Method", "(", "GET", ")" ]
train
https://github.com/Cocolabs-SAS/CocoricoSwiftReaderBundle/blob/ba3df4ccef1bd473e67121112f6a5d7ce0b369aa/Controller/MessageController.php#L30-L43
Cocolabs-SAS/CocoricoSwiftReaderBundle
Controller/MessageController.php
MessageController.showAction
public function showAction($filename) { $message = $this->get('cocorico.swift_reader.message_manager') ->getOneByFileName($filename); return $this->render( 'CocoricoSwiftReaderBundle:Message:_show.html.twig', array( 'filename' => $filename, 'message' => $message ) ); }
php
public function showAction($filename) { $message = $this->get('cocorico.swift_reader.message_manager') ->getOneByFileName($filename); return $this->render( 'CocoricoSwiftReaderBundle:Message:_show.html.twig', array( 'filename' => $filename, 'message' => $message ) ); }
[ "public", "function", "showAction", "(", "$", "filename", ")", "{", "$", "message", "=", "$", "this", "->", "get", "(", "'cocorico.swift_reader.message_manager'", ")", "->", "getOneByFileName", "(", "$", "filename", ")", ";", "return", "$", "this", "->", "re...
@Route("/show/{filename}", name="cocorico_swift_reader_message_show") @Method("GET") @param string $filename @return \Symfony\Component\HttpFoundation\Response
[ "@Route", "(", "/", "show", "/", "{", "filename", "}", "name", "=", "cocorico_swift_reader_message_show", ")", "@Method", "(", "GET", ")" ]
train
https://github.com/Cocolabs-SAS/CocoricoSwiftReaderBundle/blob/ba3df4ccef1bd473e67121112f6a5d7ce0b369aa/Controller/MessageController.php#L53-L65
Cocolabs-SAS/CocoricoSwiftReaderBundle
Controller/MessageController.php
MessageController.fetchAction
public function fetchAction($filename) { $this->get('profiler')->disable(); $message = $this->get('cocorico.swift_reader.message_manager') ->getOneByFileName($filename); return new Response($message->body); }
php
public function fetchAction($filename) { $this->get('profiler')->disable(); $message = $this->get('cocorico.swift_reader.message_manager') ->getOneByFileName($filename); return new Response($message->body); }
[ "public", "function", "fetchAction", "(", "$", "filename", ")", "{", "$", "this", "->", "get", "(", "'profiler'", ")", "->", "disable", "(", ")", ";", "$", "message", "=", "$", "this", "->", "get", "(", "'cocorico.swift_reader.message_manager'", ")", "->",...
@Route("/fetch/{filename}", name="cocorico_swift_reader_message_fetch") @Method("GET") @param string $filename @return \Symfony\Component\HttpFoundation\Response
[ "@Route", "(", "/", "fetch", "/", "{", "filename", "}", "name", "=", "cocorico_swift_reader_message_fetch", ")", "@Method", "(", "GET", ")" ]
train
https://github.com/Cocolabs-SAS/CocoricoSwiftReaderBundle/blob/ba3df4ccef1bd473e67121112f6a5d7ce0b369aa/Controller/MessageController.php#L75-L83
Cocolabs-SAS/CocoricoSwiftReaderBundle
Controller/MessageController.php
MessageController.deleteAction
public function deleteAction($filename) { $this->get('cocorico.swift_reader.message_manager') ->deleteByFileName($filename); $messageListDTO = $this->get('cocorico.swift_reader.message_manager') ->getMessageListDTO(); return $this->render( 'CocoricoSwiftReaderBundle:Message:_list.html.twig', array( 'messages' => $messageListDTO->messages ) ); }
php
public function deleteAction($filename) { $this->get('cocorico.swift_reader.message_manager') ->deleteByFileName($filename); $messageListDTO = $this->get('cocorico.swift_reader.message_manager') ->getMessageListDTO(); return $this->render( 'CocoricoSwiftReaderBundle:Message:_list.html.twig', array( 'messages' => $messageListDTO->messages ) ); }
[ "public", "function", "deleteAction", "(", "$", "filename", ")", "{", "$", "this", "->", "get", "(", "'cocorico.swift_reader.message_manager'", ")", "->", "deleteByFileName", "(", "$", "filename", ")", ";", "$", "messageListDTO", "=", "$", "this", "->", "get",...
@Route("/delete/{filename}", name="cocorico_swift_reader_message_delete") @Method("GET") @param string $filename @return \Symfony\Component\HttpFoundation\Response
[ "@Route", "(", "/", "delete", "/", "{", "filename", "}", "name", "=", "cocorico_swift_reader_message_delete", ")", "@Method", "(", "GET", ")" ]
train
https://github.com/Cocolabs-SAS/CocoricoSwiftReaderBundle/blob/ba3df4ccef1bd473e67121112f6a5d7ce0b369aa/Controller/MessageController.php#L93-L107
budde377/Part
lib/view/page_element/FrontPageTextPageElementImpl.php
FrontPageTextPageElementImpl.generateContent
public function generateContent() { parent::generateContent(); $latest= null; $pageContent = new PageContentImpl($this->container, $this->container->getCurrentPageStrategyInstance()->getCurrentPage(), "mainContent"); if(($latest = $pageContent->latestContent()) != null){ return "<div class='editable' id='mainContent'>$latest</div>"; } return " <div class='editable' id='mainContent'> <h2>Lorem Ipsum</h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In at lobortis nibh. Nullam lobortis nunc sed iaculis fermentum. Donec convallis sapien non nunc rhoncus rhoncus. Nulla et lorem sed nibh varius dignissim. Nullam quis libero a risus volutpat feugiat in eget sem. Sed quis vehicula ipsum, et laoreet tellus. Suspendisse nec lectus sit amet massa tristique ultrices. Maecenas vitae est tortor. Mauris quis mollis arcu. Nam blandit dictum erat dignissim pulvinar. Cras nec vehicula risus. Etiam viverra quam orci, at convallis tortor tincidunt a. Duis mollis, diam sed vestibulum tempus, justo augue venenatis enim, eu sodales ipsum est sollicitudin ligula. Proin vel laoreet enim. </p> <pre>initLib.registerInitializer(new UserSettings.UserSettingsInitializer(initLib)); initLib.registerInitializer(new BackgroundPositionInitializer()); initLib.registerInitializer(new TopMenuInitializer()); initLib.registerInitializer(new LoginFormulaInitializer()); initLib.registerInitializer(new EditorInitializer()); initLib.setUp();</pre> <p> Nunc varius tellus tellus, sed semper ligula hendrerit id. Fusce placerat lectus posuere quam imperdiet accumsan. Suspendisse non lacinia tellus. Etiam lacinia ullamcorper consectetur. Mauris dapibus ligula ac odio porttitor tempor. Mauris accumsan hendrerit pellentesque. Praesent suscipit lectus sit amet adipiscing aliquam. Praesent venenatis cursus lorem ac pretium. Proin ultricies libero nec neque aliquam fringilla. Etiam sed condimentum eros, id vulputate dui. Nunc consectetur volutpat risus. Cras venenatis libero eget viverra pulvinar. </p> <h3>Phasellus aliquam </h3> <p> Phasellus aliquam orci ut scelerisque fringilla. Donec accumsan erat vehicula lectus ultrices lacinia. Vivamus eu orci feugiat tellus porttitor mollis ac eu nisi. Curabitur quis turpis id tortor scelerisque placerat posuere et lectus. Proin cursus mi eget dui pretium, quis imperdiet arcu ultricies. Donec at nibh enim. Maecenas suscipit euismod turpis ut venenatis. Sed tincidunt lacus urna, non sodales mi dapibus a. Nulla nec enim eu magna accumsan dapibus. Nulla eu tincidunt orci, eget ornare ante. </p> <blockquote> Nunc varius tellus tellus, sed semper ligula hendrerit id. Fusce placerat lectus posuere quam imperdiet accumsan. Suspendisse non lacinia tellus. Etiam lacinia ullamcorper consectetur. Mauris dapibus ligula ac odio porttitor tempor. Mauris accumsan hendrerit pellentesque. Praesent suscipit lectus sit amet adipiscing aliquam. Praesent venenatis cursus lorem ac pretium. Proin ultricies libero nec neque aliquam fringilla. Etiam sed condimentum eros, id vulputate dui. Nunc consectetur volutpat risus. Cras venenatis libero eget viverra pulvinar. </blockquote> </div> "; }
php
public function generateContent() { parent::generateContent(); $latest= null; $pageContent = new PageContentImpl($this->container, $this->container->getCurrentPageStrategyInstance()->getCurrentPage(), "mainContent"); if(($latest = $pageContent->latestContent()) != null){ return "<div class='editable' id='mainContent'>$latest</div>"; } return " <div class='editable' id='mainContent'> <h2>Lorem Ipsum</h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In at lobortis nibh. Nullam lobortis nunc sed iaculis fermentum. Donec convallis sapien non nunc rhoncus rhoncus. Nulla et lorem sed nibh varius dignissim. Nullam quis libero a risus volutpat feugiat in eget sem. Sed quis vehicula ipsum, et laoreet tellus. Suspendisse nec lectus sit amet massa tristique ultrices. Maecenas vitae est tortor. Mauris quis mollis arcu. Nam blandit dictum erat dignissim pulvinar. Cras nec vehicula risus. Etiam viverra quam orci, at convallis tortor tincidunt a. Duis mollis, diam sed vestibulum tempus, justo augue venenatis enim, eu sodales ipsum est sollicitudin ligula. Proin vel laoreet enim. </p> <pre>initLib.registerInitializer(new UserSettings.UserSettingsInitializer(initLib)); initLib.registerInitializer(new BackgroundPositionInitializer()); initLib.registerInitializer(new TopMenuInitializer()); initLib.registerInitializer(new LoginFormulaInitializer()); initLib.registerInitializer(new EditorInitializer()); initLib.setUp();</pre> <p> Nunc varius tellus tellus, sed semper ligula hendrerit id. Fusce placerat lectus posuere quam imperdiet accumsan. Suspendisse non lacinia tellus. Etiam lacinia ullamcorper consectetur. Mauris dapibus ligula ac odio porttitor tempor. Mauris accumsan hendrerit pellentesque. Praesent suscipit lectus sit amet adipiscing aliquam. Praesent venenatis cursus lorem ac pretium. Proin ultricies libero nec neque aliquam fringilla. Etiam sed condimentum eros, id vulputate dui. Nunc consectetur volutpat risus. Cras venenatis libero eget viverra pulvinar. </p> <h3>Phasellus aliquam </h3> <p> Phasellus aliquam orci ut scelerisque fringilla. Donec accumsan erat vehicula lectus ultrices lacinia. Vivamus eu orci feugiat tellus porttitor mollis ac eu nisi. Curabitur quis turpis id tortor scelerisque placerat posuere et lectus. Proin cursus mi eget dui pretium, quis imperdiet arcu ultricies. Donec at nibh enim. Maecenas suscipit euismod turpis ut venenatis. Sed tincidunt lacus urna, non sodales mi dapibus a. Nulla nec enim eu magna accumsan dapibus. Nulla eu tincidunt orci, eget ornare ante. </p> <blockquote> Nunc varius tellus tellus, sed semper ligula hendrerit id. Fusce placerat lectus posuere quam imperdiet accumsan. Suspendisse non lacinia tellus. Etiam lacinia ullamcorper consectetur. Mauris dapibus ligula ac odio porttitor tempor. Mauris accumsan hendrerit pellentesque. Praesent suscipit lectus sit amet adipiscing aliquam. Praesent venenatis cursus lorem ac pretium. Proin ultricies libero nec neque aliquam fringilla. Etiam sed condimentum eros, id vulputate dui. Nunc consectetur volutpat risus. Cras venenatis libero eget viverra pulvinar. </blockquote> </div> "; }
[ "public", "function", "generateContent", "(", ")", "{", "parent", "::", "generateContent", "(", ")", ";", "$", "latest", "=", "null", ";", "$", "pageContent", "=", "new", "PageContentImpl", "(", "$", "this", "->", "container", ",", "$", "this", "->", "co...
This will return content from page element as a string. The format can be xml, xhtml, html etc. but return type must be string @return string
[ "This", "will", "return", "content", "from", "page", "element", "as", "a", "string", ".", "The", "format", "can", "be", "xml", "xhtml", "html", "etc", ".", "but", "return", "type", "must", "be", "string" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/view/page_element/FrontPageTextPageElementImpl.php#L29-L65
wardrobecms/core-archived
src/Wardrobe/Core/WardrobeServiceProvider.php
WardrobeServiceProvider.boot
public function boot() { $this->package('wardrobe/core'); $this->setConnection(); $this->bindRepositories(); $this->bootCommands(); require_once __DIR__.'/../../themeHelpers.php'; require_once __DIR__.'/../../routes.php'; require_once __DIR__.'/../../filters.php'; }
php
public function boot() { $this->package('wardrobe/core'); $this->setConnection(); $this->bindRepositories(); $this->bootCommands(); require_once __DIR__.'/../../themeHelpers.php'; require_once __DIR__.'/../../routes.php'; require_once __DIR__.'/../../filters.php'; }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "package", "(", "'wardrobe/core'", ")", ";", "$", "this", "->", "setConnection", "(", ")", ";", "$", "this", "->", "bindRepositories", "(", ")", ";", "$", "this", "->", "bootCommands", "("...
Bootstrap the application events. @return void
[ "Bootstrap", "the", "application", "events", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/WardrobeServiceProvider.php#L20-L30
wardrobecms/core-archived
src/Wardrobe/Core/WardrobeServiceProvider.php
WardrobeServiceProvider.bindRepositories
protected function bindRepositories() { $this->app->singleton('Wardrobe\Core\Repositories\PostRepositoryInterface', 'Wardrobe\Core\Repositories\DbPostRepository'); $this->app->singleton('Wardrobe\Core\Repositories\UserRepositoryInterface', 'Wardrobe\Core\Repositories\DbUserRepository'); $this->app->bind('Wardrobe', function() { return new \Wardrobe\Core\Facades\Wardrobe(new Repositories\DbPostRepository); }); }
php
protected function bindRepositories() { $this->app->singleton('Wardrobe\Core\Repositories\PostRepositoryInterface', 'Wardrobe\Core\Repositories\DbPostRepository'); $this->app->singleton('Wardrobe\Core\Repositories\UserRepositoryInterface', 'Wardrobe\Core\Repositories\DbUserRepository'); $this->app->bind('Wardrobe', function() { return new \Wardrobe\Core\Facades\Wardrobe(new Repositories\DbPostRepository); }); }
[ "protected", "function", "bindRepositories", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'Wardrobe\\Core\\Repositories\\PostRepositoryInterface'", ",", "'Wardrobe\\Core\\Repositories\\DbPostRepository'", ")", ";", "$", "this", "->", "app", "->", "s...
Bind repositories. @return void
[ "Bind", "repositories", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/WardrobeServiceProvider.php#L37-L47