repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
hackzilla/TicketBundle
Controller/TicketController.php
TicketController.newAction
public function newAction() { $ticketManager = $this->get('hackzilla_ticket.ticket_manager'); $entity = $ticketManager->createTicket(); $form = $this->createForm(TicketType::class, $entity); return $this->render( $this->container->getParameter('hackzilla_ticket.templates')['new'], [ 'entity' => $entity, 'form' => $form->createView(), ] ); }
php
public function newAction() { $ticketManager = $this->get('hackzilla_ticket.ticket_manager'); $entity = $ticketManager->createTicket(); $form = $this->createForm(TicketType::class, $entity); return $this->render( $this->container->getParameter('hackzilla_ticket.templates')['new'], [ 'entity' => $entity, 'form' => $form->createView(), ] ); }
[ "public", "function", "newAction", "(", ")", "{", "$", "ticketManager", "=", "$", "this", "->", "get", "(", "'hackzilla_ticket.ticket_manager'", ")", ";", "$", "entity", "=", "$", "ticketManager", "->", "createTicket", "(", ")", ";", "$", "form", "=", "$",...
Displays a form to create a new Ticket entity.
[ "Displays", "a", "form", "to", "create", "a", "new", "Ticket", "entity", "." ]
7bfd6c513979272a32bae582b7f96948605af459
https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketController.php#L96-L110
train
hackzilla/TicketBundle
Controller/TicketController.php
TicketController.deleteAction
public function deleteAction(Request $request, $ticketId) { $userManager = $this->getUserManager(); $user = $userManager->getCurrentUser(); if (!\is_object($user) || !$userManager->hasRole($user, TicketRole::ADMIN)) { throw new \Symfony\Component\HttpKernel\Exception\HttpException(403); } $form = $this->createDeleteForm($ticketId); if ($request->isMethod('DELETE')) { $form->submit($request->request->get($form->getName())); if ($form->isValid()) { $ticketManager = $this->get('hackzilla_ticket.ticket_manager'); $ticket = $ticketManager->getTicketById($ticketId); if (!$ticket) { throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle')); } $ticketManager->deleteTicket($ticket); $this->dispatchTicketEvent(TicketEvents::TICKET_DELETE, $ticket); } } return $this->redirect($this->generateUrl('hackzilla_ticket')); }
php
public function deleteAction(Request $request, $ticketId) { $userManager = $this->getUserManager(); $user = $userManager->getCurrentUser(); if (!\is_object($user) || !$userManager->hasRole($user, TicketRole::ADMIN)) { throw new \Symfony\Component\HttpKernel\Exception\HttpException(403); } $form = $this->createDeleteForm($ticketId); if ($request->isMethod('DELETE')) { $form->submit($request->request->get($form->getName())); if ($form->isValid()) { $ticketManager = $this->get('hackzilla_ticket.ticket_manager'); $ticket = $ticketManager->getTicketById($ticketId); if (!$ticket) { throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle')); } $ticketManager->deleteTicket($ticket); $this->dispatchTicketEvent(TicketEvents::TICKET_DELETE, $ticket); } } return $this->redirect($this->generateUrl('hackzilla_ticket')); }
[ "public", "function", "deleteAction", "(", "Request", "$", "request", ",", "$", "ticketId", ")", "{", "$", "userManager", "=", "$", "this", "->", "getUserManager", "(", ")", ";", "$", "user", "=", "$", "userManager", "->", "getCurrentUser", "(", ")", ";"...
Deletes a Ticket entity. @param Request $request @param int $ticketId @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Deletes", "a", "Ticket", "entity", "." ]
7bfd6c513979272a32bae582b7f96948605af459
https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketController.php#L196-L224
train
hackzilla/TicketBundle
Manager/TicketManager.php
TicketManager.createTicket
public function createTicket() { /* @var TicketInterface $ticket */ $ticket = new $this->ticketClass(); $ticket->setPriority(TicketMessageInterface::PRIORITY_MEDIUM); $ticket->setStatus(TicketMessageInterface::STATUS_OPEN); return $ticket; }
php
public function createTicket() { /* @var TicketInterface $ticket */ $ticket = new $this->ticketClass(); $ticket->setPriority(TicketMessageInterface::PRIORITY_MEDIUM); $ticket->setStatus(TicketMessageInterface::STATUS_OPEN); return $ticket; }
[ "public", "function", "createTicket", "(", ")", "{", "/* @var TicketInterface $ticket */", "$", "ticket", "=", "new", "$", "this", "->", "ticketClass", "(", ")", ";", "$", "ticket", "->", "setPriority", "(", "TicketMessageInterface", "::", "PRIORITY_MEDIUM", ")", ...
Create a new instance of Ticket entity. @return TicketInterface
[ "Create", "a", "new", "instance", "of", "Ticket", "entity", "." ]
7bfd6c513979272a32bae582b7f96948605af459
https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Manager/TicketManager.php#L69-L77
train
hackzilla/TicketBundle
Entity/Traits/TicketMessageTrait.php
TicketMessageTrait.setTicket
public function setTicket(TicketInterface $ticket = null) { $this->ticket = $ticket; if (\is_null($this->getUserObject())) { $user = $this->getUser(); } else { $user = $this->getUserObject(); } // if null, then new ticket if (\is_null($ticket->getUserCreated())) { $ticket->setUserCreated($user); } $ticket->setLastUser($user); $ticket->setLastMessage($this->getCreatedAt()); $ticket->setPriority($this->getPriority()); // if ticket not closed, then it'll be set to null if (\is_null($this->getStatus())) { $this->setStatus($ticket->getStatus()); } else { $ticket->setStatus($this->getStatus()); } return $this; }
php
public function setTicket(TicketInterface $ticket = null) { $this->ticket = $ticket; if (\is_null($this->getUserObject())) { $user = $this->getUser(); } else { $user = $this->getUserObject(); } // if null, then new ticket if (\is_null($ticket->getUserCreated())) { $ticket->setUserCreated($user); } $ticket->setLastUser($user); $ticket->setLastMessage($this->getCreatedAt()); $ticket->setPriority($this->getPriority()); // if ticket not closed, then it'll be set to null if (\is_null($this->getStatus())) { $this->setStatus($ticket->getStatus()); } else { $ticket->setStatus($this->getStatus()); } return $this; }
[ "public", "function", "setTicket", "(", "TicketInterface", "$", "ticket", "=", "null", ")", "{", "$", "this", "->", "ticket", "=", "$", "ticket", ";", "if", "(", "\\", "is_null", "(", "$", "this", "->", "getUserObject", "(", ")", ")", ")", "{", "$", ...
Set ticket. @param TicketInterface $ticket @return $this
[ "Set", "ticket", "." ]
7bfd6c513979272a32bae582b7f96948605af459
https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketMessageTrait.php#L258-L285
train
goaop/parser-reflection
src/ReflectionFile.php
ReflectionFile.getFileNamespaces
public function getFileNamespaces() { if (!isset($this->fileNamespaces)) { $this->fileNamespaces = $this->findFileNamespaces(); } return $this->fileNamespaces; }
php
public function getFileNamespaces() { if (!isset($this->fileNamespaces)) { $this->fileNamespaces = $this->findFileNamespaces(); } return $this->fileNamespaces; }
[ "public", "function", "getFileNamespaces", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "fileNamespaces", ")", ")", "{", "$", "this", "->", "fileNamespaces", "=", "$", "this", "->", "findFileNamespaces", "(", ")", ";", "}", "return", ...
Gets the list of namespaces in the file @return array|ReflectionFileNamespace[]
[ "Gets", "the", "list", "of", "namespaces", "in", "the", "file" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFile.php#L87-L94
train
goaop/parser-reflection
src/ReflectionFile.php
ReflectionFile.isStrictMode
public function isStrictMode() { // declare statement for the strict_types can be only top-level node $topLevelNode = reset($this->topLevelNodes); if (!$topLevelNode instanceof Node\Stmt\Declare_) { return false; } $declareStatement = reset($topLevelNode->declares); $isStrictTypeKey = $declareStatement->key->toString() === 'strict_types'; $isScalarValue = $declareStatement->value instanceof Node\Scalar\LNumber; $isStrictMode = $isStrictTypeKey && $isScalarValue && $declareStatement->value->value === 1; return $isStrictMode; }
php
public function isStrictMode() { // declare statement for the strict_types can be only top-level node $topLevelNode = reset($this->topLevelNodes); if (!$topLevelNode instanceof Node\Stmt\Declare_) { return false; } $declareStatement = reset($topLevelNode->declares); $isStrictTypeKey = $declareStatement->key->toString() === 'strict_types'; $isScalarValue = $declareStatement->value instanceof Node\Scalar\LNumber; $isStrictMode = $isStrictTypeKey && $isScalarValue && $declareStatement->value->value === 1; return $isStrictMode; }
[ "public", "function", "isStrictMode", "(", ")", "{", "// declare statement for the strict_types can be only top-level node", "$", "topLevelNode", "=", "reset", "(", "$", "this", "->", "topLevelNodes", ")", ";", "if", "(", "!", "$", "topLevelNode", "instanceof", "Node"...
Checks if the current file is in strict mode @return bool
[ "Checks", "if", "the", "current", "file", "is", "in", "strict", "mode" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFile.php#L135-L149
train
goaop/parser-reflection
src/ReflectionFile.php
ReflectionFile.findFileNamespaces
private function findFileNamespaces() { $namespaces = array(); // namespaces can be only top-level nodes, so we can scan them directly foreach ($this->topLevelNodes as $topLevelNode) { if ($topLevelNode instanceof Namespace_) { $namespaceName = $topLevelNode->name ? $topLevelNode->name->toString() : ''; $namespaces[$namespaceName] = new ReflectionFileNamespace( $this->fileName, $namespaceName, $topLevelNode ); } } return $namespaces; }
php
private function findFileNamespaces() { $namespaces = array(); // namespaces can be only top-level nodes, so we can scan them directly foreach ($this->topLevelNodes as $topLevelNode) { if ($topLevelNode instanceof Namespace_) { $namespaceName = $topLevelNode->name ? $topLevelNode->name->toString() : ''; $namespaces[$namespaceName] = new ReflectionFileNamespace( $this->fileName, $namespaceName, $topLevelNode ); } } return $namespaces; }
[ "private", "function", "findFileNamespaces", "(", ")", "{", "$", "namespaces", "=", "array", "(", ")", ";", "// namespaces can be only top-level nodes, so we can scan them directly", "foreach", "(", "$", "this", "->", "topLevelNodes", "as", "$", "topLevelNode", ")", "...
Searches for file namespaces in the given AST @return array|ReflectionFileNamespace[]
[ "Searches", "for", "file", "namespaces", "in", "the", "given", "AST" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFile.php#L156-L174
train
majkel89/dbase
benchmarks/TransactionalUpdateBenchmark.php
TransactionalUpdateBenchmark.setUp
public function setUp() { $this->sourceTable->next(); $this->currentIndex = $this->sourceTable->key(); $this->currentField = $this->sourceTable->current(); }
php
public function setUp() { $this->sourceTable->next(); $this->currentIndex = $this->sourceTable->key(); $this->currentField = $this->sourceTable->current(); }
[ "public", "function", "setUp", "(", ")", "{", "$", "this", "->", "sourceTable", "->", "next", "(", ")", ";", "$", "this", "->", "currentIndex", "=", "$", "this", "->", "sourceTable", "->", "key", "(", ")", ";", "$", "this", "->", "currentField", "=",...
Fetch new record
[ "Fetch", "new", "record" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/benchmarks/TransactionalUpdateBenchmark.php#L56-L60
train
majkel89/dbase
src/FormatFactory.php
FormatFactory.getFormat
public function getFormat($name, $filePath, $mode) { $formats = $this->getFormats(); if (!isset($formats[$name])) { throw new Exception("Format `$name` is not registered"); } if (!is_callable($formats[$name])) { throw new Exception("Cannot generate format `$name`"); } $format = call_user_func($formats[$name], $filePath, $mode); if (!$format instanceof Format) { throw new Exception("Cannot generate format `$name`"); } return $format; }
php
public function getFormat($name, $filePath, $mode) { $formats = $this->getFormats(); if (!isset($formats[$name])) { throw new Exception("Format `$name` is not registered"); } if (!is_callable($formats[$name])) { throw new Exception("Cannot generate format `$name`"); } $format = call_user_func($formats[$name], $filePath, $mode); if (!$format instanceof Format) { throw new Exception("Cannot generate format `$name`"); } return $format; }
[ "public", "function", "getFormat", "(", "$", "name", ",", "$", "filePath", ",", "$", "mode", ")", "{", "$", "formats", "=", "$", "this", "->", "getFormats", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "formats", "[", "$", "name", "]", ")", ...
Returns new format object @param string $name @param string $filePath @param integer $mode @return \org\majkel\dbase\Format @throws Exception
[ "Returns", "new", "format", "object" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/FormatFactory.php#L35-L48
train
goaop/parser-reflection
src/ReflectionParameter.php
ReflectionParameter.haveSiblingsDefalutValues
protected function haveSiblingsDefalutValues() { $function = $this->getDeclaringFunction(); if (null === $function) { throw new ReflectionException('Could not get the declaring function reflection.'); } /** @var \ReflectionParameter[] $remainingParameters */ $remainingParameters = array_slice($function->getParameters(), $this->parameterIndex + 1); foreach ($remainingParameters as $reflectionParameter) { if (!$reflectionParameter->isDefaultValueAvailable()) { return false; } } return true; }
php
protected function haveSiblingsDefalutValues() { $function = $this->getDeclaringFunction(); if (null === $function) { throw new ReflectionException('Could not get the declaring function reflection.'); } /** @var \ReflectionParameter[] $remainingParameters */ $remainingParameters = array_slice($function->getParameters(), $this->parameterIndex + 1); foreach ($remainingParameters as $reflectionParameter) { if (!$reflectionParameter->isDefaultValueAvailable()) { return false; } } return true; }
[ "protected", "function", "haveSiblingsDefalutValues", "(", ")", "{", "$", "function", "=", "$", "this", "->", "getDeclaringFunction", "(", ")", ";", "if", "(", "null", "===", "$", "function", ")", "{", "throw", "new", "ReflectionException", "(", "'Could not ge...
Returns if all following parameters have a default value definition. @return bool @throws ReflectionException If could not fetch declaring function reflection
[ "Returns", "if", "all", "following", "parameters", "have", "a", "default", "value", "definition", "." ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionParameter.php#L381-L397
train
goaop/parser-reflection
src/ReflectionProperty.php
ReflectionProperty.collectFromClassNode
public static function collectFromClassNode(ClassLike $classLikeNode, $fullClassName) { $properties = []; foreach ($classLikeNode->stmts as $classLevelNode) { if ($classLevelNode instanceof Property) { foreach ($classLevelNode->props as $classPropertyNode) { $propertyName = $classPropertyNode->name->toString(); $properties[$propertyName] = new static( $fullClassName, $propertyName, $classLevelNode, $classPropertyNode ); } } } return $properties; }
php
public static function collectFromClassNode(ClassLike $classLikeNode, $fullClassName) { $properties = []; foreach ($classLikeNode->stmts as $classLevelNode) { if ($classLevelNode instanceof Property) { foreach ($classLevelNode->props as $classPropertyNode) { $propertyName = $classPropertyNode->name->toString(); $properties[$propertyName] = new static( $fullClassName, $propertyName, $classLevelNode, $classPropertyNode ); } } } return $properties; }
[ "public", "static", "function", "collectFromClassNode", "(", "ClassLike", "$", "classLikeNode", ",", "$", "fullClassName", ")", "{", "$", "properties", "=", "[", "]", ";", "foreach", "(", "$", "classLikeNode", "->", "stmts", "as", "$", "classLevelNode", ")", ...
Parses properties from the concrete class node @param ClassLike $classLikeNode Class-like node @param string $fullClassName FQN of the class @return array|ReflectionProperty[]
[ "Parses", "properties", "from", "the", "concrete", "class", "node" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionProperty.php#L259-L278
train
majkel89/dbase
src/Record.php
Record.getMemoEntryId
public function getMemoEntryId($name) { return isset($this->memoEntries[$name]) ? $this->memoEntries[$name] : null; }
php
public function getMemoEntryId($name) { return isset($this->memoEntries[$name]) ? $this->memoEntries[$name] : null; }
[ "public", "function", "getMemoEntryId", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "memoEntries", "[", "$", "name", "]", ")", "?", "$", "this", "->", "memoEntries", "[", "$", "name", "]", ":", "null", ";", "}" ]
Retrieves entity id for memo value @param string $name memo field name @return integer|null entity id @internal
[ "Retrieves", "entity", "id", "for", "memo", "value" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Record.php#L80-L82
train
majkel89/dbase
src/Table.php
Table.update
public function update($index, $data) { if (!$data instanceof Record) { $data = new Record(Utils::toArray($data)); } $this->getFormat()->update($index, $data); // update buffer to reflect current changes if (isset($this->buffer[$index])) { $this->buffer[$index] = $data; } }
php
public function update($index, $data) { if (!$data instanceof Record) { $data = new Record(Utils::toArray($data)); } $this->getFormat()->update($index, $data); // update buffer to reflect current changes if (isset($this->buffer[$index])) { $this->buffer[$index] = $data; } }
[ "public", "function", "update", "(", "$", "index", ",", "$", "data", ")", "{", "if", "(", "!", "$", "data", "instanceof", "Record", ")", "{", "$", "data", "=", "new", "Record", "(", "Utils", "::", "toArray", "(", "$", "data", ")", ")", ";", "}", ...
Stores record in database @param integer $index @param \org\majkel\dbase\Record|\Traversable|array $data @return void @throws Exception
[ "Stores", "record", "in", "database" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Table.php#L113-L122
train
majkel89/dbase
src/Table.php
Table.insert
public function insert($data) { if ($data instanceof Record) { $data = clone $data; } else { $data = new Record(Utils::toArray($data)); } return $this->getFormat()->insert($data); }
php
public function insert($data) { if ($data instanceof Record) { $data = clone $data; } else { $data = new Record(Utils::toArray($data)); } return $this->getFormat()->insert($data); }
[ "public", "function", "insert", "(", "$", "data", ")", "{", "if", "(", "$", "data", "instanceof", "Record", ")", "{", "$", "data", "=", "clone", "$", "data", ";", "}", "else", "{", "$", "data", "=", "new", "Record", "(", "Utils", "::", "toArray", ...
Adds new record to database @param \org\majkel\dbase\Record|\Traversable|array $data @return integer index of new record @throws Exception
[ "Adds", "new", "record", "to", "database" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Table.php#L130-L137
train
majkel89/dbase
src/Table.php
Table.getRecord
public function getRecord($index) { if (!$this->isValid()) { throw new Exception('File is not opened', Exception::FILE_NOT_OPENED); } if (!$this->offsetExists($index)) { throw new Exception('Offset '.strval($index).' does not exists', Exception::INVALID_OFFSET); } if (isset($this->buffer[$index])) { return $this->buffer[$index]; } $this->buffer = $this->getFormat()->getRecords($index, $this->getBufferSize()); return $this->buffer[$index]; }
php
public function getRecord($index) { if (!$this->isValid()) { throw new Exception('File is not opened', Exception::FILE_NOT_OPENED); } if (!$this->offsetExists($index)) { throw new Exception('Offset '.strval($index).' does not exists', Exception::INVALID_OFFSET); } if (isset($this->buffer[$index])) { return $this->buffer[$index]; } $this->buffer = $this->getFormat()->getRecords($index, $this->getBufferSize()); return $this->buffer[$index]; }
[ "public", "function", "getRecord", "(", "$", "index", ")", "{", "if", "(", "!", "$", "this", "->", "isValid", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'File is not opened'", ",", "Exception", "::", "FILE_NOT_OPENED", ")", ";", "}", "if", ...
Reads record from table @param integer $index @return \org\majkel\dbase\Record @throws \org\majkel\dbase\Exception
[ "Reads", "record", "from", "table" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Table.php#L193-L205
train
goaop/parser-reflection
src/ReflectionType.php
ReflectionType.convertToDisplayType
public static function convertToDisplayType(\ReflectionType $type) { static $typeMap = [ 'int' => 'integer', 'bool' => 'boolean' ]; $displayType = (string)$type; if (isset($typeMap[$displayType])) { $displayType = $typeMap[$displayType]; } $displayType = ltrim($displayType, '\\'); if ($type->allowsNull()) { $displayType .= ' or NULL'; } return $displayType; }
php
public static function convertToDisplayType(\ReflectionType $type) { static $typeMap = [ 'int' => 'integer', 'bool' => 'boolean' ]; $displayType = (string)$type; if (isset($typeMap[$displayType])) { $displayType = $typeMap[$displayType]; } $displayType = ltrim($displayType, '\\'); if ($type->allowsNull()) { $displayType .= ' or NULL'; } return $displayType; }
[ "public", "static", "function", "convertToDisplayType", "(", "\\", "ReflectionType", "$", "type", ")", "{", "static", "$", "typeMap", "=", "[", "'int'", "=>", "'integer'", ",", "'bool'", "=>", "'boolean'", "]", ";", "$", "displayType", "=", "(", "string", ...
PHP reflection has it's own rules, so 'int' type will be displayed as 'integer', etc... @see https://3v4l.org/nZFiT @param ReflectionType $type Type to display @return string
[ "PHP", "reflection", "has", "it", "s", "own", "rules", "so", "int", "type", "will", "be", "displayed", "as", "integer", "etc", "..." ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionType.php#L82-L100
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.getMethods
public function getMethods($filter = null) { if (!isset($this->methods)) { $directMethods = ReflectionMethod::collectFromClassNode($this->classLikeNode, $this); $parentMethods = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) { $reflectionMethods = []; foreach ($instance->getMethods() as $reflectionMethod) { if (!$isParent || !$reflectionMethod->isPrivate()) { $reflectionMethods[$reflectionMethod->name] = $reflectionMethod; } } $result += $reflectionMethods; }); $methods = $directMethods + $parentMethods; $this->methods = $methods; } if (!isset($filter)) { return array_values($this->methods); } $methods = []; foreach ($this->methods as $method) { if (!($filter & $method->getModifiers())) { continue; } $methods[] = $method; } return $methods; }
php
public function getMethods($filter = null) { if (!isset($this->methods)) { $directMethods = ReflectionMethod::collectFromClassNode($this->classLikeNode, $this); $parentMethods = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) { $reflectionMethods = []; foreach ($instance->getMethods() as $reflectionMethod) { if (!$isParent || !$reflectionMethod->isPrivate()) { $reflectionMethods[$reflectionMethod->name] = $reflectionMethod; } } $result += $reflectionMethods; }); $methods = $directMethods + $parentMethods; $this->methods = $methods; } if (!isset($filter)) { return array_values($this->methods); } $methods = []; foreach ($this->methods as $method) { if (!($filter & $method->getModifiers())) { continue; } $methods[] = $method; } return $methods; }
[ "public", "function", "getMethods", "(", "$", "filter", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "methods", ")", ")", "{", "$", "directMethods", "=", "ReflectionMethod", "::", "collectFromClassNode", "(", "$", "this", "->",...
Returns list of reflection methods @param null|integer $filter Optional filter @return array|\ReflectionMethod[]
[ "Returns", "list", "of", "reflection", "methods" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L346-L376
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.getModifiers
public function getModifiers() { $modifiers = 0; if ($this->isFinal()) { $modifiers += \ReflectionClass::IS_FINAL; } if (PHP_VERSION_ID < 70000 && $this->isTrait()) { $modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT; } if ($this->classLikeNode instanceof Class_ && $this->classLikeNode->isAbstract()) { $modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT; } if ($this->isInterface()) { $abstractMethods = $this->getMethods(); } else { $abstractMethods = $this->getMethods(\ReflectionMethod::IS_ABSTRACT); } if (!empty($abstractMethods)) { $modifiers += \ReflectionClass::IS_IMPLICIT_ABSTRACT; } return $modifiers; }
php
public function getModifiers() { $modifiers = 0; if ($this->isFinal()) { $modifiers += \ReflectionClass::IS_FINAL; } if (PHP_VERSION_ID < 70000 && $this->isTrait()) { $modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT; } if ($this->classLikeNode instanceof Class_ && $this->classLikeNode->isAbstract()) { $modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT; } if ($this->isInterface()) { $abstractMethods = $this->getMethods(); } else { $abstractMethods = $this->getMethods(\ReflectionMethod::IS_ABSTRACT); } if (!empty($abstractMethods)) { $modifiers += \ReflectionClass::IS_IMPLICIT_ABSTRACT; } return $modifiers; }
[ "public", "function", "getModifiers", "(", ")", "{", "$", "modifiers", "=", "0", ";", "if", "(", "$", "this", "->", "isFinal", "(", ")", ")", "{", "$", "modifiers", "+=", "\\", "ReflectionClass", "::", "IS_FINAL", ";", "}", "if", "(", "PHP_VERSION_ID",...
Returns a bitfield of the access modifiers for this class. @link http://php.net/manual/en/reflectionclass.getmodifiers.php NB: this method is not fully compatible with original value because of hidden internal constants @return int
[ "Returns", "a", "bitfield", "of", "the", "access", "modifiers", "for", "this", "class", "." ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L387-L413
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.getProperties
public function getProperties($filter = null) { if (!isset($this->properties)) { $directProperties = ReflectionProperty::collectFromClassNode($this->classLikeNode, $this->getName()); $parentProperties = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) { $reflectionProperties = []; foreach ($instance->getProperties() as $reflectionProperty) { if (!$isParent || !$reflectionProperty->isPrivate()) { $reflectionProperties[$reflectionProperty->name] = $reflectionProperty; } } $result += $reflectionProperties; }); $properties = $directProperties + $parentProperties; $this->properties = $properties; } // Without filter we can just return the full list if (!isset($filter)) { return array_values($this->properties); } $properties = []; foreach ($this->properties as $property) { if (!($filter & $property->getModifiers())) { continue; } $properties[] = $property; } return $properties; }
php
public function getProperties($filter = null) { if (!isset($this->properties)) { $directProperties = ReflectionProperty::collectFromClassNode($this->classLikeNode, $this->getName()); $parentProperties = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) { $reflectionProperties = []; foreach ($instance->getProperties() as $reflectionProperty) { if (!$isParent || !$reflectionProperty->isPrivate()) { $reflectionProperties[$reflectionProperty->name] = $reflectionProperty; } } $result += $reflectionProperties; }); $properties = $directProperties + $parentProperties; $this->properties = $properties; } // Without filter we can just return the full list if (!isset($filter)) { return array_values($this->properties); } $properties = []; foreach ($this->properties as $property) { if (!($filter & $property->getModifiers())) { continue; } $properties[] = $property; } return $properties; }
[ "public", "function", "getProperties", "(", "$", "filter", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "properties", ")", ")", "{", "$", "directProperties", "=", "ReflectionProperty", "::", "collectFromClassNode", "(", "$", "thi...
Retrieves reflected properties. @param int $filter The optional filter, for filtering desired property types. It's configured using the ReflectionProperty constants, and defaults to all property types. @return array|\Go\ParserReflection\ReflectionProperty[]
[ "Retrieves", "reflected", "properties", "." ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L462-L494
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.getTraitAliases
public function getTraitAliases() { $aliases = []; $traits = $this->getTraits(); foreach ($this->traitAdaptations as $adaptation) { if ($adaptation instanceof TraitUseAdaptation\Alias) { $methodName = $adaptation->method; $traitName = null; foreach ($traits as $trait) { if ($trait->hasMethod($methodName)) { $traitName = $trait->getName(); break; } } $aliases[$adaptation->newName] = $traitName . '::'. $methodName; } } return $aliases; }
php
public function getTraitAliases() { $aliases = []; $traits = $this->getTraits(); foreach ($this->traitAdaptations as $adaptation) { if ($adaptation instanceof TraitUseAdaptation\Alias) { $methodName = $adaptation->method; $traitName = null; foreach ($traits as $trait) { if ($trait->hasMethod($methodName)) { $traitName = $trait->getName(); break; } } $aliases[$adaptation->newName] = $traitName . '::'. $methodName; } } return $aliases; }
[ "public", "function", "getTraitAliases", "(", ")", "{", "$", "aliases", "=", "[", "]", ";", "$", "traits", "=", "$", "this", "->", "getTraits", "(", ")", ";", "foreach", "(", "$", "this", "->", "traitAdaptations", "as", "$", "adaptation", ")", "{", "...
Returns an array of trait aliases @link http://php.net/manual/en/reflectionclass.gettraitaliases.php @return array|null an array with new method names in keys and original names (in the format "TraitName::original") in values.
[ "Returns", "an", "array", "of", "trait", "aliases" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L532-L551
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.getTraits
public function getTraits() { if (!isset($this->traits)) { $traitAdaptations = []; $this->traits = ReflectionClass::collectTraitsFromClassNode($this->classLikeNode, $traitAdaptations); $this->traitAdaptations = $traitAdaptations; } return $this->traits; }
php
public function getTraits() { if (!isset($this->traits)) { $traitAdaptations = []; $this->traits = ReflectionClass::collectTraitsFromClassNode($this->classLikeNode, $traitAdaptations); $this->traitAdaptations = $traitAdaptations; } return $this->traits; }
[ "public", "function", "getTraits", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "traits", ")", ")", "{", "$", "traitAdaptations", "=", "[", "]", ";", "$", "this", "->", "traits", "=", "ReflectionClass", "::", "collectTraitsFromClassNod...
Returns an array of traits used by this class @link http://php.net/manual/en/reflectionclass.gettraits.php @return array|\ReflectionClass[]
[ "Returns", "an", "array", "of", "traits", "used", "by", "this", "class" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L572-L581
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.getStaticProperties
public function getStaticProperties() { // In runtime static properties can be changed in any time if ($this->isInitialized()) { return parent::getStaticProperties(); } $properties = []; $reflectionProperties = $this->getProperties(ReflectionProperty::IS_STATIC); foreach ($reflectionProperties as $reflectionProperty) { if (!$reflectionProperty instanceof ReflectionProperty) { if (!$reflectionProperty->isPublic()) { $reflectionProperty->setAccessible(true); } } $properties[$reflectionProperty->getName()] = $reflectionProperty->getValue(); } return $properties; }
php
public function getStaticProperties() { // In runtime static properties can be changed in any time if ($this->isInitialized()) { return parent::getStaticProperties(); } $properties = []; $reflectionProperties = $this->getProperties(ReflectionProperty::IS_STATIC); foreach ($reflectionProperties as $reflectionProperty) { if (!$reflectionProperty instanceof ReflectionProperty) { if (!$reflectionProperty->isPublic()) { $reflectionProperty->setAccessible(true); } } $properties[$reflectionProperty->getName()] = $reflectionProperty->getValue(); } return $properties; }
[ "public", "function", "getStaticProperties", "(", ")", "{", "// In runtime static properties can be changed in any time", "if", "(", "$", "this", "->", "isInitialized", "(", ")", ")", "{", "return", "parent", "::", "getStaticProperties", "(", ")", ";", "}", "$", "...
Gets static properties @link http://php.net/manual/en/reflectionclass.getstaticproperties.php @return array
[ "Gets", "static", "properties" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L799-L819
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.getStaticPropertyValue
public function getStaticPropertyValue($name, $default = null) { $properties = $this->getStaticProperties(); $propertyExists = array_key_exists($name, $properties); if (!$propertyExists && func_num_args() === 1) { throw new ReflectionException("Static property does not exist and no default value is given"); } return $propertyExists ? $properties[$name] : $default; }
php
public function getStaticPropertyValue($name, $default = null) { $properties = $this->getStaticProperties(); $propertyExists = array_key_exists($name, $properties); if (!$propertyExists && func_num_args() === 1) { throw new ReflectionException("Static property does not exist and no default value is given"); } return $propertyExists ? $properties[$name] : $default; }
[ "public", "function", "getStaticPropertyValue", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "properties", "=", "$", "this", "->", "getStaticProperties", "(", ")", ";", "$", "propertyExists", "=", "array_key_exists", "(", "$", "name", ...
Gets static property value @param string $name The name of the static property for which to return a value. @param mixed $default A default value to return in case the class does not declare a static property with the given name @return mixed @throws ReflectionException If there is no such property and no default value was given
[ "Gets", "static", "property", "value" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L831-L841
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.newInstance
public function newInstance($arg = null, ...$args) { $args = array_slice(array_merge([$arg], $args), 0, \func_num_args()); $this->initializeInternalReflection(); return parent::newInstance(...$args); }
php
public function newInstance($arg = null, ...$args) { $args = array_slice(array_merge([$arg], $args), 0, \func_num_args()); $this->initializeInternalReflection(); return parent::newInstance(...$args); }
[ "public", "function", "newInstance", "(", "$", "arg", "=", "null", ",", "...", "$", "args", ")", "{", "$", "args", "=", "array_slice", "(", "array_merge", "(", "[", "$", "arg", "]", ",", "$", "args", ")", ",", "0", ",", "\\", "func_num_args", "(", ...
Creates a new class instance from given arguments. @link http://php.net/manual/en/reflectionclass.newinstance.php Signature was hacked to support both 5.6, 7.1.x and 7.2.0 versions @see https://3v4l.org/hW9O9 @see https://3v4l.org/sWT3j @see https://3v4l.org/eeVf8 @param mixed $arg First argument @param mixed $args Accepts a variable number of arguments which are passed to the class constructor @return object
[ "Creates", "a", "new", "class", "instance", "from", "given", "arguments", "." ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L859-L865
train
goaop/parser-reflection
src/Traits/ReflectionClassLikeTrait.php
ReflectionClassLikeTrait.collectSelfConstants
private function collectSelfConstants() { $expressionSolver = new NodeExpressionResolver($this); $localConstants = []; // constants can be only top-level nodes in the class, so we can scan them directly foreach ($this->classLikeNode->stmts as $classLevelNode) { if ($classLevelNode instanceof ClassConst) { $nodeConstants = $classLevelNode->consts; if (!empty($nodeConstants)) { foreach ($nodeConstants as $nodeConstant) { $expressionSolver->process($nodeConstant->value); $localConstants[$nodeConstant->name->toString()] = $expressionSolver->getValue(); $this->constants = $localConstants + $this->constants; } } } } }
php
private function collectSelfConstants() { $expressionSolver = new NodeExpressionResolver($this); $localConstants = []; // constants can be only top-level nodes in the class, so we can scan them directly foreach ($this->classLikeNode->stmts as $classLevelNode) { if ($classLevelNode instanceof ClassConst) { $nodeConstants = $classLevelNode->consts; if (!empty($nodeConstants)) { foreach ($nodeConstants as $nodeConstant) { $expressionSolver->process($nodeConstant->value); $localConstants[$nodeConstant->name->toString()] = $expressionSolver->getValue(); $this->constants = $localConstants + $this->constants; } } } } }
[ "private", "function", "collectSelfConstants", "(", ")", "{", "$", "expressionSolver", "=", "new", "NodeExpressionResolver", "(", "$", "this", ")", ";", "$", "localConstants", "=", "[", "]", ";", "// constants can be only top-level nodes in the class, so we can scan them ...
Collects list of constants from the class itself
[ "Collects", "list", "of", "constants", "from", "the", "class", "itself" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L940-L958
train
goaop/parser-reflection
src/ReflectionMethod.php
ReflectionMethod.collectFromClassNode
public static function collectFromClassNode(ClassLike $classLikeNode, ReflectionClass $reflectionClass) { $methods = []; foreach ($classLikeNode->stmts as $classLevelNode) { if ($classLevelNode instanceof ClassMethod) { $classLevelNode->setAttribute('fileName', $classLikeNode->getAttribute('fileName')); $methodName = $classLevelNode->name->toString(); $methods[$methodName] = new ReflectionMethod( $reflectionClass->name, $methodName, $classLevelNode, $reflectionClass ); } } return $methods; }
php
public static function collectFromClassNode(ClassLike $classLikeNode, ReflectionClass $reflectionClass) { $methods = []; foreach ($classLikeNode->stmts as $classLevelNode) { if ($classLevelNode instanceof ClassMethod) { $classLevelNode->setAttribute('fileName', $classLikeNode->getAttribute('fileName')); $methodName = $classLevelNode->name->toString(); $methods[$methodName] = new ReflectionMethod( $reflectionClass->name, $methodName, $classLevelNode, $reflectionClass ); } } return $methods; }
[ "public", "static", "function", "collectFromClassNode", "(", "ClassLike", "$", "classLikeNode", ",", "ReflectionClass", "$", "reflectionClass", ")", "{", "$", "methods", "=", "[", "]", ";", "foreach", "(", "$", "classLikeNode", "->", "stmts", "as", "$", "class...
Parses methods from the concrete class node @param ClassLike $classLikeNode Class-like node @param ReflectionClass $reflectionClass Reflection of the class @return array|ReflectionMethod[]
[ "Parses", "methods", "from", "the", "concrete", "class", "node" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionMethod.php#L304-L323
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.getClasses
public function getClasses() { if (!isset($this->fileClasses)) { $this->fileClasses = $this->findClasses(); } return $this->fileClasses; }
php
public function getClasses() { if (!isset($this->fileClasses)) { $this->fileClasses = $this->findClasses(); } return $this->fileClasses; }
[ "public", "function", "getClasses", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "fileClasses", ")", ")", "{", "$", "this", "->", "fileClasses", "=", "$", "this", "->", "findClasses", "(", ")", ";", "}", "return", "$", "this", "-...
Gets list of classes in the namespace @return ReflectionClass[]|array
[ "Gets", "list", "of", "classes", "in", "the", "namespace" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L125-L132
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.getConstants
public function getConstants($withDefined = false) { if ($withDefined) { if (!isset($this->fileConstantsWithDefined)) { $this->fileConstantsWithDefined = $this->findConstants(true); } return $this->fileConstantsWithDefined; } if (!isset($this->fileConstants)) { $this->fileConstants = $this->findConstants(); } return $this->fileConstants; }
php
public function getConstants($withDefined = false) { if ($withDefined) { if (!isset($this->fileConstantsWithDefined)) { $this->fileConstantsWithDefined = $this->findConstants(true); } return $this->fileConstantsWithDefined; } if (!isset($this->fileConstants)) { $this->fileConstants = $this->findConstants(); } return $this->fileConstants; }
[ "public", "function", "getConstants", "(", "$", "withDefined", "=", "false", ")", "{", "if", "(", "$", "withDefined", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "fileConstantsWithDefined", ")", ")", "{", "$", "this", "->", "fileConstantsW...
Returns a list of defined constants in the namespace @param bool $withDefined Include constants defined via "define(...)" in results. @return array
[ "Returns", "a", "list", "of", "defined", "constants", "in", "the", "namespace" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L157-L172
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.getDocComment
public function getDocComment() { $docComment = false; $comments = $this->namespaceNode->getAttribute('comments'); if ($comments) { $docComment = (string)$comments[0]; } return $docComment; }
php
public function getDocComment() { $docComment = false; $comments = $this->namespaceNode->getAttribute('comments'); if ($comments) { $docComment = (string)$comments[0]; } return $docComment; }
[ "public", "function", "getDocComment", "(", ")", "{", "$", "docComment", "=", "false", ";", "$", "comments", "=", "$", "this", "->", "namespaceNode", "->", "getAttribute", "(", "'comments'", ")", ";", "if", "(", "$", "comments", ")", "{", "$", "docCommen...
Gets doc comments from a class. @return string|false The doc comment if it exists, otherwise "false"
[ "Gets", "doc", "comments", "from", "a", "class", "." ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L179-L189
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.getFunctions
public function getFunctions() { if (!isset($this->fileFunctions)) { $this->fileFunctions = $this->findFunctions(); } return $this->fileFunctions; }
php
public function getFunctions() { if (!isset($this->fileFunctions)) { $this->fileFunctions = $this->findFunctions(); } return $this->fileFunctions; }
[ "public", "function", "getFunctions", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "fileFunctions", ")", ")", "{", "$", "this", "->", "fileFunctions", "=", "$", "this", "->", "findFunctions", "(", ")", ";", "}", "return", "$", "thi...
Gets list of functions in the namespace @return ReflectionFunction[]|array
[ "Gets", "list", "of", "functions", "in", "the", "namespace" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L232-L239
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.getNamespaceAliases
public function getNamespaceAliases() { if (!isset($this->fileNamespaceAliases)) { $this->fileNamespaceAliases = $this->findNamespaceAliases(); } return $this->fileNamespaceAliases; }
php
public function getNamespaceAliases() { if (!isset($this->fileNamespaceAliases)) { $this->fileNamespaceAliases = $this->findNamespaceAliases(); } return $this->fileNamespaceAliases; }
[ "public", "function", "getNamespaceAliases", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "fileNamespaceAliases", ")", ")", "{", "$", "this", "->", "fileNamespaceAliases", "=", "$", "this", "->", "findNamespaceAliases", "(", ")", ";", "}...
Returns a list of namespace aliases @return array
[ "Returns", "a", "list", "of", "namespace", "aliases" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L258-L265
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.getLastTokenPosition
public function getLastTokenPosition() { $endNamespaceTokenPosition = $this->namespaceNode->getAttribute('endTokenPos'); /** @var Node $lastNamespaceNode */ $lastNamespaceNode = end($this->namespaceNode->stmts); $endStatementTokenPosition = $lastNamespaceNode->getAttribute('endTokenPos'); return max($endNamespaceTokenPosition, $endStatementTokenPosition); }
php
public function getLastTokenPosition() { $endNamespaceTokenPosition = $this->namespaceNode->getAttribute('endTokenPos'); /** @var Node $lastNamespaceNode */ $lastNamespaceNode = end($this->namespaceNode->stmts); $endStatementTokenPosition = $lastNamespaceNode->getAttribute('endTokenPos'); return max($endNamespaceTokenPosition, $endStatementTokenPosition); }
[ "public", "function", "getLastTokenPosition", "(", ")", "{", "$", "endNamespaceTokenPosition", "=", "$", "this", "->", "namespaceNode", "->", "getAttribute", "(", "'endTokenPos'", ")", ";", "/** @var Node $lastNamespaceNode */", "$", "lastNamespaceNode", "=", "end", "...
Helper method to access last token position for namespace This method is useful because namespace can be declared with braces or without them
[ "Helper", "method", "to", "access", "last", "token", "position", "for", "namespace" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L282-L291
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.findClasses
private function findClasses() { $classes = array(); $namespaceName = $this->getName(); // classes can be only top-level nodes in the namespace, so we can scan them directly foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof ClassLike) { $classShortName = $namespaceLevelNode->name->toString(); $className = $namespaceName ? $namespaceName .'\\' . $classShortName : $classShortName; $namespaceLevelNode->setAttribute('fileName', $this->fileName); $classes[$className] = new ReflectionClass($className, $namespaceLevelNode); } } return $classes; }
php
private function findClasses() { $classes = array(); $namespaceName = $this->getName(); // classes can be only top-level nodes in the namespace, so we can scan them directly foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof ClassLike) { $classShortName = $namespaceLevelNode->name->toString(); $className = $namespaceName ? $namespaceName .'\\' . $classShortName : $classShortName; $namespaceLevelNode->setAttribute('fileName', $this->fileName); $classes[$className] = new ReflectionClass($className, $namespaceLevelNode); } } return $classes; }
[ "private", "function", "findClasses", "(", ")", "{", "$", "classes", "=", "array", "(", ")", ";", "$", "namespaceName", "=", "$", "this", "->", "getName", "(", ")", ";", "// classes can be only top-level nodes in the namespace, so we can scan them directly", "foreach"...
Searches for classes in the given AST @return array|ReflectionClass[]
[ "Searches", "for", "classes", "in", "the", "given", "AST" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L350-L366
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.findFunctions
private function findFunctions() { $functions = array(); $namespaceName = $this->getName(); // functions can be only top-level nodes in the namespace, so we can scan them directly foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof Function_) { $funcShortName = $namespaceLevelNode->name->toString(); $functionName = $namespaceName ? $namespaceName .'\\' . $funcShortName : $funcShortName; $namespaceLevelNode->setAttribute('fileName', $this->fileName); $functions[$funcShortName] = new ReflectionFunction($functionName, $namespaceLevelNode); } } return $functions; }
php
private function findFunctions() { $functions = array(); $namespaceName = $this->getName(); // functions can be only top-level nodes in the namespace, so we can scan them directly foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof Function_) { $funcShortName = $namespaceLevelNode->name->toString(); $functionName = $namespaceName ? $namespaceName .'\\' . $funcShortName : $funcShortName; $namespaceLevelNode->setAttribute('fileName', $this->fileName); $functions[$funcShortName] = new ReflectionFunction($functionName, $namespaceLevelNode); } } return $functions; }
[ "private", "function", "findFunctions", "(", ")", "{", "$", "functions", "=", "array", "(", ")", ";", "$", "namespaceName", "=", "$", "this", "->", "getName", "(", ")", ";", "// functions can be only top-level nodes in the namespace, so we can scan them directly", "fo...
Searches for functions in the given AST @return array
[ "Searches", "for", "functions", "in", "the", "given", "AST" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L373-L390
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.findConstants
private function findConstants($withDefined = false) { $constants = array(); $expressionSolver = new NodeExpressionResolver($this); // constants can be only top-level nodes in the namespace, so we can scan them directly foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof Const_) { $nodeConstants = $namespaceLevelNode->consts; if (!empty($nodeConstants)) { foreach ($nodeConstants as $nodeConstant) { $expressionSolver->process($nodeConstant->value); $constants[$nodeConstant->name->toString()] = $expressionSolver->getValue(); } } } } if ($withDefined) { foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof Expression && $namespaceLevelNode->expr instanceof FuncCall && $namespaceLevelNode->expr->name instanceof Name && (string)$namespaceLevelNode->expr->name === 'define' ) { $functionCallNode = $namespaceLevelNode->expr; $expressionSolver->process($functionCallNode->args[0]->value); $constantName = $expressionSolver->getValue(); // Ignore constants, for which name can't be determined. if (strlen($constantName)) { $expressionSolver->process($functionCallNode->args[1]->value); $constantValue = $expressionSolver->getValue(); $constants[$constantName] = $constantValue; } } } } return $constants; }
php
private function findConstants($withDefined = false) { $constants = array(); $expressionSolver = new NodeExpressionResolver($this); // constants can be only top-level nodes in the namespace, so we can scan them directly foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof Const_) { $nodeConstants = $namespaceLevelNode->consts; if (!empty($nodeConstants)) { foreach ($nodeConstants as $nodeConstant) { $expressionSolver->process($nodeConstant->value); $constants[$nodeConstant->name->toString()] = $expressionSolver->getValue(); } } } } if ($withDefined) { foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof Expression && $namespaceLevelNode->expr instanceof FuncCall && $namespaceLevelNode->expr->name instanceof Name && (string)$namespaceLevelNode->expr->name === 'define' ) { $functionCallNode = $namespaceLevelNode->expr; $expressionSolver->process($functionCallNode->args[0]->value); $constantName = $expressionSolver->getValue(); // Ignore constants, for which name can't be determined. if (strlen($constantName)) { $expressionSolver->process($functionCallNode->args[1]->value); $constantValue = $expressionSolver->getValue(); $constants[$constantName] = $constantValue; } } } } return $constants; }
[ "private", "function", "findConstants", "(", "$", "withDefined", "=", "false", ")", "{", "$", "constants", "=", "array", "(", ")", ";", "$", "expressionSolver", "=", "new", "NodeExpressionResolver", "(", "$", "this", ")", ";", "// constants can be only top-level...
Searches for constants in the given AST @param bool $withDefined Include constants defined via "define(...)" in results. @return array
[ "Searches", "for", "constants", "in", "the", "given", "AST" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L399-L440
train
goaop/parser-reflection
src/ReflectionFileNamespace.php
ReflectionFileNamespace.findNamespaceAliases
private function findNamespaceAliases() { $namespaceAliases = []; // aliases can be only top-level nodes in the namespace, so we can scan them directly foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof Use_) { $useAliases = $namespaceLevelNode->uses; if (!empty($useAliases)) { foreach ($useAliases as $useNode) { $namespaceAliases[$useNode->name->toString()] = $useNode->alias; } } } } return $namespaceAliases; }
php
private function findNamespaceAliases() { $namespaceAliases = []; // aliases can be only top-level nodes in the namespace, so we can scan them directly foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { if ($namespaceLevelNode instanceof Use_) { $useAliases = $namespaceLevelNode->uses; if (!empty($useAliases)) { foreach ($useAliases as $useNode) { $namespaceAliases[$useNode->name->toString()] = $useNode->alias; } } } } return $namespaceAliases; }
[ "private", "function", "findNamespaceAliases", "(", ")", "{", "$", "namespaceAliases", "=", "[", "]", ";", "// aliases can be only top-level nodes in the namespace, so we can scan them directly", "foreach", "(", "$", "this", "->", "namespaceNode", "->", "stmts", "as", "$"...
Searchse for namespace aliases for the current block @return array
[ "Searchse", "for", "namespace", "aliases", "for", "the", "current", "block" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L447-L464
train
goaop/parser-reflection
src/Traits/ReflectionFunctionLikeTrait.php
ReflectionFunctionLikeTrait.getReturnType
public function getReturnType() { $isBuiltin = false; $returnType = $this->functionLikeNode->getReturnType(); $isNullable = $returnType instanceof NullableType; if ($isNullable) { $returnType = $returnType->type; } if ($returnType instanceof Identifier) { $isBuiltin = true; $returnType = $returnType->toString(); } elseif (is_object($returnType)) { $returnType = $returnType->toString(); } elseif (is_string($returnType)) { $isBuiltin = true; } else { return null; } return new ReflectionType($returnType, $isNullable, $isBuiltin); }
php
public function getReturnType() { $isBuiltin = false; $returnType = $this->functionLikeNode->getReturnType(); $isNullable = $returnType instanceof NullableType; if ($isNullable) { $returnType = $returnType->type; } if ($returnType instanceof Identifier) { $isBuiltin = true; $returnType = $returnType->toString(); } elseif (is_object($returnType)) { $returnType = $returnType->toString(); } elseif (is_string($returnType)) { $isBuiltin = true; } else { return null; } return new ReflectionType($returnType, $isNullable, $isBuiltin); }
[ "public", "function", "getReturnType", "(", ")", "{", "$", "isBuiltin", "=", "false", ";", "$", "returnType", "=", "$", "this", "->", "functionLikeNode", "->", "getReturnType", "(", ")", ";", "$", "isNullable", "=", "$", "returnType", "instanceof", "Nullable...
Gets the specified return type of a function @return \ReflectionType @link http://php.net/manual/en/reflectionfunctionabstract.getreturntype.php
[ "Gets", "the", "specified", "return", "type", "of", "a", "function" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionFunctionLikeTrait.php#L182-L203
train
goaop/parser-reflection
src/ValueResolver/NodeExpressionResolver.php
NodeExpressionResolver.resolve
protected function resolve(Node $node) { $value = null; try { ++$this->nodeLevel; $methodName = $this->getDispatchMethodFor($node); if (method_exists($this, $methodName)) { $value = $this->$methodName($node); } } finally { --$this->nodeLevel; } return $value; }
php
protected function resolve(Node $node) { $value = null; try { ++$this->nodeLevel; $methodName = $this->getDispatchMethodFor($node); if (method_exists($this, $methodName)) { $value = $this->$methodName($node); } } finally { --$this->nodeLevel; } return $value; }
[ "protected", "function", "resolve", "(", "Node", "$", "node", ")", "{", "$", "value", "=", "null", ";", "try", "{", "++", "$", "this", "->", "nodeLevel", ";", "$", "methodName", "=", "$", "this", "->", "getDispatchMethodFor", "(", "$", "node", ")", "...
Resolves node into valid value @param Node $node @return mixed
[ "Resolves", "node", "into", "valid", "value" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ValueResolver/NodeExpressionResolver.php#L115-L130
train
goaop/parser-reflection
src/ValueResolver/NodeExpressionResolver.php
NodeExpressionResolver.fetchReflectionClass
private function fetchReflectionClass(Node\Name $node) { $className = $node->toString(); $isFQNClass = $node instanceof Node\Name\FullyQualified; if ($isFQNClass) { // check to see if the class is already loaded and is safe to use // PHP's ReflectionClass to determine if the class is user defined if (class_exists($className, false)) { $refClass = new \ReflectionClass($className); if (!$refClass->isUserDefined()) { return $refClass; } } return new ReflectionClass($className); } if ('self' === $className) { if ($this->context instanceof \ReflectionClass) { return $this->context; } elseif (method_exists($this->context, 'getDeclaringClass')) { return $this->context->getDeclaringClass(); } } if ('parent' === $className) { if ($this->context instanceof \ReflectionClass) { return $this->context->getParentClass(); } elseif (method_exists($this->context, 'getDeclaringClass')) { return $this->context->getDeclaringClass()->getParentClass(); } } if (method_exists($this->context, 'getFileName')) { /** @var ReflectionFileNamespace|null $fileNamespace */ $fileName = $this->context->getFileName(); $namespaceName = $this->resolveScalarMagicConstNamespace(); $fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName); return $fileNamespace->getClass($className); } throw new ReflectionException("Can not resolve class $className"); }
php
private function fetchReflectionClass(Node\Name $node) { $className = $node->toString(); $isFQNClass = $node instanceof Node\Name\FullyQualified; if ($isFQNClass) { // check to see if the class is already loaded and is safe to use // PHP's ReflectionClass to determine if the class is user defined if (class_exists($className, false)) { $refClass = new \ReflectionClass($className); if (!$refClass->isUserDefined()) { return $refClass; } } return new ReflectionClass($className); } if ('self' === $className) { if ($this->context instanceof \ReflectionClass) { return $this->context; } elseif (method_exists($this->context, 'getDeclaringClass')) { return $this->context->getDeclaringClass(); } } if ('parent' === $className) { if ($this->context instanceof \ReflectionClass) { return $this->context->getParentClass(); } elseif (method_exists($this->context, 'getDeclaringClass')) { return $this->context->getDeclaringClass()->getParentClass(); } } if (method_exists($this->context, 'getFileName')) { /** @var ReflectionFileNamespace|null $fileNamespace */ $fileName = $this->context->getFileName(); $namespaceName = $this->resolveScalarMagicConstNamespace(); $fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName); return $fileNamespace->getClass($className); } throw new ReflectionException("Can not resolve class $className"); }
[ "private", "function", "fetchReflectionClass", "(", "Node", "\\", "Name", "$", "node", ")", "{", "$", "className", "=", "$", "node", "->", "toString", "(", ")", ";", "$", "isFQNClass", "=", "$", "node", "instanceof", "Node", "\\", "Name", "\\", "FullyQua...
Utility method to fetch reflection class instance by name Supports: 'self' keyword 'parent' keyword not-FQN class names @param Node\Name $node Class name node @return bool|\ReflectionClass @throws ReflectionException
[ "Utility", "method", "to", "fetch", "reflection", "class", "instance", "by", "name" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ValueResolver/NodeExpressionResolver.php#L471-L513
train
majkel89/dbase
src/Field.php
Field.removeFilter
public function removeFilter($indexOrFilter) { if (is_scalar($indexOrFilter)) { unset($this->filters[$indexOrFilter]); } else if ($indexOrFilter instanceof FilterInterface) { foreach ($this->filters as $i => $filter) { if ($filter === $indexOrFilter) { unset($this->filters[$i]); } } } return $this; }
php
public function removeFilter($indexOrFilter) { if (is_scalar($indexOrFilter)) { unset($this->filters[$indexOrFilter]); } else if ($indexOrFilter instanceof FilterInterface) { foreach ($this->filters as $i => $filter) { if ($filter === $indexOrFilter) { unset($this->filters[$i]); } } } return $this; }
[ "public", "function", "removeFilter", "(", "$", "indexOrFilter", ")", "{", "if", "(", "is_scalar", "(", "$", "indexOrFilter", ")", ")", "{", "unset", "(", "$", "this", "->", "filters", "[", "$", "indexOrFilter", "]", ")", ";", "}", "else", "if", "(", ...
Removes filter at index or by object @param integer $indexOrFilter @return \org\majkel\dbase\Field
[ "Removes", "filter", "at", "index", "or", "by", "object" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L89-L100
train
majkel89/dbase
src/Field.php
Field.setName
public function setName($name) { if (strlen($name) > self::MAX_NAME_LENGTH) { throw new Exception("Field name cannot be longer than ".self::MAX_NAME_LENGTH." characters"); } $this->name = $name; return $this; }
php
public function setName($name) { if (strlen($name) > self::MAX_NAME_LENGTH) { throw new Exception("Field name cannot be longer than ".self::MAX_NAME_LENGTH." characters"); } $this->name = $name; return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "if", "(", "strlen", "(", "$", "name", ")", ">", "self", "::", "MAX_NAME_LENGTH", ")", "{", "throw", "new", "Exception", "(", "\"Field name cannot be longer than \"", ".", "self", "::", "MAX_NAME_L...
Sets filed name @param string $name @return \org\majkel\dbase\Field @throws \org\majkel\dbase\Exception
[ "Sets", "filed", "name" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L118-L124
train
majkel89/dbase
src/Field.php
Field.unserialize
public function unserialize($data) { $value = $this->fromData($data); foreach ($this->getFilters() as $filter) { $value = $filter->toValue($value); } return $value; }
php
public function unserialize($data) { $value = $this->fromData($data); foreach ($this->getFilters() as $filter) { $value = $filter->toValue($value); } return $value; }
[ "public", "function", "unserialize", "(", "$", "data", ")", "{", "$", "value", "=", "$", "this", "->", "fromData", "(", "$", "data", ")", ";", "foreach", "(", "$", "this", "->", "getFilters", "(", ")", "as", "$", "filter", ")", "{", "$", "value", ...
Constructs value from raw data and applies filters @param string $data @return mixed
[ "Constructs", "value", "from", "raw", "data", "and", "applies", "filters" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L185-L191
train
majkel89/dbase
src/Field.php
Field.serialize
public function serialize($value) { $filters = $this->getFilters(); for ($i = count($filters) - 1; $i >= 0; --$i) { $value = $filters[$i]->fromValue($value); } return $this->toData($value); }
php
public function serialize($value) { $filters = $this->getFilters(); for ($i = count($filters) - 1; $i >= 0; --$i) { $value = $filters[$i]->fromValue($value); } return $this->toData($value); }
[ "public", "function", "serialize", "(", "$", "value", ")", "{", "$", "filters", "=", "$", "this", "->", "getFilters", "(", ")", ";", "for", "(", "$", "i", "=", "count", "(", "$", "filters", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "--", ...
Applies filters and converts value to raw data @param mixed $value @return string
[ "Applies", "filters", "and", "converts", "value", "to", "raw", "data" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L198-L204
train
majkel89/dbase
src/Field.php
Field.create
public static function create($type) { switch ($type) { case Field::TYPE_CHARACTER: return new field\CharacterField; case Field::TYPE_DATE: return new field\DateField; case Field::TYPE_LOGICAL: return new field\LogicalField; case Field::TYPE_MEMO: return new field\MemoField; case Field::TYPE_NUMERIC: return new field\NumericField; default: throw new Exception("Unsupported field `$type`"); } }
php
public static function create($type) { switch ($type) { case Field::TYPE_CHARACTER: return new field\CharacterField; case Field::TYPE_DATE: return new field\DateField; case Field::TYPE_LOGICAL: return new field\LogicalField; case Field::TYPE_MEMO: return new field\MemoField; case Field::TYPE_NUMERIC: return new field\NumericField; default: throw new Exception("Unsupported field `$type`"); } }
[ "public", "static", "function", "create", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "Field", "::", "TYPE_CHARACTER", ":", "return", "new", "field", "\\", "CharacterField", ";", "case", "Field", "::", "TYPE_DATE", ":", "ret...
Constructs Filed based on type @param string $type @return \org\majkel\dbase\Field @throws Exception
[ "Constructs", "Filed", "based", "on", "type" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L240-L255
train
majkel89/dbase
src/Field.php
Field.getTypes
public static function getTypes() { return array( self::TYPE_CHARACTER, self::TYPE_LOGICAL, self::TYPE_DATE , self::TYPE_NUMERIC, self::TYPE_MEMO, ); }
php
public static function getTypes() { return array( self::TYPE_CHARACTER, self::TYPE_LOGICAL, self::TYPE_DATE , self::TYPE_NUMERIC, self::TYPE_MEMO, ); }
[ "public", "static", "function", "getTypes", "(", ")", "{", "return", "array", "(", "self", "::", "TYPE_CHARACTER", ",", "self", "::", "TYPE_LOGICAL", ",", "self", "::", "TYPE_DATE", ",", "self", "::", "TYPE_NUMERIC", ",", "self", "::", "TYPE_MEMO", ",", ")...
Returns all supported types @return integer[]
[ "Returns", "all", "supported", "types" ]
483f27e83bae5323817c26aa297d923a4231dd6f
https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L261-L269
train
goaop/parser-reflection
src/ReflectionClass.php
ReflectionClass.collectInterfacesFromClassNode
public static function collectInterfacesFromClassNode(ClassLike $classLikeNode) { $interfaces = []; $isInterface = $classLikeNode instanceof Interface_; $interfaceField = $isInterface ? 'extends' : 'implements'; $hasInterfaces = in_array($interfaceField, $classLikeNode->getSubNodeNames()); $implementsList = $hasInterfaces ? $classLikeNode->$interfaceField : array(); if ($implementsList) { foreach ($implementsList as $implementNode) { if ($implementNode instanceof FullyQualified) { $implementName = $implementNode->toString(); $interface = interface_exists($implementName, false) ? new parent($implementName) : new static($implementName); $interfaces[$implementName] = $interface; } } } return $interfaces; }
php
public static function collectInterfacesFromClassNode(ClassLike $classLikeNode) { $interfaces = []; $isInterface = $classLikeNode instanceof Interface_; $interfaceField = $isInterface ? 'extends' : 'implements'; $hasInterfaces = in_array($interfaceField, $classLikeNode->getSubNodeNames()); $implementsList = $hasInterfaces ? $classLikeNode->$interfaceField : array(); if ($implementsList) { foreach ($implementsList as $implementNode) { if ($implementNode instanceof FullyQualified) { $implementName = $implementNode->toString(); $interface = interface_exists($implementName, false) ? new parent($implementName) : new static($implementName); $interfaces[$implementName] = $interface; } } } return $interfaces; }
[ "public", "static", "function", "collectInterfacesFromClassNode", "(", "ClassLike", "$", "classLikeNode", ")", "{", "$", "interfaces", "=", "[", "]", ";", "$", "isInterface", "=", "$", "classLikeNode", "instanceof", "Interface_", ";", "$", "interfaceField", "=", ...
Parses interfaces from the concrete class node @param ClassLike $classLikeNode Class-like node @return array|\ReflectionClass[] List of reflections of interfaces
[ "Parses", "interfaces", "from", "the", "concrete", "class", "node" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionClass.php#L54-L75
train
goaop/parser-reflection
src/ReflectionClass.php
ReflectionClass.collectTraitsFromClassNode
public static function collectTraitsFromClassNode(ClassLike $classLikeNode, array &$traitAdaptations) { $traits = []; if (!empty($classLikeNode->stmts)) { foreach ($classLikeNode->stmts as $classLevelNode) { if ($classLevelNode instanceof TraitUse) { foreach ($classLevelNode->traits as $classTraitName) { if ($classTraitName instanceof FullyQualified) { $traitName = $classTraitName->toString(); $trait = trait_exists($traitName, false) ? new parent($traitName) : new static($traitName); $traits[$traitName] = $trait; } } $traitAdaptations = $classLevelNode->adaptations; } } } return $traits; }
php
public static function collectTraitsFromClassNode(ClassLike $classLikeNode, array &$traitAdaptations) { $traits = []; if (!empty($classLikeNode->stmts)) { foreach ($classLikeNode->stmts as $classLevelNode) { if ($classLevelNode instanceof TraitUse) { foreach ($classLevelNode->traits as $classTraitName) { if ($classTraitName instanceof FullyQualified) { $traitName = $classTraitName->toString(); $trait = trait_exists($traitName, false) ? new parent($traitName) : new static($traitName); $traits[$traitName] = $trait; } } $traitAdaptations = $classLevelNode->adaptations; } } } return $traits; }
[ "public", "static", "function", "collectTraitsFromClassNode", "(", "ClassLike", "$", "classLikeNode", ",", "array", "&", "$", "traitAdaptations", ")", "{", "$", "traits", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "classLikeNode", "->", "stmts", ...
Parses traits from the concrete class node @param ClassLike $classLikeNode Class-like node @param array $traitAdaptations List of method adaptations @return array|\ReflectionClass[] List of reflections of traits
[ "Parses", "traits", "from", "the", "concrete", "class", "node" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionClass.php#L85-L107
train
goaop/parser-reflection
src/ReflectionEngine.php
ReflectionEngine.setMaximumCachedFiles
public static function setMaximumCachedFiles($newLimit) { self::$maximumCachedFiles = $newLimit; if (count(self::$parsedFiles) > $newLimit) { self::$parsedFiles = array_slice(self::$parsedFiles, 0, $newLimit); } }
php
public static function setMaximumCachedFiles($newLimit) { self::$maximumCachedFiles = $newLimit; if (count(self::$parsedFiles) > $newLimit) { self::$parsedFiles = array_slice(self::$parsedFiles, 0, $newLimit); } }
[ "public", "static", "function", "setMaximumCachedFiles", "(", "$", "newLimit", ")", "{", "self", "::", "$", "maximumCachedFiles", "=", "$", "newLimit", ";", "if", "(", "count", "(", "self", "::", "$", "parsedFiles", ")", ">", "$", "newLimit", ")", "{", "...
Limits number of files, that can be cached at any given moment @param integer $newLimit New limit @return void
[ "Limits", "number", "of", "files", "that", "can", "be", "cached", "at", "any", "given", "moment" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L91-L97
train
goaop/parser-reflection
src/ReflectionEngine.php
ReflectionEngine.locateClassFile
public static function locateClassFile($fullClassName) { if (class_exists($fullClassName, false) || interface_exists($fullClassName, false) || trait_exists($fullClassName, false) ) { $refClass = new \ReflectionClass($fullClassName); $classFileName = $refClass->getFileName(); } else { $classFileName = self::$locator->locateClass($fullClassName); } if (!$classFileName) { throw new \InvalidArgumentException("Class $fullClassName was not found by locator"); } return $classFileName; }
php
public static function locateClassFile($fullClassName) { if (class_exists($fullClassName, false) || interface_exists($fullClassName, false) || trait_exists($fullClassName, false) ) { $refClass = new \ReflectionClass($fullClassName); $classFileName = $refClass->getFileName(); } else { $classFileName = self::$locator->locateClass($fullClassName); } if (!$classFileName) { throw new \InvalidArgumentException("Class $fullClassName was not found by locator"); } return $classFileName; }
[ "public", "static", "function", "locateClassFile", "(", "$", "fullClassName", ")", "{", "if", "(", "class_exists", "(", "$", "fullClassName", ",", "false", ")", "||", "interface_exists", "(", "$", "fullClassName", ",", "false", ")", "||", "trait_exists", "(", ...
Locates a file name for class @param string $fullClassName Full name of the class @return string
[ "Locates", "a", "file", "name", "for", "class" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L106-L123
train
goaop/parser-reflection
src/ReflectionEngine.php
ReflectionEngine.parseClass
public static function parseClass($fullClassName) { $classFileName = self::locateClassFile($fullClassName); $namespaceParts = explode('\\', $fullClassName); $className = array_pop($namespaceParts); $namespaceName = join('\\', $namespaceParts); // we have a namespace node somewhere $namespace = self::parseFileNamespace($classFileName, $namespaceName); $namespaceNodes = $namespace->stmts; foreach ($namespaceNodes as $namespaceLevelNode) { if ($namespaceLevelNode instanceof ClassLike && $namespaceLevelNode->name == $className) { $namespaceLevelNode->setAttribute('fileName', $classFileName); return $namespaceLevelNode; } } throw new \InvalidArgumentException("Class $fullClassName was not found in the $classFileName"); }
php
public static function parseClass($fullClassName) { $classFileName = self::locateClassFile($fullClassName); $namespaceParts = explode('\\', $fullClassName); $className = array_pop($namespaceParts); $namespaceName = join('\\', $namespaceParts); // we have a namespace node somewhere $namespace = self::parseFileNamespace($classFileName, $namespaceName); $namespaceNodes = $namespace->stmts; foreach ($namespaceNodes as $namespaceLevelNode) { if ($namespaceLevelNode instanceof ClassLike && $namespaceLevelNode->name == $className) { $namespaceLevelNode->setAttribute('fileName', $classFileName); return $namespaceLevelNode; } } throw new \InvalidArgumentException("Class $fullClassName was not found in the $classFileName"); }
[ "public", "static", "function", "parseClass", "(", "$", "fullClassName", ")", "{", "$", "classFileName", "=", "self", "::", "locateClassFile", "(", "$", "fullClassName", ")", ";", "$", "namespaceParts", "=", "explode", "(", "'\\\\'", ",", "$", "fullClassName",...
Tries to parse a class by name using LocatorInterface @param string $fullClassName Class name to load @return ClassLike
[ "Tries", "to", "parse", "a", "class", "by", "name", "using", "LocatorInterface" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L132-L152
train
goaop/parser-reflection
src/ReflectionEngine.php
ReflectionEngine.parseClassMethod
public static function parseClassMethod($fullClassName, $methodName) { $class = self::parseClass($fullClassName); $classNodes = $class->stmts; foreach ($classNodes as $classLevelNode) { if ($classLevelNode instanceof ClassMethod && $classLevelNode->name->toString() == $methodName) { return $classLevelNode; } } throw new \InvalidArgumentException("Method $methodName was not found in the $fullClassName"); }
php
public static function parseClassMethod($fullClassName, $methodName) { $class = self::parseClass($fullClassName); $classNodes = $class->stmts; foreach ($classNodes as $classLevelNode) { if ($classLevelNode instanceof ClassMethod && $classLevelNode->name->toString() == $methodName) { return $classLevelNode; } } throw new \InvalidArgumentException("Method $methodName was not found in the $fullClassName"); }
[ "public", "static", "function", "parseClassMethod", "(", "$", "fullClassName", ",", "$", "methodName", ")", "{", "$", "class", "=", "self", "::", "parseClass", "(", "$", "fullClassName", ")", ";", "$", "classNodes", "=", "$", "class", "->", "stmts", ";", ...
Parses class method @param string $fullClassName Name of the class @param string $methodName Name of the method @return ClassMethod
[ "Parses", "class", "method" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L162-L174
train
goaop/parser-reflection
src/ReflectionEngine.php
ReflectionEngine.parseClassProperty
public static function parseClassProperty($fullClassName, $propertyName) { $class = self::parseClass($fullClassName); $classNodes = $class->stmts; foreach ($classNodes as $classLevelNode) { if ($classLevelNode instanceof Property) { foreach ($classLevelNode->props as $classProperty) { if ($classProperty->name->toString() == $propertyName) { return [$classLevelNode, $classProperty]; } } } } throw new \InvalidArgumentException("Property $propertyName was not found in the $fullClassName"); }
php
public static function parseClassProperty($fullClassName, $propertyName) { $class = self::parseClass($fullClassName); $classNodes = $class->stmts; foreach ($classNodes as $classLevelNode) { if ($classLevelNode instanceof Property) { foreach ($classLevelNode->props as $classProperty) { if ($classProperty->name->toString() == $propertyName) { return [$classLevelNode, $classProperty]; } } } } throw new \InvalidArgumentException("Property $propertyName was not found in the $fullClassName"); }
[ "public", "static", "function", "parseClassProperty", "(", "$", "fullClassName", ",", "$", "propertyName", ")", "{", "$", "class", "=", "self", "::", "parseClass", "(", "$", "fullClassName", ")", ";", "$", "classNodes", "=", "$", "class", "->", "stmts", ";...
Parses class property @param string $fullClassName Name of the class @param string $propertyName Name of the property @return array Pair of [Property and PropertyProperty] nodes
[ "Parses", "class", "property" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L184-L200
train
goaop/parser-reflection
src/ReflectionEngine.php
ReflectionEngine.parseFile
public static function parseFile($fileName, $fileContent = null) { $fileName = PathResolver::realpath($fileName); if (isset(self::$parsedFiles[$fileName]) && !isset($fileContent)) { return self::$parsedFiles[$fileName]; } if (isset(self::$maximumCachedFiles) && (count(self::$parsedFiles) === self::$maximumCachedFiles)) { array_shift(self::$parsedFiles); } if (!isset($fileContent)) { $fileContent = file_get_contents($fileName); } $treeNode = self::$parser->parse($fileContent); $treeNode = self::$traverser->traverse($treeNode); self::$parsedFiles[$fileName] = $treeNode; return $treeNode; }
php
public static function parseFile($fileName, $fileContent = null) { $fileName = PathResolver::realpath($fileName); if (isset(self::$parsedFiles[$fileName]) && !isset($fileContent)) { return self::$parsedFiles[$fileName]; } if (isset(self::$maximumCachedFiles) && (count(self::$parsedFiles) === self::$maximumCachedFiles)) { array_shift(self::$parsedFiles); } if (!isset($fileContent)) { $fileContent = file_get_contents($fileName); } $treeNode = self::$parser->parse($fileContent); $treeNode = self::$traverser->traverse($treeNode); self::$parsedFiles[$fileName] = $treeNode; return $treeNode; }
[ "public", "static", "function", "parseFile", "(", "$", "fileName", ",", "$", "fileContent", "=", "null", ")", "{", "$", "fileName", "=", "PathResolver", "::", "realpath", "(", "$", "fileName", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "pars...
Parses a file and returns an AST for it @param string $fileName Name of the file @param string|null $fileContent Optional content of the file @return \PhpParser\Node[]
[ "Parses", "a", "file", "and", "returns", "an", "AST", "for", "it" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L210-L230
train
goaop/parser-reflection
src/ReflectionEngine.php
ReflectionEngine.parseFileNamespace
public static function parseFileNamespace($fileName, $namespaceName) { $topLevelNodes = self::parseFile($fileName); // namespaces can be only top-level nodes, so we can scan them directly foreach ($topLevelNodes as $topLevelNode) { if (!$topLevelNode instanceof Namespace_) { continue; } $topLevelNodeName = $topLevelNode->name ? $topLevelNode->name->toString() : ''; if (ltrim($topLevelNodeName, '\\') === trim($namespaceName, '\\')) { return $topLevelNode; } } throw new ReflectionException("Namespace $namespaceName was not found in the file $fileName"); }
php
public static function parseFileNamespace($fileName, $namespaceName) { $topLevelNodes = self::parseFile($fileName); // namespaces can be only top-level nodes, so we can scan them directly foreach ($topLevelNodes as $topLevelNode) { if (!$topLevelNode instanceof Namespace_) { continue; } $topLevelNodeName = $topLevelNode->name ? $topLevelNode->name->toString() : ''; if (ltrim($topLevelNodeName, '\\') === trim($namespaceName, '\\')) { return $topLevelNode; } } throw new ReflectionException("Namespace $namespaceName was not found in the file $fileName"); }
[ "public", "static", "function", "parseFileNamespace", "(", "$", "fileName", ",", "$", "namespaceName", ")", "{", "$", "topLevelNodes", "=", "self", "::", "parseFile", "(", "$", "fileName", ")", ";", "// namespaces can be only top-level nodes, so we can scan them directl...
Parses a file namespace and returns an AST for it @param string $fileName Name of the file @param string $namespaceName Namespace name @return Namespace_ @throws ReflectionException
[ "Parses", "a", "file", "namespace", "and", "returns", "an", "AST", "for", "it" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L241-L256
train
goaop/parser-reflection
src/Locator/ComposerLocator.php
ComposerLocator.locateClass
public function locateClass($className) { $filePath = $this->loader->findFile(ltrim($className, '\\')); if (!empty($filePath)) { $filePath = PathResolver::realpath($filePath); } return $filePath; }
php
public function locateClass($className) { $filePath = $this->loader->findFile(ltrim($className, '\\')); if (!empty($filePath)) { $filePath = PathResolver::realpath($filePath); } return $filePath; }
[ "public", "function", "locateClass", "(", "$", "className", ")", "{", "$", "filePath", "=", "$", "this", "->", "loader", "->", "findFile", "(", "ltrim", "(", "$", "className", ",", "'\\\\'", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "filePath...
Returns a path to the file for given class name @param string $className Name of the class @return string|false Path to the file with given class or false if not found
[ "Returns", "a", "path", "to", "the", "file", "for", "given", "class", "name" ]
a71d0454ef8bfa416a39bbb7dd3ed497e063e54c
https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Locator/ComposerLocator.php#L52-L60
train
rossedman/teamwork
src/Rossedman/Teamwork/AbstractObject.php
AbstractObject.areArgumentsValid
protected function areArgumentsValid($args, array $accepted) { if ($args == null) { return; } foreach ($accepted as $accept) { if (array_key_exists($accept, $args)) { return true; } } throw new \InvalidArgumentException('This call only accepts these arguments: ' . implode(" | ",$accepted)); }
php
protected function areArgumentsValid($args, array $accepted) { if ($args == null) { return; } foreach ($accepted as $accept) { if (array_key_exists($accept, $args)) { return true; } } throw new \InvalidArgumentException('This call only accepts these arguments: ' . implode(" | ",$accepted)); }
[ "protected", "function", "areArgumentsValid", "(", "$", "args", ",", "array", "$", "accepted", ")", "{", "if", "(", "$", "args", "==", "null", ")", "{", "return", ";", "}", "foreach", "(", "$", "accepted", "as", "$", "accept", ")", "{", "if", "(", ...
Are Arguments Valid @param array $args @param string[] $accepted @return null|bool
[ "Are", "Arguments", "Valid" ]
c929b0f11114ec6a808df81762879be84a9d2e36
https://github.com/rossedman/teamwork/blob/c929b0f11114ec6a808df81762879be84a9d2e36/src/Rossedman/Teamwork/AbstractObject.php#L52-L68
train
rossedman/teamwork
src/Rossedman/Teamwork/Client.php
Client.buildQuery
public function buildQuery($query) { $q = $this->request->getQuery(); foreach ($query as $key => $value) { $q[$key] = $value; } }
php
public function buildQuery($query) { $q = $this->request->getQuery(); foreach ($query as $key => $value) { $q[$key] = $value; } }
[ "public", "function", "buildQuery", "(", "$", "query", ")", "{", "$", "q", "=", "$", "this", "->", "request", "->", "getQuery", "(", ")", ";", "foreach", "(", "$", "query", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "q", "[", "$", "ke...
Build Query String if a query string is needed it will be built up and added to the request. This is only used in certain GET requests @param $query
[ "Build", "Query", "String" ]
c929b0f11114ec6a808df81762879be84a9d2e36
https://github.com/rossedman/teamwork/blob/c929b0f11114ec6a808df81762879be84a9d2e36/src/Rossedman/Teamwork/Client.php#L197-L205
train
alterphp/components
src/AlterPHP/Component/ToolBox/BitTools.php
BitTools.getBitArrayFromInt
public static function getBitArrayFromInt($int) { $binstr = (string) decbin($int); $binarr = array_reverse(str_split($binstr)); $bitarr = array_keys($binarr, '1', true); return $bitarr; }
php
public static function getBitArrayFromInt($int) { $binstr = (string) decbin($int); $binarr = array_reverse(str_split($binstr)); $bitarr = array_keys($binarr, '1', true); return $bitarr; }
[ "public", "static", "function", "getBitArrayFromInt", "(", "$", "int", ")", "{", "$", "binstr", "=", "(", "string", ")", "decbin", "(", "$", "int", ")", ";", "$", "binarr", "=", "array_reverse", "(", "str_split", "(", "$", "binstr", ")", ")", ";", "$...
Return an array of active bits in the binary representation of the given integer @param integer $int @return array
[ "Return", "an", "array", "of", "active", "bits", "in", "the", "binary", "representation", "of", "the", "given", "integer" ]
a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5
https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/ToolBox/BitTools.php#L31-L38
train
alterphp/components
src/AlterPHP/Component/Behavior/StatusableEntity.php
StatusableEntity.getStatusList
public static function getStatusList($withLabelsAsIndexes = false, array $filterStatus = null) { // Build $statusValues if this is the first call if (null === static::$statusValues) { static::$statusValues = array(); $refClass = new \ReflectionClass(get_called_class()); $classConstants = $refClass->getConstants(); $className = $refClass->getShortName(); $constantPrefix = 'STATUS_'; foreach ($classConstants as $key => $val) { if (substr($key, 0, strlen($constantPrefix)) === $constantPrefix) { static::$statusValues[$val] = static::getLowerCaseClassName().'.status.'.$val; } } } $statusValues = static::$statusValues; // Filter on specified status list if (isset($filterStatus)) { $statusValues = array_filter($statusValues, function ($key) use ($filterStatus) { return in_array($key, $filterStatus); }, ARRAY_FILTER_USE_KEY); } if ($withLabelsAsIndexes) { return array_flip($statusValues); } return array_keys($statusValues); }
php
public static function getStatusList($withLabelsAsIndexes = false, array $filterStatus = null) { // Build $statusValues if this is the first call if (null === static::$statusValues) { static::$statusValues = array(); $refClass = new \ReflectionClass(get_called_class()); $classConstants = $refClass->getConstants(); $className = $refClass->getShortName(); $constantPrefix = 'STATUS_'; foreach ($classConstants as $key => $val) { if (substr($key, 0, strlen($constantPrefix)) === $constantPrefix) { static::$statusValues[$val] = static::getLowerCaseClassName().'.status.'.$val; } } } $statusValues = static::$statusValues; // Filter on specified status list if (isset($filterStatus)) { $statusValues = array_filter($statusValues, function ($key) use ($filterStatus) { return in_array($key, $filterStatus); }, ARRAY_FILTER_USE_KEY); } if ($withLabelsAsIndexes) { return array_flip($statusValues); } return array_keys($statusValues); }
[ "public", "static", "function", "getStatusList", "(", "$", "withLabelsAsIndexes", "=", "false", ",", "array", "$", "filterStatus", "=", "null", ")", "{", "// Build $statusValues if this is the first call", "if", "(", "null", "===", "static", "::", "$", "statusValues...
Returns status list, with or without labels. @param bool $withLabelsAsIndexes @param array $filterStatus @return array
[ "Returns", "status", "list", "with", "or", "without", "labels", "." ]
a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5
https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L39-L70
train
alterphp/components
src/AlterPHP/Component/Behavior/StatusableEntity.php
StatusableEntity.isStatusBetween
public function isStatusBetween($from = null, $to = null, $strict = false, $strictTo = null) { return in_array($this->status, static::getStatusBetween($from, $to, $strict, $strictTo)); }
php
public function isStatusBetween($from = null, $to = null, $strict = false, $strictTo = null) { return in_array($this->status, static::getStatusBetween($from, $to, $strict, $strictTo)); }
[ "public", "function", "isStatusBetween", "(", "$", "from", "=", "null", ",", "$", "to", "=", "null", ",", "$", "strict", "=", "false", ",", "$", "strictTo", "=", "null", ")", "{", "return", "in_array", "(", "$", "this", "->", "status", ",", "static",...
Checks if status is between a "from" and a "to" status. @param string $from @param string $to @param bool $strict @param bool $strictTo @return bool
[ "Checks", "if", "status", "is", "between", "a", "from", "and", "a", "to", "status", "." ]
a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5
https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L82-L85
train
alterphp/components
src/AlterPHP/Component/Behavior/StatusableEntity.php
StatusableEntity.getStatusBetween
public static function getStatusBetween($from = null, $to = null, $strict = false, $strictTo = null) { $statusList = static::getStatusList(); $strictFrom = $strict; $strictTo = isset($strictTo) ? (bool) $strictTo : $strict; // Remove status before given $from if (isset($from)) { static::checkAllowedStatus($from); foreach ($statusList as $key => $status) { if ($from !== $status) { unset($statusList[$key]); } else { if ($strictFrom) { unset($statusList[$key]); } break; } } } // Remove status after given $to if (isset($to)) { static::checkAllowedStatus($to); // On inverse l'ordre des statuts $statusList = array_reverse($statusList); foreach ($statusList as $key => $status) { if ($to !== $status) { unset($statusList[$key]); } else { if ($strictTo) { unset($statusList[$key]); } break; } } // On inverse l'ordre des statuts $statusList = array_reverse($statusList); } return array_values($statusList); }
php
public static function getStatusBetween($from = null, $to = null, $strict = false, $strictTo = null) { $statusList = static::getStatusList(); $strictFrom = $strict; $strictTo = isset($strictTo) ? (bool) $strictTo : $strict; // Remove status before given $from if (isset($from)) { static::checkAllowedStatus($from); foreach ($statusList as $key => $status) { if ($from !== $status) { unset($statusList[$key]); } else { if ($strictFrom) { unset($statusList[$key]); } break; } } } // Remove status after given $to if (isset($to)) { static::checkAllowedStatus($to); // On inverse l'ordre des statuts $statusList = array_reverse($statusList); foreach ($statusList as $key => $status) { if ($to !== $status) { unset($statusList[$key]); } else { if ($strictTo) { unset($statusList[$key]); } break; } } // On inverse l'ordre des statuts $statusList = array_reverse($statusList); } return array_values($statusList); }
[ "public", "static", "function", "getStatusBetween", "(", "$", "from", "=", "null", ",", "$", "to", "=", "null", ",", "$", "strict", "=", "false", ",", "$", "strictTo", "=", "null", ")", "{", "$", "statusList", "=", "static", "::", "getStatusList", "(",...
Returns list of status between a "from" and a "to" status. @param string $from @param string $to @param bool $strict Is lower bound strict (or both bounds if $strictTo is null) ? @param bool $strictTo Is higher bound strict ? @return array
[ "Returns", "list", "of", "status", "between", "a", "from", "and", "a", "to", "status", "." ]
a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5
https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L97-L139
train
alterphp/components
src/AlterPHP/Component/Behavior/StatusableEntity.php
StatusableEntity.isGreaterThan
public static function isGreaterThan($status1, $status2, $strict = true) { static::checkAllowedStatus($status1); static::checkAllowedStatus($status2); $entityStatusIdx = array_search($status1, static::getStatusList()); $comparedStatusIdx = array_search($status2, static::getStatusList()); if ($strict) { return $entityStatusIdx > $comparedStatusIdx; } return $entityStatusIdx >= $comparedStatusIdx; }
php
public static function isGreaterThan($status1, $status2, $strict = true) { static::checkAllowedStatus($status1); static::checkAllowedStatus($status2); $entityStatusIdx = array_search($status1, static::getStatusList()); $comparedStatusIdx = array_search($status2, static::getStatusList()); if ($strict) { return $entityStatusIdx > $comparedStatusIdx; } return $entityStatusIdx >= $comparedStatusIdx; }
[ "public", "static", "function", "isGreaterThan", "(", "$", "status1", ",", "$", "status2", ",", "$", "strict", "=", "true", ")", "{", "static", "::", "checkAllowedStatus", "(", "$", "status1", ")", ";", "static", "::", "checkAllowedStatus", "(", "$", "stat...
Compare first status to second passed status. @param string $status1 @param string $status2 @param bool $strict @return bool
[ "Compare", "first", "status", "to", "second", "passed", "status", "." ]
a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5
https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L166-L179
train
alterphp/components
src/AlterPHP/Component/Behavior/StatusableEntity.php
StatusableEntity.getStatusLabel
public function getStatusLabel() { $statusList = array_flip($this->getStatusList(true)); return isset($statusList[$this->status]) ? $statusList[$this->status] : $this->status; }
php
public function getStatusLabel() { $statusList = array_flip($this->getStatusList(true)); return isset($statusList[$this->status]) ? $statusList[$this->status] : $this->status; }
[ "public", "function", "getStatusLabel", "(", ")", "{", "$", "statusList", "=", "array_flip", "(", "$", "this", "->", "getStatusList", "(", "true", ")", ")", ";", "return", "isset", "(", "$", "statusList", "[", "$", "this", "->", "status", "]", ")", "?"...
Get statusLabel. @return string
[ "Get", "statusLabel", "." ]
a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5
https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L262-L267
train
alterphp/components
src/AlterPHP/Component/Mailer/Mailer.php
Mailer.forceFlushForCommand
public function forceFlushForCommand() { // L'envoi des emails est déclenché sur une réponse du Kernel (inactif en mode commande) $transport = $this->swift->getTransport(); if (!$transport instanceof \Swift_Transport_SpoolTransport) { return; } $spool = $transport->getSpool(); if (!$spool instanceof \Swift_MemorySpool) { return; } return $spool->flushQueue($this->mailerRealTransport); }
php
public function forceFlushForCommand() { // L'envoi des emails est déclenché sur une réponse du Kernel (inactif en mode commande) $transport = $this->swift->getTransport(); if (!$transport instanceof \Swift_Transport_SpoolTransport) { return; } $spool = $transport->getSpool(); if (!$spool instanceof \Swift_MemorySpool) { return; } return $spool->flushQueue($this->mailerRealTransport); }
[ "public", "function", "forceFlushForCommand", "(", ")", "{", "// L'envoi des emails est déclenché sur une réponse du Kernel (inactif en mode commande)", "$", "transport", "=", "$", "this", "->", "swift", "->", "getTransport", "(", ")", ";", "if", "(", "!", "$", "transpo...
Force l'envoi des mails en mode Command @return integer Number of emails sent
[ "Force", "l", "envoi", "des", "mails", "en", "mode", "Command" ]
a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5
https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Mailer/Mailer.php#L144-L157
train
alterphp/components
src/AlterPHP/Component/ToolBox/PolylineEncoder.php
PolylineEncoder.dpEncode
public function dpEncode() { if(count($this->points) > 2) { $stack[] = array(0, count($this->points)-1); while(count($stack) > 0) { $current = array_pop($stack); $maxDist = 0; $absMaxDist = 0; for($i = $current[0]+1; $i < $current[1]; $i++) { $temp = self::distance($this->points[$i], $this->points[$current[0]], $this->points[$current[1]]); if($temp > $maxDist) { $maxDist = $temp; $maxLoc = $i; if($maxDist > $absMaxDist) { $absMaxDist = $maxDist; } } } if($maxDist > $this->verySmall) { $dists[$maxLoc] = $maxDist; array_push($stack, array($current[0], $maxLoc)); array_push($stack, array($maxLoc, $current[1])); } } } $encodedPoints = self::createEncodings($this->points, $dists); $encodedLevels = self::encodeLevels($this->points, $dists, $absMaxDist); $encodedPointsLiteral = str_replace('\\',"\\\\",$encodedPoints); $polyline["Points"] = $encodedPoints; $polyline["Levels"] = $encodedLevels; $polyline["PointsLiteral"] = $encodedPointsLiteral; $polyline["ZoomFactor"] = $this->zoomFactor; $polyline["NumLevels"] = $this->numLevels; return $polyline; }
php
public function dpEncode() { if(count($this->points) > 2) { $stack[] = array(0, count($this->points)-1); while(count($stack) > 0) { $current = array_pop($stack); $maxDist = 0; $absMaxDist = 0; for($i = $current[0]+1; $i < $current[1]; $i++) { $temp = self::distance($this->points[$i], $this->points[$current[0]], $this->points[$current[1]]); if($temp > $maxDist) { $maxDist = $temp; $maxLoc = $i; if($maxDist > $absMaxDist) { $absMaxDist = $maxDist; } } } if($maxDist > $this->verySmall) { $dists[$maxLoc] = $maxDist; array_push($stack, array($current[0], $maxLoc)); array_push($stack, array($maxLoc, $current[1])); } } } $encodedPoints = self::createEncodings($this->points, $dists); $encodedLevels = self::encodeLevels($this->points, $dists, $absMaxDist); $encodedPointsLiteral = str_replace('\\',"\\\\",$encodedPoints); $polyline["Points"] = $encodedPoints; $polyline["Levels"] = $encodedLevels; $polyline["PointsLiteral"] = $encodedPointsLiteral; $polyline["ZoomFactor"] = $this->zoomFactor; $polyline["NumLevels"] = $this->numLevels; return $polyline; }
[ "public", "function", "dpEncode", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "points", ")", ">", "2", ")", "{", "$", "stack", "[", "]", "=", "array", "(", "0", ",", "count", "(", "$", "this", "->", "points", ")", "-", "1", ")"...
It also returns the zoomFactor and numLevels
[ "It", "also", "returns", "the", "zoomFactor", "and", "numLevels" ]
a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5
https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/ToolBox/PolylineEncoder.php#L102-L142
train
box-project/box2-lib
src/lib/Herrera/Box/Box.php
Box.addFromString
public function addFromString($local, $contents) { $this->phar->addFromString( $local, $this->replaceValues($this->compactContents($local, $contents)) ); }
php
public function addFromString($local, $contents) { $this->phar->addFromString( $local, $this->replaceValues($this->compactContents($local, $contents)) ); }
[ "public", "function", "addFromString", "(", "$", "local", ",", "$", "contents", ")", "{", "$", "this", "->", "phar", "->", "addFromString", "(", "$", "local", ",", "$", "this", "->", "replaceValues", "(", "$", "this", "->", "compactContents", "(", "$", ...
Adds the contents from a file to the Phar, after compacting it and replacing its placeholders. @param string $local The local name. @param string $contents The contents.
[ "Adds", "the", "contents", "from", "a", "file", "to", "the", "Phar", "after", "compacting", "it", "and", "replacing", "its", "placeholders", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L115-L121
train
box-project/box2-lib
src/lib/Herrera/Box/Box.php
Box.compactContents
public function compactContents($file, $contents) { foreach ($this->compactors as $compactor) { /** @var $compactor CompactorInterface */ if ($compactor->supports($file)) { $contents = $compactor->compact($contents); } } return $contents; }
php
public function compactContents($file, $contents) { foreach ($this->compactors as $compactor) { /** @var $compactor CompactorInterface */ if ($compactor->supports($file)) { $contents = $compactor->compact($contents); } } return $contents; }
[ "public", "function", "compactContents", "(", "$", "file", ",", "$", "contents", ")", "{", "foreach", "(", "$", "this", "->", "compactors", "as", "$", "compactor", ")", "{", "/** @var $compactor CompactorInterface */", "if", "(", "$", "compactor", "->", "suppo...
Compacts the file contents using the supported compactors. @param string $file The file name. @param string $contents The file contents. @return string The compacted contents.
[ "Compacts", "the", "file", "contents", "using", "the", "supported", "compactors", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L222-L232
train
box-project/box2-lib
src/lib/Herrera/Box/Box.php
Box.create
public static function create($file, $flags = null, $alias = null) { return new Box(new Phar($file, $flags, $alias), $file); }
php
public static function create($file, $flags = null, $alias = null) { return new Box(new Phar($file, $flags, $alias), $file); }
[ "public", "static", "function", "create", "(", "$", "file", ",", "$", "flags", "=", "null", ",", "$", "alias", "=", "null", ")", "{", "return", "new", "Box", "(", "new", "Phar", "(", "$", "file", ",", "$", "flags", ",", "$", "alias", ")", ",", ...
Creates a new Phar and Box instance. @param string $file The file name. @param integer $flags The RecursiveDirectoryIterator flags. @param string $alias The Phar alias. @return Box The Box instance.
[ "Creates", "a", "new", "Phar", "and", "Box", "instance", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L243-L246
train
box-project/box2-lib
src/lib/Herrera/Box/Box.php
Box.replaceValues
public function replaceValues($contents) { return str_replace( array_keys($this->values), array_values($this->values), $contents ); }
php
public function replaceValues($contents) { return str_replace( array_keys($this->values), array_values($this->values), $contents ); }
[ "public", "function", "replaceValues", "(", "$", "contents", ")", "{", "return", "str_replace", "(", "array_keys", "(", "$", "this", "->", "values", ")", ",", "array_values", "(", "$", "this", "->", "values", ")", ",", "$", "contents", ")", ";", "}" ]
Replaces the placeholders with their values. @param string $contents The contents. @return string The replaced contents.
[ "Replaces", "the", "placeholders", "with", "their", "values", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L279-L286
train
box-project/box2-lib
src/lib/Herrera/Box/Box.php
Box.setStubUsingFile
public function setStubUsingFile($file, $replace = false) { if (false === is_file($file)) { throw FileException::create( 'The file "%s" does not exist or is not a file.', $file ); } if (false === ($contents = @file_get_contents($file))) { throw FileException::lastError(); } if ($replace) { $contents = $this->replaceValues($contents); } $this->phar->setStub($contents); }
php
public function setStubUsingFile($file, $replace = false) { if (false === is_file($file)) { throw FileException::create( 'The file "%s" does not exist or is not a file.', $file ); } if (false === ($contents = @file_get_contents($file))) { throw FileException::lastError(); } if ($replace) { $contents = $this->replaceValues($contents); } $this->phar->setStub($contents); }
[ "public", "function", "setStubUsingFile", "(", "$", "file", ",", "$", "replace", "=", "false", ")", "{", "if", "(", "false", "===", "is_file", "(", "$", "file", ")", ")", "{", "throw", "FileException", "::", "create", "(", "'The file \"%s\" does not exist or...
Sets the bootstrap loader stub using a file. @param string $file The file path. @param boolean $replace Replace placeholders? @throws Exception\Exception @throws FileException If the stub file could not be used.
[ "Sets", "the", "bootstrap", "loader", "stub", "using", "a", "file", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L297-L315
train
box-project/box2-lib
src/lib/Herrera/Box/Box.php
Box.setValues
public function setValues(array $values) { foreach ($values as $value) { if (false === is_scalar($value)) { throw InvalidArgumentException::create( 'Non-scalar values (such as %s) are not supported.', gettype($value) ); } } $this->values = $values; }
php
public function setValues(array $values) { foreach ($values as $value) { if (false === is_scalar($value)) { throw InvalidArgumentException::create( 'Non-scalar values (such as %s) are not supported.', gettype($value) ); } } $this->values = $values; }
[ "public", "function", "setValues", "(", "array", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "if", "(", "false", "===", "is_scalar", "(", "$", "value", ")", ")", "{", "throw", "InvalidArgumentException", "::", ...
Sets the placeholder values. @param array $values The values. @throws Exception\Exception @throws InvalidArgumentException If a non-scalar value is used.
[ "Sets", "the", "placeholder", "values", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L325-L337
train
box-project/box2-lib
src/lib/Herrera/Box/Box.php
Box.sign
public function sign($key, $password = null) { OpenSslException::reset(); if (false === extension_loaded('openssl')) { // @codeCoverageIgnoreStart throw OpenSslException::create( 'The "openssl" extension is not available.' ); // @codeCoverageIgnoreEnd } if (false === ($resource = openssl_pkey_get_private($key, $password))) { // @codeCoverageIgnoreStart throw OpenSslException::lastError(); // @codeCoverageIgnoreEnd } if (false === openssl_pkey_export($resource, $private)) { // @codeCoverageIgnoreStart throw OpenSslException::lastError(); // @codeCoverageIgnoreEnd } if (false === ($details = openssl_pkey_get_details($resource))) { // @codeCoverageIgnoreStart throw OpenSslException::lastError(); // @codeCoverageIgnoreEnd } $this->phar->setSignatureAlgorithm(Phar::OPENSSL, $private); if (false === @file_put_contents($this->file . '.pubkey', $details['key'])) { throw FileException::lastError(); } }
php
public function sign($key, $password = null) { OpenSslException::reset(); if (false === extension_loaded('openssl')) { // @codeCoverageIgnoreStart throw OpenSslException::create( 'The "openssl" extension is not available.' ); // @codeCoverageIgnoreEnd } if (false === ($resource = openssl_pkey_get_private($key, $password))) { // @codeCoverageIgnoreStart throw OpenSslException::lastError(); // @codeCoverageIgnoreEnd } if (false === openssl_pkey_export($resource, $private)) { // @codeCoverageIgnoreStart throw OpenSslException::lastError(); // @codeCoverageIgnoreEnd } if (false === ($details = openssl_pkey_get_details($resource))) { // @codeCoverageIgnoreStart throw OpenSslException::lastError(); // @codeCoverageIgnoreEnd } $this->phar->setSignatureAlgorithm(Phar::OPENSSL, $private); if (false === @file_put_contents($this->file . '.pubkey', $details['key'])) { throw FileException::lastError(); } }
[ "public", "function", "sign", "(", "$", "key", ",", "$", "password", "=", "null", ")", "{", "OpenSslException", "::", "reset", "(", ")", ";", "if", "(", "false", "===", "extension_loaded", "(", "'openssl'", ")", ")", "{", "// @codeCoverageIgnoreStart", "th...
Signs the Phar using a private key. @param string $key The private key. @param string $password The private key password. @throws Exception\Exception @throws OpenSslException If the "openssl" extension could not be used or has generated an error.
[ "Signs", "the", "Phar", "using", "a", "private", "key", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L349-L384
train
box-project/box2-lib
src/lib/Herrera/Box/Box.php
Box.signUsingFile
public function signUsingFile($file, $password = null) { if (false === is_file($file)) { throw FileException::create( 'The file "%s" does not exist or is not a file.', $file ); } if (false === ($key = @file_get_contents($file))) { throw FileException::lastError(); } $this->sign($key, $password); }
php
public function signUsingFile($file, $password = null) { if (false === is_file($file)) { throw FileException::create( 'The file "%s" does not exist or is not a file.', $file ); } if (false === ($key = @file_get_contents($file))) { throw FileException::lastError(); } $this->sign($key, $password); }
[ "public", "function", "signUsingFile", "(", "$", "file", ",", "$", "password", "=", "null", ")", "{", "if", "(", "false", "===", "is_file", "(", "$", "file", ")", ")", "{", "throw", "FileException", "::", "create", "(", "'The file \"%s\" does not exist or is...
Signs the Phar using a private key file. @param string $file The private key file name. @param string $password The private key password. @throws Exception\Exception @throws FileException If the private key file could not be read.
[ "Signs", "the", "Phar", "using", "a", "private", "key", "file", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L395-L409
train
box-project/box2-lib
src/lib/Herrera/Box/Signature.php
Signature.get
public function get($required = null) { if (null === $required) { $required = (bool) ini_get('phar.require_hash'); } $this->seek(-4, SEEK_END); if ('GBMB' !== $this->read(4)) { if ($required) { throw new PharException( sprintf( 'The phar "%s" is not signed.', $this->file ) ); } return null; } $this->seek(-8, SEEK_END); $flag = unpack('V', $this->read(4)); $flag = $flag[1]; foreach (self::$types as $type) { if ($flag === $type['flag']) { break; } unset($type); } if (!isset($type)) { throw new PharException( sprintf( 'The signature type (%x) is not recognized for the phar "%s".', $flag, $this->file ) ); } $offset = -8; if (0x10 === $type['flag']) { $offset = -12; $this->seek(-12, SEEK_END); $type['size'] = unpack('V', $this->read(4)); $type['size'] = $type['size'][1]; } $this->seek($offset - $type['size'], SEEK_END); $hash = $this->read($type['size']); $hash = unpack('H*', $hash); return array( 'hash_type' => $type['name'], 'hash' => strtoupper($hash[1]) ); }
php
public function get($required = null) { if (null === $required) { $required = (bool) ini_get('phar.require_hash'); } $this->seek(-4, SEEK_END); if ('GBMB' !== $this->read(4)) { if ($required) { throw new PharException( sprintf( 'The phar "%s" is not signed.', $this->file ) ); } return null; } $this->seek(-8, SEEK_END); $flag = unpack('V', $this->read(4)); $flag = $flag[1]; foreach (self::$types as $type) { if ($flag === $type['flag']) { break; } unset($type); } if (!isset($type)) { throw new PharException( sprintf( 'The signature type (%x) is not recognized for the phar "%s".', $flag, $this->file ) ); } $offset = -8; if (0x10 === $type['flag']) { $offset = -12; $this->seek(-12, SEEK_END); $type['size'] = unpack('V', $this->read(4)); $type['size'] = $type['size'][1]; } $this->seek($offset - $type['size'], SEEK_END); $hash = $this->read($type['size']); $hash = unpack('H*', $hash); return array( 'hash_type' => $type['name'], 'hash' => strtoupper($hash[1]) ); }
[ "public", "function", "get", "(", "$", "required", "=", "null", ")", "{", "if", "(", "null", "===", "$", "required", ")", "{", "$", "required", "=", "(", "bool", ")", "ini_get", "(", "'phar.require_hash'", ")", ";", "}", "$", "this", "->", "seek", ...
Returns the signature for the phar. The value returned is identical to that of `Phar->getSignature()`. If $required is not given, it will default to the `phar.require_hash` current value. @param boolean $required Is the signature required? @return array The signature. @throws PharException If the phar is not valid.
[ "Returns", "the", "signature", "for", "the", "phar", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Signature.php#L138-L202
train
box-project/box2-lib
src/lib/Herrera/Box/Signature.php
Signature.verify
public function verify() { $signature = $this->get(); $size = $this->size; $type = null; foreach (self::$types as $type) { if ($type['name'] === $signature['hash_type']) { if (0x10 === $type['flag']) { $this->seek(-12, SEEK_END); $less = $this->read(4); $less = unpack('V', $less); $less = $less[1]; $size -= 12 + $less; } else { $size -= 8 + $type['size']; } break; } } $this->seek(0); /** @var $verify VerifyInterface */ $verify = new $type['class'](); $verify->init($type['name'], $this->file); $buffer = 64; while (0 < $size) { if ($size < $buffer) { $buffer = $size; $size = 0; } $verify->update($this->read($buffer)); $size -= $buffer; } return $verify->verify($signature['hash']); }
php
public function verify() { $signature = $this->get(); $size = $this->size; $type = null; foreach (self::$types as $type) { if ($type['name'] === $signature['hash_type']) { if (0x10 === $type['flag']) { $this->seek(-12, SEEK_END); $less = $this->read(4); $less = unpack('V', $less); $less = $less[1]; $size -= 12 + $less; } else { $size -= 8 + $type['size']; } break; } } $this->seek(0); /** @var $verify VerifyInterface */ $verify = new $type['class'](); $verify->init($type['name'], $this->file); $buffer = 64; while (0 < $size) { if ($size < $buffer) { $buffer = $size; $size = 0; } $verify->update($this->read($buffer)); $size -= $buffer; } return $verify->verify($signature['hash']); }
[ "public", "function", "verify", "(", ")", "{", "$", "signature", "=", "$", "this", "->", "get", "(", ")", ";", "$", "size", "=", "$", "this", "->", "size", ";", "$", "type", "=", "null", ";", "foreach", "(", "self", "::", "$", "types", "as", "$...
Verifies the signature of the phar. @return boolean TRUE if verified, FALSE if not. @throws Exception @throws FileException If the private key could not be read. @throws OpenSslException If there is an OpenSSL error.
[ "Verifies", "the", "signature", "of", "the", "phar", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Signature.php#L213-L258
train
box-project/box2-lib
src/lib/Herrera/Box/Signature.php
Signature.handle
private function handle() { if (!$this->handle) { if (!($this->handle = @fopen($this->file, 'rb'))) { throw FileException::lastError(); } } return $this->handle; }
php
private function handle() { if (!$this->handle) { if (!($this->handle = @fopen($this->file, 'rb'))) { throw FileException::lastError(); } } return $this->handle; }
[ "private", "function", "handle", "(", ")", "{", "if", "(", "!", "$", "this", "->", "handle", ")", "{", "if", "(", "!", "(", "$", "this", "->", "handle", "=", "@", "fopen", "(", "$", "this", "->", "file", ",", "'rb'", ")", ")", ")", "{", "thro...
Returns the file handle. If the file handle is not opened, it will be automatically opened. @return resource The file handle. @throws Exception @throws FileException If the file could not be opened.
[ "Returns", "the", "file", "handle", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Signature.php#L282-L291
train
box-project/box2-lib
src/lib/Herrera/Box/Signature.php
Signature.read
private function read($bytes) { if (false === ($read = @fread($this->handle(), $bytes))) { throw FileException::lastError(); } if (($actual = strlen($read)) !== $bytes) { throw FileException::create( 'Only read %d of %d bytes from "%s".', $actual, $bytes, $this->file ); } return $read; }
php
private function read($bytes) { if (false === ($read = @fread($this->handle(), $bytes))) { throw FileException::lastError(); } if (($actual = strlen($read)) !== $bytes) { throw FileException::create( 'Only read %d of %d bytes from "%s".', $actual, $bytes, $this->file ); } return $read; }
[ "private", "function", "read", "(", "$", "bytes", ")", "{", "if", "(", "false", "===", "(", "$", "read", "=", "@", "fread", "(", "$", "this", "->", "handle", "(", ")", ",", "$", "bytes", ")", ")", ")", "{", "throw", "FileException", "::", "lastEr...
Reads a number of bytes from the file. @param integer $bytes The number of bytes. @return string The read bytes. @throws Exception @throws FileException If the file could not be read.
[ "Reads", "a", "number", "of", "bytes", "from", "the", "file", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Signature.php#L303-L319
train
box-project/box2-lib
src/lib/Herrera/Box/Compactor/Php.php
Php.setTokenizer
public function setTokenizer(Tokenizer $tokenizer) { if (null === $this->converter) { $this->converter = new ToString(); } $this->tokenizer = $tokenizer; }
php
public function setTokenizer(Tokenizer $tokenizer) { if (null === $this->converter) { $this->converter = new ToString(); } $this->tokenizer = $tokenizer; }
[ "public", "function", "setTokenizer", "(", "Tokenizer", "$", "tokenizer", ")", "{", "if", "(", "null", "===", "$", "this", "->", "converter", ")", "{", "$", "this", "->", "converter", "=", "new", "ToString", "(", ")", ";", "}", "$", "this", "->", "to...
Sets the annotations tokenizer. @param Tokenizer $tokenizer The tokenizer.
[ "Sets", "the", "annotations", "tokenizer", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Compactor/Php.php#L76-L83
train
box-project/box2-lib
src/lib/Herrera/Box/Compactor/Php.php
Php.compactAnnotations
private function compactAnnotations($docblock) { $annotations = array(); $index = -1; $inside = 0; $tokens = $this->tokenizer->parse($docblock); if (empty($tokens)) { return str_repeat("\n", substr_count($docblock, "\n")); } foreach ($tokens as $token) { if ((0 === $inside) && (DocLexer::T_AT === $token[0])) { $index++; } elseif (DocLexer::T_OPEN_PARENTHESIS === $token[0]) { $inside++; } elseif (DocLexer::T_CLOSE_PARENTHESIS === $token[0]) { $inside--; } if (!isset($annotations[$index])) { $annotations[$index] = array(); } $annotations[$index][] = $token; } $breaks = substr_count($docblock, "\n"); $docblock = "/**"; foreach ($annotations as $annotation) { $annotation = new Tokens($annotation); $docblock .= "\n" . $this->converter->convert($annotation); } $breaks -= count($annotations); if ($breaks > 0) { $docblock .= str_repeat("\n", $breaks - 1); $docblock .= "\n*/"; } else { $docblock .= ' */'; } return $docblock; }
php
private function compactAnnotations($docblock) { $annotations = array(); $index = -1; $inside = 0; $tokens = $this->tokenizer->parse($docblock); if (empty($tokens)) { return str_repeat("\n", substr_count($docblock, "\n")); } foreach ($tokens as $token) { if ((0 === $inside) && (DocLexer::T_AT === $token[0])) { $index++; } elseif (DocLexer::T_OPEN_PARENTHESIS === $token[0]) { $inside++; } elseif (DocLexer::T_CLOSE_PARENTHESIS === $token[0]) { $inside--; } if (!isset($annotations[$index])) { $annotations[$index] = array(); } $annotations[$index][] = $token; } $breaks = substr_count($docblock, "\n"); $docblock = "/**"; foreach ($annotations as $annotation) { $annotation = new Tokens($annotation); $docblock .= "\n" . $this->converter->convert($annotation); } $breaks -= count($annotations); if ($breaks > 0) { $docblock .= str_repeat("\n", $breaks - 1); $docblock .= "\n*/"; } else { $docblock .= ' */'; } return $docblock; }
[ "private", "function", "compactAnnotations", "(", "$", "docblock", ")", "{", "$", "annotations", "=", "array", "(", ")", ";", "$", "index", "=", "-", "1", ";", "$", "inside", "=", "0", ";", "$", "tokens", "=", "$", "this", "->", "tokenizer", "->", ...
Compacts the docblock and its annotations. @param string $docblock The docblock. @return string The compacted docblock.
[ "Compacts", "the", "docblock", "and", "its", "annotations", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Compactor/Php.php#L92-L137
train
box-project/box2-lib
src/lib/Herrera/Box/Extract.php
Extract.findStubLength
public static function findStubLength( $file, $pattern = self::PATTERN_OPEN ) { if (!($fp = fopen($file, 'rb'))) { throw new RuntimeException( sprintf( 'The phar "%s" could not be opened for reading.', $file ) ); } $stub = null; $offset = 0; $combo = str_split($pattern); while (!feof($fp)) { if (fgetc($fp) === $combo[$offset]) { $offset++; if (!isset($combo[$offset])) { $stub = ftell($fp); break; } } else { $offset = 0; } } fclose($fp); if (null === $stub) { throw new InvalidArgumentException( sprintf( 'The pattern could not be found in "%s".', $file ) ); } return $stub; }
php
public static function findStubLength( $file, $pattern = self::PATTERN_OPEN ) { if (!($fp = fopen($file, 'rb'))) { throw new RuntimeException( sprintf( 'The phar "%s" could not be opened for reading.', $file ) ); } $stub = null; $offset = 0; $combo = str_split($pattern); while (!feof($fp)) { if (fgetc($fp) === $combo[$offset]) { $offset++; if (!isset($combo[$offset])) { $stub = ftell($fp); break; } } else { $offset = 0; } } fclose($fp); if (null === $stub) { throw new InvalidArgumentException( sprintf( 'The pattern could not be found in "%s".', $file ) ); } return $stub; }
[ "public", "static", "function", "findStubLength", "(", "$", "file", ",", "$", "pattern", "=", "self", "::", "PATTERN_OPEN", ")", "{", "if", "(", "!", "(", "$", "fp", "=", "fopen", "(", "$", "file", ",", "'rb'", ")", ")", ")", "{", "throw", "new", ...
Finds the phar's stub length using the end pattern. A "pattern" is a sequence of characters that indicate the end of a stub, and the beginning of a manifest. This determines the complete size of a stub, and is used as an offset to begin parsing the data contained in the phar's manifest. The stub generated included with the Box library uses what I like to call an open-ended pattern. This pattern uses the function "__HALT_COMPILER();" at the end, with no following whitespace or closing PHP tag. By default, this method will use that pattern, defined as `Extract::PATTERN_OPEN`. The Phar class generates its own default stub. The pattern for the default stub is slightly different than the one used by Box. This pattern is defined as `Extract::PATTERN_DEFAULT`. If you have used your own custom stub, you will need to specify its pattern as the `$pattern` argument, if you cannot use either of the pattern constants defined. @param string $file The phar file path. @param string $pattern The stub end pattern. @return integer The stub length. @throws InvalidArgumentException If the pattern could not be found. @throws RuntimeException If the phar could not be read.
[ "Finds", "the", "phar", "s", "stub", "length", "using", "the", "end", "pattern", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L145-L188
train
box-project/box2-lib
src/lib/Herrera/Box/Extract.php
Extract.go
public function go($dir = null) { // set up the output directory if (null === $dir) { $dir = rtrim(sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'pharextract' . DIRECTORY_SEPARATOR . basename($this->file, '.phar'); } else { $dir = realpath($dir); } // skip if already extracted $md5 = $dir . DIRECTORY_SEPARATOR . md5_file($this->file); if (file_exists($md5)) { return $dir; } if (!is_dir($dir)) { $this->createDir($dir); } // open the file and skip stub $this->open(); if (-1 === fseek($this->handle, $this->stub)) { throw new RuntimeException( sprintf( 'Could not seek to %d in the file "%s".', $this->stub, $this->file ) ); } // read the manifest $info = $this->readManifest(); if ($info['flags'] & self::GZ) { if (!function_exists('gzinflate')) { throw new RuntimeException( 'The zlib extension is (gzinflate()) is required for "%s.', $this->file ); } } if ($info['flags'] & self::BZ2) { if (!function_exists('bzdecompress')) { throw new RuntimeException( 'The bzip2 extension (bzdecompress()) is required for "%s".', $this->file ); } } self::purge($dir); $this->createDir($dir); $this->createFile($md5); foreach ($info['files'] as $info) { $path = $dir . DIRECTORY_SEPARATOR . $info['path']; $parent = dirname($path); if (!is_dir($parent)) { $this->createDir($parent); } if (preg_match('{/$}', $info['path'])) { $this->createDir($path, 0777, false); } else { $this->createFile( $path, $this->extractFile($info) ); } } return $dir; }
php
public function go($dir = null) { // set up the output directory if (null === $dir) { $dir = rtrim(sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'pharextract' . DIRECTORY_SEPARATOR . basename($this->file, '.phar'); } else { $dir = realpath($dir); } // skip if already extracted $md5 = $dir . DIRECTORY_SEPARATOR . md5_file($this->file); if (file_exists($md5)) { return $dir; } if (!is_dir($dir)) { $this->createDir($dir); } // open the file and skip stub $this->open(); if (-1 === fseek($this->handle, $this->stub)) { throw new RuntimeException( sprintf( 'Could not seek to %d in the file "%s".', $this->stub, $this->file ) ); } // read the manifest $info = $this->readManifest(); if ($info['flags'] & self::GZ) { if (!function_exists('gzinflate')) { throw new RuntimeException( 'The zlib extension is (gzinflate()) is required for "%s.', $this->file ); } } if ($info['flags'] & self::BZ2) { if (!function_exists('bzdecompress')) { throw new RuntimeException( 'The bzip2 extension (bzdecompress()) is required for "%s".', $this->file ); } } self::purge($dir); $this->createDir($dir); $this->createFile($md5); foreach ($info['files'] as $info) { $path = $dir . DIRECTORY_SEPARATOR . $info['path']; $parent = dirname($path); if (!is_dir($parent)) { $this->createDir($parent); } if (preg_match('{/$}', $info['path'])) { $this->createDir($path, 0777, false); } else { $this->createFile( $path, $this->extractFile($info) ); } } return $dir; }
[ "public", "function", "go", "(", "$", "dir", "=", "null", ")", "{", "// set up the output directory", "if", "(", "null", "===", "$", "dir", ")", "{", "$", "dir", "=", "rtrim", "(", "sys_get_temp_dir", "(", ")", ",", "'\\\\/'", ")", ".", "DIRECTORY_SEPARA...
Extracts the phar to the directory path. If no directory path is given, a temporary one will be generated and returned. If a directory path is given, the returned directory path will be the same. @param string $dir The directory to extract to. @return string The directory extracted to. @throws LengthException @throws RuntimeException
[ "Extracts", "the", "phar", "to", "the", "directory", "path", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L204-L285
train
box-project/box2-lib
src/lib/Herrera/Box/Extract.php
Extract.purge
public static function purge($path) { if (is_dir($path)) { foreach (scandir($path) as $item) { if (('.' === $item) || ('..' === $item)) { continue; } self::purge($path . DIRECTORY_SEPARATOR . $item); } if (!rmdir($path)) { throw new RuntimeException( sprintf( 'The directory "%s" could not be deleted.', $path ) ); } } else { if (!unlink($path)) { throw new RuntimeException( sprintf( 'The file "%s" could not be deleted.', $path ) ); } } }
php
public static function purge($path) { if (is_dir($path)) { foreach (scandir($path) as $item) { if (('.' === $item) || ('..' === $item)) { continue; } self::purge($path . DIRECTORY_SEPARATOR . $item); } if (!rmdir($path)) { throw new RuntimeException( sprintf( 'The directory "%s" could not be deleted.', $path ) ); } } else { if (!unlink($path)) { throw new RuntimeException( sprintf( 'The file "%s" could not be deleted.', $path ) ); } } }
[ "public", "static", "function", "purge", "(", "$", "path", ")", "{", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "foreach", "(", "scandir", "(", "$", "path", ")", "as", "$", "item", ")", "{", "if", "(", "(", "'.'", "===", "$", "item",...
Recursively deletes the directory or file path. @param string $path The path to delete. @throws RuntimeException If the path could not be deleted.
[ "Recursively", "deletes", "the", "directory", "or", "file", "path", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L294-L323
train
box-project/box2-lib
src/lib/Herrera/Box/Extract.php
Extract.extractFile
private function extractFile($info) { if (0 === $info['size']) { return ''; } $data = $this->read($info['compressed_size']); if ($info['flags'] & self::GZ) { if (false === ($data = gzinflate($data))) { throw new RuntimeException( sprintf( 'The "%s" file could not be inflated (gzip) from "%s".', $info['path'], $this->file ) ); } } elseif ($info['flags'] & self::BZ2) { if (false === ($data = bzdecompress($data))) { throw new RuntimeException( sprintf( 'The "%s" file could not be inflated (bzip2) from "%s".', $info['path'], $this->file ) ); } } if (($actual = strlen($data)) !== $info['size']) { throw new UnexpectedValueException( sprintf( 'The size of "%s" (%d) did not match what was expected (%d) in "%s".', $info['path'], $actual, $info['size'], $this->file ) ); } $crc32 = sprintf('%u', crc32($data) & 0xffffffff); if ($info['crc32'] != $crc32) { throw new UnexpectedValueException( sprintf( 'The crc32 checksum (%s) for "%s" did not match what was expected (%s) in "%s".', $crc32, $info['path'], $info['crc32'], $this->file ) ); } return $data; }
php
private function extractFile($info) { if (0 === $info['size']) { return ''; } $data = $this->read($info['compressed_size']); if ($info['flags'] & self::GZ) { if (false === ($data = gzinflate($data))) { throw new RuntimeException( sprintf( 'The "%s" file could not be inflated (gzip) from "%s".', $info['path'], $this->file ) ); } } elseif ($info['flags'] & self::BZ2) { if (false === ($data = bzdecompress($data))) { throw new RuntimeException( sprintf( 'The "%s" file could not be inflated (bzip2) from "%s".', $info['path'], $this->file ) ); } } if (($actual = strlen($data)) !== $info['size']) { throw new UnexpectedValueException( sprintf( 'The size of "%s" (%d) did not match what was expected (%d) in "%s".', $info['path'], $actual, $info['size'], $this->file ) ); } $crc32 = sprintf('%u', crc32($data) & 0xffffffff); if ($info['crc32'] != $crc32) { throw new UnexpectedValueException( sprintf( 'The crc32 checksum (%s) for "%s" did not match what was expected (%s) in "%s".', $crc32, $info['path'], $info['crc32'], $this->file ) ); } return $data; }
[ "private", "function", "extractFile", "(", "$", "info", ")", "{", "if", "(", "0", "===", "$", "info", "[", "'size'", "]", ")", "{", "return", "''", ";", "}", "$", "data", "=", "$", "this", "->", "read", "(", "$", "info", "[", "'compressed_size'", ...
Extracts a single file from the phar. @param array $info The file information. @return string The file data. @throws RuntimeException If the file could not be extracted. @throws UnexpectedValueException If the crc32 checksum does not match the expected value.
[ "Extracts", "a", "single", "file", "from", "the", "phar", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L388-L445
train
box-project/box2-lib
src/lib/Herrera/Box/Extract.php
Extract.open
private function open() { if (null === ($this->handle = fopen($this->file, 'rb'))) { $this->handle = null; throw new RuntimeException( sprintf( 'The file "%s" could not be opened for reading.', $this->file ) ); } }
php
private function open() { if (null === ($this->handle = fopen($this->file, 'rb'))) { $this->handle = null; throw new RuntimeException( sprintf( 'The file "%s" could not be opened for reading.', $this->file ) ); } }
[ "private", "function", "open", "(", ")", "{", "if", "(", "null", "===", "(", "$", "this", "->", "handle", "=", "fopen", "(", "$", "this", "->", "file", ",", "'rb'", ")", ")", ")", "{", "$", "this", "->", "handle", "=", "null", ";", "throw", "ne...
Opens the file for reading. @throws RuntimeException If the file could not be opened.
[ "Opens", "the", "file", "for", "reading", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L452-L464
train
box-project/box2-lib
src/lib/Herrera/Box/Extract.php
Extract.read
private function read($bytes) { $read = ''; $total = $bytes; while (!feof($this->handle) && $bytes) { if (false === ($chunk = fread($this->handle, $bytes))) { throw new RuntimeException( sprintf( 'Could not read %d bytes from "%s".', $bytes, $this->file ) ); } $read .= $chunk; $bytes -= strlen($chunk); } if (($actual = strlen($read)) !== $total) { throw new RuntimeException( sprintf( 'Only read %d of %d in "%s".', $actual, $total, $this->file ) ); } return $read; }
php
private function read($bytes) { $read = ''; $total = $bytes; while (!feof($this->handle) && $bytes) { if (false === ($chunk = fread($this->handle, $bytes))) { throw new RuntimeException( sprintf( 'Could not read %d bytes from "%s".', $bytes, $this->file ) ); } $read .= $chunk; $bytes -= strlen($chunk); } if (($actual = strlen($read)) !== $total) { throw new RuntimeException( sprintf( 'Only read %d of %d in "%s".', $actual, $total, $this->file ) ); } return $read; }
[ "private", "function", "read", "(", "$", "bytes", ")", "{", "$", "read", "=", "''", ";", "$", "total", "=", "$", "bytes", ";", "while", "(", "!", "feof", "(", "$", "this", "->", "handle", ")", "&&", "$", "bytes", ")", "{", "if", "(", "false", ...
Reads the number of bytes from the file. @param integer $bytes The number of bytes. @return string The binary string read. @throws RuntimeException If the read fails.
[ "Reads", "the", "number", "of", "bytes", "from", "the", "file", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L475-L507
train
box-project/box2-lib
src/lib/Herrera/Box/Extract.php
Extract.readManifest
private function readManifest() { $size = unpack('V', $this->read(4)); $size = $size[1]; $raw = $this->read($size); // ++ start skip: API version, global flags, alias, and metadata $count = unpack('V', substr($raw, 0, 4)); $count = $count[1]; $aliasSize = unpack('V', substr($raw, 10, 4)); $aliasSize = $aliasSize[1]; $raw = substr($raw, 14 + $aliasSize); $metaSize = unpack('V', substr($raw, 0, 4)); $metaSize = $metaSize[1]; $offset = 0; $start = 4 + $metaSize; // -- end skip $manifest = array( 'files' => array(), 'flags' => 0, ); for ($i = 0; $i < $count; $i++) { $length = unpack('V', substr($raw, $start, 4)); $length = $length[1]; $start += 4; $path = substr($raw, $start, $length); $start += $length; $file = unpack( 'Vsize/Vtimestamp/Vcompressed_size/Vcrc32/Vflags/Vmetadata_length', substr($raw, $start, 24) ); $file['path'] = $path; $file['crc32'] = sprintf('%u', $file['crc32'] & 0xffffffff); $file['offset'] = $offset; $offset += $file['compressed_size']; $start += 24 + $file['metadata_length']; $manifest['flags'] |= $file['flags'] & self::MASK; $manifest['files'][] = $file; } return $manifest; }
php
private function readManifest() { $size = unpack('V', $this->read(4)); $size = $size[1]; $raw = $this->read($size); // ++ start skip: API version, global flags, alias, and metadata $count = unpack('V', substr($raw, 0, 4)); $count = $count[1]; $aliasSize = unpack('V', substr($raw, 10, 4)); $aliasSize = $aliasSize[1]; $raw = substr($raw, 14 + $aliasSize); $metaSize = unpack('V', substr($raw, 0, 4)); $metaSize = $metaSize[1]; $offset = 0; $start = 4 + $metaSize; // -- end skip $manifest = array( 'files' => array(), 'flags' => 0, ); for ($i = 0; $i < $count; $i++) { $length = unpack('V', substr($raw, $start, 4)); $length = $length[1]; $start += 4; $path = substr($raw, $start, $length); $start += $length; $file = unpack( 'Vsize/Vtimestamp/Vcompressed_size/Vcrc32/Vflags/Vmetadata_length', substr($raw, $start, 24) ); $file['path'] = $path; $file['crc32'] = sprintf('%u', $file['crc32'] & 0xffffffff); $file['offset'] = $offset; $offset += $file['compressed_size']; $start += 24 + $file['metadata_length']; $manifest['flags'] |= $file['flags'] & self::MASK; $manifest['files'][] = $file; } return $manifest; }
[ "private", "function", "readManifest", "(", ")", "{", "$", "size", "=", "unpack", "(", "'V'", ",", "$", "this", "->", "read", "(", "4", ")", ")", ";", "$", "size", "=", "$", "size", "[", "1", "]", ";", "$", "raw", "=", "$", "this", "->", "rea...
Reads and unpacks the manifest data from the phar. @return array The manifest.
[ "Reads", "and", "unpacks", "the", "manifest", "data", "from", "the", "phar", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L514-L567
train
box-project/box2-lib
src/lib/Herrera/Box/StubGenerator.php
StubGenerator.extract
public function extract($extract, $force = false) { $this->extract = $extract; $this->extractForce = $force; if ($extract) { $this->extractCode = array( 'constants' => array(), 'class' => array(), ); $compactor = new Php(); $code = file_get_contents(__DIR__ . '/Extract.php'); $code = $compactor->compact($code); $code = preg_replace('/\n+/', "\n", $code); $code = explode("\n", $code); $code = array_slice($code, 2); foreach ($code as $i => $line) { if ((0 === strpos($line, 'use')) && (false === strpos($line, '\\')) ) { unset($code[$i]); } elseif (0 === strpos($line, 'define')) { $this->extractCode['constants'][] = $line; } else { $this->extractCode['class'][] = $line; } } } return $this; }
php
public function extract($extract, $force = false) { $this->extract = $extract; $this->extractForce = $force; if ($extract) { $this->extractCode = array( 'constants' => array(), 'class' => array(), ); $compactor = new Php(); $code = file_get_contents(__DIR__ . '/Extract.php'); $code = $compactor->compact($code); $code = preg_replace('/\n+/', "\n", $code); $code = explode("\n", $code); $code = array_slice($code, 2); foreach ($code as $i => $line) { if ((0 === strpos($line, 'use')) && (false === strpos($line, '\\')) ) { unset($code[$i]); } elseif (0 === strpos($line, 'define')) { $this->extractCode['constants'][] = $line; } else { $this->extractCode['class'][] = $line; } } } return $this; }
[ "public", "function", "extract", "(", "$", "extract", ",", "$", "force", "=", "false", ")", "{", "$", "this", "->", "extract", "=", "$", "extract", ";", "$", "this", "->", "extractForce", "=", "$", "force", ";", "if", "(", "$", "extract", ")", "{",...
Embed the Extract class in the stub? @param boolean $extract Embed the class? @param boolean $force Force the use of the class? @return StubGenerator The stub generator.
[ "Embed", "the", "Extract", "class", "in", "the", "stub?" ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/StubGenerator.php#L166-L198
train
box-project/box2-lib
src/lib/Herrera/Box/StubGenerator.php
StubGenerator.mung
public function mung(array $list) { foreach ($list as $value) { if (false === in_array($value, self::$allowedMung)) { throw InvalidArgumentException::create( 'The $_SERVER variable "%s" is not allowed.', $value ); } } $this->mung = $list; return $this; }
php
public function mung(array $list) { foreach ($list as $value) { if (false === in_array($value, self::$allowedMung)) { throw InvalidArgumentException::create( 'The $_SERVER variable "%s" is not allowed.', $value ); } } $this->mung = $list; return $this; }
[ "public", "function", "mung", "(", "array", "$", "list", ")", "{", "foreach", "(", "$", "list", "as", "$", "value", ")", "{", "if", "(", "false", "===", "in_array", "(", "$", "value", ",", "self", "::", "$", "allowedMung", ")", ")", "{", "throw", ...
Sets the list of server variables to modify. @param array $list The list. @return StubGenerator The stub generator. @throws Exception\Exception @throws InvalidArgumentException If the list contains an invalid value.
[ "Sets", "the", "list", "of", "server", "variables", "to", "modify", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/StubGenerator.php#L308-L322
train
box-project/box2-lib
src/lib/Herrera/Box/StubGenerator.php
StubGenerator.getAlias
private function getAlias() { $stub = ''; $prefix = ''; if ($this->extractForce) { $prefix = '$dir/'; } if ($this->web) { $stub .= 'Phar::webPhar(' . $this->arg($this->alias); if ($this->index) { $stub .= ', ' . $this->arg($prefix . $this->index, '"'); if ($this->notFound) { $stub .= ', ' . $this->arg($prefix . $this->notFound, '"'); if ($this->mimetypes) { $stub .= ', ' . var_export( $this->mimetypes, true ); if ($this->rewrite) { $stub .= ', ' . $this->arg($this->rewrite); } } } } $stub .= ');'; } else { $stub .= 'Phar::mapPhar(' . $this->arg($this->alias) . ');'; } return $stub; }
php
private function getAlias() { $stub = ''; $prefix = ''; if ($this->extractForce) { $prefix = '$dir/'; } if ($this->web) { $stub .= 'Phar::webPhar(' . $this->arg($this->alias); if ($this->index) { $stub .= ', ' . $this->arg($prefix . $this->index, '"'); if ($this->notFound) { $stub .= ', ' . $this->arg($prefix . $this->notFound, '"'); if ($this->mimetypes) { $stub .= ', ' . var_export( $this->mimetypes, true ); if ($this->rewrite) { $stub .= ', ' . $this->arg($this->rewrite); } } } } $stub .= ');'; } else { $stub .= 'Phar::mapPhar(' . $this->arg($this->alias) . ');'; } return $stub; }
[ "private", "function", "getAlias", "(", ")", "{", "$", "stub", "=", "''", ";", "$", "prefix", "=", "''", ";", "if", "(", "$", "this", "->", "extractForce", ")", "{", "$", "prefix", "=", "'$dir/'", ";", "}", "if", "(", "$", "this", "->", "web", ...
Returns the alias map. @return string The alias map.
[ "Returns", "the", "alias", "map", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/StubGenerator.php#L398-L435
train
box-project/box2-lib
src/lib/Herrera/Box/StubGenerator.php
StubGenerator.getPharSections
private function getPharSections() { $stub = array( 'if (class_exists(\'Phar\')) {', $this->getAlias(), ); if ($this->intercept) { $stub[] = "Phar::interceptFileFuncs();"; } if ($this->mung) { $stub[] = 'Phar::mungServer(' . var_export($this->mung, true) . ");"; } if ($this->index && !$this->web && !$this->extractForce) { $stub[] = "require 'phar://' . __FILE__ . '/{$this->index}';"; } $stub[] = '}'; return $stub; }
php
private function getPharSections() { $stub = array( 'if (class_exists(\'Phar\')) {', $this->getAlias(), ); if ($this->intercept) { $stub[] = "Phar::interceptFileFuncs();"; } if ($this->mung) { $stub[] = 'Phar::mungServer(' . var_export($this->mung, true) . ");"; } if ($this->index && !$this->web && !$this->extractForce) { $stub[] = "require 'phar://' . __FILE__ . '/{$this->index}';"; } $stub[] = '}'; return $stub; }
[ "private", "function", "getPharSections", "(", ")", "{", "$", "stub", "=", "array", "(", "'if (class_exists(\\'Phar\\')) {'", ",", "$", "this", "->", "getAlias", "(", ")", ",", ")", ";", "if", "(", "$", "this", "->", "intercept", ")", "{", "$", "stub", ...
Returns the sections of the stub that use the Phar class. @return array The stub sections.
[ "Returns", "the", "sections", "of", "the", "stub", "that", "use", "the", "Phar", "class", "." ]
1c5d528d0c44af9d084c2e68ed8b5863db9abe0c
https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/StubGenerator.php#L475-L497
train
desarrolla2/Cache
src/Packer/PackingTrait.php
PackingTrait.getPacker
protected function getPacker(): PackerInterface { if (!isset($this->packer)) { $this->packer = static::createDefaultPacker(); } return $this->packer; }
php
protected function getPacker(): PackerInterface { if (!isset($this->packer)) { $this->packer = static::createDefaultPacker(); } return $this->packer; }
[ "protected", "function", "getPacker", "(", ")", ":", "PackerInterface", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "packer", ")", ")", "{", "$", "this", "->", "packer", "=", "static", "::", "createDefaultPacker", "(", ")", ";", "}", "return"...
Get the packer @return PackerInterface
[ "Get", "the", "packer" ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Packer/PackingTrait.php#L55-L62
train
desarrolla2/Cache
src/Option/FilenameTrait.php
FilenameTrait.setFilenameOption
protected function setFilenameOption($filename): void { if (is_string($filename)) { $filename = new BasicFilename($filename); } if (!is_callable($filename)) { throw new TypeError("Filename should be a string or callable"); } $this->filename = $filename; }
php
protected function setFilenameOption($filename): void { if (is_string($filename)) { $filename = new BasicFilename($filename); } if (!is_callable($filename)) { throw new TypeError("Filename should be a string or callable"); } $this->filename = $filename; }
[ "protected", "function", "setFilenameOption", "(", "$", "filename", ")", ":", "void", "{", "if", "(", "is_string", "(", "$", "filename", ")", ")", "{", "$", "filename", "=", "new", "BasicFilename", "(", "$", "filename", ")", ";", "}", "if", "(", "!", ...
Filename format or callable. The filename format will be applied using sprintf, replacing `%s` with the key. @param string|callable $filename @return void
[ "Filename", "format", "or", "callable", ".", "The", "filename", "format", "will", "be", "applied", "using", "sprintf", "replacing", "%s", "with", "the", "key", "." ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Option/FilenameTrait.php#L39-L50
train
desarrolla2/Cache
src/Option/FilenameTrait.php
FilenameTrait.getFilenameOption
protected function getFilenameOption(): callable { if (!isset($this->filename)) { $this->filename = new BasicFilename('%s.' . $this->getPacker()->getType()); } return $this->filename; }
php
protected function getFilenameOption(): callable { if (!isset($this->filename)) { $this->filename = new BasicFilename('%s.' . $this->getPacker()->getType()); } return $this->filename; }
[ "protected", "function", "getFilenameOption", "(", ")", ":", "callable", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "filename", ")", ")", "{", "$", "this", "->", "filename", "=", "new", "BasicFilename", "(", "'%s.'", ".", "$", "this", "->", ...
Get the filename callable @return callable
[ "Get", "the", "filename", "callable" ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Option/FilenameTrait.php#L57-L64
train
desarrolla2/Cache
src/Option/FilenameTrait.php
FilenameTrait.getFilename
protected function getFilename($key): string { $id = $this->keyToId($key); $generator = $this->getFilenameOption(); return $this->cacheDir . DIRECTORY_SEPARATOR . $generator($id); }
php
protected function getFilename($key): string { $id = $this->keyToId($key); $generator = $this->getFilenameOption(); return $this->cacheDir . DIRECTORY_SEPARATOR . $generator($id); }
[ "protected", "function", "getFilename", "(", "$", "key", ")", ":", "string", "{", "$", "id", "=", "$", "this", "->", "keyToId", "(", "$", "key", ")", ";", "$", "generator", "=", "$", "this", "->", "getFilenameOption", "(", ")", ";", "return", "$", ...
Create a filename based on the key @param string|mixed $key @return string
[ "Create", "a", "filename", "based", "on", "the", "key" ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Option/FilenameTrait.php#L72-L78
train
desarrolla2/Cache
src/File.php
File.getTtl
protected function getTtl(string $cacheFile) { switch ($this->ttlStrategy) { case 'embed': return (int)$this->readLine($cacheFile); case 'file': return file_exists("$cacheFile.ttl") ? (int)file_get_contents("$cacheFile.ttl") : PHP_INT_MAX; case 'mtime': return $this->getTtl() > 0 ? filemtime($cacheFile) + $this->ttl : PHP_INT_MAX; } }
php
protected function getTtl(string $cacheFile) { switch ($this->ttlStrategy) { case 'embed': return (int)$this->readLine($cacheFile); case 'file': return file_exists("$cacheFile.ttl") ? (int)file_get_contents("$cacheFile.ttl") : PHP_INT_MAX; case 'mtime': return $this->getTtl() > 0 ? filemtime($cacheFile) + $this->ttl : PHP_INT_MAX; } }
[ "protected", "function", "getTtl", "(", "string", "$", "cacheFile", ")", "{", "switch", "(", "$", "this", "->", "ttlStrategy", ")", "{", "case", "'embed'", ":", "return", "(", "int", ")", "$", "this", "->", "readLine", "(", "$", "cacheFile", ")", ";", ...
Get the TTL using one of the strategies @param string $cacheFile @return int
[ "Get", "the", "TTL", "using", "one", "of", "the", "strategies" ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/File.php#L76-L88
train
desarrolla2/Cache
src/File.php
File.setTtl
protected function setTtl($expiration, $contents, $cacheFile) { switch ($this->ttlStrategy) { case 'embed': $contents = ($expiration ?? PHP_INT_MAX) . "\n" . $contents; break; case 'file': if (isset($expiration)) { file_put_contents("$cacheFile.ttl", $expiration); } break; case 'mtime': // nothing break; } return $contents; }
php
protected function setTtl($expiration, $contents, $cacheFile) { switch ($this->ttlStrategy) { case 'embed': $contents = ($expiration ?? PHP_INT_MAX) . "\n" . $contents; break; case 'file': if (isset($expiration)) { file_put_contents("$cacheFile.ttl", $expiration); } break; case 'mtime': // nothing break; } return $contents; }
[ "protected", "function", "setTtl", "(", "$", "expiration", ",", "$", "contents", ",", "$", "cacheFile", ")", "{", "switch", "(", "$", "this", "->", "ttlStrategy", ")", "{", "case", "'embed'", ":", "$", "contents", "=", "(", "$", "expiration", "??", "PH...
Set the TTL using one of the strategies @param int $expiration @param string $contents @param string $cacheFile @return string The (modified) contents
[ "Set", "the", "TTL", "using", "one", "of", "the", "strategies" ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/File.php#L98-L115
train
desarrolla2/Cache
src/AbstractFile.php
AbstractFile.readLine
protected function readLine(string $cacheFile): string { $fp = fopen($cacheFile, 'r'); $line = fgets($fp); fclose($fp); return $line; }
php
protected function readLine(string $cacheFile): string { $fp = fopen($cacheFile, 'r'); $line = fgets($fp); fclose($fp); return $line; }
[ "protected", "function", "readLine", "(", "string", "$", "cacheFile", ")", ":", "string", "{", "$", "fp", "=", "fopen", "(", "$", "cacheFile", ",", "'r'", ")", ";", "$", "line", "=", "fgets", "(", "$", "fp", ")", ";", "fclose", "(", "$", "fp", ")...
Read the first line of the cache file @param string $cacheFile @return string
[ "Read", "the", "first", "line", "of", "the", "cache", "file" ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractFile.php#L87-L94
train
desarrolla2/Cache
src/AbstractFile.php
AbstractFile.writeFile
protected function writeFile(string $cacheFile, string $contents): bool { $dir = dirname($cacheFile); if ($dir !== $this->cacheDir && !is_dir($dir)) { mkdir($dir, 0775, true); } return (bool)file_put_contents($cacheFile, $contents); }
php
protected function writeFile(string $cacheFile, string $contents): bool { $dir = dirname($cacheFile); if ($dir !== $this->cacheDir && !is_dir($dir)) { mkdir($dir, 0775, true); } return (bool)file_put_contents($cacheFile, $contents); }
[ "protected", "function", "writeFile", "(", "string", "$", "cacheFile", ",", "string", "$", "contents", ")", ":", "bool", "{", "$", "dir", "=", "dirname", "(", "$", "cacheFile", ")", ";", "if", "(", "$", "dir", "!==", "$", "this", "->", "cacheDir", "&...
Create a cache file @param string $cacheFile @param string $contents @return bool
[ "Create", "a", "cache", "file" ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractFile.php#L103-L112
train
desarrolla2/Cache
src/Memcached.php
Memcached.ttlToMemcachedTime
protected function ttlToMemcachedTime($ttl) { $seconds = $this->ttlToSeconds($ttl); if ($seconds <= 0) { return isset($seconds) ? false : 0; } /* 2592000 seconds = 30 days */ return $seconds <= 2592000 ? $seconds : $this->ttlToTimestamp($ttl); }
php
protected function ttlToMemcachedTime($ttl) { $seconds = $this->ttlToSeconds($ttl); if ($seconds <= 0) { return isset($seconds) ? false : 0; } /* 2592000 seconds = 30 days */ return $seconds <= 2592000 ? $seconds : $this->ttlToTimestamp($ttl); }
[ "protected", "function", "ttlToMemcachedTime", "(", "$", "ttl", ")", "{", "$", "seconds", "=", "$", "this", "->", "ttlToSeconds", "(", "$", "ttl", ")", ";", "if", "(", "$", "seconds", "<=", "0", ")", "{", "return", "isset", "(", "$", "seconds", ")", ...
Convert ttl to timestamp or seconds. @see http://php.net/manual/en/memcached.expiration.php @param null|int|DateInterval $ttl @return int|null @throws InvalidArgumentException
[ "Convert", "ttl", "to", "timestamp", "or", "seconds", "." ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Memcached.php#L207-L217
train
desarrolla2/Cache
src/PhpFile.php
PhpFile.createScript
public function createScript($value, ?int $ttl): string { $macro = var_export($value, true); if (strpos($macro, 'stdClass::__set_state') !== false) { $macro = preg_replace_callback("/('([^'\\\\]++|''\\.)')|stdClass::__set_state/", $macro, function($match) { return empty($match[1]) ? '(object)' : $match[1]; }); } return $ttl !== null ? "<?php return time() < {$ttl} ? {$macro} : false;" : "<?php return {$macro};"; }
php
public function createScript($value, ?int $ttl): string { $macro = var_export($value, true); if (strpos($macro, 'stdClass::__set_state') !== false) { $macro = preg_replace_callback("/('([^'\\\\]++|''\\.)')|stdClass::__set_state/", $macro, function($match) { return empty($match[1]) ? '(object)' : $match[1]; }); } return $ttl !== null ? "<?php return time() < {$ttl} ? {$macro} : false;" : "<?php return {$macro};"; }
[ "public", "function", "createScript", "(", "$", "value", ",", "?", "int", "$", "ttl", ")", ":", "string", "{", "$", "macro", "=", "var_export", "(", "$", "value", ",", "true", ")", ";", "if", "(", "strpos", "(", "$", "macro", ",", "'stdClass::__set_s...
Create a PHP script returning the cached value @param mixed $value @param int|null $ttl @return string
[ "Create", "a", "PHP", "script", "returning", "the", "cached", "value" ]
e25b51fe0f9b386161c9c35e1d591f587617fcfa
https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/PhpFile.php#L60-L73
train