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
webdevvie/pheanstalk-task-queue-bundle
Command/WorkerTenderCommand.php
WorkerTenderCommand.countWorkers
public function countWorkers() { $total = count($this->family); $busy = 0; $available = 0; foreach ($this->family as &$child) { switch ($child->status) { case ChildProcessContainer::STATUS_ALIVE: case ChildProcessContainer::STATUS_READY: ...
php
public function countWorkers() { $total = count($this->family); $busy = 0; $available = 0; foreach ($this->family as &$child) { switch ($child->status) { case ChildProcessContainer::STATUS_ALIVE: case ChildProcessContainer::STATUS_READY: ...
[ "public", "function", "countWorkers", "(", ")", "{", "$", "total", "=", "count", "(", "$", "this", "->", "family", ")", ";", "$", "busy", "=", "0", ";", "$", "available", "=", "0", ";", "foreach", "(", "$", "this", "->", "family", "as", "&", "$",...
Returns an array with the worker counts @return array
[ "Returns", "an", "array", "with", "the", "worker", "counts" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/WorkerTenderCommand.php#L178-L196
webdevvie/pheanstalk-task-queue-bundle
Command/WorkerTenderCommand.php
WorkerTenderCommand.moreOrLess
public function moreOrLess($total, $available) { $shouldHaveMoreWorkers = false; $shouldHaveLessWorkers = false; $minWorkers = $this->input->getOption('min-workers'); $maxWorkers = $this->input->getOption('max-workers'); $spareWorkers = $this->input->getOption('spare-workers'...
php
public function moreOrLess($total, $available) { $shouldHaveMoreWorkers = false; $shouldHaveLessWorkers = false; $minWorkers = $this->input->getOption('min-workers'); $maxWorkers = $this->input->getOption('max-workers'); $spareWorkers = $this->input->getOption('spare-workers'...
[ "public", "function", "moreOrLess", "(", "$", "total", ",", "$", "available", ")", "{", "$", "shouldHaveMoreWorkers", "=", "false", ";", "$", "shouldHaveLessWorkers", "=", "false", ";", "$", "minWorkers", "=", "$", "this", "->", "input", "->", "getOption", ...
Returns two booleans if there should be more or less workers @param integer $total @param integer $busy @param integer $available @return array
[ "Returns", "two", "booleans", "if", "there", "should", "be", "more", "or", "less", "workers" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/WorkerTenderCommand.php#L206-L229
webdevvie/pheanstalk-task-queue-bundle
Command/WorkerTenderCommand.php
WorkerTenderCommand.findDisposableWorkers
private function findDisposableWorkers() { $disposableStatusses = array(ChildProcessContainer::STATUS_READY, ChildProcessContainer::STATUS_ALIVE); foreach ($this->family as &$child) { if (in_array($child->status, $disposableStatusses)) { if ($child->getAge() < 10) { ...
php
private function findDisposableWorkers() { $disposableStatusses = array(ChildProcessContainer::STATUS_READY, ChildProcessContainer::STATUS_ALIVE); foreach ($this->family as &$child) { if (in_array($child->status, $disposableStatusses)) { if ($child->getAge() < 10) { ...
[ "private", "function", "findDisposableWorkers", "(", ")", "{", "$", "disposableStatusses", "=", "array", "(", "ChildProcessContainer", "::", "STATUS_READY", ",", "ChildProcessContainer", "::", "STATUS_ALIVE", ")", ";", "foreach", "(", "$", "this", "->", "family", ...
Finds disposable workers, if it finds them it returns true @return boolean
[ "Finds", "disposable", "workers", "if", "it", "finds", "them", "it", "returns", "true" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/WorkerTenderCommand.php#L236-L251
webdevvie/pheanstalk-task-queue-bundle
Command/WorkerTenderCommand.php
WorkerTenderCommand.spawnChild
private function spawnChild() { $child = new ChildProcessContainer( $this->consolePath, $this->input->getOption('worker-command'), $this->tube, $this ); $child->start(); return $child; }
php
private function spawnChild() { $child = new ChildProcessContainer( $this->consolePath, $this->input->getOption('worker-command'), $this->tube, $this ); $child->start(); return $child; }
[ "private", "function", "spawnChild", "(", ")", "{", "$", "child", "=", "new", "ChildProcessContainer", "(", "$", "this", "->", "consolePath", ",", "$", "this", "->", "input", "->", "getOption", "(", "'worker-command'", ")", ",", "$", "this", "->", "tube", ...
Spawns a new child @return Child
[ "Spawns", "a", "new", "child" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/WorkerTenderCommand.php#L271-L281
ronaldborla/chikka
src/Borla/Chikka/Receiver.php
Receiver.message
public function message($callback) { // If there's a message if ($this->hasMessage()) { // Execute callback passing the message $this->success = Utilities::executeCallback($callback, [ // First parameter is the message $this->message, ...
php
public function message($callback) { // If there's a message if ($this->hasMessage()) { // Execute callback passing the message $this->success = Utilities::executeCallback($callback, [ // First parameter is the message $this->message, ...
[ "public", "function", "message", "(", "$", "callback", ")", "{", "// If there's a message", "if", "(", "$", "this", "->", "hasMessage", "(", ")", ")", "{", "// Execute callback passing the message", "$", "this", "->", "success", "=", "Utilities", "::", "executeC...
Handle message
[ "Handle", "message" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Receiver.php#L78-L91
ronaldborla/chikka
src/Borla/Chikka/Receiver.php
Receiver.notification
public function notification($callback) { // If there's a notification if ($this->hasNotification()) { // Execute callback passing the notification $this->success = Utilities::executeCallback($callback, [$this->notification]); } // Return self return $this; }
php
public function notification($callback) { // If there's a notification if ($this->hasNotification()) { // Execute callback passing the notification $this->success = Utilities::executeCallback($callback, [$this->notification]); } // Return self return $this; }
[ "public", "function", "notification", "(", "$", "callback", ")", "{", "// If there's a notification", "if", "(", "$", "this", "->", "hasNotification", "(", ")", ")", "{", "// Execute callback passing the notification", "$", "this", "->", "success", "=", "Utilities",...
Handle notification
[ "Handle", "notification" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Receiver.php#L96-L104
gruzilla/hydra
src/Hydra/Mappers/ArrayMapper.php
ArrayMapper.evalueateArrayQuery
public static function evalueateArrayQuery($data, $query) { // return direct hits if (isset($data[$query])) { return $data[$query]; } $path = explode('.', $query); $ref = $data; $found = false; while (count($path) > 0) { $index = arr...
php
public static function evalueateArrayQuery($data, $query) { // return direct hits if (isset($data[$query])) { return $data[$query]; } $path = explode('.', $query); $ref = $data; $found = false; while (count($path) > 0) { $index = arr...
[ "public", "static", "function", "evalueateArrayQuery", "(", "$", "data", ",", "$", "query", ")", "{", "// return direct hits", "if", "(", "isset", "(", "$", "data", "[", "$", "query", "]", ")", ")", "{", "return", "$", "data", "[", "$", "query", "]", ...
allows to query php-arrays valid queries are: Example | Result 4 | returns the 4th index of the array key | returns the index named 'key' key.subkey | returns the index named 'subkey' on the index | named 'key'. this structure is allowed to go deep key.0 ...
[ "allows", "to", "query", "php", "-", "arrays", "valid", "queries", "are", ":" ]
train
https://github.com/gruzilla/hydra/blob/47f381cc48e1a26bfe2e211d8dcb54c787ea0478/src/Hydra/Mappers/ArrayMapper.php#L137-L177
bluetree-service/event
src/Event/Base/EventDispatcher.php
EventDispatcher.createEventObject
protected function createEventObject($eventName, array $data) { if (!array_key_exists($eventName, $this->options['events'])) { throw new \InvalidArgumentException('Event is not defined.'); } $namespace = $this->options['events'][$eventName]['object']; $instance = new $na...
php
protected function createEventObject($eventName, array $data) { if (!array_key_exists($eventName, $this->options['events'])) { throw new \InvalidArgumentException('Event is not defined.'); } $namespace = $this->options['events'][$eventName]['object']; $instance = new $na...
[ "protected", "function", "createEventObject", "(", "$", "eventName", ",", "array", "$", "data", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "eventName", ",", "$", "this", "->", "options", "[", "'events'", "]", ")", ")", "{", "throw", "new", ...
return event object or create it if not exist @param string $eventName @param array $data @return EventInterface @throws \LogicException @throws \InvalidArgumentException
[ "return", "event", "object", "or", "create", "it", "if", "not", "exist" ]
train
https://github.com/bluetree-service/event/blob/64ef4c77af6284fc22748285d5e527edbdbed69b/src/Event/Base/EventDispatcher.php#L89-L103
bluetree-service/event
src/Event/Base/EventDispatcher.php
EventDispatcher.triggerEvent
public function triggerEvent($name, array $data = []) { try { /** @var EventInterface $event */ $event = $this->createEventObject($name, $data); } catch (\InvalidArgumentException $exception) { return $this; } foreach ($this->options['events'][$na...
php
public function triggerEvent($name, array $data = []) { try { /** @var EventInterface $event */ $event = $this->createEventObject($name, $data); } catch (\InvalidArgumentException $exception) { return $this; } foreach ($this->options['events'][$na...
[ "public", "function", "triggerEvent", "(", "$", "name", ",", "array", "$", "data", "=", "[", "]", ")", "{", "try", "{", "/** @var EventInterface $event */", "$", "event", "=", "$", "this", "->", "createEventObject", "(", "$", "name", ",", "$", "data", ")...
trigger new event with automatic call all subscribed listeners @param string $name @param array $data @return $this @throws \LogicException
[ "trigger", "new", "event", "with", "automatic", "call", "all", "subscribed", "listeners" ]
train
https://github.com/bluetree-service/event/blob/64ef4c77af6284fc22748285d5e527edbdbed69b/src/Event/Base/EventDispatcher.php#L129-L148
bluetree-service/event
src/Event/Base/EventDispatcher.php
EventDispatcher.addEventListener
public function addEventListener($eventName, array $listeners) { if (!array_key_exists($eventName, $this->options['events'])) { $this->options['events'][$eventName] = [ 'object' =>BaseEvent::class, 'listeners' => $listeners, ]; } $this...
php
public function addEventListener($eventName, array $listeners) { if (!array_key_exists($eventName, $this->options['events'])) { $this->options['events'][$eventName] = [ 'object' =>BaseEvent::class, 'listeners' => $listeners, ]; } $this...
[ "public", "function", "addEventListener", "(", "$", "eventName", ",", "array", "$", "listeners", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "eventName", ",", "$", "this", "->", "options", "[", "'events'", "]", ")", ")", "{", "$", "this", "...
dynamically add new listener or listeners for given event name listeners are added at end of the list @param string $eventName @param array $listeners @return $this
[ "dynamically", "add", "new", "listener", "or", "listeners", "for", "given", "event", "name", "listeners", "are", "added", "at", "end", "of", "the", "list" ]
train
https://github.com/bluetree-service/event/blob/64ef4c77af6284fc22748285d5e527edbdbed69b/src/Event/Base/EventDispatcher.php#L179-L194
bluetree-service/event
src/Event/Base/EventDispatcher.php
EventDispatcher.readEventConfiguration
public function readEventConfiguration($path, $type) { if (!file_exists($path)) { throw new \InvalidArgumentException('File ' . $path . 'don\'t exists.'); } $name = '\BlueEvent\Event\Config\\' . ucfirst($type) . 'Config'; if (!class_exists($name)) { throw ne...
php
public function readEventConfiguration($path, $type) { if (!file_exists($path)) { throw new \InvalidArgumentException('File ' . $path . 'don\'t exists.'); } $name = '\BlueEvent\Event\Config\\' . ucfirst($type) . 'Config'; if (!class_exists($name)) { throw ne...
[ "public", "function", "readEventConfiguration", "(", "$", "path", ",", "$", "type", ")", "{", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'File '", ".", "$", "path", ".", "'don\\...
read configuration from file @param mixed $path @param string $type @return $this @throws \InvalidArgumentException
[ "read", "configuration", "from", "file" ]
train
https://github.com/bluetree-service/event/blob/64ef4c77af6284fc22748285d5e527edbdbed69b/src/Event/Base/EventDispatcher.php#L217-L233
bluetree-service/event
src/Event/Base/EventDispatcher.php
EventDispatcher.logEvent
public function logEvent(array $events = []) { foreach ($events as $event) { if (!in_array($event, $this->loggerInstance->logEvents, true)) { $this->loggerInstance->logEvents[] = $event; } } return $this; }
php
public function logEvent(array $events = []) { foreach ($events as $event) { if (!in_array($event, $this->loggerInstance->logEvents, true)) { $this->loggerInstance->logEvents[] = $event; } } return $this; }
[ "public", "function", "logEvent", "(", "array", "$", "events", "=", "[", "]", ")", "{", "foreach", "(", "$", "events", "as", "$", "event", ")", "{", "if", "(", "!", "in_array", "(", "$", "event", ",", "$", "this", "->", "loggerInstance", "->", "log...
log given events by given name @param array $events @return $this
[ "log", "given", "events", "by", "given", "name" ]
train
https://github.com/bluetree-service/event/blob/64ef4c77af6284fc22748285d5e527edbdbed69b/src/Event/Base/EventDispatcher.php#L253-L262
bluetree-service/event
src/Event/Base/EventDispatcher.php
EventDispatcher.getConfiguration
public function getConfiguration($option = null) { if (!is_null($option)) { return $this->options[$option]; } return $this->options; }
php
public function getConfiguration($option = null) { if (!is_null($option)) { return $this->options[$option]; } return $this->options; }
[ "public", "function", "getConfiguration", "(", "$", "option", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "option", ")", ")", "{", "return", "$", "this", "->", "options", "[", "$", "option", "]", ";", "}", "return", "$", "this", "->...
get complete object configuration or value of single option @param $option string|null @return mixed
[ "get", "complete", "object", "configuration", "or", "value", "of", "single", "option" ]
train
https://github.com/bluetree-service/event/blob/64ef4c77af6284fc22748285d5e527edbdbed69b/src/Event/Base/EventDispatcher.php#L282-L289
bluetree-service/event
src/Event/Base/EventDispatcher.php
EventDispatcher.addError
protected function addError(\Exception $exception) { $this->errorList[$exception->getCode()] = [ 'message' => $exception->getMessage(), 'line' => $exception->getLine(), 'file' => $exception->getFile(), 'trace' => $exception->getTraceAsString(),...
php
protected function addError(\Exception $exception) { $this->errorList[$exception->getCode()] = [ 'message' => $exception->getMessage(), 'line' => $exception->getLine(), 'file' => $exception->getFile(), 'trace' => $exception->getTraceAsString(),...
[ "protected", "function", "addError", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "this", "->", "errorList", "[", "$", "exception", "->", "getCode", "(", ")", "]", "=", "[", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ...
add new error to list @param \Exception $exception @return $this
[ "add", "new", "error", "to", "list" ]
train
https://github.com/bluetree-service/event/blob/64ef4c77af6284fc22748285d5e527edbdbed69b/src/Event/Base/EventDispatcher.php#L350-L361
GreenCape/joomla-cli
src/GreenCape/JoomlaCLI/Application.php
Application.run
public function run(InputInterface $input = null, OutputInterface $output = null) { try { parent::run($input, $output); } catch (\Exception $e) { if (null === $output) { $output = new ConsoleOutput(); } $message = array( $this->getLongVersion(), '', $e->getMessage(), '' ); ...
php
public function run(InputInterface $input = null, OutputInterface $output = null) { try { parent::run($input, $output); } catch (\Exception $e) { if (null === $output) { $output = new ConsoleOutput(); } $message = array( $this->getLongVersion(), '', $e->getMessage(), '' ); ...
[ "public", "function", "run", "(", "InputInterface", "$", "input", "=", "null", ",", "OutputInterface", "$", "output", "=", "null", ")", "{", "try", "{", "parent", "::", "run", "(", "$", "input", ",", "$", "output", ")", ";", "}", "catch", "(", "\\", ...
Runs the current application. @param InputInterface $input An InputInterface instance @param OutputInterface $output An OutputInterface instance @return integer 0 if everything went fine, or an error code @throws \Exception on problems
[ "Runs", "the", "current", "application", "." ]
train
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Application.php#L68-L87
GreenCape/joomla-cli
src/GreenCape/JoomlaCLI/Application.php
Application.addPlugins
private function addPlugins($path) { foreach (glob($path . '/*.php') as $filename) { $commandClass = __NAMESPACE__ . '\\' . basename($filename, '.php') . 'Command'; $command = new $commandClass; $this->add($command); } }
php
private function addPlugins($path) { foreach (glob($path . '/*.php') as $filename) { $commandClass = __NAMESPACE__ . '\\' . basename($filename, '.php') . 'Command'; $command = new $commandClass; $this->add($command); } }
[ "private", "function", "addPlugins", "(", "$", "path", ")", "{", "foreach", "(", "glob", "(", "$", "path", ".", "'/*.php'", ")", "as", "$", "filename", ")", "{", "$", "commandClass", "=", "__NAMESPACE__", ".", "'\\\\'", ".", "basename", "(", "$", "file...
Dynamically add all commands from a path @param string $path The directory with the plugins @return void
[ "Dynamically", "add", "all", "commands", "from", "a", "path" ]
train
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Application.php#L96-L104
unclecheese/silverstripe-blubber
code/Sampler.php
Sampler.execute
public function execute() { $results = ArrayList::create(); foreach($this->classes as $c) { if($this->isOmitted($c)) continue; $list = DataList::create($c) ->filter('ClassName', $c) ->limit($this->getLimitFor($c)) ->sort("RAND()"); foreach($list as $record) { $results->push($record...
php
public function execute() { $results = ArrayList::create(); foreach($this->classes as $c) { if($this->isOmitted($c)) continue; $list = DataList::create($c) ->filter('ClassName', $c) ->limit($this->getLimitFor($c)) ->sort("RAND()"); foreach($list as $record) { $results->push($record...
[ "public", "function", "execute", "(", ")", "{", "$", "results", "=", "ArrayList", "::", "create", "(", ")", ";", "foreach", "(", "$", "this", "->", "classes", "as", "$", "c", ")", "{", "if", "(", "$", "this", "->", "isOmitted", "(", "$", "c", ")"...
Executes the query, gets the samples @return ArrayList
[ "Executes", "the", "query", "gets", "the", "samples" ]
train
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/Sampler.php#L56-L73
unclecheese/silverstripe-blubber
code/Sampler.php
Sampler.isOmitted
protected function isOmitted($c) { foreach($this->omissions as $o) { if($c == $o || is_subclass_of($c, $o)) { return true; } } return false; }
php
protected function isOmitted($c) { foreach($this->omissions as $o) { if($c == $o || is_subclass_of($c, $o)) { return true; } } return false; }
[ "protected", "function", "isOmitted", "(", "$", "c", ")", "{", "foreach", "(", "$", "this", "->", "omissions", "as", "$", "o", ")", "{", "if", "(", "$", "c", "==", "$", "o", "||", "is_subclass_of", "(", "$", "c", ",", "$", "o", ")", ")", "{", ...
Returns true if a class is omitted @param string $c The class name @return boolean
[ "Returns", "true", "if", "a", "class", "is", "omitted" ]
train
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/Sampler.php#L81-L89
songshenzong/log
src/Bridge/Twig/TraceableTwigTemplate.php
TraceableTwigTemplate.renderBlock
public function renderBlock($name, array $context, array $blocks = [], $useBlocks = true) { return $this->template->renderBlock($name, $context, $blocks, $useBlocks); }
php
public function renderBlock($name, array $context, array $blocks = [], $useBlocks = true) { return $this->template->renderBlock($name, $context, $blocks, $useBlocks); }
[ "public", "function", "renderBlock", "(", "$", "name", ",", "array", "$", "context", ",", "array", "$", "blocks", "=", "[", "]", ",", "$", "useBlocks", "=", "true", ")", "{", "return", "$", "this", "->", "template", "->", "renderBlock", "(", "$", "na...
@param $name @param array $context @param array $blocks @param bool $useBlocks @return mixed
[ "@param", "$name", "@param", "array", "$context", "@param", "array", "$blocks", "@param", "bool", "$useBlocks" ]
train
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/Bridge/Twig/TraceableTwigTemplate.php#L122-L125
kiwi-suite/frontend42
src/PageType/Service/PageTypeAbstractFactory.php
PageTypeAbstractFactory.canCreate
public function canCreate(ContainerInterface $container, $requestedName) { /** @var PageTypePluginManager $pageTypePluginManager */ $pageTypePluginManager = $container->get(PageTypePluginManager::class); $pageTypes = $pageTypePluginManager->getAvailablePageTypes(); return in_array($...
php
public function canCreate(ContainerInterface $container, $requestedName) { /** @var PageTypePluginManager $pageTypePluginManager */ $pageTypePluginManager = $container->get(PageTypePluginManager::class); $pageTypes = $pageTypePluginManager->getAvailablePageTypes(); return in_array($...
[ "public", "function", "canCreate", "(", "ContainerInterface", "$", "container", ",", "$", "requestedName", ")", "{", "/** @var PageTypePluginManager $pageTypePluginManager */", "$", "pageTypePluginManager", "=", "$", "container", "->", "get", "(", "PageTypePluginManager", ...
Can the factory create an instance for the service? @param ContainerInterface $container @param string $requestedName @return bool
[ "Can", "the", "factory", "create", "an", "instance", "for", "the", "service?" ]
train
https://github.com/kiwi-suite/frontend42/blob/67e5208387957823ac84f7833eba83d4a8dab8cd/src/PageType/Service/PageTypeAbstractFactory.php#L21-L28
PHPPowertools/HTML5
src/PowerTools/HTML5/Parser/DOMTreeBuilder.php
HTML5_Parser_DOMTreeBuilder.startTag
public function startTag($name, $attributes = array(), $selfClosing = false) { // fprintf(STDOUT, $name); $lname = $this->normalizeTagName($name); // Make sure we have an html element. if (!$this->doc->documentElement && $name !== 'html' && !$this->frag) { $this->startTag('h...
php
public function startTag($name, $attributes = array(), $selfClosing = false) { // fprintf(STDOUT, $name); $lname = $this->normalizeTagName($name); // Make sure we have an html element. if (!$this->doc->documentElement && $name !== 'html' && !$this->frag) { $this->startTag('h...
[ "public", "function", "startTag", "(", "$", "name", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "selfClosing", "=", "false", ")", "{", "// fprintf(STDOUT, $name);", "$", "lname", "=", "$", "this", "->", "normalizeTagName", "(", "$", "name", ...
Process the start tag. @todo - XMLNS namespace handling (we need to parse, even if it's not valid) - XLink, MathML and SVG namespace handling - Omission rules: 8.1.2.4 Optional tags
[ "Process", "the", "start", "tag", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/DOMTreeBuilder.php#L282-L469
PHPPowertools/HTML5
src/PowerTools/HTML5/Parser/DOMTreeBuilder.php
HTML5_Parser_DOMTreeBuilder.autoclose
protected function autoclose($tag) { $working = $this->current; do { if ($working->nodeType != XML_ELEMENT_NODE) { return false; } if ($working->tagName == $tag) { $this->current = $working->parentNode; return true; ...
php
protected function autoclose($tag) { $working = $this->current; do { if ($working->nodeType != XML_ELEMENT_NODE) { return false; } if ($working->tagName == $tag) { $this->current = $working->parentNode; return true; ...
[ "protected", "function", "autoclose", "(", "$", "tag", ")", "{", "$", "working", "=", "$", "this", "->", "current", ";", "do", "{", "if", "(", "$", "working", "->", "nodeType", "!=", "XML_ELEMENT_NODE", ")", "{", "return", "false", ";", "}", "if", "(...
Automatically climb the tree and close the closest node with the matching $tag.
[ "Automatically", "climb", "the", "tree", "and", "close", "the", "closest", "node", "with", "the", "matching", "$tag", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/DOMTreeBuilder.php#L642-L655
PHPPowertools/HTML5
src/PowerTools/HTML5/Parser/DOMTreeBuilder.php
HTML5_Parser_DOMTreeBuilder.isAncestor
protected function isAncestor($tagname) { $candidate = $this->current; while ($candidate->nodeType === XML_ELEMENT_NODE) { if ($candidate->tagName == $tagname) { return true; } $candidate = $candidate->parentNode; } return false; }
php
protected function isAncestor($tagname) { $candidate = $this->current; while ($candidate->nodeType === XML_ELEMENT_NODE) { if ($candidate->tagName == $tagname) { return true; } $candidate = $candidate->parentNode; } return false; }
[ "protected", "function", "isAncestor", "(", "$", "tagname", ")", "{", "$", "candidate", "=", "$", "this", "->", "current", ";", "while", "(", "$", "candidate", "->", "nodeType", "===", "XML_ELEMENT_NODE", ")", "{", "if", "(", "$", "candidate", "->", "tag...
Checks if the given tagname is an ancestor of the present candidate. If $this->current or anything above $this->current matches the given tag name, this returns true.
[ "Checks", "if", "the", "given", "tagname", "is", "an", "ancestor", "of", "the", "present", "candidate", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/DOMTreeBuilder.php#L663-L673
php-lug/lug
src/Component/Resource/Form/Type/ResourceType.php
ResourceType.configureOptions
public function configureOptions(OptionsResolver $resolver) { $resolver ->setRequired(['resource', 'factory']) ->setAllowedTypes('resource', ResourceInterface::class) ->setAllowedTypes('factory', FactoryInterface::class) ->setDefaults([ 'data_c...
php
public function configureOptions(OptionsResolver $resolver) { $resolver ->setRequired(['resource', 'factory']) ->setAllowedTypes('resource', ResourceInterface::class) ->setAllowedTypes('factory', FactoryInterface::class) ->setDefaults([ 'data_c...
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", "{", "$", "resolver", "->", "setRequired", "(", "[", "'resource'", ",", "'factory'", "]", ")", "->", "setAllowedTypes", "(", "'resource'", ",", "ResourceInterface", "::", "cl...
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Form/Type/ResourceType.php#L30-L52
surebert/surebert-framework
src/sb/Graph/Point.php
Point.setPointColor
public function setPointColor($r, $g, $b) { $this->ink['point'] = imagecolorallocate($this->im, $r, $g, $b); }
php
public function setPointColor($r, $g, $b) { $this->ink['point'] = imagecolorallocate($this->im, $r, $g, $b); }
[ "public", "function", "setPointColor", "(", "$", "r", ",", "$", "g", ",", "$", "b", ")", "{", "$", "this", "->", "ink", "[", "'point'", "]", "=", "imagecolorallocate", "(", "$", "this", "->", "im", ",", "$", "r", ",", "$", "g", ",", "$", "b", ...
Sets the point color in rgb format @param integer $r The red value 0-255 @param integer $g The green value 0-255 @param integer $b The blue value 0-255
[ "Sets", "the", "point", "color", "in", "rgb", "format" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L143-L147
surebert/surebert-framework
src/sb/Graph/Point.php
Point.setLineColor
public function setLineColor($r, $g, $b) { $this->ink['line'] = imagecolorallocate($this->im, $r, $g, $b); }
php
public function setLineColor($r, $g, $b) { $this->ink['line'] = imagecolorallocate($this->im, $r, $g, $b); }
[ "public", "function", "setLineColor", "(", "$", "r", ",", "$", "g", ",", "$", "b", ")", "{", "$", "this", "->", "ink", "[", "'line'", "]", "=", "imagecolorallocate", "(", "$", "this", "->", "im", ",", "$", "r", ",", "$", "g", ",", "$", "b", "...
Sets the line color in rgb format @param integer $r The red value 0-255 @param integer $g The green value 0-255 @param integer $b The blue value 0-255
[ "Sets", "the", "line", "color", "in", "rgb", "format" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L156-L160
surebert/surebert-framework
src/sb/Graph/Point.php
Point.setTextColor
public function setTextColor($r, $g, $b) { $this->ink['text'] = imagecolorallocate($this->im, $r, $g, $b); }
php
public function setTextColor($r, $g, $b) { $this->ink['text'] = imagecolorallocate($this->im, $r, $g, $b); }
[ "public", "function", "setTextColor", "(", "$", "r", ",", "$", "g", ",", "$", "b", ")", "{", "$", "this", "->", "ink", "[", "'text'", "]", "=", "imagecolorallocate", "(", "$", "this", "->", "im", ",", "$", "r", ",", "$", "g", ",", "$", "b", "...
Sets the text color in rgb format - labels @param integer $r The red value 0-255 @param integer $g The green value 0-255 @param integer $b The blue value 0-255
[ "Sets", "the", "text", "color", "in", "rgb", "format", "-", "labels" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L169-L172
surebert/surebert-framework
src/sb/Graph/Point.php
Point.setAxisColor
public function setAxisColor($r, $g, $b) { $this->ink['axis'] = imagecolorallocate($this->im, $r, $g, $b); }
php
public function setAxisColor($r, $g, $b) { $this->ink['axis'] = imagecolorallocate($this->im, $r, $g, $b); }
[ "public", "function", "setAxisColor", "(", "$", "r", ",", "$", "g", ",", "$", "b", ")", "{", "$", "this", "->", "ink", "[", "'axis'", "]", "=", "imagecolorallocate", "(", "$", "this", "->", "im", ",", "$", "r", ",", "$", "g", ",", "$", "b", "...
Sets the axis color in rgb format - axis @param integer $r The red value 0-255 @param integer $g The green value 0-255 @param integer $b The blue value 0-255
[ "Sets", "the", "axis", "color", "in", "rgb", "format", "-", "axis" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L181-L184
surebert/surebert-framework
src/sb/Graph/Point.php
Point.createBackground
private function createBackground() { imagefilledrectangle($this->im, 0, 0, $this->width, $this->height, $this->ink['black']); }
php
private function createBackground() { imagefilledrectangle($this->im, 0, 0, $this->width, $this->height, $this->ink['black']); }
[ "private", "function", "createBackground", "(", ")", "{", "imagefilledrectangle", "(", "$", "this", "->", "im", ",", "0", ",", "0", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "$", "this", "->", "ink", "[", "'black'", "]",...
Create the backgrround image
[ "Create", "the", "backgrround", "image" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L198-L203
surebert/surebert-framework
src/sb/Graph/Point.php
Point.allocateColors
private function allocateColors() { $this->ink['red'] = imagecolorallocate($this->im, 0xff, 0x00, 0x00); $this->ink['orange'] = imagecolorallocate($this->im, 0xd2, 0x8a, 0x00); $this->ink['yellow'] = imagecolorallocate($this->im, 0xff, 0xff, 0x00); $this->ink['green'] = imagecoloral...
php
private function allocateColors() { $this->ink['red'] = imagecolorallocate($this->im, 0xff, 0x00, 0x00); $this->ink['orange'] = imagecolorallocate($this->im, 0xd2, 0x8a, 0x00); $this->ink['yellow'] = imagecolorallocate($this->im, 0xff, 0xff, 0x00); $this->ink['green'] = imagecoloral...
[ "private", "function", "allocateColors", "(", ")", "{", "$", "this", "->", "ink", "[", "'red'", "]", "=", "imagecolorallocate", "(", "$", "this", "->", "im", ",", "0xff", ",", "0x00", ",", "0x00", ")", ";", "$", "this", "->", "ink", "[", "'orange'", ...
Allocates the default color used
[ "Allocates", "the", "default", "color", "used" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L209-L230
surebert/surebert-framework
src/sb/Graph/Point.php
Point.mapYvalue
private function mapYvalue($value) { $rangeMapper = new \sb\Math\RangeMapper(Array(30, $this->graph_height), Array($this->min, $this->max)); return $rangeMapper->convert($value); }
php
private function mapYvalue($value) { $rangeMapper = new \sb\Math\RangeMapper(Array(30, $this->graph_height), Array($this->min, $this->max)); return $rangeMapper->convert($value); }
[ "private", "function", "mapYvalue", "(", "$", "value", ")", "{", "$", "rangeMapper", "=", "new", "\\", "sb", "\\", "Math", "\\", "RangeMapper", "(", "Array", "(", "30", ",", "$", "this", "->", "graph_height", ")", ",", "Array", "(", "$", "this", "->"...
Converts the range from point to pixel value @param integer $value The value to convert @return integer The number as converted into the pixel range on the graph
[ "Converts", "the", "range", "from", "point", "to", "pixel", "value" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L238-L243
surebert/surebert-framework
src/sb/Graph/Point.php
Point.setValues
private function setValues($values) { $numbers = Array(); foreach ($values as $key => $val) { $value = new \stdClass(); $value->label = trim($key); if (!is_numeric($val)) { $val = null; } $value->value = $val; ...
php
private function setValues($values) { $numbers = Array(); foreach ($values as $key => $val) { $value = new \stdClass(); $value->label = trim($key); if (!is_numeric($val)) { $val = null; } $value->value = $val; ...
[ "private", "function", "setValues", "(", "$", "values", ")", "{", "$", "numbers", "=", "Array", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "value", "=", "new", "\\", "stdClass", "(", ")", ";",...
Converts the values into usable data for the drawing of the graph @param array $values
[ "Converts", "the", "values", "into", "usable", "data", "for", "the", "drawing", "of", "the", "graph" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L250-L294
surebert/surebert-framework
src/sb/Graph/Point.php
Point.drawYaxis
private function drawYaxis() { $min = round($this->min, $this->precision); $max = round($this->max, $this->precision); if (!isset($this->y_axis_legend_increment)) { $increment = round(($max - $min) / $this->total_values, $this->precision...
php
private function drawYaxis() { $min = round($this->min, $this->precision); $max = round($this->max, $this->precision); if (!isset($this->y_axis_legend_increment)) { $increment = round(($max - $min) / $this->total_values, $this->precision...
[ "private", "function", "drawYaxis", "(", ")", "{", "$", "min", "=", "round", "(", "$", "this", "->", "min", ",", "$", "this", "->", "precision", ")", ";", "$", "max", "=", "round", "(", "$", "this", "->", "max", ",", "$", "this", "->", "precision...
Draws the y axis on the graph at each point in a dashed line fashion. This is totally optional and only happens if $this->draw_y_axis ==1
[ "Draws", "the", "y", "axis", "on", "the", "graph", "at", "each", "point", "in", "a", "dashed", "line", "fashion", ".", "This", "is", "totally", "optional", "and", "only", "happens", "if", "$this", "-", ">", "draw_y_axis", "==", "1" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L302-L333
surebert/surebert-framework
src/sb/Graph/Point.php
Point.plotValue
private function plotValue($y) { $rangeMapper = new \sb\Math\RangeMapper(Array( $this->axis_offset, $this->graph_height - $this->axis_offset ), Array($this->max, $this->min)); return $rangeMapper->convert($y); }
php
private function plotValue($y) { $rangeMapper = new \sb\Math\RangeMapper(Array( $this->axis_offset, $this->graph_height - $this->axis_offset ), Array($this->max, $this->min)); return $rangeMapper->convert($y); }
[ "private", "function", "plotValue", "(", "$", "y", ")", "{", "$", "rangeMapper", "=", "new", "\\", "sb", "\\", "Math", "\\", "RangeMapper", "(", "Array", "(", "$", "this", "->", "axis_offset", ",", "$", "this", "->", "graph_height", "-", "$", "this", ...
Converts points on the graph to pixels @param integer $y @return integer The value in pixels
[ "Converts", "points", "on", "the", "graph", "to", "pixels" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L341-L348
surebert/surebert-framework
src/sb/Graph/Point.php
Point.connectPoints
private function connectPoints() { foreach ($this->points as $point) { if (is_null($point->value)) { $last_x = $point->x; $last_y = $point->y; $last_val = $point->value; continue; } if (isset($last_x) && (i...
php
private function connectPoints() { foreach ($this->points as $point) { if (is_null($point->value)) { $last_x = $point->x; $last_y = $point->y; $last_val = $point->value; continue; } if (isset($last_x) && (i...
[ "private", "function", "connectPoints", "(", ")", "{", "foreach", "(", "$", "this", "->", "points", "as", "$", "point", ")", "{", "if", "(", "is_null", "(", "$", "point", "->", "value", ")", ")", "{", "$", "last_x", "=", "$", "point", "->", "x", ...
Connect the points on a graph
[ "Connect", "the", "points", "on", "a", "graph" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L354-L373
surebert/surebert-framework
src/sb/Graph/Point.php
Point.draw
public function draw() { $this->drawYaxis(); if ($this->connect_points == 1) { $this->connectPoints(); } foreach ($this->points as $point) { if ($this->y_axis_hints == 1) { imagedashedline($this->im, $point->x, $this->height, $point->x, ...
php
public function draw() { $this->drawYaxis(); if ($this->connect_points == 1) { $this->connectPoints(); } foreach ($this->points as $point) { if ($this->y_axis_hints == 1) { imagedashedline($this->im, $point->x, $this->height, $point->x, ...
[ "public", "function", "draw", "(", ")", "{", "$", "this", "->", "drawYaxis", "(", ")", ";", "if", "(", "$", "this", "->", "connect_points", "==", "1", ")", "{", "$", "this", "->", "connectPoints", "(", ")", ";", "}", "foreach", "(", "$", "this", ...
Draw the basic graph and plot the points
[ "Draw", "the", "basic", "graph", "and", "plot", "the", "points" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L379-L425
surebert/surebert-framework
src/sb/Graph/Point.php
Point.addHorizontalLine
public function addHorizontalLine($y, $color = 'red', $label = '') { if (!array_key_exists($color, $this->ink)) { throw(new \Exception("Ink color must be in " . implode(",", \array_keys($this->ink)))); } $y = $this->plotValue($y); imageline($this->im...
php
public function addHorizontalLine($y, $color = 'red', $label = '') { if (!array_key_exists($color, $this->ink)) { throw(new \Exception("Ink color must be in " . implode(",", \array_keys($this->ink)))); } $y = $this->plotValue($y); imageline($this->im...
[ "public", "function", "addHorizontalLine", "(", "$", "y", ",", "$", "color", "=", "'red'", ",", "$", "label", "=", "''", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "color", ",", "$", "this", "->", "ink", ")", ")", "{", "throw", "(", ...
Add a horizontal line @param integer $y The y value @param string $color red, orange, yellow, green, blue, purple @param string $label The line label
[ "Add", "a", "horizontal", "line" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Graph/Point.php#L434-L447
spiral-modules/listing
source/Listing/Prototypes/DependedModificator.php
DependedModificator.loadDependencies
protected function loadDependencies(RecordSelector $selector) { if (empty($this->dependencies)) { return $selector; } foreach ($this->dependencies as $dependency) { $selector = $selector->with( $dependency->getRelation(), $dependency->...
php
protected function loadDependencies(RecordSelector $selector) { if (empty($this->dependencies)) { return $selector; } foreach ($this->dependencies as $dependency) { $selector = $selector->with( $dependency->getRelation(), $dependency->...
[ "protected", "function", "loadDependencies", "(", "RecordSelector", "$", "selector", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "dependencies", ")", ")", "{", "return", "$", "selector", ";", "}", "foreach", "(", "$", "this", "->", "dependencies"...
Apply dependencies for RecordSelector @param RecordSelector $selector @return RecordSelector
[ "Apply", "dependencies", "for", "RecordSelector" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Prototypes/DependedModificator.php#L72-L86
interactivesolutions/honeycomb-core
src/models/HCUuidModel.php
HCUuidModel.boot
protected static function boot () { parent::boot (); /** * Attach to the 'creating' Model Event to provide a UUID * for the `id` field (provided by $model->getKeyName()) */ static::creating (function ($model) { if (!isset($model->attributes['id...
php
protected static function boot () { parent::boot (); /** * Attach to the 'creating' Model Event to provide a UUID * for the `id` field (provided by $model->getKeyName()) */ static::creating (function ($model) { if (!isset($model->attributes['id...
[ "protected", "static", "function", "boot", "(", ")", "{", "parent", "::", "boot", "(", ")", ";", "/**\n * Attach to the 'creating' Model Event to provide a UUID\n * for the `id` field (provided by $model->getKeyName())\n */", "static", "::", "creating", "(",...
The "booting" method of the model. @return void
[ "The", "booting", "method", "of", "the", "model", "." ]
train
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/models/HCUuidModel.php#L23-L38
LeaseCloud/leasecloud-php-sdk
src/Webook.php
Webook.validateSignature
public static function validateSignature($signature, $payload) { $parts = explode(',', $signature); $parameters = []; $t = 0; // Find the timestamp foreach ($parts as $part) { parse_str($part, $parsed); if (key($parsed) === 't') { $t = ...
php
public static function validateSignature($signature, $payload) { $parts = explode(',', $signature); $parameters = []; $t = 0; // Find the timestamp foreach ($parts as $part) { parse_str($part, $parsed); if (key($parsed) === 't') { $t = ...
[ "public", "static", "function", "validateSignature", "(", "$", "signature", ",", "$", "payload", ")", "{", "$", "parts", "=", "explode", "(", "','", ",", "$", "signature", ")", ";", "$", "parameters", "=", "[", "]", ";", "$", "t", "=", "0", ";", "/...
Validate the webhook signature @param string $signature The string passed in header LeaseCloud-Signature @param string $payload The raw payload @return bool True if the signature is valid, otherwise false
[ "Validate", "the", "webhook", "signature" ]
train
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/Webook.php#L35-L66
NuclearCMS/Hierarchy
src/Tags/Taggable.php
Taggable.attachTag
public function attachTag($id) { if ( ! $this->tags->contains($id)) { return $this->tags()->attach($id); } }
php
public function attachTag($id) { if ( ! $this->tags->contains($id)) { return $this->tags()->attach($id); } }
[ "public", "function", "attachTag", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "tags", "->", "contains", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "tags", "(", ")", "->", "attach", "(", "$", "id", ")", ";", ...
Links a tag to the node @param int $id
[ "Links", "a", "tag", "to", "the", "node" ]
train
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Tags/Taggable.php#L36-L42
bpolaszek/simple-dbal
src/Model/Adapter/Mysqli/MysqliAdapter.php
MysqliAdapter.executeParallel
private function executeParallel($stmt, array $values = null): PromiseInterface { if (is_string($stmt)) { $stmt = $this->emulatePrepare((string) $stmt, $values); } else { if (!$stmt instanceof Statement) { throw new \InvalidArgumentException(sprintf('Expected ...
php
private function executeParallel($stmt, array $values = null): PromiseInterface { if (is_string($stmt)) { $stmt = $this->emulatePrepare((string) $stmt, $values); } else { if (!$stmt instanceof Statement) { throw new \InvalidArgumentException(sprintf('Expected ...
[ "private", "function", "executeParallel", "(", "$", "stmt", ",", "array", "$", "values", "=", "null", ")", ":", "PromiseInterface", "{", "if", "(", "is_string", "(", "$", "stmt", ")", ")", "{", "$", "stmt", "=", "$", "this", "->", "emulatePrepare", "("...
EXPERIMENTAL ! Executes a statement asynchronously. The promise will return a Result object. @param $stmt @param array|null $values @return PromiseInterface
[ "EXPERIMENTAL", "!", "Executes", "a", "statement", "asynchronously", ".", "The", "promise", "will", "return", "a", "Result", "object", "." ]
train
https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/Mysqli/MysqliAdapter.php#L232-L266
watoki/curir
src/protocol/MimeTypes.php
MimeTypes.getType
public static function getType($extension) { foreach (self::$map as $mime => $exts) { if (in_array(strtolower($extension), $exts)) { return $mime; } } return null; }
php
public static function getType($extension) { foreach (self::$map as $mime => $exts) { if (in_array(strtolower($extension), $exts)) { return $mime; } } return null; }
[ "public", "static", "function", "getType", "(", "$", "extension", ")", "{", "foreach", "(", "self", "::", "$", "map", "as", "$", "mime", "=>", "$", "exts", ")", "{", "if", "(", "in_array", "(", "strtolower", "(", "$", "extension", ")", ",", "$", "e...
Retruns MIME type belonging to given file extension or null if not found. @static @param $extension @return null|string
[ "Retruns", "MIME", "type", "belonging", "to", "given", "file", "extension", "or", "null", "if", "not", "found", "." ]
train
https://github.com/watoki/curir/blob/20a44e1d1980f472369991e19ef8d3bafda79a64/src/protocol/MimeTypes.php#L137-L144
zicht/z
src/Zicht/Tool/PropertyPath/PropertyAccessor.php
PropertyAccessor.getByPath
public static function getByPath($subject, array $path, $notFoundIsError = true) { $ptr = & $subject; foreach ($path as $key) { if (is_object($ptr) && property_exists($ptr, $key)) { $ptr = & $ptr->$key; } elseif (is_array($ptr) && array_key_exists($key, $ptr))...
php
public static function getByPath($subject, array $path, $notFoundIsError = true) { $ptr = & $subject; foreach ($path as $key) { if (is_object($ptr) && property_exists($ptr, $key)) { $ptr = & $ptr->$key; } elseif (is_array($ptr) && array_key_exists($key, $ptr))...
[ "public", "static", "function", "getByPath", "(", "$", "subject", ",", "array", "$", "path", ",", "$", "notFoundIsError", "=", "true", ")", "{", "$", "ptr", "=", "&", "$", "subject", ";", "foreach", "(", "$", "path", "as", "$", "key", ")", "{", "if...
Get a property value by a path of property names or key names. @param mixed $subject @param array $path @param bool $notFoundIsError @return null @throws \InvalidArgumentException
[ "Get", "a", "property", "value", "by", "a", "path", "of", "property", "names", "or", "key", "names", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/PropertyPath/PropertyAccessor.php#L25-L41
zicht/z
src/Zicht/Tool/PropertyPath/PropertyAccessor.php
PropertyAccessor.setByPath
public static function setByPath(&$subject, array $path, $value) { $ptr = & $subject; foreach ($path as $key) { if (is_object($ptr)) { if (!isset($ptr->$key)) { $ptr->$key = array(); } $ptr = & $ptr->$key; } ...
php
public static function setByPath(&$subject, array $path, $value) { $ptr = & $subject; foreach ($path as $key) { if (is_object($ptr)) { if (!isset($ptr->$key)) { $ptr->$key = array(); } $ptr = & $ptr->$key; } ...
[ "public", "static", "function", "setByPath", "(", "&", "$", "subject", ",", "array", "$", "path", ",", "$", "value", ")", "{", "$", "ptr", "=", "&", "$", "subject", ";", "foreach", "(", "$", "path", "as", "$", "key", ")", "{", "if", "(", "is_obje...
Set a property value by a path of property or key names. @param mixed &$subject @param array $path @param mixed $value @return mixed
[ "Set", "a", "property", "value", "by", "a", "path", "of", "property", "or", "key", "names", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/PropertyPath/PropertyAccessor.php#L52-L70
netvlies/NetvliesFormBundle
Service/FormService.php
FormService.get
public function get($id) { if (!isset($this->forms[$id])) { $contentRepository = $this->container->get('doctrine')->getRepository('NetvliesFormBundle:Form'); $form = $contentRepository->findOneById($id); $formBuilder = $this->container->get('form.factory')->createBuilder...
php
public function get($id) { if (!isset($this->forms[$id])) { $contentRepository = $this->container->get('doctrine')->getRepository('NetvliesFormBundle:Form'); $form = $contentRepository->findOneById($id); $formBuilder = $this->container->get('form.factory')->createBuilder...
[ "public", "function", "get", "(", "$", "id", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "forms", "[", "$", "id", "]", ")", ")", "{", "$", "contentRepository", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")...
Builds the form with the requested ID. When a form is requested for the second time, the instance created earlier is returned to ensure only one form instance is used and form properties can be set and retrieved from all locations where the form is used. @param $id @return mixed
[ "Builds", "the", "form", "with", "the", "requested", "ID", ".", "When", "a", "form", "is", "requested", "for", "the", "second", "time", "the", "instance", "created", "earlier", "is", "returned", "to", "ensure", "only", "one", "form", "instance", "is", "use...
train
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/Service/FormService.php#L32-L99
PHPPowertools/HTML5
src/PowerTools/HTML5.php
HTML5.load
public function load($file) { // Handle the case where file is a resource. if (is_resource($file)) { // FIXME: We need a StreamInputStream class. return $this->loadHTML(stream_get_contents($file)); } $input = new HTML5_Inputstream_File($file); return $th...
php
public function load($file) { // Handle the case where file is a resource. if (is_resource($file)) { // FIXME: We need a StreamInputStream class. return $this->loadHTML(stream_get_contents($file)); } $input = new HTML5_Inputstream_File($file); return $th...
[ "public", "function", "load", "(", "$", "file", ")", "{", "// Handle the case where file is a resource.", "if", "(", "is_resource", "(", "$", "file", ")", ")", "{", "// FIXME: We need a StreamInputStream class.", "return", "$", "this", "->", "loadHTML", "(", "stream...
Load and parse an HTML file. This will apply the HTML5 parser, which is tolerant of many varieties of HTML, including XHTML 1, HTML 4, and well-formed HTML 3. Note that in these cases, not all of the old data will be preserved. For example, XHTML's XML declaration will be removed. The rules governing parsing are set ...
[ "Load", "and", "parse", "an", "HTML", "file", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5.php#L139-L149
PHPPowertools/HTML5
src/PowerTools/HTML5.php
HTML5.parse
public function parse(HTML5_Inputstream_Interface $input) { $this->errors = array(); $events = new HTML5_Parser_DOMTreeBuilder(false, $this->options); $scanner = new HTML5_Parser_Scanner($input); $parser = new HTML5_Parser_Tokenizer($scanner, $events); $parser->parse(); ...
php
public function parse(HTML5_Inputstream_Interface $input) { $this->errors = array(); $events = new HTML5_Parser_DOMTreeBuilder(false, $this->options); $scanner = new HTML5_Parser_Scanner($input); $parser = new HTML5_Parser_Tokenizer($scanner, $events); $parser->parse(); ...
[ "public", "function", "parse", "(", "HTML5_Inputstream_Interface", "$", "input", ")", "{", "$", "this", "->", "errors", "=", "array", "(", ")", ";", "$", "events", "=", "new", "HTML5_Parser_DOMTreeBuilder", "(", "false", ",", "$", "this", "->", "options", ...
Parse an input stream. Lower-level loading function. This requires an input stream instead of a string, file, or resource.
[ "Parse", "an", "input", "stream", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5.php#L225-L235
PHPPowertools/HTML5
src/PowerTools/HTML5.php
HTML5.parseFragment
public function parseFragment(HTML5_Inputstream_Interface $input) { $events = new HTML5_Parser_DOMTreeBuilder(true, $this->options); $scanner = new HTML5_Parser_Scanner($input); $parser = new HTML5_Parser_Tokenizer($scanner, $events); $parser->parse(); $this->errors = $events->g...
php
public function parseFragment(HTML5_Inputstream_Interface $input) { $events = new HTML5_Parser_DOMTreeBuilder(true, $this->options); $scanner = new HTML5_Parser_Scanner($input); $parser = new HTML5_Parser_Tokenizer($scanner, $events); $parser->parse(); $this->errors = $events->g...
[ "public", "function", "parseFragment", "(", "HTML5_Inputstream_Interface", "$", "input", ")", "{", "$", "events", "=", "new", "HTML5_Parser_DOMTreeBuilder", "(", "true", ",", "$", "this", "->", "options", ")", ";", "$", "scanner", "=", "new", "HTML5_Parser_Scann...
Parse an input stream where the stream is a fragment. Lower-level loading function. This requires an input stream instead of a string, file, or resource.
[ "Parse", "an", "input", "stream", "where", "the", "stream", "is", "a", "fragment", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5.php#L243-L252
PHPPowertools/HTML5
src/PowerTools/HTML5.php
HTML5.save
public function save($dom, $file, $options = array()) { $close = true; if (is_resource($file)) { $stream = $file; $close = false; } else { $stream = fopen($file, 'w'); } $options = array_merge($this->getOptions(), $options); $rules = ne...
php
public function save($dom, $file, $options = array()) { $close = true; if (is_resource($file)) { $stream = $file; $close = false; } else { $stream = fopen($file, 'w'); } $options = array_merge($this->getOptions(), $options); $rules = ne...
[ "public", "function", "save", "(", "$", "dom", ",", "$", "file", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "close", "=", "true", ";", "if", "(", "is_resource", "(", "$", "file", ")", ")", "{", "$", "stream", "=", "$", "file", ...
Save a DOM into a given file as HTML5. @param mixed $dom The DOM to be serialized. @param string $file The filename to be written. @param array $options Configuration options when serializing the DOM. These include: - encode_entities: Text written to the output is escaped by default and not all entities are encoded. I...
[ "Save", "a", "DOM", "into", "a", "given", "file", "as", "HTML5", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5.php#L267-L284
PHPPowertools/HTML5
src/PowerTools/HTML5.php
HTML5.saveHTML
public function saveHTML($dom, $options = array()) { $stream = fopen('php://temp', 'w'); $this->save($dom, $stream, array_merge($this->getOptions(), $options)); return stream_get_contents($stream, - 1, 0); }
php
public function saveHTML($dom, $options = array()) { $stream = fopen('php://temp', 'w'); $this->save($dom, $stream, array_merge($this->getOptions(), $options)); return stream_get_contents($stream, - 1, 0); }
[ "public", "function", "saveHTML", "(", "$", "dom", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "stream", "=", "fopen", "(", "'php://temp'", ",", "'w'", ")", ";", "$", "this", "->", "save", "(", "$", "dom", ",", "$", "stream", ",",...
Convert a DOM into an HTML5 string. @param mixed $dom The DOM to be serialized. @param array $options Configuration options when serializing the DOM. These include: - encode_entities: Text written to the output is escaped by default and not all entities are encoded. If this is set to true all entities will be encoded....
[ "Convert", "a", "DOM", "into", "an", "HTML5", "string", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5.php#L299-L304
Erdiko/core
src/Logger.php
Logger.addRecord
public function addRecord($level, $message, array $context = array()) { $message = (string) $message; $logString=date('Y-m-d H:i:s')." ".$level.": ".$this->interpolate($message, $context).PHP_EOL; $logFileName=$this->_logFiles["default"]; // If log key is null use the default log file ...
php
public function addRecord($level, $message, array $context = array()) { $message = (string) $message; $logString=date('Y-m-d H:i:s')." ".$level.": ".$this->interpolate($message, $context).PHP_EOL; $logFileName=$this->_logFiles["default"]; // If log key is null use the default log file ...
[ "public", "function", "addRecord", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "$", "message", "=", "(", "string", ")", "$", "message", ";", "$", "logString", "=", "date", "(", "'Y-m-d H:i:s...
Add Record @param string $level @param string or an object with a __toString() method$ message @param array $context @return bool
[ "Add", "Record" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L97-L104
Erdiko/core
src/Logger.php
Logger.interpolate
function interpolate($message, array $context = array()) { // build a replacement array with braces around the context keys $replace = array(); foreach ($context as $key => $val) { if ($key == "exception" && $val instanceof \Exception) { $replace['{' . $key . '}']...
php
function interpolate($message, array $context = array()) { // build a replacement array with braces around the context keys $replace = array(); foreach ($context as $key => $val) { if ($key == "exception" && $val instanceof \Exception) { $replace['{' . $key . '}']...
[ "function", "interpolate", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "// build a replacement array with braces around the context keys", "$", "replace", "=", "array", "(", ")", ";", "foreach", "(", "$", "context", "as",...
Implementation of Placeholder Interpolation The message MAY contain placeholders which implementors MAY replace with values from the context array. Placeholder names MUST correspond to keys in the context array. @param string $message or an object with a __toString() method @param array $context replacement values for...
[ "Implementation", "of", "Placeholder", "Interpolation", "The", "message", "MAY", "contain", "placeholders", "which", "implementors", "MAY", "replace", "with", "values", "from", "the", "context", "array", ".", "Placeholder", "names", "MUST", "correspond", "to", "keys...
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L115-L129
Erdiko/core
src/Logger.php
Logger.addLogFile
public function addLogFile($key, $logFileName) { $arrayKey=strtolower($key); return $this->_logFiles[$arrayKey] = $logFileName; }
php
public function addLogFile($key, $logFileName) { $arrayKey=strtolower($key); return $this->_logFiles[$arrayKey] = $logFileName; }
[ "public", "function", "addLogFile", "(", "$", "key", ",", "$", "logFileName", ")", "{", "$", "arrayKey", "=", "strtolower", "(", "$", "key", ")", ";", "return", "$", "this", "->", "_logFiles", "[", "$", "arrayKey", "]", "=", "$", "logFileName", ";", ...
Add log file Valid if multiple log files exist @param mixed $key @param string $logFileName @return bool
[ "Add", "log", "file", "Valid", "if", "multiple", "log", "files", "exist" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L139-L143
Erdiko/core
src/Logger.php
Logger.clearLog
public function clearLog($logKey = null) { $ret=true; if ($logKey==null) { foreach ($this->_logFiles as $key => $logFile) { $ret = $ret && $this->write("", $logFile); } return $ret; } else { $arrayKey=strtolower($logKey); ...
php
public function clearLog($logKey = null) { $ret=true; if ($logKey==null) { foreach ($this->_logFiles as $key => $logFile) { $ret = $ret && $this->write("", $logFile); } return $ret; } else { $arrayKey=strtolower($logKey); ...
[ "public", "function", "clearLog", "(", "$", "logKey", "=", "null", ")", "{", "$", "ret", "=", "true", ";", "if", "(", "$", "logKey", "==", "null", ")", "{", "foreach", "(", "$", "this", "->", "_logFiles", "as", "$", "key", "=>", "$", "logFile", "...
Clear Log @param string $logKey @return bool
[ "Clear", "Log" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L164-L180
Erdiko/core
src/Logger.php
Logger.emergency
public function emergency($message, array $context = array()) { // TODO: Implement emergency() method. return $this->addRecord(\Psr\Log\LogLevel::EMERGENCY, $message, $context); }
php
public function emergency($message, array $context = array()) { // TODO: Implement emergency() method. return $this->addRecord(\Psr\Log\LogLevel::EMERGENCY, $message, $context); }
[ "public", "function", "emergency", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "// TODO: Implement emergency() method.", "return", "$", "this", "->", "addRecord", "(", "\\", "Psr", "\\", "Log", "\\", "LogLevel", "::",...
System is unusable. @param string $message @param array $context @return null
[ "System", "is", "unusable", "." ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L195-L199
Erdiko/core
src/Logger.php
Logger.alert
public function alert($message, array $context = array()) { // TODO: Implement alert() method. return $this->addRecord(\Psr\Log\LogLevel::ALERT, $message, $context); }
php
public function alert($message, array $context = array()) { // TODO: Implement alert() method. return $this->addRecord(\Psr\Log\LogLevel::ALERT, $message, $context); }
[ "public", "function", "alert", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "// TODO: Implement alert() method.", "return", "$", "this", "->", "addRecord", "(", "\\", "Psr", "\\", "Log", "\\", "LogLevel", "::", "ALER...
Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up. @param string $message @param array $context @return null
[ "Action", "must", "be", "taken", "immediately", "." ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L212-L216
Erdiko/core
src/Logger.php
Logger.critical
public function critical($message, array $context = array()) { // TODO: Implement critical() method. return $this->addRecord(\Psr\Log\LogLevel::CRITICAL, $message, $context); }
php
public function critical($message, array $context = array()) { // TODO: Implement critical() method. return $this->addRecord(\Psr\Log\LogLevel::CRITICAL, $message, $context); }
[ "public", "function", "critical", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "// TODO: Implement critical() method.", "return", "$", "this", "->", "addRecord", "(", "\\", "Psr", "\\", "Log", "\\", "LogLevel", "::", ...
Critical conditions. Example: Application component unavailable, unexpected exception. @param string $message @param array $context @return null
[ "Critical", "conditions", "." ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L228-L232
Erdiko/core
src/Logger.php
Logger.notice
public function notice($message, array $context = array()) { // TODO: Implement notice() method. return $this->addRecord(\Psr\Log\LogLevel::NOTICE, $message, $context); }
php
public function notice($message, array $context = array()) { // TODO: Implement notice() method. return $this->addRecord(\Psr\Log\LogLevel::NOTICE, $message, $context); }
[ "public", "function", "notice", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "// TODO: Implement notice() method.", "return", "$", "this", "->", "addRecord", "(", "\\", "Psr", "\\", "Log", "\\", "LogLevel", "::", "NO...
Normal but significant events. @param string $message @param array $context @return null
[ "Normal", "but", "significant", "events", "." ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L274-L278
Erdiko/core
src/Logger.php
Logger.info
public function info($message, array $context = array()) { // TODO: Implement info() method. return $this->addRecord(\Psr\Log\LogLevel::INFO, $message, $context); }
php
public function info($message, array $context = array()) { // TODO: Implement info() method. return $this->addRecord(\Psr\Log\LogLevel::INFO, $message, $context); }
[ "public", "function", "info", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "// TODO: Implement info() method.", "return", "$", "this", "->", "addRecord", "(", "\\", "Psr", "\\", "Log", "\\", "LogLevel", "::", "INFO",...
Interesting events. Example: User logs in, SQL logs. @param string $message @param array $context @return null
[ "Interesting", "events", "." ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L290-L294
Erdiko/core
src/Logger.php
Logger.debug
public function debug($message, array $context = array()) { // TODO: Implement debug() method. return $this->addRecord(\Psr\Log\LogLevel::DEBUG, $message, $context); }
php
public function debug($message, array $context = array()) { // TODO: Implement debug() method. return $this->addRecord(\Psr\Log\LogLevel::DEBUG, $message, $context); }
[ "public", "function", "debug", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "// TODO: Implement debug() method.", "return", "$", "this", "->", "addRecord", "(", "\\", "Psr", "\\", "Log", "\\", "LogLevel", "::", "DEBU...
Detailed debug information. @param string $message @param array $context @return null
[ "Detailed", "debug", "information", "." ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Logger.php#L304-L308
zhouyl/mellivora
Mellivora/Application/App.php
App.registerFacades
protected function registerFacades() { $container = $this->getContainer(); if ($container->has('facades')) { foreach ($container->get('facades') as $alias => $abstract) { class_alias($abstract, $alias); } } }
php
protected function registerFacades() { $container = $this->getContainer(); if ($container->has('facades')) { foreach ($container->get('facades') as $alias => $abstract) { class_alias($abstract, $alias); } } }
[ "protected", "function", "registerFacades", "(", ")", "{", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "if", "(", "$", "container", "->", "has", "(", "'facades'", ")", ")", "{", "foreach", "(", "$", "container", "->", "get"...
注册类别名
[ "注册类别名" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Application/App.php#L52-L61
zhouyl/mellivora
Mellivora/Application/App.php
App.registerProviders
protected function registerProviders() { $container = $this->getContainer(); if ($container->has('providers')) { foreach ($container->get('providers') as $class) { if (!is_subclass_of($class, ServiceProvider::class)) { throw new UnexpectedValueExcepti...
php
protected function registerProviders() { $container = $this->getContainer(); if ($container->has('providers')) { foreach ($container->get('providers') as $class) { if (!is_subclass_of($class, ServiceProvider::class)) { throw new UnexpectedValueExcepti...
[ "protected", "function", "registerProviders", "(", ")", "{", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "if", "(", "$", "container", "->", "has", "(", "'providers'", ")", ")", "{", "foreach", "(", "$", "container", "->", "...
注册 Service Providers
[ "注册", "Service", "Providers" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Application/App.php#L66-L81
zhouyl/mellivora
Mellivora/Application/App.php
App.refreshContainer
protected function refreshContainer() { $container = $this->getContainer(); $this->add(function ($request, $response, $next) use ($container) { $container['request'] = $request; $container['response'] = $response; return $next($request, $response); }); ...
php
protected function refreshContainer() { $container = $this->getContainer(); $this->add(function ($request, $response, $next) use ($container) { $container['request'] = $request; $container['response'] = $response; return $next($request, $response); }); ...
[ "protected", "function", "refreshContainer", "(", ")", "{", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "$", "this", "->", "add", "(", "function", "(", "$", "request", ",", "$", "response", ",", "$", "next", ")", "use", "...
刷新 container 中注册的 request/response 组件
[ "刷新", "container", "中注册的", "request", "/", "response", "组件" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Application/App.php#L86-L96
zhouyl/mellivora
Mellivora/Application/App.php
App.registerDefaultArguments
protected function registerDefaultArguments() { $container = $this->getContainer(); $this->add(function ($request, $response, $next) use ($container) { $route = $request->getAttribute('route'); $route ->setArgument( 'namespace', ...
php
protected function registerDefaultArguments() { $container = $this->getContainer(); $this->add(function ($request, $response, $next) use ($container) { $route = $request->getAttribute('route'); $route ->setArgument( 'namespace', ...
[ "protected", "function", "registerDefaultArguments", "(", ")", "{", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "$", "this", "->", "add", "(", "function", "(", "$", "request", ",", "$", "response", ",", "$", "next", ")", "u...
注册默认路由参数
[ "注册默认路由参数" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Application/App.php#L101-L128
zhouyl/mellivora
Mellivora/Translation/Translator.php
Translator.addPath
public function addPath($basepath) { foreach (new DirectoryIterator($basepath) as $dir) { if ($dir->isDir() && !$dir->isDot()) { $lang = $dir->getBasename(); $path = $dir->getPathname(); if (!isset($this->paths[$lang])) { $this...
php
public function addPath($basepath) { foreach (new DirectoryIterator($basepath) as $dir) { if ($dir->isDir() && !$dir->isDot()) { $lang = $dir->getBasename(); $path = $dir->getPathname(); if (!isset($this->paths[$lang])) { $this...
[ "public", "function", "addPath", "(", "$", "basepath", ")", "{", "foreach", "(", "new", "DirectoryIterator", "(", "$", "basepath", ")", "as", "$", "dir", ")", "{", "if", "(", "$", "dir", "->", "isDir", "(", ")", "&&", "!", "$", "dir", "->", "isDot"...
新增语言包加载路径 @param string $basepath @return \Mellivora\Translation\Translator
[ "新增语言包加载路径" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/Translator.php#L68-L89
zhouyl/mellivora
Mellivora/Translation/Translator.php
Translator.alias
public function alias($lang, $aliases) { $lang = strtolower($lang); if (!is_array($aliases)) { $aliases = [$aliases]; } $aliases = array_map('strtolower', $aliases); $this->aliases[$lang] = array_unique( array_merge(Arr::get($this->aliases, $lang, [...
php
public function alias($lang, $aliases) { $lang = strtolower($lang); if (!is_array($aliases)) { $aliases = [$aliases]; } $aliases = array_map('strtolower', $aliases); $this->aliases[$lang] = array_unique( array_merge(Arr::get($this->aliases, $lang, [...
[ "public", "function", "alias", "(", "$", "lang", ",", "$", "aliases", ")", "{", "$", "lang", "=", "strtolower", "(", "$", "lang", ")", ";", "if", "(", "!", "is_array", "(", "$", "aliases", ")", ")", "{", "$", "aliases", "=", "[", "$", "aliases", ...
设定语言包别名 @param string $lang @param array|string $aliases @return \Mellivora\Translation\Translator
[ "设定语言包别名" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/Translator.php#L99-L114
zhouyl/mellivora
Mellivora/Translation/Translator.php
Translator.lang
public function lang($alias) { $alias = Str::slug($alias); foreach ($this->aliases as $lang => $aliases) { if (in_array($alias, $aliases)) { return $lang; } } return $alias; }
php
public function lang($alias) { $alias = Str::slug($alias); foreach ($this->aliases as $lang => $aliases) { if (in_array($alias, $aliases)) { return $lang; } } return $alias; }
[ "public", "function", "lang", "(", "$", "alias", ")", "{", "$", "alias", "=", "Str", "::", "slug", "(", "$", "alias", ")", ";", "foreach", "(", "$", "this", "->", "aliases", "as", "$", "lang", "=>", "$", "aliases", ")", "{", "if", "(", "in_array"...
将别名转换为语言包名 @param string $alias @return string
[ "将别名转换为语言包名" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/Translator.php#L139-L150
zhouyl/mellivora
Mellivora/Translation/Translator.php
Translator.import
public function import($packages) { if (!is_array($packages)) { $packages = func_get_args(); } // 新增的语言包 $diff = array_diff($packages, $this->packages); // 合并到已加载的语言包中 $this->packages = array_merge($this->packages, $diff); // 载入新增的语言包 fo...
php
public function import($packages) { if (!is_array($packages)) { $packages = func_get_args(); } // 新增的语言包 $diff = array_diff($packages, $this->packages); // 合并到已加载的语言包中 $this->packages = array_merge($this->packages, $diff); // 载入新增的语言包 fo...
[ "public", "function", "import", "(", "$", "packages", ")", "{", "if", "(", "!", "is_array", "(", "$", "packages", ")", ")", "{", "$", "packages", "=", "func_get_args", "(", ")", ";", "}", "// 新增的语言包", "$", "diff", "=", "array_diff", "(", "$", "packag...
加载语言包 @param array|string $packages @return \Mellivora\Translation\Translator
[ "加载语言包" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/Translator.php#L159-L177
zhouyl/mellivora
Mellivora/Translation/Translator.php
Translator.export
public function export($lang = null) { $lang = $lang ? $this->lang($lang) : $this->default; if (!isset($this->imported[$lang])) { return []; } return $this->imported[$lang]; }
php
public function export($lang = null) { $lang = $lang ? $this->lang($lang) : $this->default; if (!isset($this->imported[$lang])) { return []; } return $this->imported[$lang]; }
[ "public", "function", "export", "(", "$", "lang", "=", "null", ")", "{", "$", "lang", "=", "$", "lang", "?", "$", "this", "->", "lang", "(", "$", "lang", ")", ":", "$", "this", "->", "default", ";", "if", "(", "!", "isset", "(", "$", "this", ...
导出已加载的语言包数据 @param string $lang @return array
[ "导出已加载的语言包数据" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/Translator.php#L186-L195
zhouyl/mellivora
Mellivora/Translation/Translator.php
Translator.trans
public function trans($text, array $replace = null, $lang = null) { $lang = $lang ? $this->lang($lang) : $this->default; if (isset($this->imported[$lang])) { $text = Arr::get($this->imported[$lang], $text, $text); } return $replace ? strtr($text, $replace) : $text; ...
php
public function trans($text, array $replace = null, $lang = null) { $lang = $lang ? $this->lang($lang) : $this->default; if (isset($this->imported[$lang])) { $text = Arr::get($this->imported[$lang], $text, $text); } return $replace ? strtr($text, $replace) : $text; ...
[ "public", "function", "trans", "(", "$", "text", ",", "array", "$", "replace", "=", "null", ",", "$", "lang", "=", "null", ")", "{", "$", "lang", "=", "$", "lang", "?", "$", "this", "->", "lang", "(", "$", "lang", ")", ":", "$", "this", "->", ...
执行翻译 @param string $text @param array $replace @param string $lang @return string
[ "执行翻译" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/Translator.php#L206-L215
zhouyl/mellivora
Mellivora/Translation/Translator.php
Translator.reverse
public function reverse($text, $from = null, $to = null) { $from = $from ? $this->lang($from) : $this->default; $to = $to ? $this->lang($to) : null; if ($from === $to) { return $text; } if (isset($this->imported[$from])) { $text = Arr::get(array_fl...
php
public function reverse($text, $from = null, $to = null) { $from = $from ? $this->lang($from) : $this->default; $to = $to ? $this->lang($to) : null; if ($from === $to) { return $text; } if (isset($this->imported[$from])) { $text = Arr::get(array_fl...
[ "public", "function", "reverse", "(", "$", "text", ",", "$", "from", "=", "null", ",", "$", "to", "=", "null", ")", "{", "$", "from", "=", "$", "from", "?", "$", "this", "->", "lang", "(", "$", "from", ")", ":", "$", "this", "->", "default", ...
反向翻译 @param string $text @param string $from @param string $to @return string
[ "反向翻译" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/Translator.php#L226-L244
zhouyl/mellivora
Mellivora/Translation/Translator.php
Translator.load
protected function load($lang, $path, array $packages) { // 扫描目录并加载语言包 foreach ($packages as $package) { $file = sprintf('%s/%s.php', $path, str_replace('.', '/', $package)); // 语言文件不存在 if (!is_file($file)) { continue; } /...
php
protected function load($lang, $path, array $packages) { // 扫描目录并加载语言包 foreach ($packages as $package) { $file = sprintf('%s/%s.php', $path, str_replace('.', '/', $package)); // 语言文件不存在 if (!is_file($file)) { continue; } /...
[ "protected", "function", "load", "(", "$", "lang", ",", "$", "path", ",", "array", "$", "packages", ")", "{", "// 扫描目录并加载语言包", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "$", "file", "=", "sprintf", "(", "'%s/%s.php'", ",", "$", ...
加载语言包 @param string $lang @param string $path @param array $packages
[ "加载语言包" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Translation/Translator.php#L253-L274
zhengb302/LumengPHP-Db
src/LumengPHP/Db/Misc/FieldHelper.php
FieldHelper.quoteField
public static function quoteField($field) { $trimmedField = trim($field); if ($trimmedField == '*') { return $trimmedField; } if (strpos($trimmedField, ' ') !== false) { return $trimmedField; } return strpos($trimmedField, '.') !== false ? ...
php
public static function quoteField($field) { $trimmedField = trim($field); if ($trimmedField == '*') { return $trimmedField; } if (strpos($trimmedField, ' ') !== false) { return $trimmedField; } return strpos($trimmedField, '.') !== false ? ...
[ "public", "static", "function", "quoteField", "(", "$", "field", ")", "{", "$", "trimmedField", "=", "trim", "(", "$", "field", ")", ";", "if", "(", "$", "trimmedField", "==", "'*'", ")", "{", "return", "$", "trimmedField", ";", "}", "if", "(", "strp...
给单个字段打引号 @param string $field 字段名 @return string 如果字段带英文句点,则不打引号直接返回原值, 否则返回打引号之后的字段名
[ "给单个字段打引号" ]
train
https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Misc/FieldHelper.php#L18-L30
zhengb302/LumengPHP-Db
src/LumengPHP/Db/Misc/FieldHelper.php
FieldHelper.quoteFields
public static function quoteFields($fields) { $fieldArr = is_array($fields) ? $fields : explode(',', $fields); $resultFieldArr = array(); foreach ($fieldArr as $field) { $resultFieldArr[] = self::quoteField($field); } return implode(', ', $resultFieldArr); }
php
public static function quoteFields($fields) { $fieldArr = is_array($fields) ? $fields : explode(',', $fields); $resultFieldArr = array(); foreach ($fieldArr as $field) { $resultFieldArr[] = self::quoteField($field); } return implode(', ', $resultFieldArr); }
[ "public", "static", "function", "quoteFields", "(", "$", "fields", ")", "{", "$", "fieldArr", "=", "is_array", "(", "$", "fields", ")", "?", "$", "fields", ":", "explode", "(", "','", ",", "$", "fields", ")", ";", "$", "resultFieldArr", "=", "array", ...
给多个字段打引号 @param string|array $fields 以英文逗号分隔的字段列表或字段数组 @return string 以英文逗号分割的已打过引号的字段列表
[ "给多个字段打引号" ]
train
https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Misc/FieldHelper.php#L37-L45
grozzzny/catalog
models/Base.php
Base.beforeSave
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if(!$insert){ foreach ($this->getAttributes() as $attribute => $value){ if($this->hasValidator(['image', 'file'], $attribute)) { if($this->$attribute !== $this->ol...
php
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if(!$insert){ foreach ($this->getAttributes() as $attribute => $value){ if($this->hasValidator(['image', 'file'], $attribute)) { if($this->$attribute !== $this->ol...
[ "public", "function", "beforeSave", "(", "$", "insert", ")", "{", "if", "(", "parent", "::", "beforeSave", "(", "$", "insert", ")", ")", "{", "if", "(", "!", "$", "insert", ")", "{", "foreach", "(", "$", "this", "->", "getAttributes", "(", ")", "as...
Используется при отчистке ранее загруженных файлов @param bool $insert @return bool
[ "Используется", "при", "отчистке", "ранее", "загруженных", "файлов" ]
train
https://github.com/grozzzny/catalog/blob/ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a/models/Base.php#L88-L104
grozzzny/catalog
models/Base.php
Base.afterDelete
public function afterDelete() { parent::afterDelete(); foreach ($this->getAttributes() as $attribute => $value){ if($this->hasValidator(['image', 'file'], $attribute)) { @unlink(Yii::getAlias('@webroot').$this->$attribute); } } }
php
public function afterDelete() { parent::afterDelete(); foreach ($this->getAttributes() as $attribute => $value){ if($this->hasValidator(['image', 'file'], $attribute)) { @unlink(Yii::getAlias('@webroot').$this->$attribute); } } }
[ "public", "function", "afterDelete", "(", ")", "{", "parent", "::", "afterDelete", "(", ")", ";", "foreach", "(", "$", "this", "->", "getAttributes", "(", ")", "as", "$", "attribute", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "hasVa...
Используется при отчистке файлов
[ "Используется", "при", "отчистке", "файлов" ]
train
https://github.com/grozzzny/catalog/blob/ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a/models/Base.php#L109-L118
mothership-ec/composer
src/Composer/Command/HomeCommand.php
HomeCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $repos = $this->initializeRepos(); $return = 0; foreach ($input->getArgument('packages') as $packageName) { foreach ($repos as $repo) { $package = $this->getPackage($repo, $packageName);...
php
protected function execute(InputInterface $input, OutputInterface $output) { $repos = $this->initializeRepos(); $return = 0; foreach ($input->getArgument('packages') as $packageName) { foreach ($repos as $repo) { $package = $this->getPackage($repo, $packageName);...
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "repos", "=", "$", "this", "->", "initializeRepos", "(", ")", ";", "$", "return", "=", "0", ";", "foreach", "(", "$", "input", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/HomeCommand.php#L58-L100
mothership-ec/composer
src/Composer/Command/HomeCommand.php
HomeCommand.getPackage
protected function getPackage(RepositoryInterface $repos, $name) { $name = strtolower($name); $pool = new Pool('dev'); $pool->addRepository($repos); $matches = $pool->whatProvides($name); foreach ($matches as $index => $package) { // skip providers/replacers ...
php
protected function getPackage(RepositoryInterface $repos, $name) { $name = strtolower($name); $pool = new Pool('dev'); $pool->addRepository($repos); $matches = $pool->whatProvides($name); foreach ($matches as $index => $package) { // skip providers/replacers ...
[ "protected", "function", "getPackage", "(", "RepositoryInterface", "$", "repos", ",", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "$", "pool", "=", "new", "Pool", "(", "'dev'", ")", ";", "$", "pool", "->", "addR...
finds a package by name @param RepositoryInterface $repos @param string $name @return CompletePackageInterface
[ "finds", "a", "package", "by", "name" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/HomeCommand.php#L109-L125
mothership-ec/composer
src/Composer/Command/HomeCommand.php
HomeCommand.openBrowser
private function openBrowser($url) { $url = ProcessExecutor::escape($url); if (defined('PHP_WINDOWS_VERSION_MAJOR')) { return passthru('start "web" explorer "' . $url . '"'); } passthru('which xdg-open', $linux); passthru('which open', $osx); if (0 === ...
php
private function openBrowser($url) { $url = ProcessExecutor::escape($url); if (defined('PHP_WINDOWS_VERSION_MAJOR')) { return passthru('start "web" explorer "' . $url . '"'); } passthru('which xdg-open', $linux); passthru('which open', $osx); if (0 === ...
[ "private", "function", "openBrowser", "(", "$", "url", ")", "{", "$", "url", "=", "ProcessExecutor", "::", "escape", "(", "$", "url", ")", ";", "if", "(", "defined", "(", "'PHP_WINDOWS_VERSION_MAJOR'", ")", ")", "{", "return", "passthru", "(", "'start \"we...
opens a url in your system default browser @param string $url
[ "opens", "a", "url", "in", "your", "system", "default", "browser" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/HomeCommand.php#L132-L150
mothership-ec/composer
src/Composer/Command/HomeCommand.php
HomeCommand.initializeRepos
private function initializeRepos() { $composer = $this->getComposer(false); if ($composer) { return array( $composer->getRepositoryManager()->getLocalRepository(), new CompositeRepository($composer->getRepositoryManager()->getRepositories()) )...
php
private function initializeRepos() { $composer = $this->getComposer(false); if ($composer) { return array( $composer->getRepositoryManager()->getLocalRepository(), new CompositeRepository($composer->getRepositoryManager()->getRepositories()) )...
[ "private", "function", "initializeRepos", "(", ")", "{", "$", "composer", "=", "$", "this", "->", "getComposer", "(", "false", ")", ";", "if", "(", "$", "composer", ")", "{", "return", "array", "(", "$", "composer", "->", "getRepositoryManager", "(", ")"...
Initializes repositories Returns an array of repos in order they should be checked in @return RepositoryInterface[]
[ "Initializes", "repositories" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/HomeCommand.php#L159-L173
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.when
public function when($value, $callback, $default = null) { $builder = $this; if ($value) { $builder = $callback($builder); } elseif ($default) { $builder = $default($builder); } return $builder; }
php
public function when($value, $callback, $default = null) { $builder = $this; if ($value) { $builder = $callback($builder); } elseif ($default) { $builder = $default($builder); } return $builder; }
[ "public", "function", "when", "(", "$", "value", ",", "$", "callback", ",", "$", "default", "=", "null", ")", "{", "$", "builder", "=", "$", "this", ";", "if", "(", "$", "value", ")", "{", "$", "builder", "=", "$", "callback", "(", "$", "builder"...
Apply the callback's query changes if the given "value" is true. @param bool $value @param \Closure $callback @param \Closure $default @return $this
[ "Apply", "the", "callback", "s", "query", "changes", "if", "the", "given", "value", "is", "true", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L170-L181
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.hydrate
public function hydrate(array $items) { $instance = $this->model->newInstance(); return $instance->newCollection(array_map(function ($item) use ($instance) { return $instance->newFromBuilder($item); }, $items)); }
php
public function hydrate(array $items) { $instance = $this->model->newInstance(); return $instance->newCollection(array_map(function ($item) use ($instance) { return $instance->newFromBuilder($item); }, $items)); }
[ "public", "function", "hydrate", "(", "array", "$", "items", ")", "{", "$", "instance", "=", "$", "this", "->", "model", "->", "newInstance", "(", ")", ";", "return", "$", "instance", "->", "newCollection", "(", "array_map", "(", "function", "(", "$", ...
Create a collection of models from plain arrays. @param array $items @return \Mellivora\Database\Eloquent\Collection
[ "Create", "a", "collection", "of", "models", "from", "plain", "arrays", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L247-L254
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.fromQuery
public function fromQuery($query, $bindings = []) { $instance = $this->model->newInstance(); return $this->hydrate( $instance->getConnection()->select($query, $bindings) ); }
php
public function fromQuery($query, $bindings = []) { $instance = $this->model->newInstance(); return $this->hydrate( $instance->getConnection()->select($query, $bindings) ); }
[ "public", "function", "fromQuery", "(", "$", "query", ",", "$", "bindings", "=", "[", "]", ")", "{", "$", "instance", "=", "$", "this", "->", "model", "->", "newInstance", "(", ")", ";", "return", "$", "this", "->", "hydrate", "(", "$", "instance", ...
Create a collection of models from a raw query. @param string $query @param array $bindings @return \Mellivora\Database\Eloquent\Collection
[ "Create", "a", "collection", "of", "models", "from", "a", "raw", "query", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L264-L271
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.findOrNew
public function findOrNew($id, $columns = ['*']) { if (!is_null($model = $this->find($id, $columns))) { return $model; } return $this->model->newInstance()->setConnection( $this->query->getConnection()->getName() ); }
php
public function findOrNew($id, $columns = ['*']) { if (!is_null($model = $this->find($id, $columns))) { return $model; } return $this->model->newInstance()->setConnection( $this->query->getConnection()->getName() ); }
[ "public", "function", "findOrNew", "(", "$", "id", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "if", "(", "!", "is_null", "(", "$", "model", "=", "$", "this", "->", "find", "(", "$", "id", ",", "$", "columns", ")", ")", ")", "{", "re...
Find a model by its primary key or return fresh model instance. @param mixed $id @param array $columns @return \Mellivora\Database\Eloquent\Model
[ "Find", "a", "model", "by", "its", "primary", "key", "or", "return", "fresh", "model", "instance", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L343-L352
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.firstOrNew
public function firstOrNew(array $attributes, array $values = []) { if (!is_null($instance = $this->where($attributes)->first())) { return $instance; } return $this->model->newInstance($attributes + $values)->setConnection( $this->query->getConnection()->getName() ...
php
public function firstOrNew(array $attributes, array $values = []) { if (!is_null($instance = $this->where($attributes)->first())) { return $instance; } return $this->model->newInstance($attributes + $values)->setConnection( $this->query->getConnection()->getName() ...
[ "public", "function", "firstOrNew", "(", "array", "$", "attributes", ",", "array", "$", "values", "=", "[", "]", ")", "{", "if", "(", "!", "is_null", "(", "$", "instance", "=", "$", "this", "->", "where", "(", "$", "attributes", ")", "->", "first", ...
Get the first record matching the attributes or instantiate it. @param array $attributes @param array $values @return \Mellivora\Database\Eloquent\Model
[ "Get", "the", "first", "record", "matching", "the", "attributes", "or", "instantiate", "it", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L362-L371
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.getModels
public function getModels($columns = ['*']) { return $this->model->hydrate( $this->query->get($columns)->all(), $this->model->getConnectionName() )->all(); }
php
public function getModels($columns = ['*']) { return $this->model->hydrate( $this->query->get($columns)->all(), $this->model->getConnectionName() )->all(); }
[ "public", "function", "getModels", "(", "$", "columns", "=", "[", "'*'", "]", ")", "{", "return", "$", "this", "->", "model", "->", "hydrate", "(", "$", "this", "->", "query", "->", "get", "(", "$", "columns", ")", "->", "all", "(", ")", ",", "$"...
Get the hydrated models without eager loading. @param array $columns @return \Mellivora\Database\Eloquent\Model[]
[ "Get", "the", "hydrated", "models", "without", "eager", "loading", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L506-L512
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.chunkById
public function chunkById($count, callable $callback, $column = null, $alias = null) { $column = is_null($column) ? $this->getModel()->getKeyName() : $column; $alias = is_null($alias) ? $column : $alias; $lastId = 0; do { $clone = clone $this; // We'll exe...
php
public function chunkById($count, callable $callback, $column = null, $alias = null) { $column = is_null($column) ? $this->getModel()->getKeyName() : $column; $alias = is_null($alias) ? $column : $alias; $lastId = 0; do { $clone = clone $this; // We'll exe...
[ "public", "function", "chunkById", "(", "$", "count", ",", "callable", "$", "callback", ",", "$", "column", "=", "null", ",", "$", "alias", "=", "null", ")", "{", "$", "column", "=", "is_null", "(", "$", "column", ")", "?", "$", "this", "->", "getM...
Chunk the results of a query by comparing numeric IDs. @param int $count @param callable $callback @param string $column @param null|string $alias @return bool
[ "Chunk", "the", "results", "of", "a", "query", "by", "comparing", "numeric", "IDs", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L694-L727
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.create
public function create(array $attributes = []) { $instance = $this->model->newInstance($attributes)->setConnection( $this->query->getConnection()->getName() ); $instance->save(); return $instance; }
php
public function create(array $attributes = []) { $instance = $this->model->newInstance($attributes)->setConnection( $this->query->getConnection()->getName() ); $instance->save(); return $instance; }
[ "public", "function", "create", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "instance", "=", "$", "this", "->", "model", "->", "newInstance", "(", "$", "attributes", ")", "->", "setConnection", "(", "$", "this", "->", "query", "->", ...
Save a new model and return the instance. @param array $attributes @return \Mellivora\Database\Eloquent\Model
[ "Save", "a", "new", "model", "and", "return", "the", "instance", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L848-L857
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.forceCreate
public function forceCreate(array $attributes) { $instance = $this->model->newInstance()->setConnection( $this->query->getConnection()->getName() ); return $this->model->unguarded(function () use ($attributes, $instance) { return $instance->create($attributes); ...
php
public function forceCreate(array $attributes) { $instance = $this->model->newInstance()->setConnection( $this->query->getConnection()->getName() ); return $this->model->unguarded(function () use ($attributes, $instance) { return $instance->create($attributes); ...
[ "public", "function", "forceCreate", "(", "array", "$", "attributes", ")", "{", "$", "instance", "=", "$", "this", "->", "model", "->", "newInstance", "(", ")", "->", "setConnection", "(", "$", "this", "->", "query", "->", "getConnection", "(", ")", "->"...
Save a new model and return the instance. Allow mass-assignment. @param array $attributes @return \Mellivora\Database\Eloquent\Model
[ "Save", "a", "new", "model", "and", "return", "the", "instance", ".", "Allow", "mass", "-", "assignment", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L866-L875
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.addUpdatedAtColumn
protected function addUpdatedAtColumn(array $values) { if (!$this->model->usesTimestamps()) { return $values; } return Arr::add( $values, $this->model->getUpdatedAtColumn(), $this->model->freshTimestampString() ); }
php
protected function addUpdatedAtColumn(array $values) { if (!$this->model->usesTimestamps()) { return $values; } return Arr::add( $values, $this->model->getUpdatedAtColumn(), $this->model->freshTimestampString() ); }
[ "protected", "function", "addUpdatedAtColumn", "(", "array", "$", "values", ")", "{", "if", "(", "!", "$", "this", "->", "model", "->", "usesTimestamps", "(", ")", ")", "{", "return", "$", "values", ";", "}", "return", "Arr", "::", "add", "(", "$", "...
Add the "updated at" column to an array of values. @param array $values @return array
[ "Add", "the", "updated", "at", "column", "to", "an", "array", "of", "values", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L932-L943
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.callScope
protected function callScope(callable $scope, $parameters = []) { array_unshift($parameters, $this); $query = $this->getQuery(); // We will keep track of how many wheres are on the query before running the // scope so that we can properly group the added scope constraints in the ...
php
protected function callScope(callable $scope, $parameters = []) { array_unshift($parameters, $this); $query = $this->getQuery(); // We will keep track of how many wheres are on the query before running the // scope so that we can properly group the added scope constraints in the ...
[ "protected", "function", "callScope", "(", "callable", "$", "scope", ",", "$", "parameters", "=", "[", "]", ")", "{", "array_unshift", "(", "$", "parameters", ",", "$", "this", ")", ";", "$", "query", "=", "$", "this", "->", "getQuery", "(", ")", ";"...
Apply the given scope on the current builder instance. @param callable $scope @param array $parameters @return mixed
[ "Apply", "the", "given", "scope", "on", "the", "current", "builder", "instance", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L1056-L1074
zhouyl/mellivora
Mellivora/Database/Eloquent/Builder.php
Builder.parseWithRelations
protected function parseWithRelations(array $relations) { $results = []; foreach ($relations as $name => $constraints) { // If the "relation" value is actually a numeric key, we can assume that no // constraints have been specified for the eager load and we'll just put ...
php
protected function parseWithRelations(array $relations) { $results = []; foreach ($relations as $name => $constraints) { // If the "relation" value is actually a numeric key, we can assume that no // constraints have been specified for the eager load and we'll just put ...
[ "protected", "function", "parseWithRelations", "(", "array", "$", "relations", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "relations", "as", "$", "name", "=>", "$", "constraints", ")", "{", "// If the \"relation\" value is actually a nume...
Parse a list of relations into individuals. @param array $relations @return array
[ "Parse", "a", "list", "of", "relations", "into", "individuals", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Builder.php#L1185-L1212
Baachi/CouchDB
src/CouchDB/DesignDocument/Result.php
Result.getFirstRow
public function getFirstRow() { $rows = $this->data['rows']; if (empty($rows)) { return false; } $row = array_slice($rows, 0, 1); return current($row); }
php
public function getFirstRow() { $rows = $this->data['rows']; if (empty($rows)) { return false; } $row = array_slice($rows, 0, 1); return current($row); }
[ "public", "function", "getFirstRow", "(", ")", "{", "$", "rows", "=", "$", "this", "->", "data", "[", "'rows'", "]", ";", "if", "(", "empty", "(", "$", "rows", ")", ")", "{", "return", "false", ";", "}", "$", "row", "=", "array_slice", "(", "$", ...
Return the first row. @return bool|array
[ "Return", "the", "first", "row", "." ]
train
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/DesignDocument/Result.php#L60-L70
Baachi/CouchDB
src/CouchDB/DesignDocument/Result.php
Result.getLastRow
public function getLastRow() { $rows = $this->data['rows']; if (empty($rows)) { return false; } $row = array_slice($rows, count($rows) - 1); return current($row); }
php
public function getLastRow() { $rows = $this->data['rows']; if (empty($rows)) { return false; } $row = array_slice($rows, count($rows) - 1); return current($row); }
[ "public", "function", "getLastRow", "(", ")", "{", "$", "rows", "=", "$", "this", "->", "data", "[", "'rows'", "]", ";", "if", "(", "empty", "(", "$", "rows", ")", ")", "{", "return", "false", ";", "}", "$", "row", "=", "array_slice", "(", "$", ...
Return the last row. @return bool|array
[ "Return", "the", "last", "row", "." ]
train
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/DesignDocument/Result.php#L77-L87
artincms/laravel_tagable
src/LTSServiceProvider.php
LTSServiceProvider.boot
public function boot() { // the main router $this->loadRoutesFrom( __DIR__.'/Routes/backend_lts_route.php'); $this->loadRoutesFrom( __DIR__.'/Routes/frontend_lts_route.php'); // the main views folder $this->loadViewsFrom(__DIR__ . '/Views', 'laravel_tagable'); // the main migrati...
php
public function boot() { // the main router $this->loadRoutesFrom( __DIR__.'/Routes/backend_lts_route.php'); $this->loadRoutesFrom( __DIR__.'/Routes/frontend_lts_route.php'); // the main views folder $this->loadViewsFrom(__DIR__ . '/Views', 'laravel_tagable'); // the main migrati...
[ "public", "function", "boot", "(", ")", "{", "// the main router", "$", "this", "->", "loadRoutesFrom", "(", "__DIR__", ".", "'/Routes/backend_lts_route.php'", ")", ";", "$", "this", "->", "loadRoutesFrom", "(", "__DIR__", ".", "'/Routes/frontend_lts_route.php'", ")...
Bootstrap the application services. @return void
[ "Bootstrap", "the", "application", "services", "." ]
train
https://github.com/artincms/laravel_tagable/blob/175b299f496bdeda7bd91cae27d30a9aa3533328/src/LTSServiceProvider.php#L15-L48
kiwi-suite/frontend42
src/Module.php
Module.init
public function init(ModuleManagerInterface $manager) { $events = $manager->getEventManager(); $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'addPageTypes')); $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'addBlocks')); }
php
public function init(ModuleManagerInterface $manager) { $events = $manager->getEventManager(); $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'addPageTypes')); $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'addBlocks')); }
[ "public", "function", "init", "(", "ModuleManagerInterface", "$", "manager", ")", "{", "$", "events", "=", "$", "manager", "->", "getEventManager", "(", ")", ";", "$", "events", "->", "attach", "(", "ModuleEvent", "::", "EVENT_MERGE_CONFIG", ",", "array", "(...
Initialize workflow @param ModuleManagerInterface $manager @return void
[ "Initialize", "workflow" ]
train
https://github.com/kiwi-suite/frontend42/blob/67e5208387957823ac84f7833eba83d4a8dab8cd/src/Module.php#L55-L60
kiwi-suite/frontend42
src/Module.php
Module.onBootstrap
public function onBootstrap(EventInterface $e) { /** @var ServiceManager $serviceManager */ $serviceManager = $e->getApplication()->getServiceManager(); /** @var Environment $environment */ $environment = $serviceManager->get(Environment::class); if ($environment->is(\Admin...
php
public function onBootstrap(EventInterface $e) { /** @var ServiceManager $serviceManager */ $serviceManager = $e->getApplication()->getServiceManager(); /** @var Environment $environment */ $environment = $serviceManager->get(Environment::class); if ($environment->is(\Admin...
[ "public", "function", "onBootstrap", "(", "EventInterface", "$", "e", ")", "{", "/** @var ServiceManager $serviceManager */", "$", "serviceManager", "=", "$", "e", "->", "getApplication", "(", ")", "->", "getServiceManager", "(", ")", ";", "/** @var Environment $envir...
Listen to the bootstrap event @param EventInterface $e @return array
[ "Listen", "to", "the", "bootstrap", "event" ]
train
https://github.com/kiwi-suite/frontend42/blob/67e5208387957823ac84f7833eba83d4a8dab8cd/src/Module.php#L124-L148
inhere/php-librarys
src/Traits/FixedEventTrait.php
FixedEventTrait.on
public function on(string $event, callable $cb, bool $replace = false) { if (false === ($key = array_search($event, $this->getSupportedEvents(), true))) { $sup = implode(',', $this->getSupportedEvents()); throw new \InvalidArgumentException("The want registered event [$event] is not...
php
public function on(string $event, callable $cb, bool $replace = false) { if (false === ($key = array_search($event, $this->getSupportedEvents(), true))) { $sup = implode(',', $this->getSupportedEvents()); throw new \InvalidArgumentException("The want registered event [$event] is not...
[ "public", "function", "on", "(", "string", "$", "event", ",", "callable", "$", "cb", ",", "bool", "$", "replace", "=", "false", ")", "{", "if", "(", "false", "===", "(", "$", "key", "=", "array_search", "(", "$", "event", ",", "$", "this", "->", ...
register a event callback @param string $event event name @param callable $cb event callback @param bool $replace replace exists's event cb @throws \InvalidArgumentException
[ "register", "a", "event", "callback" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/FixedEventTrait.php#L99-L117
inhere/php-librarys
src/Traits/FixedEventTrait.php
FixedEventTrait.off
public function off(string $event) { if (false === ($key = array_search($event, $this->getSupportedEvents(), true))) { return null; } if (!isset($this->eventHandlers[$key]) || !($cb = $this->eventHandlers[$key])) { return null; } $this->eventHandlers...
php
public function off(string $event) { if (false === ($key = array_search($event, $this->getSupportedEvents(), true))) { return null; } if (!isset($this->eventHandlers[$key]) || !($cb = $this->eventHandlers[$key])) { return null; } $this->eventHandlers...
[ "public", "function", "off", "(", "string", "$", "event", ")", "{", "if", "(", "false", "===", "(", "$", "key", "=", "array_search", "(", "$", "event", ",", "$", "this", "->", "getSupportedEvents", "(", ")", ",", "true", ")", ")", ")", "{", "return...
remove event handler @param string $event @return bool
[ "remove", "event", "handler" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/FixedEventTrait.php#L124-L137