repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
39
1.84M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php
Xsl.getArtifactPath
private function getArtifactPath(Transformation $transformation) { return $transformation->getArtifact() ? $transformation->getTransformer()->getTarget() . DIRECTORY_SEPARATOR . $transformation->getArtifact() : null; }
php
private function getArtifactPath(Transformation $transformation) { return $transformation->getArtifact() ? $transformation->getTransformer()->getTarget() . DIRECTORY_SEPARATOR . $transformation->getArtifact() : null; }
[ "private", "function", "getArtifactPath", "(", "Transformation", "$", "transformation", ")", "{", "return", "$", "transformation", "->", "getArtifact", "(", ")", "?", "$", "transformation", "->", "getTransformer", "(", ")", "->", "getTarget", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "transformation", "->", "getArtifact", "(", ")", ":", "null", ";", "}" ]
Returns the path to the location where the artifact should be written, or null to automatically detect the location using the router. @return string|null
[ "Returns", "the", "path", "to", "the", "location", "where", "the", "artifact", "should", "be", "written", "or", "null", "to", "automatically", "detect", "the", "location", "using", "the", "router", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php#L304-L309
phpDocumentor/phpDocumentor2
src/phpDocumentor/Application/Console/Command/Project/TransformCommand.php
TransformCommand.configure
protected function configure(): void { $this->setAliases(['transform']) ->setDescription( 'Converts the PHPDocumentor structure file to documentation' ) ->setHelp( <<<TEXT This task will execute the transformation rules described in the given template (defaults to 'responsive') with the given source (defaults to output/structure.xml) and writes these to the target location (defaults to 'output'). It is possible for the user to receive additional information using the verbose option or stop additional information using the quiet option. Please take note that the quiet option also disables logging to file. TEXT ); $this->addOption( 'source', 's', InputOption::VALUE_OPTIONAL, 'Path where the XML source file is located (optional)' ); $this->addOption( 'target', 't', InputOption::VALUE_OPTIONAL, 'Path where to store the generated output (optional)' ); $this->addOption( 'template', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Name of the template to use (optional)' ); parent::configure(); }
php
protected function configure(): void { $this->setAliases(['transform']) ->setDescription( 'Converts the PHPDocumentor structure file to documentation' ) ->setHelp( <<<TEXT This task will execute the transformation rules described in the given template (defaults to 'responsive') with the given source (defaults to output/structure.xml) and writes these to the target location (defaults to 'output'). It is possible for the user to receive additional information using the verbose option or stop additional information using the quiet option. Please take note that the quiet option also disables logging to file. TEXT ); $this->addOption( 'source', 's', InputOption::VALUE_OPTIONAL, 'Path where the XML source file is located (optional)' ); $this->addOption( 'target', 't', InputOption::VALUE_OPTIONAL, 'Path where to store the generated output (optional)' ); $this->addOption( 'template', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Name of the template to use (optional)' ); parent::configure(); }
[ "protected", "function", "configure", "(", ")", ":", "void", "{", "$", "this", "->", "setAliases", "(", "[", "'transform'", "]", ")", "->", "setDescription", "(", "'Converts the PHPDocumentor structure file to documentation'", ")", "->", "setHelp", "(", "\n <<<TEXT\n This task will execute the transformation rules described in the given\n template (defaults to 'responsive') with the given source (defaults to\n output/structure.xml) and writes these to the target location (defaults to\n 'output').\n \n It is possible for the user to receive additional information using the\n verbose option or stop additional information using the quiet option. Please\n take note that the quiet option also disables logging to file.\nTEXT", ")", ";", "$", "this", "->", "addOption", "(", "'source'", ",", "'s'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'Path where the XML source file is located (optional)'", ")", ";", "$", "this", "->", "addOption", "(", "'target'", ",", "'t'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'Path where to store the generated output (optional)'", ")", ";", "$", "this", "->", "addOption", "(", "'template'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Name of the template to use (optional)'", ")", ";", "parent", "::", "configure", "(", ")", ";", "}" ]
Initializes this command and sets the name, description, options and arguments.
[ "Initializes", "this", "command", "and", "sets", "the", "name", "description", "options", "and", "arguments", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application/Console/Command/Project/TransformCommand.php#L57-L96
phpDocumentor/phpDocumentor2
src/phpDocumentor/Application/Console/Command/Project/TransformCommand.php
TransformCommand.execute
protected function execute(InputInterface $input, OutputInterface $output): int { $pipeLine = $this->pipeline; $pipeLine($input->getOptions()); return 0; }
php
protected function execute(InputInterface $input, OutputInterface $output): int { $pipeLine = $this->pipeline; $pipeLine($input->getOptions()); return 0; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", ":", "int", "{", "$", "pipeLine", "=", "$", "this", "->", "pipeline", ";", "$", "pipeLine", "(", "$", "input", "->", "getOptions", "(", ")", ")", ";", "return", "0", ";", "}" ]
Executes the business logic involved with this command. @throws Exception if the provided source is not an existing file or a folder.
[ "Executes", "the", "business", "logic", "involved", "with", "this", "command", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application/Console/Command/Project/TransformCommand.php#L103-L109
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/ConstantAssembler.php
ConstantAssembler.create
public function create($data) { $constantDescriptor = new ConstantDescriptor(); $constantDescriptor->setName($data->getName()); $constantDescriptor->setValue($data->getValue()); // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself $constantDescriptor->setNamespace( substr((string) $data->getFqsen(), 0, - strlen($data->getName()) - static::SEPARATOR_SIZE) ); $constantDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $this->assembleDocBlock($data->getDocBlock(), $constantDescriptor); $constantDescriptor->setLine($data->getLocation()->getLineNumber()); return $constantDescriptor; }
php
public function create($data) { $constantDescriptor = new ConstantDescriptor(); $constantDescriptor->setName($data->getName()); $constantDescriptor->setValue($data->getValue()); $constantDescriptor->setNamespace( substr((string) $data->getFqsen(), 0, - strlen($data->getName()) - static::SEPARATOR_SIZE) ); $constantDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $this->assembleDocBlock($data->getDocBlock(), $constantDescriptor); $constantDescriptor->setLine($data->getLocation()->getLineNumber()); return $constantDescriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "constantDescriptor", "=", "new", "ConstantDescriptor", "(", ")", ";", "$", "constantDescriptor", "->", "setName", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "constantDescriptor", "->", "setValue", "(", "$", "data", "->", "getValue", "(", ")", ")", ";", "// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself", "$", "constantDescriptor", "->", "setNamespace", "(", "substr", "(", "(", "string", ")", "$", "data", "->", "getFqsen", "(", ")", ",", "0", ",", "-", "strlen", "(", "$", "data", "->", "getName", "(", ")", ")", "-", "static", "::", "SEPARATOR_SIZE", ")", ")", ";", "$", "constantDescriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "data", "->", "getFqsen", "(", ")", ")", ";", "$", "this", "->", "assembleDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ",", "$", "constantDescriptor", ")", ";", "$", "constantDescriptor", "->", "setLine", "(", "$", "data", "->", "getLocation", "(", ")", "->", "getLineNumber", "(", ")", ")", ";", "return", "$", "constantDescriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param Constant $data @return ConstantDescriptor
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/ConstantAssembler.php#L35-L51
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ProjectDescriptor/Settings.php
Settings.setValueAndCheckIfModified
protected function setValueAndCheckIfModified($propertyName, $value) { if ($this->{$propertyName} !== $value) { $this->isModified = true; } $this->{$propertyName} = $value; }
php
protected function setValueAndCheckIfModified($propertyName, $value) { if ($this->{$propertyName} !== $value) { $this->isModified = true; } $this->{$propertyName} = $value; }
[ "protected", "function", "setValueAndCheckIfModified", "(", "$", "propertyName", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "{", "$", "propertyName", "}", "!==", "$", "value", ")", "{", "$", "this", "->", "isModified", "=", "true", ";", "}", "$", "this", "->", "{", "$", "propertyName", "}", "=", "$", "value", ";", "}" ]
Sets a property's value and if it differs from the previous then mark these settings as modified.
[ "Sets", "a", "property", "s", "value", "and", "if", "it", "differs", "from", "the", "previous", "then", "mark", "these", "settings", "as", "modified", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptor/Settings.php#L88-L95
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Template/Collection.php
Collection.load
public function load($nameOrPath) { $template = $this->factory->get($nameOrPath); /** @var Transformation $transformation */ foreach ($template as $transformation) { /** @var WriterAbstract $writer */ $writer = $this->writerCollection[$transformation->getWriter()]; if ($writer) { $writer->checkRequirements(); } } $this[$template->getName()] = $template; }
php
public function load($nameOrPath) { $template = $this->factory->get($nameOrPath); foreach ($template as $transformation) { $writer = $this->writerCollection[$transformation->getWriter()]; if ($writer) { $writer->checkRequirements(); } } $this[$template->getName()] = $template; }
[ "public", "function", "load", "(", "$", "nameOrPath", ")", "{", "$", "template", "=", "$", "this", "->", "factory", "->", "get", "(", "$", "nameOrPath", ")", ";", "/** @var Transformation $transformation */", "foreach", "(", "$", "template", "as", "$", "transformation", ")", "{", "/** @var WriterAbstract $writer */", "$", "writer", "=", "$", "this", "->", "writerCollection", "[", "$", "transformation", "->", "getWriter", "(", ")", "]", ";", "if", "(", "$", "writer", ")", "{", "$", "writer", "->", "checkRequirements", "(", ")", ";", "}", "}", "$", "this", "[", "$", "template", "->", "getName", "(", ")", "]", "=", "$", "template", ";", "}" ]
Loads a template with the given name or file path. @param string $nameOrPath
[ "Loads", "a", "template", "with", "the", "given", "name", "or", "file", "path", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Collection.php#L49-L63
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Template/Collection.php
Collection.getTransformations
public function getTransformations() { $result = []; foreach ($this as $template) { foreach ($template as $transformation) { $result[] = $transformation; } } return $result; }
php
public function getTransformations() { $result = []; foreach ($this as $template) { foreach ($template as $transformation) { $result[] = $transformation; } } return $result; }
[ "public", "function", "getTransformations", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "template", ")", "{", "foreach", "(", "$", "template", "as", "$", "transformation", ")", "{", "$", "result", "[", "]", "=", "$", "transformation", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns a list of all transformations contained in the templates of this collection. @return Transformation[]
[ "Returns", "a", "list", "of", "all", "transformations", "contained", "in", "the", "templates", "of", "this", "collection", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Collection.php#L70-L80
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Filter/StripOnVisibility.php
StripOnVisibility.filter
public function filter($value) { if ($value instanceof VisibilityInterface && !$this->builder->isVisibilityAllowed($value->getVisibility()) ) { return null; } return $value; }
php
public function filter($value) { if ($value instanceof VisibilityInterface && !$this->builder->isVisibilityAllowed($value->getVisibility()) ) { return null; } return $value; }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "VisibilityInterface", "&&", "!", "$", "this", "->", "builder", "->", "isVisibilityAllowed", "(", "$", "value", "->", "getVisibility", "(", ")", ")", ")", "{", "return", "null", ";", "}", "return", "$", "value", ";", "}" ]
Filter Descriptor with based on visibility. @param DescriptorAbstract $value @return DescriptorAbstract|null
[ "Filter", "Descriptor", "with", "based", "on", "visibility", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Filter/StripOnVisibility.php#L46-L55
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/ClassAssembler.php
ClassAssembler.create
public function create($data) { $classDescriptor = new ClassDescriptor(); $classDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $classDescriptor->setName($data->getName()); $classDescriptor->setPackage( $this->extractPackageFromDocBlock($data->getDocBlock()) ?: $this->getBuilder()->getDefaultPackage() ); $classDescriptor->setLine($data->getLocation()->getLineNumber()); $classDescriptor->setParent($data->getParent()); $classDescriptor->setAbstract($data->isAbstract()); $classDescriptor->setFinal($data->isFinal()); $classDescriptor->setNamespace(substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1)); foreach ($data->getInterfaces() as $interfaceClassName) { $classDescriptor->getInterfaces()->set((string) $interfaceClassName, $interfaceClassName); } $this->assembleDocBlock($data->getDocBlock(), $classDescriptor); $this->addConstants($data->getConstants(), $classDescriptor); $this->addProperties($data->getProperties(), $classDescriptor); $this->addMethods($data->getMethods(), $classDescriptor); $this->addUses($data->getUsedTraits(), $classDescriptor); return $classDescriptor; }
php
public function create($data) { $classDescriptor = new ClassDescriptor(); $classDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $classDescriptor->setName($data->getName()); $classDescriptor->setPackage( $this->extractPackageFromDocBlock($data->getDocBlock()) ?: $this->getBuilder()->getDefaultPackage() ); $classDescriptor->setLine($data->getLocation()->getLineNumber()); $classDescriptor->setParent($data->getParent()); $classDescriptor->setAbstract($data->isAbstract()); $classDescriptor->setFinal($data->isFinal()); $classDescriptor->setNamespace(substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1)); foreach ($data->getInterfaces() as $interfaceClassName) { $classDescriptor->getInterfaces()->set((string) $interfaceClassName, $interfaceClassName); } $this->assembleDocBlock($data->getDocBlock(), $classDescriptor); $this->addConstants($data->getConstants(), $classDescriptor); $this->addProperties($data->getProperties(), $classDescriptor); $this->addMethods($data->getMethods(), $classDescriptor); $this->addUses($data->getUsedTraits(), $classDescriptor); return $classDescriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "classDescriptor", "=", "new", "ClassDescriptor", "(", ")", ";", "$", "classDescriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "data", "->", "getFqsen", "(", ")", ")", ";", "$", "classDescriptor", "->", "setName", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "classDescriptor", "->", "setPackage", "(", "$", "this", "->", "extractPackageFromDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ")", "?", ":", "$", "this", "->", "getBuilder", "(", ")", "->", "getDefaultPackage", "(", ")", ")", ";", "$", "classDescriptor", "->", "setLine", "(", "$", "data", "->", "getLocation", "(", ")", "->", "getLineNumber", "(", ")", ")", ";", "$", "classDescriptor", "->", "setParent", "(", "$", "data", "->", "getParent", "(", ")", ")", ";", "$", "classDescriptor", "->", "setAbstract", "(", "$", "data", "->", "isAbstract", "(", ")", ")", ";", "$", "classDescriptor", "->", "setFinal", "(", "$", "data", "->", "isFinal", "(", ")", ")", ";", "$", "classDescriptor", "->", "setNamespace", "(", "substr", "(", "(", "string", ")", "$", "data", "->", "getFqsen", "(", ")", ",", "0", ",", "-", "strlen", "(", "$", "data", "->", "getName", "(", ")", ")", "-", "1", ")", ")", ";", "foreach", "(", "$", "data", "->", "getInterfaces", "(", ")", "as", "$", "interfaceClassName", ")", "{", "$", "classDescriptor", "->", "getInterfaces", "(", ")", "->", "set", "(", "(", "string", ")", "$", "interfaceClassName", ",", "$", "interfaceClassName", ")", ";", "}", "$", "this", "->", "assembleDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ",", "$", "classDescriptor", ")", ";", "$", "this", "->", "addConstants", "(", "$", "data", "->", "getConstants", "(", ")", ",", "$", "classDescriptor", ")", ";", "$", "this", "->", "addProperties", "(", "$", "data", "->", "getProperties", "(", ")", ",", "$", "classDescriptor", ")", ";", "$", "this", "->", "addMethods", "(", "$", "data", "->", "getMethods", "(", ")", ",", "$", "classDescriptor", ")", ";", "$", "this", "->", "addUses", "(", "$", "data", "->", "getUsedTraits", "(", ")", ",", "$", "classDescriptor", ")", ";", "return", "$", "classDescriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param Class_ $data @return ClassDescriptor
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/ClassAssembler.php#L40-L67
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/ClassAssembler.php
ClassAssembler.addConstants
protected function addConstants(array $constants, ClassDescriptor $classDescriptor): void { foreach ($constants as $constant) { $constantDescriptor = $this->getBuilder()->buildDescriptor($constant); if ($constantDescriptor instanceof ConstantDescriptor) { $constantDescriptor->setParent($classDescriptor); $classDescriptor->getConstants()->set($constantDescriptor->getName(), $constantDescriptor); } } }
php
protected function addConstants(array $constants, ClassDescriptor $classDescriptor): void { foreach ($constants as $constant) { $constantDescriptor = $this->getBuilder()->buildDescriptor($constant); if ($constantDescriptor instanceof ConstantDescriptor) { $constantDescriptor->setParent($classDescriptor); $classDescriptor->getConstants()->set($constantDescriptor->getName(), $constantDescriptor); } } }
[ "protected", "function", "addConstants", "(", "array", "$", "constants", ",", "ClassDescriptor", "$", "classDescriptor", ")", ":", "void", "{", "foreach", "(", "$", "constants", "as", "$", "constant", ")", "{", "$", "constantDescriptor", "=", "$", "this", "->", "getBuilder", "(", ")", "->", "buildDescriptor", "(", "$", "constant", ")", ";", "if", "(", "$", "constantDescriptor", "instanceof", "ConstantDescriptor", ")", "{", "$", "constantDescriptor", "->", "setParent", "(", "$", "classDescriptor", ")", ";", "$", "classDescriptor", "->", "getConstants", "(", ")", "->", "set", "(", "$", "constantDescriptor", "->", "getName", "(", ")", ",", "$", "constantDescriptor", ")", ";", "}", "}", "}" ]
Registers the child constants with the generated Class Descriptor. @param Constant[] $constants
[ "Registers", "the", "child", "constants", "with", "the", "generated", "Class", "Descriptor", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/ClassAssembler.php#L74-L83
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Template/Factory.php
Factory.register
public function register(string $name, TemplateInterface $templateEngine): void { Assert::stringNotEmpty($name); $this->engines[$name] = $templateEngine; }
php
public function register(string $name, TemplateInterface $templateEngine): void { Assert::stringNotEmpty($name); $this->engines[$name] = $templateEngine; }
[ "public", "function", "register", "(", "string", "$", "name", ",", "TemplateInterface", "$", "templateEngine", ")", ":", "void", "{", "Assert", "::", "stringNotEmpty", "(", "$", "name", ")", ";", "$", "this", "->", "engines", "[", "$", "name", "]", "=", "$", "templateEngine", ";", "}" ]
Associates a human-readable / simplified name with a class name representing a template engine. The class belonging to the given class name should implement the TemplateInterface. If it does not then this method won't complain (as no instantiation is done here for performance reasons) but the `get()` method will throw an exception. @see get() to retrieve an instance for the given $name.
[ "Associates", "a", "human", "-", "readable", "/", "simplified", "name", "with", "a", "class", "name", "representing", "a", "template", "engine", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Template/Factory.php#L50-L54
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Template/Factory.php
Factory.get
public function get(string $name): TemplateInterface { if (!isset($this->engines[$name])) { throw new InvalidArgumentException('Template engine "' . $name . '" is not known or registered'); } return $this->engines[$name]; }
php
public function get(string $name): TemplateInterface { if (!isset($this->engines[$name])) { throw new InvalidArgumentException('Template engine "' . $name . '" is not known or registered'); } return $this->engines[$name]; }
[ "public", "function", "get", "(", "string", "$", "name", ")", ":", "TemplateInterface", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "engines", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Template engine \"'", ".", "$", "name", ".", "'\" is not known or registered'", ")", ";", "}", "return", "$", "this", "->", "engines", "[", "$", "name", "]", ";", "}" ]
Returns a new instance of the template engine belonging to the given name. @throws InvalidArgumentException if the given name is not registered
[ "Returns", "a", "new", "instance", "of", "the", "template", "engine", "belonging", "to", "the", "given", "name", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Template/Factory.php#L61-L68
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Example/Finder.php
Finder.constructExamplePath
private function constructExamplePath(string $directory, string $file): string { return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file; }
php
private function constructExamplePath(string $directory, string $file): string { return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file; }
[ "private", "function", "constructExamplePath", "(", "string", "$", "directory", ",", "string", "$", "file", ")", ":", "string", "{", "return", "rtrim", "(", "$", "directory", ",", "'\\\\/'", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", ";", "}" ]
Returns a path to the example file in the given directory..
[ "Returns", "a", "path", "to", "the", "example", "file", "in", "the", "given", "directory", ".." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Example/Finder.php#L129-L132
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Example/Finder.php
Finder.getExamplePathFromSource
private function getExamplePathFromSource(string $file): string { return sprintf( '%s%s%s', trim($this->getSourceDirectory(), '\\/'), DIRECTORY_SEPARATOR, trim($file, '"') ); }
php
private function getExamplePathFromSource(string $file): string { return sprintf( '%s%s%s', trim($this->getSourceDirectory(), '\\/'), DIRECTORY_SEPARATOR, trim($file, '"') ); }
[ "private", "function", "getExamplePathFromSource", "(", "string", "$", "file", ")", ":", "string", "{", "return", "sprintf", "(", "'%s%s%s'", ",", "trim", "(", "$", "this", "->", "getSourceDirectory", "(", ")", ",", "'\\\\/'", ")", ",", "DIRECTORY_SEPARATOR", ",", "trim", "(", "$", "file", ",", "'\"'", ")", ")", ";", "}" ]
Get example filepath based on sourcecode.
[ "Get", "example", "filepath", "based", "on", "sourcecode", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Example/Finder.php#L137-L145
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/ExampleAssembler.php
ExampleAssembler.create
public function create($data) { Assert::isInstanceOf($data, Example::class); $descriptor = new ExampleDescriptor($data->getName()); $descriptor->setFilePath((string) $data->getFilePath()); $descriptor->setStartingLine($data->getStartingLine()); $descriptor->setLineCount($data->getLineCount()); $descriptor->setDescription($data->getDescription()); $descriptor->setExample($this->finder->find($data)); return $descriptor; }
php
public function create($data) { Assert::isInstanceOf($data, Example::class); $descriptor = new ExampleDescriptor($data->getName()); $descriptor->setFilePath((string) $data->getFilePath()); $descriptor->setStartingLine($data->getStartingLine()); $descriptor->setLineCount($data->getLineCount()); $descriptor->setDescription($data->getDescription()); $descriptor->setExample($this->finder->find($data)); return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "Assert", "::", "isInstanceOf", "(", "$", "data", ",", "Example", "::", "class", ")", ";", "$", "descriptor", "=", "new", "ExampleDescriptor", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setFilePath", "(", "(", "string", ")", "$", "data", "->", "getFilePath", "(", ")", ")", ";", "$", "descriptor", "->", "setStartingLine", "(", "$", "data", "->", "getStartingLine", "(", ")", ")", ";", "$", "descriptor", "->", "setLineCount", "(", "$", "data", "->", "getLineCount", "(", ")", ")", ";", "$", "descriptor", "->", "setDescription", "(", "$", "data", "->", "getDescription", "(", ")", ")", ";", "$", "descriptor", "->", "setExample", "(", "$", "this", "->", "finder", "->", "find", "(", "$", "data", ")", ")", ";", "return", "$", "descriptor", ";", "}" ]
Creates a new Descriptor from the given Reflector. @param Example $data @throws InvalidArgumentException if the provided parameter is not of type ExampleTag; the interface won't let up typehint the signature. @return ExampleDescriptor
[ "Creates", "a", "new", "Descriptor", "from", "the", "given", "Reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/ExampleAssembler.php#L53-L64
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/NamespaceAssembler.php
NamespaceAssembler.create
public function create($data) { $descriptor = new NamespaceDescriptor(); $descriptor->setName($data->getName()); $descriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $namespace = substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1); $descriptor->setNamespace($namespace === '' ? '\\' : $namespace); return $descriptor; }
php
public function create($data) { $descriptor = new NamespaceDescriptor(); $descriptor->setName($data->getName()); $descriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $namespace = substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1); $descriptor->setNamespace($namespace === '' ? '\\' : $namespace); return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "descriptor", "=", "new", "NamespaceDescriptor", "(", ")", ";", "$", "descriptor", "->", "setName", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "data", "->", "getFqsen", "(", ")", ")", ";", "$", "namespace", "=", "substr", "(", "(", "string", ")", "$", "data", "->", "getFqsen", "(", ")", ",", "0", ",", "-", "strlen", "(", "$", "data", "->", "getName", "(", ")", ")", "-", "1", ")", ";", "$", "descriptor", "->", "setNamespace", "(", "$", "namespace", "===", "''", "?", "'\\\\'", ":", "$", "namespace", ")", ";", "return", "$", "descriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param Namespace_ $data @return DescriptorAbstract|Collection
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/NamespaceAssembler.php#L32-L41
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Router/Queue.php
Queue.match
public function match($node) { /** @var RouterAbstract $router */ foreach (clone $this as $router) { $rule = $router->match($node); if ($rule) { return $rule; } } return null; }
php
public function match($node) { foreach (clone $this as $router) { $rule = $router->match($node); if ($rule) { return $rule; } } return null; }
[ "public", "function", "match", "(", "$", "node", ")", "{", "/** @var RouterAbstract $router */", "foreach", "(", "clone", "$", "this", "as", "$", "router", ")", "{", "$", "rule", "=", "$", "router", "->", "match", "(", "$", "node", ")", ";", "if", "(", "$", "rule", ")", "{", "return", "$", "rule", ";", "}", "}", "return", "null", ";", "}" ]
Tries to match the given node with a rule defined in one of the routers. @param string|DescriptorAbstract $node @return Rule|null
[ "Tries", "to", "match", "the", "given", "node", "with", "a", "rule", "defined", "in", "one", "of", "the", "routers", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/Queue.php#L32-L43
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php
DocBlockConverter.addSummary
protected function addSummary(\DOMElement $node, DescriptorAbstract $element) { $node->appendChild(new \DOMElement('description')) ->appendChild(new \DOMText($element->getSummary())); }
php
protected function addSummary(\DOMElement $node, DescriptorAbstract $element) { $node->appendChild(new \DOMElement('description')) ->appendChild(new \DOMText($element->getSummary())); }
[ "protected", "function", "addSummary", "(", "\\", "DOMElement", "$", "node", ",", "DescriptorAbstract", "$", "element", ")", "{", "$", "node", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'description'", ")", ")", "->", "appendChild", "(", "new", "\\", "DOMText", "(", "$", "element", "->", "getSummary", "(", ")", ")", ")", ";", "}" ]
Adds the short description of $docblock to the given node as description field.
[ "Adds", "the", "short", "description", "of", "$docblock", "to", "the", "given", "node", "as", "description", "field", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php#L81-L85
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php
DocBlockConverter.addTags
protected function addTags(\DOMElement $docBlock, $descriptor) { foreach ($descriptor->getTags() as $tagGroup) { if (! $tagGroup) { continue; } foreach ($tagGroup as $tag) { $this->tagConverter->convert($docBlock, $tag); } } }
php
protected function addTags(\DOMElement $docBlock, $descriptor) { foreach ($descriptor->getTags() as $tagGroup) { if (! $tagGroup) { continue; } foreach ($tagGroup as $tag) { $this->tagConverter->convert($docBlock, $tag); } } }
[ "protected", "function", "addTags", "(", "\\", "DOMElement", "$", "docBlock", ",", "$", "descriptor", ")", "{", "foreach", "(", "$", "descriptor", "->", "getTags", "(", ")", "as", "$", "tagGroup", ")", "{", "if", "(", "!", "$", "tagGroup", ")", "{", "continue", ";", "}", "foreach", "(", "$", "tagGroup", "as", "$", "tag", ")", "{", "$", "this", "->", "tagConverter", "->", "convert", "(", "$", "docBlock", ",", "$", "tag", ")", ";", "}", "}", "}" ]
Adds each tag to the XML Node representing the DocBlock. The Descriptor contains an array of tag groups (that are tags grouped by their name), which in itself contains an array of the individual tags. @param DescriptorAbstract $descriptor
[ "Adds", "each", "tag", "to", "the", "XML", "Node", "representing", "the", "DocBlock", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php#L104-L115
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php
AssemblerAbstract.assembleDocBlock
protected function assembleDocBlock($docBlock, $target) { if (!$docBlock) { return; } $target->setSummary($docBlock->getSummary()); $target->setDescription($docBlock->getDescription()); /** @var DocBlock\Tag $tag */ foreach ($docBlock->getTags() as $tag) { $tagDescriptor = $this->builder->buildDescriptor($tag); // allow filtering of tags if (!$tagDescriptor) { continue; } $target->getTags() ->get($tag->getName(), new Collection()) ->add($tagDescriptor); } }
php
protected function assembleDocBlock($docBlock, $target) { if (!$docBlock) { return; } $target->setSummary($docBlock->getSummary()); $target->setDescription($docBlock->getDescription()); foreach ($docBlock->getTags() as $tag) { $tagDescriptor = $this->builder->buildDescriptor($tag); if (!$tagDescriptor) { continue; } $target->getTags() ->get($tag->getName(), new Collection()) ->add($tagDescriptor); } }
[ "protected", "function", "assembleDocBlock", "(", "$", "docBlock", ",", "$", "target", ")", "{", "if", "(", "!", "$", "docBlock", ")", "{", "return", ";", "}", "$", "target", "->", "setSummary", "(", "$", "docBlock", "->", "getSummary", "(", ")", ")", ";", "$", "target", "->", "setDescription", "(", "$", "docBlock", "->", "getDescription", "(", ")", ")", ";", "/** @var DocBlock\\Tag $tag */", "foreach", "(", "$", "docBlock", "->", "getTags", "(", ")", "as", "$", "tag", ")", "{", "$", "tagDescriptor", "=", "$", "this", "->", "builder", "->", "buildDescriptor", "(", "$", "tag", ")", ";", "// allow filtering of tags", "if", "(", "!", "$", "tagDescriptor", ")", "{", "continue", ";", "}", "$", "target", "->", "getTags", "(", ")", "->", "get", "(", "$", "tag", "->", "getName", "(", ")", ",", "new", "Collection", "(", ")", ")", "->", "add", "(", "$", "tagDescriptor", ")", ";", "}", "}" ]
Assemble DocBlock. @param DocBlock|null $docBlock @param DescriptorAbstract $target
[ "Assemble", "DocBlock", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php#L33-L55
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php
AssemblerAbstract.extractPackageFromDocBlock
protected function extractPackageFromDocBlock($docBlock) { $packageTags = $docBlock ? $docBlock->getTagsByName('package') : []; if (count($packageTags) === 0) { return null; } /** @var DocBlock\Tags\Generic $tag */ $tag = reset($packageTags); return trim((string) $tag->getDescription()); }
php
protected function extractPackageFromDocBlock($docBlock) { $packageTags = $docBlock ? $docBlock->getTagsByName('package') : []; if (count($packageTags) === 0) { return null; } $tag = reset($packageTags); return trim((string) $tag->getDescription()); }
[ "protected", "function", "extractPackageFromDocBlock", "(", "$", "docBlock", ")", "{", "$", "packageTags", "=", "$", "docBlock", "?", "$", "docBlock", "->", "getTagsByName", "(", "'package'", ")", ":", "[", "]", ";", "if", "(", "count", "(", "$", "packageTags", ")", "===", "0", ")", "{", "return", "null", ";", "}", "/** @var DocBlock\\Tags\\Generic $tag */", "$", "tag", "=", "reset", "(", "$", "packageTags", ")", ";", "return", "trim", "(", "(", "string", ")", "$", "tag", "->", "getDescription", "(", ")", ")", ";", "}" ]
Extracts the package from the DocBlock. @param DocBlock $docBlock @return string|null
[ "Extracts", "the", "package", "from", "the", "DocBlock", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php#L64-L75
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Template/Factory.php
Factory.get
public function get($nameOrPath) { return $this->createTemplateFromXml( $this->fetchTemplateXmlFromPath( $this->pathResolver->resolve($nameOrPath) ) ); }
php
public function get($nameOrPath) { return $this->createTemplateFromXml( $this->fetchTemplateXmlFromPath( $this->pathResolver->resolve($nameOrPath) ) ); }
[ "public", "function", "get", "(", "$", "nameOrPath", ")", "{", "return", "$", "this", "->", "createTemplateFromXml", "(", "$", "this", "->", "fetchTemplateXmlFromPath", "(", "$", "this", "->", "pathResolver", "->", "resolve", "(", "$", "nameOrPath", ")", ")", ")", ";", "}" ]
Attempts to find, construct and return a template object with the given template name or (relative/absolute) path. @param string $nameOrPath @return Template
[ "Attempts", "to", "find", "construct", "and", "return", "a", "template", "object", "with", "the", "given", "template", "name", "or", "(", "relative", "/", "absolute", ")", "path", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Factory.php#L50-L57
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Template/Factory.php
Factory.getAllNames
public function getAllNames() { /** @var \RecursiveDirectoryIterator $files */ $files = new \DirectoryIterator($this->getTemplatePath()); $template_names = []; while ($files->valid()) { $name = $files->getBasename(); // skip abstract files if (!$files->isDir() || in_array($name, ['.', '..'], true)) { $files->next(); continue; } $template_names[] = $name; $files->next(); } return $template_names; }
php
public function getAllNames() { $files = new \DirectoryIterator($this->getTemplatePath()); $template_names = []; while ($files->valid()) { $name = $files->getBasename(); if (!$files->isDir() || in_array($name, ['.', '..'], true)) { $files->next(); continue; } $template_names[] = $name; $files->next(); } return $template_names; }
[ "public", "function", "getAllNames", "(", ")", "{", "/** @var \\RecursiveDirectoryIterator $files */", "$", "files", "=", "new", "\\", "DirectoryIterator", "(", "$", "this", "->", "getTemplatePath", "(", ")", ")", ";", "$", "template_names", "=", "[", "]", ";", "while", "(", "$", "files", "->", "valid", "(", ")", ")", "{", "$", "name", "=", "$", "files", "->", "getBasename", "(", ")", ";", "// skip abstract files", "if", "(", "!", "$", "files", "->", "isDir", "(", ")", "||", "in_array", "(", "$", "name", ",", "[", "'.'", ",", "'..'", "]", ",", "true", ")", ")", "{", "$", "files", "->", "next", "(", ")", ";", "continue", ";", "}", "$", "template_names", "[", "]", "=", "$", "name", ";", "$", "files", "->", "next", "(", ")", ";", "}", "return", "$", "template_names", ";", "}" ]
Returns a list of all template names. @return string[]
[ "Returns", "a", "list", "of", "all", "template", "names", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Factory.php#L64-L84
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Template/Factory.php
Factory.createTemplateFromXml
protected function createTemplateFromXml($xml) { /** @var Template $template */ $template = $this->serializer->deserialize($xml, 'phpDocumentor\Transformer\Template', 'xml'); $template->propagateParameters(); return $template; }
php
protected function createTemplateFromXml($xml) { $template = $this->serializer->deserialize($xml, 'phpDocumentor\Transformer\Template', 'xml'); $template->propagateParameters(); return $template; }
[ "protected", "function", "createTemplateFromXml", "(", "$", "xml", ")", "{", "/** @var Template $template */", "$", "template", "=", "$", "this", "->", "serializer", "->", "deserialize", "(", "$", "xml", ",", "'phpDocumentor\\Transformer\\Template'", ",", "'xml'", ")", ";", "$", "template", "->", "propagateParameters", "(", ")", ";", "return", "$", "template", ";", "}" ]
Creates and returns a template object based on the provided template definition. @param string $xml @return Template
[ "Creates", "and", "returns", "a", "template", "object", "based", "on", "the", "provided", "template", "definition", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Factory.php#L115-L122
phpDocumentor/phpDocumentor2
src/phpDocumentor/Parser/Parser.php
Parser.parse
public function parse(ProjectDescriptorBuilder $builder, array $files) { $this->startTimingTheParsePhase(); $this->forceRebuildIfSettingsHaveModified($builder); $event = PreParsingEvent::createInstance($this); assert($event instanceof PreParsingEvent); Dispatcher::getInstance() ->dispatch( 'parser.pre', $event->setFileCount(count($files)) ); /** @var \phpDocumentor\Reflection\Php\Project $project */ $project = $this->projectFactory->create(ProjectDescriptorBuilder::DEFAULT_PROJECT_NAME, $files); $this->logAfterParsingAllFiles(); /* * TODO: This should be moved to some view adapter layer when * we are removing the descriptors from the application. * because we are now partly migrating to the new reflection component * we are transforming back to the original structure. */ $builder->build($project); return $builder->getProjectDescriptor(); }
php
public function parse(ProjectDescriptorBuilder $builder, array $files) { $this->startTimingTheParsePhase(); $this->forceRebuildIfSettingsHaveModified($builder); $event = PreParsingEvent::createInstance($this); assert($event instanceof PreParsingEvent); Dispatcher::getInstance() ->dispatch( 'parser.pre', $event->setFileCount(count($files)) ); $project = $this->projectFactory->create(ProjectDescriptorBuilder::DEFAULT_PROJECT_NAME, $files); $this->logAfterParsingAllFiles(); $builder->build($project); return $builder->getProjectDescriptor(); }
[ "public", "function", "parse", "(", "ProjectDescriptorBuilder", "$", "builder", ",", "array", "$", "files", ")", "{", "$", "this", "->", "startTimingTheParsePhase", "(", ")", ";", "$", "this", "->", "forceRebuildIfSettingsHaveModified", "(", "$", "builder", ")", ";", "$", "event", "=", "PreParsingEvent", "::", "createInstance", "(", "$", "this", ")", ";", "assert", "(", "$", "event", "instanceof", "PreParsingEvent", ")", ";", "Dispatcher", "::", "getInstance", "(", ")", "->", "dispatch", "(", "'parser.pre'", ",", "$", "event", "->", "setFileCount", "(", "count", "(", "$", "files", ")", ")", ")", ";", "/** @var \\phpDocumentor\\Reflection\\Php\\Project $project */", "$", "project", "=", "$", "this", "->", "projectFactory", "->", "create", "(", "ProjectDescriptorBuilder", "::", "DEFAULT_PROJECT_NAME", ",", "$", "files", ")", ";", "$", "this", "->", "logAfterParsingAllFiles", "(", ")", ";", "/*\n * TODO: This should be moved to some view adapter layer when\n * we are removing the descriptors from the application.\n * because we are now partly migrating to the new reflection component\n * we are transforming back to the original structure.\n */", "$", "builder", "->", "build", "(", "$", "project", ")", ";", "return", "$", "builder", "->", "getProjectDescriptor", "(", ")", ";", "}" ]
Iterates through the given files feeds them to the builder. @api @throws FilesNotFoundException if no files were found. @return ProjectDescriptor
[ "Iterates", "through", "the", "given", "files", "feeds", "them", "to", "the", "builder", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Parser/Parser.php#L267-L294
phpDocumentor/phpDocumentor2
src/phpDocumentor/Parser/Parser.php
Parser.forceRebuildIfSettingsHaveModified
private function forceRebuildIfSettingsHaveModified(ProjectDescriptorBuilder $builder) { if ($builder->getProjectDescriptor()->getSettings()->isModified()) { $this->setForced(true); $this->log( 'One of the project\'s settings have changed, forcing a complete rebuild', LogLevel::NOTICE ); } }
php
private function forceRebuildIfSettingsHaveModified(ProjectDescriptorBuilder $builder) { if ($builder->getProjectDescriptor()->getSettings()->isModified()) { $this->setForced(true); $this->log( 'One of the project\'s settings have changed, forcing a complete rebuild', LogLevel::NOTICE ); } }
[ "private", "function", "forceRebuildIfSettingsHaveModified", "(", "ProjectDescriptorBuilder", "$", "builder", ")", "{", "if", "(", "$", "builder", "->", "getProjectDescriptor", "(", ")", "->", "getSettings", "(", ")", "->", "isModified", "(", ")", ")", "{", "$", "this", "->", "setForced", "(", "true", ")", ";", "$", "this", "->", "log", "(", "'One of the project\\'s settings have changed, forcing a complete rebuild'", ",", "LogLevel", "::", "NOTICE", ")", ";", "}", "}" ]
Checks if the settings of the project have changed and forces a complete rebuild if they have.
[ "Checks", "if", "the", "settings", "of", "the", "project", "have", "changed", "and", "forces", "a", "complete", "rebuild", "if", "they", "have", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Parser/Parser.php#L299-L308
phpDocumentor/phpDocumentor2
src/phpDocumentor/Parser/Parser.php
Parser.logAfterParsingAllFiles
private function logAfterParsingAllFiles() { if (!$this->stopwatch) { return; } $event = $this->stopwatch->stop('parser.parse'); $this->log('Elapsed time to parse all files: ' . round($event->getDuration() / 1000, 2) . 's'); $this->log('Peak memory usage: ' . round($event->getMemory() / 1024 / 1024, 2) . 'M'); }
php
private function logAfterParsingAllFiles() { if (!$this->stopwatch) { return; } $event = $this->stopwatch->stop('parser.parse'); $this->log('Elapsed time to parse all files: ' . round($event->getDuration() / 1000, 2) . 's'); $this->log('Peak memory usage: ' . round($event->getMemory() / 1024 / 1024, 2) . 'M'); }
[ "private", "function", "logAfterParsingAllFiles", "(", ")", "{", "if", "(", "!", "$", "this", "->", "stopwatch", ")", "{", "return", ";", "}", "$", "event", "=", "$", "this", "->", "stopwatch", "->", "stop", "(", "'parser.parse'", ")", ";", "$", "this", "->", "log", "(", "'Elapsed time to parse all files: '", ".", "round", "(", "$", "event", "->", "getDuration", "(", ")", "/", "1000", ",", "2", ")", ".", "'s'", ")", ";", "$", "this", "->", "log", "(", "'Peak memory usage: '", ".", "round", "(", "$", "event", "->", "getMemory", "(", ")", "/", "1024", "/", "1024", ",", "2", ")", ".", "'M'", ")", ";", "}" ]
Writes the complete parsing cycle to log.
[ "Writes", "the", "complete", "parsing", "cycle", "to", "log", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Parser/Parser.php#L313-L323
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php
LegacyNamespaceFilter.filter
public function filter($value) { if ($value) { $namespace = $value->getNamespace() === '' ? '\\' . $this->namespacePrefix : $value->getNamespace(); $value->setNamespace($this->namespaceFromLegacyNamespace($namespace, $value->getName())); $value->setName($this->classNameFromLegacyNamespace($value->getName())); } return $value; }
php
public function filter($value) { if ($value) { $namespace = $value->getNamespace() === '' ? '\\' . $this->namespacePrefix : $value->getNamespace(); $value->setNamespace($this->namespaceFromLegacyNamespace($namespace, $value->getName())); $value->setName($this->classNameFromLegacyNamespace($value->getName())); } return $value; }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "namespace", "=", "$", "value", "->", "getNamespace", "(", ")", "===", "''", "?", "'\\\\'", ".", "$", "this", "->", "namespacePrefix", ":", "$", "value", "->", "getNamespace", "(", ")", ";", "$", "value", "->", "setNamespace", "(", "$", "this", "->", "namespaceFromLegacyNamespace", "(", "$", "namespace", ",", "$", "value", "->", "getName", "(", ")", ")", ")", ";", "$", "value", "->", "setName", "(", "$", "this", "->", "classNameFromLegacyNamespace", "(", "$", "value", "->", "getName", "(", ")", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
Overrides the name and namespace of an element with a separated version of the class name. If a class is separated by underscores than the last part is set as name and the first parts are set as namespace with the namespace separator instead of an underscore. @param DescriptorAbstract $value @return DescriptorAbstract|null
[ "Overrides", "the", "name", "and", "namespace", "of", "an", "element", "with", "a", "separated", "version", "of", "the", "class", "name", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php#L57-L66
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php
LegacyNamespaceFilter.namespaceFromLegacyNamespace
private function namespaceFromLegacyNamespace($namespace, $className) { $qcn = str_replace('_', '\\', $className); $lastBackslash = strrpos($qcn, '\\'); if ($lastBackslash) { $namespace = rtrim($namespace, '\\') . '\\' . substr($qcn, 0, $lastBackslash); } return $namespace; }
php
private function namespaceFromLegacyNamespace($namespace, $className) { $qcn = str_replace('_', '\\', $className); $lastBackslash = strrpos($qcn, '\\'); if ($lastBackslash) { $namespace = rtrim($namespace, '\\') . '\\' . substr($qcn, 0, $lastBackslash); } return $namespace; }
[ "private", "function", "namespaceFromLegacyNamespace", "(", "$", "namespace", ",", "$", "className", ")", "{", "$", "qcn", "=", "str_replace", "(", "'_'", ",", "'\\\\'", ",", "$", "className", ")", ";", "$", "lastBackslash", "=", "strrpos", "(", "$", "qcn", ",", "'\\\\'", ")", ";", "if", "(", "$", "lastBackslash", ")", "{", "$", "namespace", "=", "rtrim", "(", "$", "namespace", ",", "'\\\\'", ")", ".", "'\\\\'", ".", "substr", "(", "$", "qcn", ",", "0", ",", "$", "lastBackslash", ")", ";", "}", "return", "$", "namespace", ";", "}" ]
Extracts the namespace from the class name. @param string $namespace @param string $className @return string
[ "Extracts", "the", "namespace", "from", "the", "class", "name", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php#L76-L86
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php
LegacyNamespaceFilter.classNameFromLegacyNamespace
private function classNameFromLegacyNamespace($className) { $lastUnderscore = strrpos($className, '_'); if ($lastUnderscore) { $className = substr($className, $lastUnderscore + 1); } return $className; }
php
private function classNameFromLegacyNamespace($className) { $lastUnderscore = strrpos($className, '_'); if ($lastUnderscore) { $className = substr($className, $lastUnderscore + 1); } return $className; }
[ "private", "function", "classNameFromLegacyNamespace", "(", "$", "className", ")", "{", "$", "lastUnderscore", "=", "strrpos", "(", "$", "className", ",", "'_'", ")", ";", "if", "(", "$", "lastUnderscore", ")", "{", "$", "className", "=", "substr", "(", "$", "className", ",", "$", "lastUnderscore", "+", "1", ")", ";", "}", "return", "$", "className", ";", "}" ]
Extracts the class name without prefix from the full class name. @param string $className @return string
[ "Extracts", "the", "class", "name", "without", "prefix", "from", "the", "full", "class", "name", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php#L95-L103
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
ResolveInlineLinkAndSeeTags.execute
public function execute(ProjectDescriptor $project): void { /** @var Collection|DescriptorAbstract[] $elementCollection */ $this->elementCollection = $project->getIndexes()->get('elements'); foreach ($this->elementCollection as $descriptor) { $this->resolveSeeAndLinkTags($descriptor); } }
php
public function execute(ProjectDescriptor $project): void { $this->elementCollection = $project->getIndexes()->get('elements'); foreach ($this->elementCollection as $descriptor) { $this->resolveSeeAndLinkTags($descriptor); } }
[ "public", "function", "execute", "(", "ProjectDescriptor", "$", "project", ")", ":", "void", "{", "/** @var Collection|DescriptorAbstract[] $elementCollection */", "$", "this", "->", "elementCollection", "=", "$", "project", "->", "getIndexes", "(", ")", "->", "get", "(", "'elements'", ")", ";", "foreach", "(", "$", "this", "->", "elementCollection", "as", "$", "descriptor", ")", "{", "$", "this", "->", "resolveSeeAndLinkTags", "(", "$", "descriptor", ")", ";", "}", "}" ]
Iterates through each element in the project and replaces its inline @see and @link tag with a markdown representation.
[ "Iterates", "through", "each", "element", "in", "the", "project", "and", "replaces", "its", "inline" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L69-L77
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
ResolveInlineLinkAndSeeTags.resolveSeeAndLinkTags
private function resolveSeeAndLinkTags(DescriptorAbstract $descriptor): void { // store descriptor to use it in the resolveTag method $this->descriptor = $descriptor; $descriptor->setDescription( preg_replace_callback( self::REGEX_INLINE_LINK_OR_SEE_TAG, [$this, 'resolveTag'], $descriptor->getDescription() ) ); }
php
private function resolveSeeAndLinkTags(DescriptorAbstract $descriptor): void { $this->descriptor = $descriptor; $descriptor->setDescription( preg_replace_callback( self::REGEX_INLINE_LINK_OR_SEE_TAG, [$this, 'resolveTag'], $descriptor->getDescription() ) ); }
[ "private", "function", "resolveSeeAndLinkTags", "(", "DescriptorAbstract", "$", "descriptor", ")", ":", "void", "{", "// store descriptor to use it in the resolveTag method", "$", "this", "->", "descriptor", "=", "$", "descriptor", ";", "$", "descriptor", "->", "setDescription", "(", "preg_replace_callback", "(", "self", "::", "REGEX_INLINE_LINK_OR_SEE_TAG", ",", "[", "$", "this", ",", "'resolveTag'", "]", ",", "$", "descriptor", "->", "getDescription", "(", ")", ")", ")", ";", "}" ]
Resolves all @see and @link tags in the description of the given descriptor to their markdown representation. @uses self::resolveTag()
[ "Resolves", "all", "@see", "and", "@link", "tags", "in", "the", "description", "of", "the", "given", "descriptor", "to", "their", "markdown", "representation", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L84-L96
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
ResolveInlineLinkAndSeeTags.resolveTag
private function resolveTag(array $match) { $tagReflector = $this->createLinkOrSeeTagFromRegexMatch($match); if (!$tagReflector instanceof See && !$tagReflector instanceof Link) { return $match; } $link = $this->getLinkText($tagReflector); $description = (string) $tagReflector->getDescription(); if ($this->isUrl($link)) { return $this->generateMarkdownLink($link, $description ?: $link); } $link = $this->resolveQsen($link); $element = $this->findElement($link); if (!$element) { return (string) $link; } return $this->resolveElement($element, $link, $description); }
php
private function resolveTag(array $match) { $tagReflector = $this->createLinkOrSeeTagFromRegexMatch($match); if (!$tagReflector instanceof See && !$tagReflector instanceof Link) { return $match; } $link = $this->getLinkText($tagReflector); $description = (string) $tagReflector->getDescription(); if ($this->isUrl($link)) { return $this->generateMarkdownLink($link, $description ?: $link); } $link = $this->resolveQsen($link); $element = $this->findElement($link); if (!$element) { return (string) $link; } return $this->resolveElement($element, $link, $description); }
[ "private", "function", "resolveTag", "(", "array", "$", "match", ")", "{", "$", "tagReflector", "=", "$", "this", "->", "createLinkOrSeeTagFromRegexMatch", "(", "$", "match", ")", ";", "if", "(", "!", "$", "tagReflector", "instanceof", "See", "&&", "!", "$", "tagReflector", "instanceof", "Link", ")", "{", "return", "$", "match", ";", "}", "$", "link", "=", "$", "this", "->", "getLinkText", "(", "$", "tagReflector", ")", ";", "$", "description", "=", "(", "string", ")", "$", "tagReflector", "->", "getDescription", "(", ")", ";", "if", "(", "$", "this", "->", "isUrl", "(", "$", "link", ")", ")", "{", "return", "$", "this", "->", "generateMarkdownLink", "(", "$", "link", ",", "$", "description", "?", ":", "$", "link", ")", ";", "}", "$", "link", "=", "$", "this", "->", "resolveQsen", "(", "$", "link", ")", ";", "$", "element", "=", "$", "this", "->", "findElement", "(", "$", "link", ")", ";", "if", "(", "!", "$", "element", ")", "{", "return", "(", "string", ")", "$", "link", ";", "}", "return", "$", "this", "->", "resolveElement", "(", "$", "element", ",", "$", "link", ",", "$", "description", ")", ";", "}" ]
Resolves an individual tag, indicated by the results of the Regex used to extract tags. @param string[] $match @return string|string[]
[ "Resolves", "an", "individual", "tag", "indicated", "by", "the", "results", "of", "the", "Regex", "used", "to", "extract", "tags", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L104-L125
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
ResolveInlineLinkAndSeeTags.createLinkOrSeeTagFromRegexMatch
private function createLinkOrSeeTagFromRegexMatch(array $match): Tag { list($completeMatch, $tagName, $tagContent) = $match; $fqsenResolver = new FqsenResolver(); $tagFactory = new StandardTagFactory($fqsenResolver); $descriptionFactory = new DescriptionFactory($tagFactory); $tagFactory->addService($descriptionFactory); $tagFactory->addService(new TypeResolver($fqsenResolver)); switch ($tagName) { case 'see': return See::create($tagContent, $fqsenResolver, $descriptionFactory, $this->createDocBlockContext()); case 'link': return Link::create($tagContent, $descriptionFactory, $this->createDocBlockContext()); } }
php
private function createLinkOrSeeTagFromRegexMatch(array $match): Tag { list($completeMatch, $tagName, $tagContent) = $match; $fqsenResolver = new FqsenResolver(); $tagFactory = new StandardTagFactory($fqsenResolver); $descriptionFactory = new DescriptionFactory($tagFactory); $tagFactory->addService($descriptionFactory); $tagFactory->addService(new TypeResolver($fqsenResolver)); switch ($tagName) { case 'see': return See::create($tagContent, $fqsenResolver, $descriptionFactory, $this->createDocBlockContext()); case 'link': return Link::create($tagContent, $descriptionFactory, $this->createDocBlockContext()); } }
[ "private", "function", "createLinkOrSeeTagFromRegexMatch", "(", "array", "$", "match", ")", ":", "Tag", "{", "list", "(", "$", "completeMatch", ",", "$", "tagName", ",", "$", "tagContent", ")", "=", "$", "match", ";", "$", "fqsenResolver", "=", "new", "FqsenResolver", "(", ")", ";", "$", "tagFactory", "=", "new", "StandardTagFactory", "(", "$", "fqsenResolver", ")", ";", "$", "descriptionFactory", "=", "new", "DescriptionFactory", "(", "$", "tagFactory", ")", ";", "$", "tagFactory", "->", "addService", "(", "$", "descriptionFactory", ")", ";", "$", "tagFactory", "->", "addService", "(", "new", "TypeResolver", "(", "$", "fqsenResolver", ")", ")", ";", "switch", "(", "$", "tagName", ")", "{", "case", "'see'", ":", "return", "See", "::", "create", "(", "$", "tagContent", ",", "$", "fqsenResolver", ",", "$", "descriptionFactory", ",", "$", "this", "->", "createDocBlockContext", "(", ")", ")", ";", "case", "'link'", ":", "return", "Link", "::", "create", "(", "$", "tagContent", ",", "$", "descriptionFactory", ",", "$", "this", "->", "createDocBlockContext", "(", ")", ")", ";", "}", "}" ]
Creates a Tag Reflector from the given array of tag line, tag name and tag content. @param string[] $match
[ "Creates", "a", "Tag", "Reflector", "from", "the", "given", "array", "of", "tag", "line", "tag", "name", "and", "tag", "content", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L150-L166
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
ResolveInlineLinkAndSeeTags.resolveElement
private function resolveElement(DescriptorAbstract $element, $link, ?string $description = null): string { $rule = $this->router->match($element); if ($rule) { $url = '..' . $rule->generate($element); $link = $this->generateMarkdownLink($url, $description ?: (string) $link); } return $link; }
php
private function resolveElement(DescriptorAbstract $element, $link, ?string $description = null): string { $rule = $this->router->match($element); if ($rule) { $url = '..' . $rule->generate($element); $link = $this->generateMarkdownLink($url, $description ?: (string) $link); } return $link; }
[ "private", "function", "resolveElement", "(", "DescriptorAbstract", "$", "element", ",", "$", "link", ",", "?", "string", "$", "description", "=", "null", ")", ":", "string", "{", "$", "rule", "=", "$", "this", "->", "router", "->", "match", "(", "$", "element", ")", ";", "if", "(", "$", "rule", ")", "{", "$", "url", "=", "'..'", ".", "$", "rule", "->", "generate", "(", "$", "element", ")", ";", "$", "link", "=", "$", "this", "->", "generateMarkdownLink", "(", "$", "url", ",", "$", "description", "?", ":", "(", "string", ")", "$", "link", ")", ";", "}", "return", "$", "link", ";", "}" ]
Generates a Markdown link to the given Descriptor or returns the link text if no route to the Descriptor could be matched. @param Fqsen|string $link
[ "Generates", "a", "Markdown", "link", "to", "the", "given", "Descriptor", "or", "returns", "the", "link", "text", "if", "no", "route", "to", "the", "Descriptor", "could", "be", "matched", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L192-L202
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
ResolveInlineLinkAndSeeTags.getLinkText
private function getLinkText(Tag $tagReflector): ?string { if ($tagReflector instanceof See) { return (string) $tagReflector->getReference(); } if ($tagReflector instanceof Link) { return (string) $tagReflector->getLink(); } return null; }
php
private function getLinkText(Tag $tagReflector): ?string { if ($tagReflector instanceof See) { return (string) $tagReflector->getReference(); } if ($tagReflector instanceof Link) { return (string) $tagReflector->getLink(); } return null; }
[ "private", "function", "getLinkText", "(", "Tag", "$", "tagReflector", ")", ":", "?", "string", "{", "if", "(", "$", "tagReflector", "instanceof", "See", ")", "{", "return", "(", "string", ")", "$", "tagReflector", "->", "getReference", "(", ")", ";", "}", "if", "(", "$", "tagReflector", "instanceof", "Link", ")", "{", "return", "(", "string", ")", "$", "tagReflector", "->", "getLink", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the link for the given reflector. Because the link tag and the see tag have different methods to acquire the link text we abstract that into this method.
[ "Returns", "the", "link", "for", "the", "given", "reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L210-L221
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
ResolveInlineLinkAndSeeTags.createDocBlockContext
private function createDocBlockContext(): Context { $file = $this->descriptor->getFile(); $namespaceAliases = $file ? $file->getNamespaceAliases()->getAll() : []; foreach ($namespaceAliases as $alias => $fqsen) { $namespaceAliases[$alias] = (string) $fqsen; } return new Context((string) $this->descriptor->getNamespace(), $namespaceAliases); }
php
private function createDocBlockContext(): Context { $file = $this->descriptor->getFile(); $namespaceAliases = $file ? $file->getNamespaceAliases()->getAll() : []; foreach ($namespaceAliases as $alias => $fqsen) { $namespaceAliases[$alias] = (string) $fqsen; } return new Context((string) $this->descriptor->getNamespace(), $namespaceAliases); }
[ "private", "function", "createDocBlockContext", "(", ")", ":", "Context", "{", "$", "file", "=", "$", "this", "->", "descriptor", "->", "getFile", "(", ")", ";", "$", "namespaceAliases", "=", "$", "file", "?", "$", "file", "->", "getNamespaceAliases", "(", ")", "->", "getAll", "(", ")", ":", "[", "]", ";", "foreach", "(", "$", "namespaceAliases", "as", "$", "alias", "=>", "$", "fqsen", ")", "{", "$", "namespaceAliases", "[", "$", "alias", "]", "=", "(", "string", ")", "$", "fqsen", ";", "}", "return", "new", "Context", "(", "(", "string", ")", "$", "this", "->", "descriptor", "->", "getNamespace", "(", ")", ",", "$", "namespaceAliases", ")", ";", "}" ]
Creates a DocBlock context containing the namespace and aliases for the current descriptor.
[ "Creates", "a", "DocBlock", "context", "containing", "the", "namespace", "and", "aliases", "for", "the", "current", "descriptor", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L236-L245
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php
ProjectDescriptorBuilder.isVisibilityAllowed
public function isVisibilityAllowed($visibility) { switch ($visibility) { case 'public': $visibility = Settings::VISIBILITY_PUBLIC; break; case 'protected': $visibility = Settings::VISIBILITY_PROTECTED; break; case 'private': $visibility = Settings::VISIBILITY_PRIVATE; break; case 'internal': $visibility = Settings::VISIBILITY_INTERNAL; break; } return $this->getProjectDescriptor()->isVisibilityAllowed($visibility); }
php
public function isVisibilityAllowed($visibility) { switch ($visibility) { case 'public': $visibility = Settings::VISIBILITY_PUBLIC; break; case 'protected': $visibility = Settings::VISIBILITY_PROTECTED; break; case 'private': $visibility = Settings::VISIBILITY_PRIVATE; break; case 'internal': $visibility = Settings::VISIBILITY_INTERNAL; break; } return $this->getProjectDescriptor()->isVisibilityAllowed($visibility); }
[ "public", "function", "isVisibilityAllowed", "(", "$", "visibility", ")", "{", "switch", "(", "$", "visibility", ")", "{", "case", "'public'", ":", "$", "visibility", "=", "Settings", "::", "VISIBILITY_PUBLIC", ";", "break", ";", "case", "'protected'", ":", "$", "visibility", "=", "Settings", "::", "VISIBILITY_PROTECTED", ";", "break", ";", "case", "'private'", ":", "$", "visibility", "=", "Settings", "::", "VISIBILITY_PRIVATE", ";", "break", ";", "case", "'internal'", ":", "$", "visibility", "=", "Settings", "::", "VISIBILITY_INTERNAL", ";", "break", ";", "}", "return", "$", "this", "->", "getProjectDescriptor", "(", ")", "->", "isVisibilityAllowed", "(", "$", "visibility", ")", ";", "}" ]
Verifies whether the given visibility is allowed to be included in the Descriptors. This method is used anytime a Descriptor is added to a collection (for example, when adding a Method to a Class) to determine whether the visibility of that element is matches what the user has specified when it ran phpDocumentor. @param string|integer $visibility One of the visibility constants of the ProjectDescriptor class or the words 'public', 'protected', 'private' or 'internal'. @see ProjectDescriptor where the visibility is stored and that declares the constants to use. @return boolean
[ "Verifies", "whether", "the", "given", "visibility", "is", "allowed", "to", "be", "included", "in", "the", "Descriptors", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php#L86-L104
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php
ProjectDescriptorBuilder.buildDescriptor
public function buildDescriptor($data) { $assembler = $this->getAssembler($data); if (!$assembler) { throw new \InvalidArgumentException( 'Unable to build a Descriptor; the provided data did not match any Assembler ' . get_class($data) ); } if ($assembler instanceof Builder\AssemblerAbstract) { $assembler->setBuilder($this); } // create Descriptor and populate with the provided data $descriptor = $assembler->create($data); if (!$descriptor) { return null; } return (!is_array($descriptor) && (!$descriptor instanceof Collection)) ? $this->filterDescriptor($descriptor) : $this->filterEachDescriptor($descriptor); }
php
public function buildDescriptor($data) { $assembler = $this->getAssembler($data); if (!$assembler) { throw new \InvalidArgumentException( 'Unable to build a Descriptor; the provided data did not match any Assembler ' . get_class($data) ); } if ($assembler instanceof Builder\AssemblerAbstract) { $assembler->setBuilder($this); } $descriptor = $assembler->create($data); if (!$descriptor) { return null; } return (!is_array($descriptor) && (!$descriptor instanceof Collection)) ? $this->filterDescriptor($descriptor) : $this->filterEachDescriptor($descriptor); }
[ "public", "function", "buildDescriptor", "(", "$", "data", ")", "{", "$", "assembler", "=", "$", "this", "->", "getAssembler", "(", "$", "data", ")", ";", "if", "(", "!", "$", "assembler", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unable to build a Descriptor; the provided data did not match any Assembler '", ".", "get_class", "(", "$", "data", ")", ")", ";", "}", "if", "(", "$", "assembler", "instanceof", "Builder", "\\", "AssemblerAbstract", ")", "{", "$", "assembler", "->", "setBuilder", "(", "$", "this", ")", ";", "}", "// create Descriptor and populate with the provided data", "$", "descriptor", "=", "$", "assembler", "->", "create", "(", "$", "data", ")", ";", "if", "(", "!", "$", "descriptor", ")", "{", "return", "null", ";", "}", "return", "(", "!", "is_array", "(", "$", "descriptor", ")", "&&", "(", "!", "$", "descriptor", "instanceof", "Collection", ")", ")", "?", "$", "this", "->", "filterDescriptor", "(", "$", "descriptor", ")", ":", "$", "this", "->", "filterEachDescriptor", "(", "$", "descriptor", ")", ";", "}" ]
Takes the given data and attempts to build a Descriptor from it. @param mixed $data @throws \InvalidArgumentException if no Assembler could be found that matches the given data. @return DescriptorAbstract|Collection|null
[ "Takes", "the", "given", "data", "and", "attempts", "to", "build", "a", "Descriptor", "from", "it", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php#L115-L138
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php
ProjectDescriptorBuilder.filterEachDescriptor
private function filterEachDescriptor($descriptor) { $descriptors = new Collection(); foreach ($descriptor as $key => $item) { $item = $this->filterDescriptor($item); if (!$item) { continue; } $descriptors[$key] = $item; } return $descriptors; }
php
private function filterEachDescriptor($descriptor) { $descriptors = new Collection(); foreach ($descriptor as $key => $item) { $item = $this->filterDescriptor($item); if (!$item) { continue; } $descriptors[$key] = $item; } return $descriptors; }
[ "private", "function", "filterEachDescriptor", "(", "$", "descriptor", ")", "{", "$", "descriptors", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "descriptor", "as", "$", "key", "=>", "$", "item", ")", "{", "$", "item", "=", "$", "this", "->", "filterDescriptor", "(", "$", "item", ")", ";", "if", "(", "!", "$", "item", ")", "{", "continue", ";", "}", "$", "descriptors", "[", "$", "key", "]", "=", "$", "item", ";", "}", "return", "$", "descriptors", ";", "}" ]
Filters each descriptor, validates them, stores the validation results and returns a collection of transmuted objects. @param DescriptorAbstract[] $descriptor @return Collection
[ "Filters", "each", "descriptor", "validates", "them", "stores", "the", "validation", "results", "and", "returns", "a", "collection", "of", "transmuted", "objects", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php#L170-L183
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php
ProjectDescriptorBuilder.filterDescriptor
protected function filterDescriptor(Descriptor $descriptor) { if (!$descriptor instanceof Filterable) { return $descriptor; } // filter the descriptor; this may result in the descriptor being removed! $descriptor = $this->filter($descriptor); if (!$descriptor) { return null; } return $descriptor; }
php
protected function filterDescriptor(Descriptor $descriptor) { if (!$descriptor instanceof Filterable) { return $descriptor; } $descriptor = $this->filter($descriptor); if (!$descriptor) { return null; } return $descriptor; }
[ "protected", "function", "filterDescriptor", "(", "Descriptor", "$", "descriptor", ")", "{", "if", "(", "!", "$", "descriptor", "instanceof", "Filterable", ")", "{", "return", "$", "descriptor", ";", "}", "// filter the descriptor; this may result in the descriptor being removed!", "$", "descriptor", "=", "$", "this", "->", "filter", "(", "$", "descriptor", ")", ";", "if", "(", "!", "$", "descriptor", ")", "{", "return", "null", ";", "}", "return", "$", "descriptor", ";", "}" ]
Filters a descriptor, validates it, stores the validation results and returns the transmuted object or null if it is supposed to be removed. @param Descriptor $descriptor @return Descriptor|null
[ "Filters", "a", "descriptor", "validates", "it", "stores", "the", "validation", "results", "and", "returns", "the", "transmuted", "object", "or", "null", "if", "it", "is", "supposed", "to", "be", "removed", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php#L193-L206
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/AuthorTag.php
AuthorTag.process
public function process(\DOMDocument $xml) { // matches: // - [email protected] // - <[email protected]> // - Some Name <[email protected]> // ignores leading and trailing whitespace // requires angled brackets when a name is given (that's what the // two (?(1)) conditions do) // requires closing angled bracket if email address is given with an // opening angled bracket but no name (that's what the (?(3)) // condition is for) $regex = '#^\s*(?P<name>[^<]+?)?\s*((?(1)<|<?)(?:mailto:)?' . '(?P<email>\b[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}\b)' . '(?(1)>|(?(3)>|>?)))\s*$#u'; $xpath = new \DOMXPath($xml); $nodes = $xpath->query('//tag[@name="author"]/@description'); /** @var \DOMElement $node */ foreach ($nodes as $node) { // FIXME: #193 if (preg_match($regex, $node->nodeValue, $matches)) { if ($matches['name']) { $value = $matches['name']; } else { // in case there were <> but no name... this cleans up the // output a bit $value = $matches['email']; } $node->nodeValue = $value; /** @var \DOMElement $parentNode */ $parentNode = $node->parentNode; $parentNode->setAttribute( 'link', 'mailto:' . $matches['email'] ); } } return $xml; }
php
public function process(\DOMDocument $xml) { $regex = ' . '(?P<email>\b[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}\b)' . '(?(1)>|(?(3)>|>?)))\s*$ $xpath = new \DOMXPath($xml); $nodes = $xpath->query(' foreach ($nodes as $node) { if (preg_match($regex, $node->nodeValue, $matches)) { if ($matches['name']) { $value = $matches['name']; } else { $value = $matches['email']; } $node->nodeValue = $value; $parentNode = $node->parentNode; $parentNode->setAttribute( 'link', 'mailto:' . $matches['email'] ); } } return $xml; }
[ "public", "function", "process", "(", "\\", "DOMDocument", "$", "xml", ")", "{", "// matches:", "// - [email protected]", "// - <[email protected]>", "// - Some Name <[email protected]>", "// ignores leading and trailing whitespace", "// requires angled brackets when a name is given (that's what the", "// two (?(1)) conditions do)", "// requires closing angled bracket if email address is given with an", "// opening angled bracket but no name (that's what the (?(3))", "// condition is for)", "$", "regex", "=", "'#^\\s*(?P<name>[^<]+?)?\\s*((?(1)<|<?)(?:mailto:)?'", ".", "'(?P<email>\\b[a-z0-9._%-]+@[a-z0-9.-]+\\.[a-z]{2,4}\\b)'", ".", "'(?(1)>|(?(3)>|>?)))\\s*$#u'", ";", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "xml", ")", ";", "$", "nodes", "=", "$", "xpath", "->", "query", "(", "'//tag[@name=\"author\"]/@description'", ")", ";", "/** @var \\DOMElement $node */", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "// FIXME: #193", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "node", "->", "nodeValue", ",", "$", "matches", ")", ")", "{", "if", "(", "$", "matches", "[", "'name'", "]", ")", "{", "$", "value", "=", "$", "matches", "[", "'name'", "]", ";", "}", "else", "{", "// in case there were <> but no name... this cleans up the", "// output a bit", "$", "value", "=", "$", "matches", "[", "'email'", "]", ";", "}", "$", "node", "->", "nodeValue", "=", "$", "value", ";", "/** @var \\DOMElement $parentNode */", "$", "parentNode", "=", "$", "node", "->", "parentNode", ";", "$", "parentNode", "->", "setAttribute", "(", "'link'", ",", "'mailto:'", ".", "$", "matches", "[", "'email'", "]", ")", ";", "}", "}", "return", "$", "xml", ";", "}" ]
Find all return tags that contain 'self' or '$this' and replace those terms for the name of the current class' type. @param \DOMDocument $xml Structure source to apply behaviour onto. @return \DOMDocument
[ "Find", "all", "return", "tags", "that", "contain", "self", "or", "$this", "and", "replace", "those", "terms", "for", "the", "name", "of", "the", "current", "class", "type", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/AuthorTag.php#L31-L74
phpDocumentor/phpDocumentor2
src/phpDocumentor/Parser/Middleware/ErrorHandlingMiddleware.php
ErrorHandlingMiddleware.execute
public function execute(Command $command, callable $next) { $filename = $command->getFile()->path(); $this->log('Starting to parse file: ' . $filename, LogLevel::INFO); try { return $next($command); } catch (Exception $e) { $this->log( ' Unable to parse file "' . $filename . '", an error was detected: ' . $e->getMessage(), LogLevel::ALERT ); } return null; }
php
public function execute(Command $command, callable $next) { $filename = $command->getFile()->path(); $this->log('Starting to parse file: ' . $filename, LogLevel::INFO); try { return $next($command); } catch (Exception $e) { $this->log( ' Unable to parse file "' . $filename . '", an error was detected: ' . $e->getMessage(), LogLevel::ALERT ); } return null; }
[ "public", "function", "execute", "(", "Command", "$", "command", ",", "callable", "$", "next", ")", "{", "$", "filename", "=", "$", "command", "->", "getFile", "(", ")", "->", "path", "(", ")", ";", "$", "this", "->", "log", "(", "'Starting to parse file: '", ".", "$", "filename", ",", "LogLevel", "::", "INFO", ")", ";", "try", "{", "return", "$", "next", "(", "$", "command", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "log", "(", "' Unable to parse file \"'", ".", "$", "filename", ".", "'\", an error was detected: '", ".", "$", "e", "->", "getMessage", "(", ")", ",", "LogLevel", "::", "ALERT", ")", ";", "}", "return", "null", ";", "}" ]
Executes this middle ware class. @param callable $next @return object
[ "Executes", "this", "middle", "ware", "class", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Parser/Middleware/ErrorHandlingMiddleware.php#L39-L54
phpDocumentor/phpDocumentor2
src/phpDocumentor/Event/Dispatcher.php
Dispatcher.getInstance
public static function getInstance(string $name = 'default'): self { if (!isset(self::$instances[$name])) { self::setInstance($name, new self()); } return self::$instances[$name]; }
php
public static function getInstance(string $name = 'default'): self { if (!isset(self::$instances[$name])) { self::setInstance($name, new self()); } return self::$instances[$name]; }
[ "public", "static", "function", "getInstance", "(", "string", "$", "name", "=", "'default'", ")", ":", "self", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "name", "]", ")", ")", "{", "self", "::", "setInstance", "(", "$", "name", ",", "new", "self", "(", ")", ")", ";", "}", "return", "self", "::", "$", "instances", "[", "$", "name", "]", ";", "}" ]
Returns a named instance of the Event Dispatcher.
[ "Returns", "a", "named", "instance", "of", "the", "Event", "Dispatcher", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Event/Dispatcher.php#L47-L54
phpDocumentor/phpDocumentor2
src/phpDocumentor/Event/Dispatcher.php
Dispatcher.setInstance
public static function setInstance(string $name, self $instance): void { self::$instances[$name] = $instance; }
php
public static function setInstance(string $name, self $instance): void { self::$instances[$name] = $instance; }
[ "public", "static", "function", "setInstance", "(", "string", "$", "name", ",", "self", "$", "instance", ")", ":", "void", "{", "self", "::", "$", "instances", "[", "$", "name", "]", "=", "$", "instance", ";", "}" ]
Sets a names instance of the Event Dispatcher.
[ "Sets", "a", "names", "instance", "of", "the", "Event", "Dispatcher", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Event/Dispatcher.php#L59-L62
phpDocumentor/phpDocumentor2
src/phpDocumentor/Parser/Middleware/CacheMiddleware.php
CacheMiddleware.execute
public function execute(Command $command, callable $next) { $itemName = $this->getItemName($command->getFile()->path()); $item = $this->dataStore->getItem($itemName); if ($item->isMiss() || $this->parser->isForced()) { return $this->updateCache($command, $next, $item); } /** @var File $cachedFile */ $cachedFile = $item->get(); if ($cachedFile === null) { return $this->updateCache($command, $next, $item); } if ($cachedFile->getHash() !== $command->getFile()->md5()) { return $this->updateCache($command, $next, $item); } return $cachedFile; }
php
public function execute(Command $command, callable $next) { $itemName = $this->getItemName($command->getFile()->path()); $item = $this->dataStore->getItem($itemName); if ($item->isMiss() || $this->parser->isForced()) { return $this->updateCache($command, $next, $item); } $cachedFile = $item->get(); if ($cachedFile === null) { return $this->updateCache($command, $next, $item); } if ($cachedFile->getHash() !== $command->getFile()->md5()) { return $this->updateCache($command, $next, $item); } return $cachedFile; }
[ "public", "function", "execute", "(", "Command", "$", "command", ",", "callable", "$", "next", ")", "{", "$", "itemName", "=", "$", "this", "->", "getItemName", "(", "$", "command", "->", "getFile", "(", ")", "->", "path", "(", ")", ")", ";", "$", "item", "=", "$", "this", "->", "dataStore", "->", "getItem", "(", "$", "itemName", ")", ";", "if", "(", "$", "item", "->", "isMiss", "(", ")", "||", "$", "this", "->", "parser", "->", "isForced", "(", ")", ")", "{", "return", "$", "this", "->", "updateCache", "(", "$", "command", ",", "$", "next", ",", "$", "item", ")", ";", "}", "/** @var File $cachedFile */", "$", "cachedFile", "=", "$", "item", "->", "get", "(", ")", ";", "if", "(", "$", "cachedFile", "===", "null", ")", "{", "return", "$", "this", "->", "updateCache", "(", "$", "command", ",", "$", "next", ",", "$", "item", ")", ";", "}", "if", "(", "$", "cachedFile", "->", "getHash", "(", ")", "!==", "$", "command", "->", "getFile", "(", ")", "->", "md5", "(", ")", ")", "{", "return", "$", "this", "->", "updateCache", "(", "$", "command", ",", "$", "next", ",", "$", "item", ")", ";", "}", "return", "$", "cachedFile", ";", "}" ]
Executes this middle ware class. A middle ware class MUST return a File object or call the $next callable. @param CreateCommand $command @param callable $next @return File
[ "Executes", "this", "middle", "ware", "class", ".", "A", "middle", "ware", "class", "MUST", "return", "a", "File", "object", "or", "call", "the", "$next", "callable", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Parser/Middleware/CacheMiddleware.php#L61-L81
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Twig/Writer/Twig.php
Twig.transform
public function transform(ProjectDescriptor $project, Transformation $transformation): void { $template_path = $this->getTemplatePath($transformation); $finder = new Pathfinder(); $nodes = $finder->find($project, $transformation->getQuery()); foreach ($nodes as $node) { if (!$node) { continue; } $destination = $this->getDestinationPath($node, $transformation); if ($destination === false) { continue; } $environment = $this->initializeEnvironment($project, $transformation, $destination); $environment->addGlobal('node', $node); $html = $environment->render(substr($transformation->getSource(), strlen($template_path))); file_put_contents($destination, $html); } }
php
public function transform(ProjectDescriptor $project, Transformation $transformation): void { $template_path = $this->getTemplatePath($transformation); $finder = new Pathfinder(); $nodes = $finder->find($project, $transformation->getQuery()); foreach ($nodes as $node) { if (!$node) { continue; } $destination = $this->getDestinationPath($node, $transformation); if ($destination === false) { continue; } $environment = $this->initializeEnvironment($project, $transformation, $destination); $environment->addGlobal('node', $node); $html = $environment->render(substr($transformation->getSource(), strlen($template_path))); file_put_contents($destination, $html); } }
[ "public", "function", "transform", "(", "ProjectDescriptor", "$", "project", ",", "Transformation", "$", "transformation", ")", ":", "void", "{", "$", "template_path", "=", "$", "this", "->", "getTemplatePath", "(", "$", "transformation", ")", ";", "$", "finder", "=", "new", "Pathfinder", "(", ")", ";", "$", "nodes", "=", "$", "finder", "->", "find", "(", "$", "project", ",", "$", "transformation", "->", "getQuery", "(", ")", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "!", "$", "node", ")", "{", "continue", ";", "}", "$", "destination", "=", "$", "this", "->", "getDestinationPath", "(", "$", "node", ",", "$", "transformation", ")", ";", "if", "(", "$", "destination", "===", "false", ")", "{", "continue", ";", "}", "$", "environment", "=", "$", "this", "->", "initializeEnvironment", "(", "$", "project", ",", "$", "transformation", ",", "$", "destination", ")", ";", "$", "environment", "->", "addGlobal", "(", "'node'", ",", "$", "node", ")", ";", "$", "html", "=", "$", "environment", "->", "render", "(", "substr", "(", "$", "transformation", "->", "getSource", "(", ")", ",", "strlen", "(", "$", "template_path", ")", ")", ")", ";", "file_put_contents", "(", "$", "destination", ",", "$", "html", ")", ";", "}", "}" ]
This method combines the ProjectDescriptor and the given target template and creates a static html page at the artifact location. @param ProjectDescriptor $project Document containing the structure. @param Transformation $transformation Transformation to execute.
[ "This", "method", "combines", "the", "ProjectDescriptor", "and", "the", "given", "target", "template", "and", "creates", "a", "static", "html", "page", "at", "the", "artifact", "location", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L108-L131
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Twig/Writer/Twig.php
Twig.initializeEnvironment
protected function initializeEnvironment( ProjectDescriptor $project, Transformation $transformation, string $destination ): Twig_Environment { $callingTemplatePath = $this->getTemplatePath($transformation); $baseTemplatesPath = $transformation->getTransformer()->getTemplates()->getTemplatesPath(); $templateFolders = [ $baseTemplatesPath . '/..' . DIRECTORY_SEPARATOR . $callingTemplatePath, // http://twig.sensiolabs.org/doc/recipes.html#overriding-a-template-that-also-extends-itself $baseTemplatesPath, ]; // get all invoked template paths, they overrule the calling template path /** @var \phpDocumentor\Transformer\Template $template */ foreach ($transformation->getTransformer()->getTemplates() as $template) { $path = $baseTemplatesPath . DIRECTORY_SEPARATOR . $template->getName(); array_unshift($templateFolders, $path); } // Clone twig because otherwise we cannot re-set the extensions on this twig environment on every run of this // writer $env = clone $this->twig; $env->setLoader(new Twig_Loader_Filesystem($templateFolders)); $this->addPhpDocumentorExtension($project, $transformation, $destination, $env); $this->addExtensionsFromTemplateConfiguration($transformation, $project, $env); return $env; }
php
protected function initializeEnvironment( ProjectDescriptor $project, Transformation $transformation, string $destination ): Twig_Environment { $callingTemplatePath = $this->getTemplatePath($transformation); $baseTemplatesPath = $transformation->getTransformer()->getTemplates()->getTemplatesPath(); $templateFolders = [ $baseTemplatesPath . '/..' . DIRECTORY_SEPARATOR . $callingTemplatePath, $baseTemplatesPath, ]; foreach ($transformation->getTransformer()->getTemplates() as $template) { $path = $baseTemplatesPath . DIRECTORY_SEPARATOR . $template->getName(); array_unshift($templateFolders, $path); } $env = clone $this->twig; $env->setLoader(new Twig_Loader_Filesystem($templateFolders)); $this->addPhpDocumentorExtension($project, $transformation, $destination, $env); $this->addExtensionsFromTemplateConfiguration($transformation, $project, $env); return $env; }
[ "protected", "function", "initializeEnvironment", "(", "ProjectDescriptor", "$", "project", ",", "Transformation", "$", "transformation", ",", "string", "$", "destination", ")", ":", "Twig_Environment", "{", "$", "callingTemplatePath", "=", "$", "this", "->", "getTemplatePath", "(", "$", "transformation", ")", ";", "$", "baseTemplatesPath", "=", "$", "transformation", "->", "getTransformer", "(", ")", "->", "getTemplates", "(", ")", "->", "getTemplatesPath", "(", ")", ";", "$", "templateFolders", "=", "[", "$", "baseTemplatesPath", ".", "'/..'", ".", "DIRECTORY_SEPARATOR", ".", "$", "callingTemplatePath", ",", "// http://twig.sensiolabs.org/doc/recipes.html#overriding-a-template-that-also-extends-itself", "$", "baseTemplatesPath", ",", "]", ";", "// get all invoked template paths, they overrule the calling template path", "/** @var \\phpDocumentor\\Transformer\\Template $template */", "foreach", "(", "$", "transformation", "->", "getTransformer", "(", ")", "->", "getTemplates", "(", ")", "as", "$", "template", ")", "{", "$", "path", "=", "$", "baseTemplatesPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "template", "->", "getName", "(", ")", ";", "array_unshift", "(", "$", "templateFolders", ",", "$", "path", ")", ";", "}", "// Clone twig because otherwise we cannot re-set the extensions on this twig environment on every run of this", "// writer", "$", "env", "=", "clone", "$", "this", "->", "twig", ";", "$", "env", "->", "setLoader", "(", "new", "Twig_Loader_Filesystem", "(", "$", "templateFolders", ")", ")", ";", "$", "this", "->", "addPhpDocumentorExtension", "(", "$", "project", ",", "$", "transformation", ",", "$", "destination", ",", "$", "env", ")", ";", "$", "this", "->", "addExtensionsFromTemplateConfiguration", "(", "$", "transformation", ",", "$", "project", ",", "$", "env", ")", ";", "return", "$", "env", ";", "}" ]
Initializes the Twig environment with the template, base extension and additionally defined extensions.
[ "Initializes", "the", "Twig", "environment", "with", "the", "template", "base", "extension", "and", "additionally", "defined", "extensions", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L136-L167
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Twig/Writer/Twig.php
Twig.addPhpDocumentorExtension
protected function addPhpDocumentorExtension( ProjectDescriptor $project, Transformation $transformation, string $destination, Twig_Environment $twigEnvironment ): void { $base_extension = new Extension($project, $transformation); $base_extension->setDestination( substr($destination, strlen($transformation->getTransformer()->getTarget()) + 1) ); $base_extension->setRouters($this->routers); $twigEnvironment->addExtension($base_extension); }
php
protected function addPhpDocumentorExtension( ProjectDescriptor $project, Transformation $transformation, string $destination, Twig_Environment $twigEnvironment ): void { $base_extension = new Extension($project, $transformation); $base_extension->setDestination( substr($destination, strlen($transformation->getTransformer()->getTarget()) + 1) ); $base_extension->setRouters($this->routers); $twigEnvironment->addExtension($base_extension); }
[ "protected", "function", "addPhpDocumentorExtension", "(", "ProjectDescriptor", "$", "project", ",", "Transformation", "$", "transformation", ",", "string", "$", "destination", ",", "Twig_Environment", "$", "twigEnvironment", ")", ":", "void", "{", "$", "base_extension", "=", "new", "Extension", "(", "$", "project", ",", "$", "transformation", ")", ";", "$", "base_extension", "->", "setDestination", "(", "substr", "(", "$", "destination", ",", "strlen", "(", "$", "transformation", "->", "getTransformer", "(", ")", "->", "getTarget", "(", ")", ")", "+", "1", ")", ")", ";", "$", "base_extension", "->", "setRouters", "(", "$", "this", "->", "routers", ")", ";", "$", "twigEnvironment", "->", "addExtension", "(", "$", "base_extension", ")", ";", "}" ]
Adds the phpDocumentor base extension to the Twig Environment.
[ "Adds", "the", "phpDocumentor", "base", "extension", "to", "the", "Twig", "Environment", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L172-L184
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Twig/Writer/Twig.php
Twig.getTemplatePath
protected function getTemplatePath(Transformation $transformation): string { $parts = preg_split('[\\\\|/]', $transformation->getSource()); return $parts[0] . DIRECTORY_SEPARATOR . $parts[1]; }
php
protected function getTemplatePath(Transformation $transformation): string { $parts = preg_split('[\\\\|/]', $transformation->getSource()); return $parts[0] . DIRECTORY_SEPARATOR . $parts[1]; }
[ "protected", "function", "getTemplatePath", "(", "Transformation", "$", "transformation", ")", ":", "string", "{", "$", "parts", "=", "preg_split", "(", "'[\\\\\\\\|/]'", ",", "$", "transformation", "->", "getSource", "(", ")", ")", ";", "return", "$", "parts", "[", "0", "]", ".", "DIRECTORY_SEPARATOR", ".", "$", "parts", "[", "1", "]", ";", "}" ]
Returns the path belonging to the template.
[ "Returns", "the", "path", "belonging", "to", "the", "template", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L317-L322
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/PropertyTag.php
PropertyTag.process
public function process(\DOMDocument $xml) { $xpath = new \DOMXPath($xml); $nodes = $xpath->query( '/project/file/class/docblock/tag[@name="property"]' . '|/project/file/class/docblock/tag[@name="property-read"]' . '|/project/file/class/docblock/tag[@name="property-write"]' ); /** @var \DOMElement $node */ foreach ($nodes as $node) { $class = $node->parentNode->parentNode; $property = new \DOMElement('property'); $class->appendChild($property); $property->setAttribute('final', 'false'); $property->setAttribute('static', 'false'); $property->setAttribute('visibility', 'public'); $property->setAttribute('line', $node->getAttribute('line')); $property->appendChild( new \DOMElement('name', $node->getAttribute('variable')) ); $property->appendChild(new \DOMElement('default')); $docblock = new \DOMElement('docblock'); $property->appendChild($docblock); $docblock->appendChild( new \DOMElement('description', $node->getAttribute('description')) ); $docblock->appendChild(new \DOMElement('long-description')); $var_tag = new \DOMElement('tag'); $docblock->appendChild($var_tag); $var_tag->setAttribute('name', 'var'); $var_tag->setAttribute('description', $node->getAttribute('description')); $var_tag->setAttribute('type', $node->getAttribute('type')); $var_tag->setAttribute('line', $node->getAttribute('line')); $var_tag_type = new \DOMElement('type', $node->getAttribute('type')); $var_tag->appendChild($var_tag_type); $var_tag_type->setAttribute('by_reference', 'false'); $magic_tag = new \DOMElement('tag'); $docblock->appendChild($magic_tag); $magic_tag->setAttribute('name', 'magic'); $magic_tag->setAttribute('line', $node->getAttribute('line')); $node->parentNode->removeChild($node); $docblock->appendChild($node); } return $xml; }
php
public function process(\DOMDocument $xml) { $xpath = new \DOMXPath($xml); $nodes = $xpath->query( '/project/file/class/docblock/tag[@name="property"]' . '|/project/file/class/docblock/tag[@name="property-read"]' . '|/project/file/class/docblock/tag[@name="property-write"]' ); foreach ($nodes as $node) { $class = $node->parentNode->parentNode; $property = new \DOMElement('property'); $class->appendChild($property); $property->setAttribute('final', 'false'); $property->setAttribute('static', 'false'); $property->setAttribute('visibility', 'public'); $property->setAttribute('line', $node->getAttribute('line')); $property->appendChild( new \DOMElement('name', $node->getAttribute('variable')) ); $property->appendChild(new \DOMElement('default')); $docblock = new \DOMElement('docblock'); $property->appendChild($docblock); $docblock->appendChild( new \DOMElement('description', $node->getAttribute('description')) ); $docblock->appendChild(new \DOMElement('long-description')); $var_tag = new \DOMElement('tag'); $docblock->appendChild($var_tag); $var_tag->setAttribute('name', 'var'); $var_tag->setAttribute('description', $node->getAttribute('description')); $var_tag->setAttribute('type', $node->getAttribute('type')); $var_tag->setAttribute('line', $node->getAttribute('line')); $var_tag_type = new \DOMElement('type', $node->getAttribute('type')); $var_tag->appendChild($var_tag_type); $var_tag_type->setAttribute('by_reference', 'false'); $magic_tag = new \DOMElement('tag'); $docblock->appendChild($magic_tag); $magic_tag->setAttribute('name', 'magic'); $magic_tag->setAttribute('line', $node->getAttribute('line')); $node->parentNode->removeChild($node); $docblock->appendChild($node); } return $xml; }
[ "public", "function", "process", "(", "\\", "DOMDocument", "$", "xml", ")", "{", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "xml", ")", ";", "$", "nodes", "=", "$", "xpath", "->", "query", "(", "'/project/file/class/docblock/tag[@name=\"property\"]'", ".", "'|/project/file/class/docblock/tag[@name=\"property-read\"]'", ".", "'|/project/file/class/docblock/tag[@name=\"property-write\"]'", ")", ";", "/** @var \\DOMElement $node */", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "class", "=", "$", "node", "->", "parentNode", "->", "parentNode", ";", "$", "property", "=", "new", "\\", "DOMElement", "(", "'property'", ")", ";", "$", "class", "->", "appendChild", "(", "$", "property", ")", ";", "$", "property", "->", "setAttribute", "(", "'final'", ",", "'false'", ")", ";", "$", "property", "->", "setAttribute", "(", "'static'", ",", "'false'", ")", ";", "$", "property", "->", "setAttribute", "(", "'visibility'", ",", "'public'", ")", ";", "$", "property", "->", "setAttribute", "(", "'line'", ",", "$", "node", "->", "getAttribute", "(", "'line'", ")", ")", ";", "$", "property", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'name'", ",", "$", "node", "->", "getAttribute", "(", "'variable'", ")", ")", ")", ";", "$", "property", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'default'", ")", ")", ";", "$", "docblock", "=", "new", "\\", "DOMElement", "(", "'docblock'", ")", ";", "$", "property", "->", "appendChild", "(", "$", "docblock", ")", ";", "$", "docblock", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'description'", ",", "$", "node", "->", "getAttribute", "(", "'description'", ")", ")", ")", ";", "$", "docblock", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'long-description'", ")", ")", ";", "$", "var_tag", "=", "new", "\\", "DOMElement", "(", "'tag'", ")", ";", "$", "docblock", "->", "appendChild", "(", "$", "var_tag", ")", ";", "$", "var_tag", "->", "setAttribute", "(", "'name'", ",", "'var'", ")", ";", "$", "var_tag", "->", "setAttribute", "(", "'description'", ",", "$", "node", "->", "getAttribute", "(", "'description'", ")", ")", ";", "$", "var_tag", "->", "setAttribute", "(", "'type'", ",", "$", "node", "->", "getAttribute", "(", "'type'", ")", ")", ";", "$", "var_tag", "->", "setAttribute", "(", "'line'", ",", "$", "node", "->", "getAttribute", "(", "'line'", ")", ")", ";", "$", "var_tag_type", "=", "new", "\\", "DOMElement", "(", "'type'", ",", "$", "node", "->", "getAttribute", "(", "'type'", ")", ")", ";", "$", "var_tag", "->", "appendChild", "(", "$", "var_tag_type", ")", ";", "$", "var_tag_type", "->", "setAttribute", "(", "'by_reference'", ",", "'false'", ")", ";", "$", "magic_tag", "=", "new", "\\", "DOMElement", "(", "'tag'", ")", ";", "$", "docblock", "->", "appendChild", "(", "$", "magic_tag", ")", ";", "$", "magic_tag", "->", "setAttribute", "(", "'name'", ",", "'magic'", ")", ";", "$", "magic_tag", "->", "setAttribute", "(", "'line'", ",", "$", "node", "->", "getAttribute", "(", "'line'", ")", ")", ";", "$", "node", "->", "parentNode", "->", "removeChild", "(", "$", "node", ")", ";", "$", "docblock", "->", "appendChild", "(", "$", "node", ")", ";", "}", "return", "$", "xml", ";", "}" ]
Find all return tags that contain 'self' or '$this' and replace those terms for the name of the current class' type. @param \DOMDocument $xml Structure source to apply behaviour onto. @return \DOMDocument
[ "Find", "all", "return", "tags", "that", "contain", "self", "or", "$this", "and", "replace", "those", "terms", "for", "the", "name", "of", "the", "current", "class", "type", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/PropertyTag.php#L31-L84
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/MethodConverter.php
MethodConverter.convert
public function convert(\DOMElement $parent, MethodDescriptor $method) { $fullyQualifiedNamespaceName = $method->getNamespace() instanceof NamespaceDescriptor ? $method->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace'); $child = new \DOMElement('method'); $parent->appendChild($child); $child->setAttribute('final', var_export($method->isFinal(), true)); $child->setAttribute('abstract', var_export($method->isAbstract(), true)); $child->setAttribute('static', var_export($method->isStatic(), true)); $child->setAttribute('visibility', $method->getVisibility()); $child->setAttribute('namespace', $fullyQualifiedNamespaceName); $child->setAttribute('line', (string) $method->getLine()); $child->appendChild(new \DOMElement('name', $method->getName())); $child->appendChild(new \DOMElement('full_name', $method->getFullyQualifiedStructuralElementName())); $this->docBlockConverter->convert($child, $method); foreach ($method->getArguments() as $argument) { $this->argumentConverter->convert($child, $argument); } return $child; }
php
public function convert(\DOMElement $parent, MethodDescriptor $method) { $fullyQualifiedNamespaceName = $method->getNamespace() instanceof NamespaceDescriptor ? $method->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace'); $child = new \DOMElement('method'); $parent->appendChild($child); $child->setAttribute('final', var_export($method->isFinal(), true)); $child->setAttribute('abstract', var_export($method->isAbstract(), true)); $child->setAttribute('static', var_export($method->isStatic(), true)); $child->setAttribute('visibility', $method->getVisibility()); $child->setAttribute('namespace', $fullyQualifiedNamespaceName); $child->setAttribute('line', (string) $method->getLine()); $child->appendChild(new \DOMElement('name', $method->getName())); $child->appendChild(new \DOMElement('full_name', $method->getFullyQualifiedStructuralElementName())); $this->docBlockConverter->convert($child, $method); foreach ($method->getArguments() as $argument) { $this->argumentConverter->convert($child, $argument); } return $child; }
[ "public", "function", "convert", "(", "\\", "DOMElement", "$", "parent", ",", "MethodDescriptor", "$", "method", ")", "{", "$", "fullyQualifiedNamespaceName", "=", "$", "method", "->", "getNamespace", "(", ")", "instanceof", "NamespaceDescriptor", "?", "$", "method", "->", "getNamespace", "(", ")", "->", "getFullyQualifiedStructuralElementName", "(", ")", ":", "$", "parent", "->", "getAttribute", "(", "'namespace'", ")", ";", "$", "child", "=", "new", "\\", "DOMElement", "(", "'method'", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "child", ")", ";", "$", "child", "->", "setAttribute", "(", "'final'", ",", "var_export", "(", "$", "method", "->", "isFinal", "(", ")", ",", "true", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'abstract'", ",", "var_export", "(", "$", "method", "->", "isAbstract", "(", ")", ",", "true", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'static'", ",", "var_export", "(", "$", "method", "->", "isStatic", "(", ")", ",", "true", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'visibility'", ",", "$", "method", "->", "getVisibility", "(", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'namespace'", ",", "$", "fullyQualifiedNamespaceName", ")", ";", "$", "child", "->", "setAttribute", "(", "'line'", ",", "(", "string", ")", "$", "method", "->", "getLine", "(", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'name'", ",", "$", "method", "->", "getName", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'full_name'", ",", "$", "method", "->", "getFullyQualifiedStructuralElementName", "(", ")", ")", ")", ";", "$", "this", "->", "docBlockConverter", "->", "convert", "(", "$", "child", ",", "$", "method", ")", ";", "foreach", "(", "$", "method", "->", "getArguments", "(", ")", "as", "$", "argument", ")", "{", "$", "this", "->", "argumentConverter", "->", "convert", "(", "$", "child", ",", "$", "argument", ")", ";", "}", "return", "$", "child", ";", "}" ]
Export the given reflected method definition to the provided parent element. @param \DOMElement $parent Element to augment. @param MethodDescriptor $method Element to export. @return \DOMElement
[ "Export", "the", "given", "reflected", "method", "definition", "to", "the", "provided", "parent", "element", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/MethodConverter.php#L52-L78
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/FileDescriptor.php
FileDescriptor.getAllErrors
public function getAllErrors() { $errors = $this->getErrors(); $types = $this->getClasses()->merge($this->getInterfaces())->merge($this->getTraits()); $elements = $this->getFunctions()->merge($this->getConstants())->merge($types); foreach ($elements as $element) { if (!$element) { continue; } $errors = $errors->merge($element->getErrors()); } foreach ($types as $element) { if (!$element) { continue; } foreach ($element->getMethods() as $item) { if (!$item) { continue; } $errors = $errors->merge($item->getErrors()); } if (method_exists($element, 'getConstants')) { foreach ($element->getConstants() as $item) { if (!$item) { continue; } $errors = $errors->merge($item->getErrors()); } } if (method_exists($element, 'getProperties')) { foreach ($element->getProperties() as $item) { if (!$item) { continue; } $errors = $errors->merge($item->getErrors()); } } } return $errors; }
php
public function getAllErrors() { $errors = $this->getErrors(); $types = $this->getClasses()->merge($this->getInterfaces())->merge($this->getTraits()); $elements = $this->getFunctions()->merge($this->getConstants())->merge($types); foreach ($elements as $element) { if (!$element) { continue; } $errors = $errors->merge($element->getErrors()); } foreach ($types as $element) { if (!$element) { continue; } foreach ($element->getMethods() as $item) { if (!$item) { continue; } $errors = $errors->merge($item->getErrors()); } if (method_exists($element, 'getConstants')) { foreach ($element->getConstants() as $item) { if (!$item) { continue; } $errors = $errors->merge($item->getErrors()); } } if (method_exists($element, 'getProperties')) { foreach ($element->getProperties() as $item) { if (!$item) { continue; } $errors = $errors->merge($item->getErrors()); } } } return $errors; }
[ "public", "function", "getAllErrors", "(", ")", "{", "$", "errors", "=", "$", "this", "->", "getErrors", "(", ")", ";", "$", "types", "=", "$", "this", "->", "getClasses", "(", ")", "->", "merge", "(", "$", "this", "->", "getInterfaces", "(", ")", ")", "->", "merge", "(", "$", "this", "->", "getTraits", "(", ")", ")", ";", "$", "elements", "=", "$", "this", "->", "getFunctions", "(", ")", "->", "merge", "(", "$", "this", "->", "getConstants", "(", ")", ")", "->", "merge", "(", "$", "types", ")", ";", "foreach", "(", "$", "elements", "as", "$", "element", ")", "{", "if", "(", "!", "$", "element", ")", "{", "continue", ";", "}", "$", "errors", "=", "$", "errors", "->", "merge", "(", "$", "element", "->", "getErrors", "(", ")", ")", ";", "}", "foreach", "(", "$", "types", "as", "$", "element", ")", "{", "if", "(", "!", "$", "element", ")", "{", "continue", ";", "}", "foreach", "(", "$", "element", "->", "getMethods", "(", ")", "as", "$", "item", ")", "{", "if", "(", "!", "$", "item", ")", "{", "continue", ";", "}", "$", "errors", "=", "$", "errors", "->", "merge", "(", "$", "item", "->", "getErrors", "(", ")", ")", ";", "}", "if", "(", "method_exists", "(", "$", "element", ",", "'getConstants'", ")", ")", "{", "foreach", "(", "$", "element", "->", "getConstants", "(", ")", "as", "$", "item", ")", "{", "if", "(", "!", "$", "item", ")", "{", "continue", ";", "}", "$", "errors", "=", "$", "errors", "->", "merge", "(", "$", "item", "->", "getErrors", "(", ")", ")", ";", "}", "}", "if", "(", "method_exists", "(", "$", "element", ",", "'getProperties'", ")", ")", "{", "foreach", "(", "$", "element", "->", "getProperties", "(", ")", "as", "$", "item", ")", "{", "if", "(", "!", "$", "item", ")", "{", "continue", ";", "}", "$", "errors", "=", "$", "errors", "->", "merge", "(", "$", "item", "->", "getErrors", "(", ")", ")", ";", "}", "}", "}", "return", "$", "errors", ";", "}" ]
Returns a list of all errors in this file and all its child elements. @return Collection
[ "Returns", "a", "list", "of", "all", "errors", "in", "this", "file", "and", "all", "its", "child", "elements", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/FileDescriptor.php#L281-L332
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php
BaseConvertCommand.configure
protected function configure() { $this ->addOption( 'target', 't', InputOption::VALUE_OPTIONAL, 'target location for output', 'build' ) ->addOption( 'input-format', 'i', InputOption::VALUE_OPTIONAL, 'which input format does the documentation sources have?', 'rst' ) ->addOption( 'title', null, InputOption::VALUE_OPTIONAL, 'The title of this document', 'Scrybe' ) ->addOption( 'template', null, InputOption::VALUE_OPTIONAL, 'which template should be used to generate the documentation?', 'default' ) ->addArgument( 'source', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'One or more files or directories to fetch files from' ); $this->setHelp( <<<DESCRIPTION Generates reference documentation as {$this->output_format}. You can define the type of files use as input using the <info>--input-format</info> of <info>-i</info> option. DESCRIPTION ); }
php
protected function configure() { $this ->addOption( 'target', 't', InputOption::VALUE_OPTIONAL, 'target location for output', 'build' ) ->addOption( 'input-format', 'i', InputOption::VALUE_OPTIONAL, 'which input format does the documentation sources have?', 'rst' ) ->addOption( 'title', null, InputOption::VALUE_OPTIONAL, 'The title of this document', 'Scrybe' ) ->addOption( 'template', null, InputOption::VALUE_OPTIONAL, 'which template should be used to generate the documentation?', 'default' ) ->addArgument( 'source', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'One or more files or directories to fetch files from' ); $this->setHelp( <<<DESCRIPTION Generates reference documentation as {$this->output_format}. You can define the type of files use as input using the <info>--input-format</info> of <info>-i</info> option. DESCRIPTION ); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "addOption", "(", "'target'", ",", "'t'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'target location for output'", ",", "'build'", ")", "->", "addOption", "(", "'input-format'", ",", "'i'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'which input format does the documentation sources have?'", ",", "'rst'", ")", "->", "addOption", "(", "'title'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'The title of this document'", ",", "'Scrybe'", ")", "->", "addOption", "(", "'template'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'which template should be used to generate the documentation?'", ",", "'default'", ")", "->", "addArgument", "(", "'source'", ",", "InputArgument", "::", "IS_ARRAY", "|", "InputArgument", "::", "REQUIRED", ",", "'One or more files or directories to fetch files from'", ")", ";", "$", "this", "->", "setHelp", "(", "\n <<<DESCRIPTION\nGenerates reference documentation as {$this->output_format}.\n\nYou can define the type of files use as input using the <info>--input-format</info>\nof <info>-i</info> option.\n\nDESCRIPTION", ")", ";", "}" ]
Configures the options and default help text.
[ "Configures", "the", "options", "and", "default", "help", "text", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php#L59-L105
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php
BaseConvertCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $this->getHelper('phpdocumentor_logger')->connectOutputToLogging($output, $this); $converter = $this->getConverter($input); $converter->setOption('title', $input->getOption('title')); $output->writeln('Collect all documents'); $files = $this->buildCollection( $input->getArgument('source'), $converter->getDefinition()->getInputFormat()->getExtensions() ); $output->writeln('Converting documents'); $files = $converter->convert($files, $this->getTemplate($input)); $output->writeln('Writing converted documents to disk'); $this->writeToDisk($files, $input->getOption('target')); $output->writeln('Writing assets to disk'); $converter->getAssets()->copyTo($input->getOption('target')); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $this->getHelper('phpdocumentor_logger')->connectOutputToLogging($output, $this); $converter = $this->getConverter($input); $converter->setOption('title', $input->getOption('title')); $output->writeln('Collect all documents'); $files = $this->buildCollection( $input->getArgument('source'), $converter->getDefinition()->getInputFormat()->getExtensions() ); $output->writeln('Converting documents'); $files = $converter->convert($files, $this->getTemplate($input)); $output->writeln('Writing converted documents to disk'); $this->writeToDisk($files, $input->getOption('target')); $output->writeln('Writing assets to disk'); $converter->getAssets()->copyTo($input->getOption('target')); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "getHelper", "(", "'phpdocumentor_logger'", ")", "->", "connectOutputToLogging", "(", "$", "output", ",", "$", "this", ")", ";", "$", "converter", "=", "$", "this", "->", "getConverter", "(", "$", "input", ")", ";", "$", "converter", "->", "setOption", "(", "'title'", ",", "$", "input", "->", "getOption", "(", "'title'", ")", ")", ";", "$", "output", "->", "writeln", "(", "'Collect all documents'", ")", ";", "$", "files", "=", "$", "this", "->", "buildCollection", "(", "$", "input", "->", "getArgument", "(", "'source'", ")", ",", "$", "converter", "->", "getDefinition", "(", ")", "->", "getInputFormat", "(", ")", "->", "getExtensions", "(", ")", ")", ";", "$", "output", "->", "writeln", "(", "'Converting documents'", ")", ";", "$", "files", "=", "$", "converter", "->", "convert", "(", "$", "files", ",", "$", "this", "->", "getTemplate", "(", "$", "input", ")", ")", ";", "$", "output", "->", "writeln", "(", "'Writing converted documents to disk'", ")", ";", "$", "this", "->", "writeToDisk", "(", "$", "files", ",", "$", "input", "->", "getOption", "(", "'target'", ")", ")", ";", "$", "output", "->", "writeln", "(", "'Writing assets to disk'", ")", ";", "$", "converter", "->", "getAssets", "(", ")", "->", "copyTo", "(", "$", "input", "->", "getOption", "(", "'target'", ")", ")", ";", "}" ]
Execute the transformation process to an output format as defined in the $output_format class variable. @see BaseConvertCommand::$output_format to determine the output format. @return int
[ "Execute", "the", "transformation", "process", "to", "an", "output", "format", "as", "defined", "in", "the", "$output_format", "class", "variable", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php#L114-L135
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php
BaseConvertCommand.getTemplate
protected function getTemplate(InputInterface $input) { $template = $this->getTemplateFactory()->get('twig'); $template->setName($input->getOption('template')); return $template; }
php
protected function getTemplate(InputInterface $input) { $template = $this->getTemplateFactory()->get('twig'); $template->setName($input->getOption('template')); return $template; }
[ "protected", "function", "getTemplate", "(", "InputInterface", "$", "input", ")", "{", "$", "template", "=", "$", "this", "->", "getTemplateFactory", "(", ")", "->", "get", "(", "'twig'", ")", ";", "$", "template", "->", "setName", "(", "$", "input", "->", "getOption", "(", "'template'", ")", ")", ";", "return", "$", "template", ";", "}" ]
Returns a template object based off the human-readable template name. @return TemplateInterface
[ "Returns", "a", "template", "object", "based", "off", "the", "human", "-", "readable", "template", "name", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php#L160-L166
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php
BaseConvertCommand.getConverter
protected function getConverter(InputInterface $input) { return $this->getConverterFactory()->get($input->getOption('input-format'), $this->output_format); }
php
protected function getConverter(InputInterface $input) { return $this->getConverterFactory()->get($input->getOption('input-format'), $this->output_format); }
[ "protected", "function", "getConverter", "(", "InputInterface", "$", "input", ")", "{", "return", "$", "this", "->", "getConverterFactory", "(", ")", "->", "get", "(", "$", "input", "->", "getOption", "(", "'input-format'", ")", ",", "$", "this", "->", "output_format", ")", ";", "}" ]
Returns the converter for this operation. @return ConverterInterface
[ "Returns", "the", "converter", "for", "this", "operation", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php#L173-L176
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Discover.php
Discover.visitSection
protected function visitSection(\DOMNode $root, \ezcDocumentRstNode $node) { if ($node instanceof ezcDocumentRstSectionNode || $node instanceof ezcDocumentRstDocumentNode) { if ($node->depth === 1) { $toc = $this->getTableOfContents(); $file = $toc[$this->getFilenameWithoutExtension()]; $file->setName($this->nodeToString($node->title)); } else { // find nearest parent pointer depth-wise $parent_depth = $node->depth - 1; while (!isset($this->entry_pointers[$parent_depth]) && $parent_depth > 0) { --$parent_depth; } $parent = $this->entry_pointers[$parent_depth]; $heading = new TableOfContents\Heading($parent); $heading->setName($this->nodeToString($node->title)); $heading->setSlug($node->reference); $parent->addChild($heading); // set as last indexed heading $this->last_heading = $heading; // add as new entry pointer array_splice($this->entry_pointers, $parent_depth + 1, count($this->entry_pointers), [$heading]); } } parent::visitSection($root, $node); }
php
protected function visitSection(\DOMNode $root, \ezcDocumentRstNode $node) { if ($node instanceof ezcDocumentRstSectionNode || $node instanceof ezcDocumentRstDocumentNode) { if ($node->depth === 1) { $toc = $this->getTableOfContents(); $file = $toc[$this->getFilenameWithoutExtension()]; $file->setName($this->nodeToString($node->title)); } else { $parent_depth = $node->depth - 1; while (!isset($this->entry_pointers[$parent_depth]) && $parent_depth > 0) { --$parent_depth; } $parent = $this->entry_pointers[$parent_depth]; $heading = new TableOfContents\Heading($parent); $heading->setName($this->nodeToString($node->title)); $heading->setSlug($node->reference); $parent->addChild($heading); $this->last_heading = $heading; array_splice($this->entry_pointers, $parent_depth + 1, count($this->entry_pointers), [$heading]); } } parent::visitSection($root, $node); }
[ "protected", "function", "visitSection", "(", "\\", "DOMNode", "$", "root", ",", "\\", "ezcDocumentRstNode", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "ezcDocumentRstSectionNode", "||", "$", "node", "instanceof", "ezcDocumentRstDocumentNode", ")", "{", "if", "(", "$", "node", "->", "depth", "===", "1", ")", "{", "$", "toc", "=", "$", "this", "->", "getTableOfContents", "(", ")", ";", "$", "file", "=", "$", "toc", "[", "$", "this", "->", "getFilenameWithoutExtension", "(", ")", "]", ";", "$", "file", "->", "setName", "(", "$", "this", "->", "nodeToString", "(", "$", "node", "->", "title", ")", ")", ";", "}", "else", "{", "// find nearest parent pointer depth-wise", "$", "parent_depth", "=", "$", "node", "->", "depth", "-", "1", ";", "while", "(", "!", "isset", "(", "$", "this", "->", "entry_pointers", "[", "$", "parent_depth", "]", ")", "&&", "$", "parent_depth", ">", "0", ")", "{", "--", "$", "parent_depth", ";", "}", "$", "parent", "=", "$", "this", "->", "entry_pointers", "[", "$", "parent_depth", "]", ";", "$", "heading", "=", "new", "TableOfContents", "\\", "Heading", "(", "$", "parent", ")", ";", "$", "heading", "->", "setName", "(", "$", "this", "->", "nodeToString", "(", "$", "node", "->", "title", ")", ")", ";", "$", "heading", "->", "setSlug", "(", "$", "node", "->", "reference", ")", ";", "$", "parent", "->", "addChild", "(", "$", "heading", ")", ";", "// set as last indexed heading", "$", "this", "->", "last_heading", "=", "$", "heading", ";", "// add as new entry pointer", "array_splice", "(", "$", "this", "->", "entry_pointers", ",", "$", "parent_depth", "+", "1", ",", "count", "(", "$", "this", "->", "entry_pointers", ")", ",", "[", "$", "heading", "]", ")", ";", "}", "}", "parent", "::", "visitSection", "(", "$", "root", ",", "$", "node", ")", ";", "}" ]
Visitor for the section heading used to populate the TableOfContents. This method interprets the heading and its containing text and adds new entries to the TableOfContents object in the RestructuredText document. @see getDocument() for the document containing the TableOfContents. @see phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents for the Table of Contents class.
[ "Visitor", "for", "the", "section", "heading", "used", "to", "populate", "the", "TableOfContents", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Discover.php#L75-L104
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Discover.php
Discover.addFileToLastHeading
public function addFileToLastHeading(TableOfContents\File $file) { $this->last_heading->addChild($file); $file->setParent($this->last_heading); }
php
public function addFileToLastHeading(TableOfContents\File $file) { $this->last_heading->addChild($file); $file->setParent($this->last_heading); }
[ "public", "function", "addFileToLastHeading", "(", "TableOfContents", "\\", "File", "$", "file", ")", "{", "$", "this", "->", "last_heading", "->", "addChild", "(", "$", "file", ")", ";", "$", "file", "->", "setParent", "(", "$", "this", "->", "last_heading", ")", ";", "}" ]
Adds a TableOfContents File object to the last heading that was discovered. This may be used by roles or directives to insert an include file into the TableOfContents and thus all its headings. This method is explicitly bound to File objects and not other BaseEntry descendents because inline elements such as headings should also modify the internal pointers for this visitor.
[ "Adds", "a", "TableOfContents", "File", "object", "to", "the", "last", "heading", "that", "was", "discovered", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Discover.php#L115-L119
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/MethodTag.php
MethodTag.process
public function process(\DOMDocument $xml) { $xpath = new \DOMXPath($xml); $nodes = $xpath->query( '/project/file/class/docblock/tag[@name="method"]' ); /** @var \DOMElement $node */ foreach ($nodes as $node) { $class = $node->parentNode->parentNode; $method = new \DOMElement('method'); $class->appendChild($method); // set basic information $method->setAttribute('final', 'false'); $method->setAttribute('static', 'false'); $method->setAttribute('visibility', 'public'); $method->setAttribute('line', $node->getAttribute('line')); $method->appendChild( new \DOMElement('name', $node->getAttribute('method_name')) ); // fill docblock $docblock = new \DOMElement('docblock'); $method->appendChild($docblock); $docblock->appendChild( new \DOMElement('description', $node->getAttribute('description')) ); $docblock->appendChild(new \DOMElement('long-description')); // for each argument; create an @param tag and an argument element /** @var \DOMElement $argument */ foreach ($node->getElementsByTagName('argument') as $argument) { $param_tag = new \DOMElement('tag'); $docblock->appendChild($param_tag); $param_tag->setAttribute('name', 'param'); $param_tag->setAttribute( 'type', $argument->getElementsByTagName('type')->item(0)->nodeValue ); $param_tag->setAttribute( 'variable', $argument->getElementsByTagName('name')->item(0)->nodeValue ); $param_tag->setAttribute('line', $node->getAttribute('line')); $types = explode( '|', $argument->getElementsByTagName('type')->item(0)->nodeValue ); foreach ($types as $type) { $type_element = new \DOMElement('type', $type); $param_tag->appendChild($type_element); } $argument_element = $argument->cloneNode(true); $method->appendChild($argument_element); } // add a tag 'magic' $magic_tag = new \DOMElement('tag'); $docblock->appendChild($magic_tag); $magic_tag->setAttribute('name', 'magic'); $magic_tag->setAttribute('line', $node->getAttribute('line')); // add a @return tag $return_tag = new \DOMElement('tag'); $docblock->appendChild($return_tag); $return_tag->setAttribute('name', 'return'); $return_tag->setAttribute('line', $node->getAttribute('line')); $return_tag->setAttribute('type', $node->getAttribute('type')); // add type sub elements to the param foreach (explode('|', $node->getAttribute('type')) as $type) { $type_element = new \DOMElement('type', $type); $return_tag->appendChild($type_element); } // remove the tag, it is unneeded $node->parentNode->removeChild($node); $docblock->appendChild($node); } return $xml; }
php
public function process(\DOMDocument $xml) { $xpath = new \DOMXPath($xml); $nodes = $xpath->query( '/project/file/class/docblock/tag[@name="method"]' ); foreach ($nodes as $node) { $class = $node->parentNode->parentNode; $method = new \DOMElement('method'); $class->appendChild($method); $method->setAttribute('final', 'false'); $method->setAttribute('static', 'false'); $method->setAttribute('visibility', 'public'); $method->setAttribute('line', $node->getAttribute('line')); $method->appendChild( new \DOMElement('name', $node->getAttribute('method_name')) ); $docblock = new \DOMElement('docblock'); $method->appendChild($docblock); $docblock->appendChild( new \DOMElement('description', $node->getAttribute('description')) ); $docblock->appendChild(new \DOMElement('long-description')); foreach ($node->getElementsByTagName('argument') as $argument) { $param_tag = new \DOMElement('tag'); $docblock->appendChild($param_tag); $param_tag->setAttribute('name', 'param'); $param_tag->setAttribute( 'type', $argument->getElementsByTagName('type')->item(0)->nodeValue ); $param_tag->setAttribute( 'variable', $argument->getElementsByTagName('name')->item(0)->nodeValue ); $param_tag->setAttribute('line', $node->getAttribute('line')); $types = explode( '|', $argument->getElementsByTagName('type')->item(0)->nodeValue ); foreach ($types as $type) { $type_element = new \DOMElement('type', $type); $param_tag->appendChild($type_element); } $argument_element = $argument->cloneNode(true); $method->appendChild($argument_element); } $magic_tag = new \DOMElement('tag'); $docblock->appendChild($magic_tag); $magic_tag->setAttribute('name', 'magic'); $magic_tag->setAttribute('line', $node->getAttribute('line')); $return_tag = new \DOMElement('tag'); $docblock->appendChild($return_tag); $return_tag->setAttribute('name', 'return'); $return_tag->setAttribute('line', $node->getAttribute('line')); $return_tag->setAttribute('type', $node->getAttribute('type')); foreach (explode('|', $node->getAttribute('type')) as $type) { $type_element = new \DOMElement('type', $type); $return_tag->appendChild($type_element); } $node->parentNode->removeChild($node); $docblock->appendChild($node); } return $xml; }
[ "public", "function", "process", "(", "\\", "DOMDocument", "$", "xml", ")", "{", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "xml", ")", ";", "$", "nodes", "=", "$", "xpath", "->", "query", "(", "'/project/file/class/docblock/tag[@name=\"method\"]'", ")", ";", "/** @var \\DOMElement $node */", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "class", "=", "$", "node", "->", "parentNode", "->", "parentNode", ";", "$", "method", "=", "new", "\\", "DOMElement", "(", "'method'", ")", ";", "$", "class", "->", "appendChild", "(", "$", "method", ")", ";", "// set basic information", "$", "method", "->", "setAttribute", "(", "'final'", ",", "'false'", ")", ";", "$", "method", "->", "setAttribute", "(", "'static'", ",", "'false'", ")", ";", "$", "method", "->", "setAttribute", "(", "'visibility'", ",", "'public'", ")", ";", "$", "method", "->", "setAttribute", "(", "'line'", ",", "$", "node", "->", "getAttribute", "(", "'line'", ")", ")", ";", "$", "method", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'name'", ",", "$", "node", "->", "getAttribute", "(", "'method_name'", ")", ")", ")", ";", "// fill docblock", "$", "docblock", "=", "new", "\\", "DOMElement", "(", "'docblock'", ")", ";", "$", "method", "->", "appendChild", "(", "$", "docblock", ")", ";", "$", "docblock", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'description'", ",", "$", "node", "->", "getAttribute", "(", "'description'", ")", ")", ")", ";", "$", "docblock", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'long-description'", ")", ")", ";", "// for each argument; create an @param tag and an argument element", "/** @var \\DOMElement $argument */", "foreach", "(", "$", "node", "->", "getElementsByTagName", "(", "'argument'", ")", "as", "$", "argument", ")", "{", "$", "param_tag", "=", "new", "\\", "DOMElement", "(", "'tag'", ")", ";", "$", "docblock", "->", "appendChild", "(", "$", "param_tag", ")", ";", "$", "param_tag", "->", "setAttribute", "(", "'name'", ",", "'param'", ")", ";", "$", "param_tag", "->", "setAttribute", "(", "'type'", ",", "$", "argument", "->", "getElementsByTagName", "(", "'type'", ")", "->", "item", "(", "0", ")", "->", "nodeValue", ")", ";", "$", "param_tag", "->", "setAttribute", "(", "'variable'", ",", "$", "argument", "->", "getElementsByTagName", "(", "'name'", ")", "->", "item", "(", "0", ")", "->", "nodeValue", ")", ";", "$", "param_tag", "->", "setAttribute", "(", "'line'", ",", "$", "node", "->", "getAttribute", "(", "'line'", ")", ")", ";", "$", "types", "=", "explode", "(", "'|'", ",", "$", "argument", "->", "getElementsByTagName", "(", "'type'", ")", "->", "item", "(", "0", ")", "->", "nodeValue", ")", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "type_element", "=", "new", "\\", "DOMElement", "(", "'type'", ",", "$", "type", ")", ";", "$", "param_tag", "->", "appendChild", "(", "$", "type_element", ")", ";", "}", "$", "argument_element", "=", "$", "argument", "->", "cloneNode", "(", "true", ")", ";", "$", "method", "->", "appendChild", "(", "$", "argument_element", ")", ";", "}", "// add a tag 'magic'", "$", "magic_tag", "=", "new", "\\", "DOMElement", "(", "'tag'", ")", ";", "$", "docblock", "->", "appendChild", "(", "$", "magic_tag", ")", ";", "$", "magic_tag", "->", "setAttribute", "(", "'name'", ",", "'magic'", ")", ";", "$", "magic_tag", "->", "setAttribute", "(", "'line'", ",", "$", "node", "->", "getAttribute", "(", "'line'", ")", ")", ";", "// add a @return tag", "$", "return_tag", "=", "new", "\\", "DOMElement", "(", "'tag'", ")", ";", "$", "docblock", "->", "appendChild", "(", "$", "return_tag", ")", ";", "$", "return_tag", "->", "setAttribute", "(", "'name'", ",", "'return'", ")", ";", "$", "return_tag", "->", "setAttribute", "(", "'line'", ",", "$", "node", "->", "getAttribute", "(", "'line'", ")", ")", ";", "$", "return_tag", "->", "setAttribute", "(", "'type'", ",", "$", "node", "->", "getAttribute", "(", "'type'", ")", ")", ";", "// add type sub elements to the param", "foreach", "(", "explode", "(", "'|'", ",", "$", "node", "->", "getAttribute", "(", "'type'", ")", ")", "as", "$", "type", ")", "{", "$", "type_element", "=", "new", "\\", "DOMElement", "(", "'type'", ",", "$", "type", ")", ";", "$", "return_tag", "->", "appendChild", "(", "$", "type_element", ")", ";", "}", "// remove the tag, it is unneeded", "$", "node", "->", "parentNode", "->", "removeChild", "(", "$", "node", ")", ";", "$", "docblock", "->", "appendChild", "(", "$", "node", ")", ";", "}", "return", "$", "xml", ";", "}" ]
Find all return tags that contain 'self' or '$this' and replace those terms for the name of the current class' type. @param \DOMDocument $xml Structure source to apply behaviour onto. @return \DOMDocument
[ "Find", "all", "return", "tags", "that", "contain", "self", "or", "$this", "and", "replace", "those", "terms", "for", "the", "name", "of", "the", "current", "class", "type", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/MethodTag.php#L31-L117
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/VarAssembler.php
VarAssembler.create
public function create($data) { $descriptor = new VarDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setVariableName($data->getVariableName()); $descriptor->setType(AssemblerAbstract::deduplicateTypes($data->getType())); return $descriptor; }
php
public function create($data) { $descriptor = new VarDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setVariableName($data->getVariableName()); $descriptor->setType(AssemblerAbstract::deduplicateTypes($data->getType())); return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "descriptor", "=", "new", "VarDescriptor", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setDescription", "(", "$", "data", "->", "getDescription", "(", ")", ")", ";", "$", "descriptor", "->", "setVariableName", "(", "$", "data", "->", "getVariableName", "(", ")", ")", ";", "$", "descriptor", "->", "setType", "(", "AssemblerAbstract", "::", "deduplicateTypes", "(", "$", "data", "->", "getType", "(", ")", ")", ")", ";", "return", "$", "descriptor", ";", "}" ]
Creates a new Descriptor from the given Reflector. @param Var_ $data @return VarDescriptor
[ "Creates", "a", "new", "Descriptor", "from", "the", "given", "Reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/VarAssembler.php#L37-L46
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php
TraitAssembler.create
public function create($data) { $traitDescriptor = new TraitDescriptor(); $traitDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $traitDescriptor->setName($data->getName()); $traitDescriptor->setLine($data->getLocation()->getLineNumber()); $traitDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: ''); // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself $traitDescriptor->setNamespace( substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1) ); $this->assembleDocBlock($data->getDocBlock(), $traitDescriptor); $this->addProperties($data->getProperties(), $traitDescriptor); $this->addMethods($data->getMethods(), $traitDescriptor); return $traitDescriptor; }
php
public function create($data) { $traitDescriptor = new TraitDescriptor(); $traitDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $traitDescriptor->setName($data->getName()); $traitDescriptor->setLine($data->getLocation()->getLineNumber()); $traitDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: ''); $traitDescriptor->setNamespace( substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1) ); $this->assembleDocBlock($data->getDocBlock(), $traitDescriptor); $this->addProperties($data->getProperties(), $traitDescriptor); $this->addMethods($data->getMethods(), $traitDescriptor); return $traitDescriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "traitDescriptor", "=", "new", "TraitDescriptor", "(", ")", ";", "$", "traitDescriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "data", "->", "getFqsen", "(", ")", ")", ";", "$", "traitDescriptor", "->", "setName", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "traitDescriptor", "->", "setLine", "(", "$", "data", "->", "getLocation", "(", ")", "->", "getLineNumber", "(", ")", ")", ";", "$", "traitDescriptor", "->", "setPackage", "(", "$", "this", "->", "extractPackageFromDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ")", "?", ":", "''", ")", ";", "// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself", "$", "traitDescriptor", "->", "setNamespace", "(", "substr", "(", "(", "string", ")", "$", "data", "->", "getFqsen", "(", ")", ",", "0", ",", "-", "strlen", "(", "$", "data", "->", "getName", "(", ")", ")", "-", "1", ")", ")", ";", "$", "this", "->", "assembleDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ",", "$", "traitDescriptor", ")", ";", "$", "this", "->", "addProperties", "(", "$", "data", "->", "getProperties", "(", ")", ",", "$", "traitDescriptor", ")", ";", "$", "this", "->", "addMethods", "(", "$", "data", "->", "getMethods", "(", ")", ",", "$", "traitDescriptor", ")", ";", "return", "$", "traitDescriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param Trait_ $data @return TraitDescriptor
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php#L37-L57
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php
TraitAssembler.addProperties
protected function addProperties(array $properties, TraitDescriptor $traitDescriptor): void { foreach ($properties as $property) { $propertyDescriptor = $this->getBuilder()->buildDescriptor($property); if ($propertyDescriptor instanceof PropertyDescriptor) { $propertyDescriptor->setParent($traitDescriptor); $traitDescriptor->getProperties()->set($propertyDescriptor->getName(), $propertyDescriptor); } } }
php
protected function addProperties(array $properties, TraitDescriptor $traitDescriptor): void { foreach ($properties as $property) { $propertyDescriptor = $this->getBuilder()->buildDescriptor($property); if ($propertyDescriptor instanceof PropertyDescriptor) { $propertyDescriptor->setParent($traitDescriptor); $traitDescriptor->getProperties()->set($propertyDescriptor->getName(), $propertyDescriptor); } } }
[ "protected", "function", "addProperties", "(", "array", "$", "properties", ",", "TraitDescriptor", "$", "traitDescriptor", ")", ":", "void", "{", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "propertyDescriptor", "=", "$", "this", "->", "getBuilder", "(", ")", "->", "buildDescriptor", "(", "$", "property", ")", ";", "if", "(", "$", "propertyDescriptor", "instanceof", "PropertyDescriptor", ")", "{", "$", "propertyDescriptor", "->", "setParent", "(", "$", "traitDescriptor", ")", ";", "$", "traitDescriptor", "->", "getProperties", "(", ")", "->", "set", "(", "$", "propertyDescriptor", "->", "getName", "(", ")", ",", "$", "propertyDescriptor", ")", ";", "}", "}", "}" ]
Registers the child properties with the generated Trait Descriptor. @param Property[] $properties
[ "Registers", "the", "child", "properties", "with", "the", "generated", "Trait", "Descriptor", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php#L64-L73
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/DeprecatedAssembler.php
DeprecatedAssembler.create
public function create($data) { $descriptor = new DeprecatedDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setVersion($data->getVersion()); return $descriptor; }
php
public function create($data) { $descriptor = new DeprecatedDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setVersion($data->getVersion()); return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "descriptor", "=", "new", "DeprecatedDescriptor", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setDescription", "(", "$", "data", "->", "getDescription", "(", ")", ")", ";", "$", "descriptor", "->", "setVersion", "(", "$", "data", "->", "getVersion", "(", ")", ")", ";", "return", "$", "descriptor", ";", "}" ]
Creates a new Descriptor from the given Reflector. @param Deprecated $data @return DeprecatedDescriptor
[ "Creates", "a", "new", "Descriptor", "from", "the", "given", "Reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/DeprecatedAssembler.php#L37-L44
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/ReturnAssembler.php
ReturnAssembler.create
public function create($data) { $descriptor = new ReturnDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setType(AssemblerAbstract::deduplicateTypes($data->getType())); return $descriptor; }
php
public function create($data) { $descriptor = new ReturnDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setType(AssemblerAbstract::deduplicateTypes($data->getType())); return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "descriptor", "=", "new", "ReturnDescriptor", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setDescription", "(", "$", "data", "->", "getDescription", "(", ")", ")", ";", "$", "descriptor", "->", "setType", "(", "AssemblerAbstract", "::", "deduplicateTypes", "(", "$", "data", "->", "getType", "(", ")", ")", ")", ";", "return", "$", "descriptor", ";", "}" ]
Creates a new Descriptor from the given Reflector. @param Return_ $data @return ReturnDescriptor
[ "Creates", "a", "new", "Descriptor", "from", "the", "given", "Reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/ReturnAssembler.php#L38-L45
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Template.php
Template.setVersion
public function setVersion(string $version) { if (!preg_match('/^\d+\.\d+\.\d+$/', $version)) { throw new \InvalidArgumentException( 'Version number is invalid; ' . $version . ' does not match ' . 'x.x.x (where x is a number)' ); } $this->version = $version; }
php
public function setVersion(string $version) { if (!preg_match('/^\d+\.\d+\.\d+$/', $version)) { throw new \InvalidArgumentException( 'Version number is invalid; ' . $version . ' does not match ' . 'x.x.x (where x is a number)' ); } $this->version = $version; }
[ "public", "function", "setVersion", "(", "string", "$", "version", ")", "{", "if", "(", "!", "preg_match", "(", "'/^\\d+\\.\\d+\\.\\d+$/'", ",", "$", "version", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Version number is invalid; '", ".", "$", "version", ".", "' does not match '", ".", "'x.x.x (where x is a number)'", ")", ";", "}", "$", "this", "->", "version", "=", "$", "version", ";", "}" ]
Sets the version number for this template. @param string $version Semantic version number in this format: 1.0.0 @throws \InvalidArgumentException if the version number is invalid
[ "Sets", "the", "version", "number", "for", "this", "template", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template.php#L136-L146
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Template.php
Template.offsetSet
public function offsetSet($offset, $value) { if (!$value instanceof Transformation) { throw new \InvalidArgumentException( '\phpDocumentor\Transformer\Template may only contain items of ' . 'type \phpDocumentor\Transformer\Transformation' ); } $this->transformations[$offset] = $value; }
php
public function offsetSet($offset, $value) { if (!$value instanceof Transformation) { throw new \InvalidArgumentException( '\phpDocumentor\Transformer\Template may only contain items of ' . 'type \phpDocumentor\Transformer\Transformation' ); } $this->transformations[$offset] = $value; }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "Transformation", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\\phpDocumentor\\Transformer\\Template may only contain items of '", ".", "'type \\phpDocumentor\\Transformer\\Transformation'", ")", ";", "}", "$", "this", "->", "transformations", "[", "$", "offset", "]", "=", "$", "value", ";", "}" ]
Sets a transformation at the given offset. @param integer|string $offset The offset to place the value at. @param Transformation $value The transformation to add to this template. @throws \InvalidArgumentException if an invalid item was received
[ "Sets", "a", "transformation", "at", "the", "given", "offset", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template.php#L183-L193
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Template.php
Template.propagateParameters
public function propagateParameters() { foreach ($this->transformations as $transformation) { $transformation->setParameters(array_merge($transformation->getParameters(), $this->getParameters())); } }
php
public function propagateParameters() { foreach ($this->transformations as $transformation) { $transformation->setParameters(array_merge($transformation->getParameters(), $this->getParameters())); } }
[ "public", "function", "propagateParameters", "(", ")", "{", "foreach", "(", "$", "this", "->", "transformations", "as", "$", "transformation", ")", "{", "$", "transformation", "->", "setParameters", "(", "array_merge", "(", "$", "transformation", "->", "getParameters", "(", ")", ",", "$", "this", "->", "getParameters", "(", ")", ")", ")", ";", "}", "}" ]
Pushes the parameters of this template into the transformations.
[ "Pushes", "the", "parameters", "of", "this", "template", "into", "the", "transformations", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template.php#L269-L274
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/Factory.php
Factory.get
public function get(string $input_format, string $output_format): ConverterInterface { $definition = $this->definition_factory->get($input_format, $output_format); foreach ($this->converters as $class => $formats) { if ([$input_format, $output_format] === $formats) { $assets = new Metadata\Assets(); $assets->setLogger($this->logger); $toc = new Metadata\TableOfContents(); $glossary = new Metadata\Glossary(); /** @var ConverterInterface $converter */ $converter = new $class($definition, $assets, $toc, $glossary); $converter->setLogger($this->logger); return $converter; } } throw new ConverterNotFoundException( 'No converter could be found to convert from ' . $input_format . ' to ' . $output_format ); }
php
public function get(string $input_format, string $output_format): ConverterInterface { $definition = $this->definition_factory->get($input_format, $output_format); foreach ($this->converters as $class => $formats) { if ([$input_format, $output_format] === $formats) { $assets = new Metadata\Assets(); $assets->setLogger($this->logger); $toc = new Metadata\TableOfContents(); $glossary = new Metadata\Glossary(); $converter = new $class($definition, $assets, $toc, $glossary); $converter->setLogger($this->logger); return $converter; } } throw new ConverterNotFoundException( 'No converter could be found to convert from ' . $input_format . ' to ' . $output_format ); }
[ "public", "function", "get", "(", "string", "$", "input_format", ",", "string", "$", "output_format", ")", ":", "ConverterInterface", "{", "$", "definition", "=", "$", "this", "->", "definition_factory", "->", "get", "(", "$", "input_format", ",", "$", "output_format", ")", ";", "foreach", "(", "$", "this", "->", "converters", "as", "$", "class", "=>", "$", "formats", ")", "{", "if", "(", "[", "$", "input_format", ",", "$", "output_format", "]", "===", "$", "formats", ")", "{", "$", "assets", "=", "new", "Metadata", "\\", "Assets", "(", ")", ";", "$", "assets", "->", "setLogger", "(", "$", "this", "->", "logger", ")", ";", "$", "toc", "=", "new", "Metadata", "\\", "TableOfContents", "(", ")", ";", "$", "glossary", "=", "new", "Metadata", "\\", "Glossary", "(", ")", ";", "/** @var ConverterInterface $converter */", "$", "converter", "=", "new", "$", "class", "(", "$", "definition", ",", "$", "assets", ",", "$", "toc", ",", "$", "glossary", ")", ";", "$", "converter", "->", "setLogger", "(", "$", "this", "->", "logger", ")", ";", "return", "$", "converter", ";", "}", "}", "throw", "new", "ConverterNotFoundException", "(", "'No converter could be found to convert from '", ".", "$", "input_format", ".", "' to '", ".", "$", "output_format", ")", ";", "}" ]
Retrieves a new instance of the converter necessary to convert the give input format to the given output format. @throws ConverterNotFoundException
[ "Retrieves", "a", "new", "instance", "of", "the", "converter", "necessary", "to", "convert", "the", "give", "input", "format", "to", "the", "given", "output", "format", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Factory.php#L71-L94
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/Factory.php
Factory.getSupportedInputFormats
public function getSupportedInputFormats(string $given_output_format): array { $result = []; foreach ($this->converters as $formats) { list($input_format, $output_format) = $formats; if ($given_output_format === $output_format) { $result[] = $input_format; } } return $result; }
php
public function getSupportedInputFormats(string $given_output_format): array { $result = []; foreach ($this->converters as $formats) { list($input_format, $output_format) = $formats; if ($given_output_format === $output_format) { $result[] = $input_format; } } return $result; }
[ "public", "function", "getSupportedInputFormats", "(", "string", "$", "given_output_format", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "converters", "as", "$", "formats", ")", "{", "list", "(", "$", "input_format", ",", "$", "output_format", ")", "=", "$", "formats", ";", "if", "(", "$", "given_output_format", "===", "$", "output_format", ")", "{", "$", "result", "[", "]", "=", "$", "input_format", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns a list of supported input formats for the given output format. @param string $given_output_format A format definition per the constants in the Format class. @return string[] An array of format definitions per the constantst in the Format class.
[ "Returns", "a", "list", "of", "supported", "input", "formats", "for", "the", "given", "output", "format", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Factory.php#L103-L114
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Transformation.php
Transformation.getSourceAsPath
public function getSourceAsPath(): string { // externally loaded templates set this parameter so that template // resources may be placed in the same folder as the template. if ($this->getParameter('template_path') !== null) { $path = rtrim($this->getParameter('template_path')->getValue(), '/\\'); if (file_exists($path . DIRECTORY_SEPARATOR . $this->source)) { return $path . DIRECTORY_SEPARATOR . $this->source; } } // counter a BC break that we introduced in 2.0 stable; we removed the notion of global assets // to be able to provide composer integration // TODO: remove in version 3.0 if (strpos($this->source, 'templates/') !== 0) { $this->source = 'templates/abstract/' . $this->source; trigger_error( 'Using shared assets in a template is deprecated and will be removed in version 3.0', E_USER_DEPRECATED ); } // check whether the file exists in the phpDocumentor project directory. if (file_exists(__DIR__ . '/../../../' . $this->source)) { return __DIR__ . '/../../../' . $this->source; } // in case of a composer installation if (file_exists(__DIR__ . '/../../../../templates')) { return __DIR__ . '/../../../../' . $this->source; } // TODO: replace this as it breaks the component stuff // we should ditch the idea of a global set of files to fetch and have // a variable / injection for the global templates folder and inject // that here. $file = __DIR__ . '/../../../data/' . $this->source; if (!file_exists($file)) { throw new Exception('The source path does not exist: ' . $file); } return $file; }
php
public function getSourceAsPath(): string { if ($this->getParameter('template_path') !== null) { $path = rtrim($this->getParameter('template_path')->getValue(), '/\\'); if (file_exists($path . DIRECTORY_SEPARATOR . $this->source)) { return $path . DIRECTORY_SEPARATOR . $this->source; } } if (strpos($this->source, 'templates/') !== 0) { $this->source = 'templates/abstract/' . $this->source; trigger_error( 'Using shared assets in a template is deprecated and will be removed in version 3.0', E_USER_DEPRECATED ); } if (file_exists(__DIR__ . '/../../../' . $this->source)) { return __DIR__ . '/../../../' . $this->source; } if (file_exists(__DIR__ . '/../../../../templates')) { return __DIR__ . '/../../../../' . $this->source; } $file = __DIR__ . '/../../../data/' . $this->source; if (!file_exists($file)) { throw new Exception('The source path does not exist: ' . $file); } return $file; }
[ "public", "function", "getSourceAsPath", "(", ")", ":", "string", "{", "// externally loaded templates set this parameter so that template", "// resources may be placed in the same folder as the template.", "if", "(", "$", "this", "->", "getParameter", "(", "'template_path'", ")", "!==", "null", ")", "{", "$", "path", "=", "rtrim", "(", "$", "this", "->", "getParameter", "(", "'template_path'", ")", "->", "getValue", "(", ")", ",", "'/\\\\'", ")", ";", "if", "(", "file_exists", "(", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "source", ")", ")", "{", "return", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "source", ";", "}", "}", "// counter a BC break that we introduced in 2.0 stable; we removed the notion of global assets", "// to be able to provide composer integration", "// TODO: remove in version 3.0", "if", "(", "strpos", "(", "$", "this", "->", "source", ",", "'templates/'", ")", "!==", "0", ")", "{", "$", "this", "->", "source", "=", "'templates/abstract/'", ".", "$", "this", "->", "source", ";", "trigger_error", "(", "'Using shared assets in a template is deprecated and will be removed in version 3.0'", ",", "E_USER_DEPRECATED", ")", ";", "}", "// check whether the file exists in the phpDocumentor project directory.", "if", "(", "file_exists", "(", "__DIR__", ".", "'/../../../'", ".", "$", "this", "->", "source", ")", ")", "{", "return", "__DIR__", ".", "'/../../../'", ".", "$", "this", "->", "source", ";", "}", "// in case of a composer installation", "if", "(", "file_exists", "(", "__DIR__", ".", "'/../../../../templates'", ")", ")", "{", "return", "__DIR__", ".", "'/../../../../'", ".", "$", "this", "->", "source", ";", "}", "// TODO: replace this as it breaks the component stuff", "// we should ditch the idea of a global set of files to fetch and have", "// a variable / injection for the global templates folder and inject", "// that here.", "$", "file", "=", "__DIR__", ".", "'/../../../data/'", ".", "$", "this", "->", "source", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "throw", "new", "Exception", "(", "'The source path does not exist: '", ".", "$", "file", ")", ";", "}", "return", "$", "file", ";", "}" ]
Returns the source as a path instead of a regular value. This method applies the following rules to the value of $source: 1. if the template_path parameter is set and that combined with the source gives an existing file; return that. 2. if the value exists as a file (either relative to the current working directory or absolute), do a realpath and return it. 3. Otherwise prepend it with the phpDocumentor data folder, if that does not exist: throw an exception @throws Exception if no valid file could be found. @return string
[ "Returns", "the", "source", "as", "a", "path", "instead", "of", "a", "regular", "value", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Transformation.php#L161-L204
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Transformation.php
Transformation.getParameter
public function getParameter($name): ?Parameter { /** @var Parameter $parameter */ foreach ($this->parameters as $parameter) { if ($parameter->getKey() === $name) { return $parameter; } } return null; }
php
public function getParameter($name): ?Parameter { foreach ($this->parameters as $parameter) { if ($parameter->getKey() === $name) { return $parameter; } } return null; }
[ "public", "function", "getParameter", "(", "$", "name", ")", ":", "?", "Parameter", "{", "/** @var Parameter $parameter */", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "parameter", ")", "{", "if", "(", "$", "parameter", "->", "getKey", "(", ")", "===", "$", "name", ")", "{", "return", "$", "parameter", ";", "}", "}", "return", "null", ";", "}" ]
Returns a specific parameter, or $default if none exists. @param string $name Name of the parameter to return. @return Parameter|null
[ "Returns", "a", "specific", "parameter", "or", "$default", "if", "none", "exists", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Transformation.php#L258-L268
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ArgumentDescriptor.php
ArgumentDescriptor.getType
public function getType(): ?Type { if ($this->type === null && $this->getInheritedElement() !== null) { $this->setType($this->getInheritedElement()->getType()); } return $this->type; }
php
public function getType(): ?Type { if ($this->type === null && $this->getInheritedElement() !== null) { $this->setType($this->getInheritedElement()->getType()); } return $this->type; }
[ "public", "function", "getType", "(", ")", ":", "?", "Type", "{", "if", "(", "$", "this", "->", "type", "===", "null", "&&", "$", "this", "->", "getInheritedElement", "(", ")", "!==", "null", ")", "{", "$", "this", "->", "setType", "(", "$", "this", "->", "getInheritedElement", "(", ")", "->", "getType", "(", ")", ")", ";", "}", "return", "$", "this", "->", "type", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ArgumentDescriptor.php#L59-L66
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php
ProjectDescriptorMapper.populate
public function populate(ProjectDescriptor $projectDescriptor): void { $this->loadCacheItemAsSettings($projectDescriptor, self::KEY_SETTINGS); foreach ($this->getCache() as $key) { $this->loadCacheItemAsFile($projectDescriptor, $key); } }
php
public function populate(ProjectDescriptor $projectDescriptor): void { $this->loadCacheItemAsSettings($projectDescriptor, self::KEY_SETTINGS); foreach ($this->getCache() as $key) { $this->loadCacheItemAsFile($projectDescriptor, $key); } }
[ "public", "function", "populate", "(", "ProjectDescriptor", "$", "projectDescriptor", ")", ":", "void", "{", "$", "this", "->", "loadCacheItemAsSettings", "(", "$", "projectDescriptor", ",", "self", "::", "KEY_SETTINGS", ")", ";", "foreach", "(", "$", "this", "->", "getCache", "(", ")", "as", "$", "key", ")", "{", "$", "this", "->", "loadCacheItemAsFile", "(", "$", "projectDescriptor", ",", "$", "key", ")", ";", "}", "}" ]
Returns the Project Descriptor from the cache.
[ "Returns", "the", "Project", "Descriptor", "from", "the", "cache", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php#L63-L70
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php
ProjectDescriptorMapper.save
public function save(ProjectDescriptor $projectDescriptor): void { $keys = []; $cache = $this->getCache(); foreach ($cache as $key) { $keys[] = $key; } // store the settings for this Project Descriptor $cache->setItem(self::KEY_SETTINGS, $projectDescriptor->getSettings()); // store cache items $usedKeys = [self::KEY_SETTINGS]; foreach ($projectDescriptor->getFiles() as $file) { $key = self::FILE_PREFIX . md5($file->getPath()); $usedKeys[] = $key; $cache->setItem($key, $file); } // remove any keys that are no longer used. $invalidatedKeys = array_diff($keys, $usedKeys); if ($invalidatedKeys) { $cache->removeItems($invalidatedKeys); } if ($cache instanceof OptimizableInterface) { $cache->optimize(); } }
php
public function save(ProjectDescriptor $projectDescriptor): void { $keys = []; $cache = $this->getCache(); foreach ($cache as $key) { $keys[] = $key; } $cache->setItem(self::KEY_SETTINGS, $projectDescriptor->getSettings()); $usedKeys = [self::KEY_SETTINGS]; foreach ($projectDescriptor->getFiles() as $file) { $key = self::FILE_PREFIX . md5($file->getPath()); $usedKeys[] = $key; $cache->setItem($key, $file); } $invalidatedKeys = array_diff($keys, $usedKeys); if ($invalidatedKeys) { $cache->removeItems($invalidatedKeys); } if ($cache instanceof OptimizableInterface) { $cache->optimize(); } }
[ "public", "function", "save", "(", "ProjectDescriptor", "$", "projectDescriptor", ")", ":", "void", "{", "$", "keys", "=", "[", "]", ";", "$", "cache", "=", "$", "this", "->", "getCache", "(", ")", ";", "foreach", "(", "$", "cache", "as", "$", "key", ")", "{", "$", "keys", "[", "]", "=", "$", "key", ";", "}", "// store the settings for this Project Descriptor", "$", "cache", "->", "setItem", "(", "self", "::", "KEY_SETTINGS", ",", "$", "projectDescriptor", "->", "getSettings", "(", ")", ")", ";", "// store cache items", "$", "usedKeys", "=", "[", "self", "::", "KEY_SETTINGS", "]", ";", "foreach", "(", "$", "projectDescriptor", "->", "getFiles", "(", ")", "as", "$", "file", ")", "{", "$", "key", "=", "self", "::", "FILE_PREFIX", ".", "md5", "(", "$", "file", "->", "getPath", "(", ")", ")", ";", "$", "usedKeys", "[", "]", "=", "$", "key", ";", "$", "cache", "->", "setItem", "(", "$", "key", ",", "$", "file", ")", ";", "}", "// remove any keys that are no longer used.", "$", "invalidatedKeys", "=", "array_diff", "(", "$", "keys", ",", "$", "usedKeys", ")", ";", "if", "(", "$", "invalidatedKeys", ")", "{", "$", "cache", "->", "removeItems", "(", "$", "invalidatedKeys", ")", ";", "}", "if", "(", "$", "cache", "instanceof", "OptimizableInterface", ")", "{", "$", "cache", "->", "optimize", "(", ")", ";", "}", "}" ]
Stores a Project Descriptor in the Cache.
[ "Stores", "a", "Project", "Descriptor", "in", "the", "Cache", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php#L75-L104
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Figure.php
Figure.toDocbook
public function toDocbook(\DOMDocument $document, \DOMElement $root) { $this->storeAsset(); parent::toDocbook($document, $root); }
php
public function toDocbook(\DOMDocument $document, \DOMElement $root) { $this->storeAsset(); parent::toDocbook($document, $root); }
[ "public", "function", "toDocbook", "(", "\\", "DOMDocument", "$", "document", ",", "\\", "DOMElement", "$", "root", ")", "{", "$", "this", "->", "storeAsset", "(", ")", ";", "parent", "::", "toDocbook", "(", "$", "document", ",", "$", "root", ")", ";", "}" ]
Converts the Image directive to aDocBook image tag. This method takes an image directive and converts it into its DocBook representation and stores a reference in the Asset manager of the Converter. @see ConverterInterface::getAssets() for the asset manager
[ "Converts", "the", "Image", "directive", "to", "aDocBook", "image", "tag", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Figure.php#L42-L46
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Figure.php
Figure.toXhtml
public function toXhtml(\DOMDocument $document, \DOMElement $root) { $this->storeAsset(); parent::toXhtml($document, $root); }
php
public function toXhtml(\DOMDocument $document, \DOMElement $root) { $this->storeAsset(); parent::toXhtml($document, $root); }
[ "public", "function", "toXhtml", "(", "\\", "DOMDocument", "$", "document", ",", "\\", "DOMElement", "$", "root", ")", "{", "$", "this", "->", "storeAsset", "(", ")", ";", "parent", "::", "toXhtml", "(", "$", "document", ",", "$", "root", ")", ";", "}" ]
Converts the Image directive to an <img/> tag. This method takes an image directive and converts it into its HTML representation and stores a reference in the Asset manager of the Converter. @see ConverterInterface::getAssets() for the asset manager
[ "Converts", "the", "Image", "directive", "to", "an", "<img", "/", ">", "tag", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Figure.php#L56-L60
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Figure.php
Figure.storeAsset
protected function storeAsset() { if (!$this->visitor instanceof Discover) { return; } $assets = $this->getAssetManager(); $project_root = $assets->getProjectRoot(); $asset_path = trim($this->node->parameters); $file_path = $this->visitor->getDocument()->getFile()->getRealPath(); // get source path $source = ($asset_path[0] !== '/') ? dirname($file_path) . '/' . $asset_path : $project_root . $asset_path; // get destination path $destination = ($asset_path[0] !== '/') ? substr(dirname($file_path) . '/' . $asset_path, strlen($project_root)) : substr($asset_path, 1); // set asset $assets->set($source, $destination); }
php
protected function storeAsset() { if (!$this->visitor instanceof Discover) { return; } $assets = $this->getAssetManager(); $project_root = $assets->getProjectRoot(); $asset_path = trim($this->node->parameters); $file_path = $this->visitor->getDocument()->getFile()->getRealPath(); $source = ($asset_path[0] !== '/') ? dirname($file_path) . '/' . $asset_path : $project_root . $asset_path; $destination = ($asset_path[0] !== '/') ? substr(dirname($file_path) . '/' . $asset_path, strlen($project_root)) : substr($asset_path, 1); $assets->set($source, $destination); }
[ "protected", "function", "storeAsset", "(", ")", "{", "if", "(", "!", "$", "this", "->", "visitor", "instanceof", "Discover", ")", "{", "return", ";", "}", "$", "assets", "=", "$", "this", "->", "getAssetManager", "(", ")", ";", "$", "project_root", "=", "$", "assets", "->", "getProjectRoot", "(", ")", ";", "$", "asset_path", "=", "trim", "(", "$", "this", "->", "node", "->", "parameters", ")", ";", "$", "file_path", "=", "$", "this", "->", "visitor", "->", "getDocument", "(", ")", "->", "getFile", "(", ")", "->", "getRealPath", "(", ")", ";", "// get source path", "$", "source", "=", "(", "$", "asset_path", "[", "0", "]", "!==", "'/'", ")", "?", "dirname", "(", "$", "file_path", ")", ".", "'/'", ".", "$", "asset_path", ":", "$", "project_root", ".", "$", "asset_path", ";", "// get destination path", "$", "destination", "=", "(", "$", "asset_path", "[", "0", "]", "!==", "'/'", ")", "?", "substr", "(", "dirname", "(", "$", "file_path", ")", ".", "'/'", ".", "$", "asset_path", ",", "strlen", "(", "$", "project_root", ")", ")", ":", "substr", "(", "$", "asset_path", ",", "1", ")", ";", "// set asset", "$", "assets", "->", "set", "(", "$", "source", ",", "$", "destination", ")", ";", "}" ]
Stores the asset in the asset manager. This method takes an asset defined in the directive and stores that in the asset manager. The following rules apply: 1. The source of the asset is the relative path of the asset prefixed with a path based on the following rules: 1. If the asset starts with a slash then the path is calculated from the project's root or 2. if the asset does not start with a slash then the path is calculated from the file's directory. 2. the destination of the asset is the path relative to the project root. 1. When the asset starts with a slash then this equals that path without the leading slash. 2. If not, the destination must be calculated by subtracting the project root from the current file's path and prepending that to the asset path (resolving `../` patterns in the mean time).
[ "Stores", "the", "asset", "in", "the", "asset", "manager", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Figure.php#L81-L104
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/ResolveInlineMarkers.php
ResolveInlineMarkers.execute
public function execute(ProjectDescriptor $project): void { $markerTerms = $project->getSettings()->getMarkers(); foreach ($project->getFiles() as $file) { $marker_data = []; $matches = []; preg_match_all( '~//[\s]*(' . implode('|', $markerTerms) . ')\:?[\s]*(.*)~', $file->getSource(), $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE ); foreach ($matches as $match) { list($before) = str_split($file->getSource(), $match[1][1]); // fetches all the text before the match $line_number = strlen($before) - strlen(str_replace("\n", '', $before)) + 1; $marker_data[] = ['type' => trim($match[1][0], '@'), 'line' => $line_number, $match[2][0]]; } $file->setMarkers(new Collection($marker_data)); } }
php
public function execute(ProjectDescriptor $project): void { $markerTerms = $project->getSettings()->getMarkers(); foreach ($project->getFiles() as $file) { $marker_data = []; $matches = []; preg_match_all( '~ $file->getSource(), $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE ); foreach ($matches as $match) { list($before) = str_split($file->getSource(), $match[1][1]); $line_number = strlen($before) - strlen(str_replace("\n", '', $before)) + 1; $marker_data[] = ['type' => trim($match[1][0], '@'), 'line' => $line_number, $match[2][0]]; } $file->setMarkers(new Collection($marker_data)); } }
[ "public", "function", "execute", "(", "ProjectDescriptor", "$", "project", ")", ":", "void", "{", "$", "markerTerms", "=", "$", "project", "->", "getSettings", "(", ")", "->", "getMarkers", "(", ")", ";", "foreach", "(", "$", "project", "->", "getFiles", "(", ")", "as", "$", "file", ")", "{", "$", "marker_data", "=", "[", "]", ";", "$", "matches", "=", "[", "]", ";", "preg_match_all", "(", "'~//[\\s]*('", ".", "implode", "(", "'|'", ",", "$", "markerTerms", ")", ".", "')\\:?[\\s]*(.*)~'", ",", "$", "file", "->", "getSource", "(", ")", ",", "$", "matches", ",", "PREG_SET_ORDER", "|", "PREG_OFFSET_CAPTURE", ")", ";", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "list", "(", "$", "before", ")", "=", "str_split", "(", "$", "file", "->", "getSource", "(", ")", ",", "$", "match", "[", "1", "]", "[", "1", "]", ")", ";", "// fetches all the text before the match", "$", "line_number", "=", "strlen", "(", "$", "before", ")", "-", "strlen", "(", "str_replace", "(", "\"\\n\"", ",", "''", ",", "$", "before", ")", ")", "+", "1", ";", "$", "marker_data", "[", "]", "=", "[", "'type'", "=>", "trim", "(", "$", "match", "[", "1", "]", "[", "0", "]", ",", "'@'", ")", ",", "'line'", "=>", "$", "line_number", ",", "$", "match", "[", "2", "]", "[", "0", "]", "]", ";", "}", "$", "file", "->", "setMarkers", "(", "new", "Collection", "(", "$", "marker_data", ")", ")", ";", "}", "}" ]
Scans the files for markers and records them in the markers property of a file.
[ "Scans", "the", "files", "for", "markers", "and", "records", "them", "in", "the", "markers", "property", "of", "a", "file", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineMarkers.php#L34-L58
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/CodeBlock.php
CodeBlock.toXhtml
public function toXhtml(\DOMDocument $document, \DOMElement $root) { $content = ''; /** @var \ezcDocumentRstToken $token */ foreach ($this->node->tokens as $token) { $content .= $token->content; } $content = rtrim($content, "\n"); $pre = $document->createElement('pre'); $root->appendChild($pre); $code = $document->createElement('code', $content); $pre->appendChild($code); }
php
public function toXhtml(\DOMDocument $document, \DOMElement $root) { $content = ''; foreach ($this->node->tokens as $token) { $content .= $token->content; } $content = rtrim($content, "\n"); $pre = $document->createElement('pre'); $root->appendChild($pre); $code = $document->createElement('code', $content); $pre->appendChild($code); }
[ "public", "function", "toXhtml", "(", "\\", "DOMDocument", "$", "document", ",", "\\", "DOMElement", "$", "root", ")", "{", "$", "content", "=", "''", ";", "/** @var \\ezcDocumentRstToken $token */", "foreach", "(", "$", "this", "->", "node", "->", "tokens", "as", "$", "token", ")", "{", "$", "content", ".=", "$", "token", "->", "content", ";", "}", "$", "content", "=", "rtrim", "(", "$", "content", ",", "\"\\n\"", ")", ";", "$", "pre", "=", "$", "document", "->", "createElement", "(", "'pre'", ")", ";", "$", "root", "->", "appendChild", "(", "$", "pre", ")", ";", "$", "code", "=", "$", "document", "->", "createElement", "(", "'code'", ",", "$", "content", ")", ";", "$", "pre", "->", "appendChild", "(", "$", "code", ")", ";", "}" ]
Transform directive to HTML Create a XHTML structure at the directives position in the document. @todo use the TableofContents collection to extract a sublisting up to the given depth or 2 if none is provided
[ "Transform", "directive", "to", "HTML" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/CodeBlock.php#L45-L60
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Twig/ServiceProvider.php
ServiceProvider.register
public function register(Container $app): void { /** @var Collection $writerCollection */ $writerCollection = $app['transformer.writer.collection']; $twigWriter = new Writer\Twig($app[\Twig\Environment::class]); $writerCollection['twig'] = $twigWriter; }
php
public function register(Container $app): void { $writerCollection = $app['transformer.writer.collection']; $twigWriter = new Writer\Twig($app[\Twig\Environment::class]); $writerCollection['twig'] = $twigWriter; }
[ "public", "function", "register", "(", "Container", "$", "app", ")", ":", "void", "{", "/** @var Collection $writerCollection */", "$", "writerCollection", "=", "$", "app", "[", "'transformer.writer.collection'", "]", ";", "$", "twigWriter", "=", "new", "Writer", "\\", "Twig", "(", "$", "app", "[", "\\", "Twig", "\\", "Environment", "::", "class", "]", ")", ";", "$", "writerCollection", "[", "'twig'", "]", "=", "$", "twigWriter", ";", "}" ]
Registers services on the given app. @param Container $app An Application instance.
[ "Registers", "services", "on", "the", "given", "app", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/ServiceProvider.php#L34-L41
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/ArgumentConverter.php
ArgumentConverter.convert
public function convert(\DOMElement $parent, ArgumentDescriptor $argument) { $child = new \DOMElement('argument'); $parent->appendChild($child); $child->setAttribute('line', (string) $argument->getLine()); $child->setAttribute('by_reference', var_export($argument->isByReference(), true)); $child->appendChild(new \DOMElement('name', $argument->getName())); $child->appendChild(new \DOMElement('default')) ->appendChild(new \DOMText((string) $argument->getDefault())); $child->appendChild(new \DOMElement('type', (string) $argument->getType())); return $child; }
php
public function convert(\DOMElement $parent, ArgumentDescriptor $argument) { $child = new \DOMElement('argument'); $parent->appendChild($child); $child->setAttribute('line', (string) $argument->getLine()); $child->setAttribute('by_reference', var_export($argument->isByReference(), true)); $child->appendChild(new \DOMElement('name', $argument->getName())); $child->appendChild(new \DOMElement('default')) ->appendChild(new \DOMText((string) $argument->getDefault())); $child->appendChild(new \DOMElement('type', (string) $argument->getType())); return $child; }
[ "public", "function", "convert", "(", "\\", "DOMElement", "$", "parent", ",", "ArgumentDescriptor", "$", "argument", ")", "{", "$", "child", "=", "new", "\\", "DOMElement", "(", "'argument'", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "child", ")", ";", "$", "child", "->", "setAttribute", "(", "'line'", ",", "(", "string", ")", "$", "argument", "->", "getLine", "(", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'by_reference'", ",", "var_export", "(", "$", "argument", "->", "isByReference", "(", ")", ",", "true", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'name'", ",", "$", "argument", "->", "getName", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'default'", ")", ")", "->", "appendChild", "(", "new", "\\", "DOMText", "(", "(", "string", ")", "$", "argument", "->", "getDefault", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'type'", ",", "(", "string", ")", "$", "argument", "->", "getType", "(", ")", ")", ")", ";", "return", "$", "child", ";", "}" ]
Exports the given reflection object to the parent XML element. This method creates a new child element on the given parent XML element and takes the properties of the Reflection argument and sets the elements and attributes on the child. @param \DOMElement $parent The parent element to augment. @param ArgumentDescriptor $argument The data source. @return \DOMElement
[ "Exports", "the", "given", "reflection", "object", "to", "the", "parent", "XML", "element", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/ArgumentConverter.php#L38-L52
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
Xml.transform
public function transform(ProjectDescriptor $project, Transformation $transformation) { $artifact = $this->getDestinationPath($transformation); $this->checkForSpacesInPath($artifact); $this->xml = new \DOMDocument('1.0', 'utf-8'); $this->xml->formatOutput = true; $document_element = new \DOMElement('project'); $this->xml->appendChild($document_element); $document_element->setAttribute('title', $project->getName()); $document_element->setAttribute('version', Application::VERSION()); $this->buildPartials($document_element, $project); $transformer = $transformation->getTransformer(); foreach ($project->getFiles() as $file) { $this->buildFile($document_element, $file, $transformer); } $this->finalize($project); file_put_contents($artifact, $this->xml->saveXML()); }
php
public function transform(ProjectDescriptor $project, Transformation $transformation) { $artifact = $this->getDestinationPath($transformation); $this->checkForSpacesInPath($artifact); $this->xml = new \DOMDocument('1.0', 'utf-8'); $this->xml->formatOutput = true; $document_element = new \DOMElement('project'); $this->xml->appendChild($document_element); $document_element->setAttribute('title', $project->getName()); $document_element->setAttribute('version', Application::VERSION()); $this->buildPartials($document_element, $project); $transformer = $transformation->getTransformer(); foreach ($project->getFiles() as $file) { $this->buildFile($document_element, $file, $transformer); } $this->finalize($project); file_put_contents($artifact, $this->xml->saveXML()); }
[ "public", "function", "transform", "(", "ProjectDescriptor", "$", "project", ",", "Transformation", "$", "transformation", ")", "{", "$", "artifact", "=", "$", "this", "->", "getDestinationPath", "(", "$", "transformation", ")", ";", "$", "this", "->", "checkForSpacesInPath", "(", "$", "artifact", ")", ";", "$", "this", "->", "xml", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "this", "->", "xml", "->", "formatOutput", "=", "true", ";", "$", "document_element", "=", "new", "\\", "DOMElement", "(", "'project'", ")", ";", "$", "this", "->", "xml", "->", "appendChild", "(", "$", "document_element", ")", ";", "$", "document_element", "->", "setAttribute", "(", "'title'", ",", "$", "project", "->", "getName", "(", ")", ")", ";", "$", "document_element", "->", "setAttribute", "(", "'version'", ",", "Application", "::", "VERSION", "(", ")", ")", ";", "$", "this", "->", "buildPartials", "(", "$", "document_element", ",", "$", "project", ")", ";", "$", "transformer", "=", "$", "transformation", "->", "getTransformer", "(", ")", ";", "foreach", "(", "$", "project", "->", "getFiles", "(", ")", "as", "$", "file", ")", "{", "$", "this", "->", "buildFile", "(", "$", "document_element", ",", "$", "file", ",", "$", "transformer", ")", ";", "}", "$", "this", "->", "finalize", "(", "$", "project", ")", ";", "file_put_contents", "(", "$", "artifact", ",", "$", "this", "->", "xml", "->", "saveXML", "(", ")", ")", ";", "}" ]
This method generates the AST output @param ProjectDescriptor $project Document containing the structure. @param Transformation $transformation Transformation to execute.
[ "This", "method", "generates", "the", "AST", "output" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L98-L122
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
Xml.finalize
protected function finalize(ProjectDescriptor $projectDescriptor) { // TODO: move all these behaviours to a central location for all template parsers $behaviour = new AuthorTag(); $behaviour->process($this->xml); $behaviour = new CoversTag(); $behaviour->process($this->xml); $behaviour = new IgnoreTag(); $behaviour->process($this->xml); $behaviour = new InternalTag( $projectDescriptor->isVisibilityAllowed(ProjectDescriptor\Settings::VISIBILITY_INTERNAL) ); $behaviour->process($this->xml); $behaviour = new LicenseTag(); $behaviour->process($this->xml); $behaviour = new MethodTag(); $behaviour->process($this->xml); $behaviour = new ParamTag(); $behaviour->process($this->xml); $behaviour = new PropertyTag(); $behaviour->process($this->xml); $behaviour = new ReturnTag(); $behaviour->process($this->xml); $behaviour = new UsesTag(); $behaviour->process($this->xml); $behaviour = new VarTag(); $behaviour->process($this->xml); $this->buildPackageTree($this->xml); $this->buildNamespaceTree($this->xml); $this->buildDeprecationList($this->xml); }
php
protected function finalize(ProjectDescriptor $projectDescriptor) { $behaviour = new AuthorTag(); $behaviour->process($this->xml); $behaviour = new CoversTag(); $behaviour->process($this->xml); $behaviour = new IgnoreTag(); $behaviour->process($this->xml); $behaviour = new InternalTag( $projectDescriptor->isVisibilityAllowed(ProjectDescriptor\Settings::VISIBILITY_INTERNAL) ); $behaviour->process($this->xml); $behaviour = new LicenseTag(); $behaviour->process($this->xml); $behaviour = new MethodTag(); $behaviour->process($this->xml); $behaviour = new ParamTag(); $behaviour->process($this->xml); $behaviour = new PropertyTag(); $behaviour->process($this->xml); $behaviour = new ReturnTag(); $behaviour->process($this->xml); $behaviour = new UsesTag(); $behaviour->process($this->xml); $behaviour = new VarTag(); $behaviour->process($this->xml); $this->buildPackageTree($this->xml); $this->buildNamespaceTree($this->xml); $this->buildDeprecationList($this->xml); }
[ "protected", "function", "finalize", "(", "ProjectDescriptor", "$", "projectDescriptor", ")", "{", "// TODO: move all these behaviours to a central location for all template parsers", "$", "behaviour", "=", "new", "AuthorTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "CoversTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "IgnoreTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "InternalTag", "(", "$", "projectDescriptor", "->", "isVisibilityAllowed", "(", "ProjectDescriptor", "\\", "Settings", "::", "VISIBILITY_INTERNAL", ")", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "LicenseTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "MethodTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "ParamTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "PropertyTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "ReturnTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "UsesTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "behaviour", "=", "new", "VarTag", "(", ")", ";", "$", "behaviour", "->", "process", "(", "$", "this", "->", "xml", ")", ";", "$", "this", "->", "buildPackageTree", "(", "$", "this", "->", "xml", ")", ";", "$", "this", "->", "buildNamespaceTree", "(", "$", "this", "->", "xml", ")", ";", "$", "this", "->", "buildDeprecationList", "(", "$", "this", "->", "xml", ")", ";", "}" ]
Finalizes the processing and executing all post-processing actions. This method is responsible for extracting and manipulating the data that is global to the project, such as: - Package tree - Namespace tree - Marker list - Deprecated elements listing - Removal of objects related to visibility
[ "Finalizes", "the", "processing", "and", "executing", "all", "post", "-", "processing", "actions", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L398-L428
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
Xml.buildDeprecationList
protected function buildDeprecationList(\DOMDocument $dom) { $nodes = $this->getNodeListForTagBasedQuery($dom, 'deprecated'); $node = new \DOMElement('deprecated'); $dom->documentElement->appendChild($node); $node->setAttribute('count', (string) $nodes->length); }
php
protected function buildDeprecationList(\DOMDocument $dom) { $nodes = $this->getNodeListForTagBasedQuery($dom, 'deprecated'); $node = new \DOMElement('deprecated'); $dom->documentElement->appendChild($node); $node->setAttribute('count', (string) $nodes->length); }
[ "protected", "function", "buildDeprecationList", "(", "\\", "DOMDocument", "$", "dom", ")", "{", "$", "nodes", "=", "$", "this", "->", "getNodeListForTagBasedQuery", "(", "$", "dom", ",", "'deprecated'", ")", ";", "$", "node", "=", "new", "\\", "DOMElement", "(", "'deprecated'", ")", ";", "$", "dom", "->", "documentElement", "->", "appendChild", "(", "$", "node", ")", ";", "$", "node", "->", "setAttribute", "(", "'count'", ",", "(", "string", ")", "$", "nodes", "->", "length", ")", ";", "}" ]
Adds a node to the xml for deprecations and the count value @param \DOMDocument $dom Markers are extracted and a summary inserted in this object.
[ "Adds", "a", "node", "to", "the", "xml", "for", "deprecations", "and", "the", "count", "value" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L483-L490
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
Xml.getNodeListForTagBasedQuery
protected function getNodeListForTagBasedQuery($dom, $marker) { $xpath = new \DOMXPath($dom); $query = '/project/file/markers/' . $marker . '|'; $query .= '/project/file/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/class/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/class/*/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/interface/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/interface/*/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/function/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/constant/docblock/tag[@name="' . $marker . '"]'; return $xpath->query($query); }
php
protected function getNodeListForTagBasedQuery($dom, $marker) { $xpath = new \DOMXPath($dom); $query = '/project/file/markers/' . $marker . '|'; $query .= '/project/file/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/class/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/classdocblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/function/docblock/tag[@name="' . $marker . '"]|'; $query .= '/project/file/constant/docblock/tag[@name="' . $marker . '"]'; return $xpath->query($query); }
[ "protected", "function", "getNodeListForTagBasedQuery", "(", "$", "dom", ",", "$", "marker", ")", "{", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "dom", ")", ";", "$", "query", "=", "'/project/file/markers/'", ".", "$", "marker", ".", "'|'", ";", "$", "query", ".=", "'/project/file/docblock/tag[@name=\"'", ".", "$", "marker", ".", "'\"]|'", ";", "$", "query", ".=", "'/project/file/class/docblock/tag[@name=\"'", ".", "$", "marker", ".", "'\"]|'", ";", "$", "query", ".=", "'/project/file/class/*/docblock/tag[@name=\"'", ".", "$", "marker", ".", "'\"]|'", ";", "$", "query", ".=", "'/project/file/interface/docblock/tag[@name=\"'", ".", "$", "marker", ".", "'\"]|'", ";", "$", "query", ".=", "'/project/file/interface/*/docblock/tag[@name=\"'", ".", "$", "marker", ".", "'\"]|'", ";", "$", "query", ".=", "'/project/file/function/docblock/tag[@name=\"'", ".", "$", "marker", ".", "'\"]|'", ";", "$", "query", ".=", "'/project/file/constant/docblock/tag[@name=\"'", ".", "$", "marker", ".", "'\"]'", ";", "return", "$", "xpath", "->", "query", "(", "$", "query", ")", ";", "}" ]
Build a tag based query string and return result @param \DOMDocument $dom Markers are extracted and a summary inserted in this object. @param string $marker The marker we're searching for throughout xml @return \DOMNodeList
[ "Build", "a", "tag", "based", "query", "string", "and", "return", "result" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L501-L515
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Command/Manual/ToLatexCommand.php
ToLatexCommand.configureConverterFromInputOptions
protected function configureConverterFromInputOptions($converter, $input) { if (!$converter instanceof ToLatexInterface) { throw new \InvalidArgumentException( 'The converter used to process ' . $input->getOption('input-format') . ' should implement the ' . 'phpDocumentor\Plugin\Scrybe\Converter\ToPdfInterface' ); } $converter->setTitle($input->getOption('title')); $converter->setAuthor($input->getOption('author')); $converter->setCoverLogo($input->getOption('cover-logo')); $converter->setTableOfContents($input->getOption('toc') !== 'false'); }
php
protected function configureConverterFromInputOptions($converter, $input) { if (!$converter instanceof ToLatexInterface) { throw new \InvalidArgumentException( 'The converter used to process ' . $input->getOption('input-format') . ' should implement the ' . 'phpDocumentor\Plugin\Scrybe\Converter\ToPdfInterface' ); } $converter->setTitle($input->getOption('title')); $converter->setAuthor($input->getOption('author')); $converter->setCoverLogo($input->getOption('cover-logo')); $converter->setTableOfContents($input->getOption('toc') !== 'false'); }
[ "protected", "function", "configureConverterFromInputOptions", "(", "$", "converter", ",", "$", "input", ")", "{", "if", "(", "!", "$", "converter", "instanceof", "ToLatexInterface", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The converter used to process '", ".", "$", "input", "->", "getOption", "(", "'input-format'", ")", ".", "' should implement the '", ".", "'phpDocumentor\\Plugin\\Scrybe\\Converter\\ToPdfInterface'", ")", ";", "}", "$", "converter", "->", "setTitle", "(", "$", "input", "->", "getOption", "(", "'title'", ")", ")", ";", "$", "converter", "->", "setAuthor", "(", "$", "input", "->", "getOption", "(", "'author'", ")", ")", ";", "$", "converter", "->", "setCoverLogo", "(", "$", "input", "->", "getOption", "(", "'cover-logo'", ")", ")", ";", "$", "converter", "->", "setTableOfContents", "(", "$", "input", "->", "getOption", "(", "'toc'", ")", "!==", "'false'", ")", ";", "}" ]
Configures the converter with the options provided by the Input options. @param ToLatexInterface $converter @param InputInterface $input @throws \InvalidArgumentException if the provided converter is not derived from ToLatexInterface
[ "Configures", "the", "converter", "with", "the", "options", "provided", "by", "the", "Input", "options", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/ToLatexCommand.php#L95-L109
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Router/ForFileProxy.php
ForFileProxy.generate
public function generate($node, $directorySeparator = DIRECTORY_SEPARATOR) { $webserverPath = $this->rule->generate($node); return $webserverPath === false ? false : str_replace('/', $directorySeparator, $webserverPath); }
php
public function generate($node, $directorySeparator = DIRECTORY_SEPARATOR) { $webserverPath = $this->rule->generate($node); return $webserverPath === false ? false : str_replace('/', $directorySeparator, $webserverPath); }
[ "public", "function", "generate", "(", "$", "node", ",", "$", "directorySeparator", "=", "DIRECTORY_SEPARATOR", ")", "{", "$", "webserverPath", "=", "$", "this", "->", "rule", "->", "generate", "(", "$", "node", ")", ";", "return", "$", "webserverPath", "===", "false", "?", "false", ":", "str_replace", "(", "'/'", ",", "$", "directorySeparator", ",", "$", "webserverPath", ")", ";", "}" ]
Generates an URL for the given node. @param string|DescriptorAbstract $node The node for which to generate an URL. @param string $directorySeparator Which directory separator should be used to generate the paths with, defaults to the default separator for the current O/S. @return string|false a well-formed relative or absolute URL, or false if no URL could be generated.
[ "Generates", "an", "URL", "for", "the", "given", "node", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/ForFileProxy.php#L52-L57
phpDocumentor/phpDocumentor2
src/phpDocumentor/Infrastructure/Parser/SpecificationFactory.php
SpecificationFactory.create
public function create(array $paths, array $ignore, array $extensions): SpecificationInterface { $pathSpec = null; foreach ($paths as $path) { $pathSpec = $this->orSpec($this->inPath($path), $pathSpec); } $ignoreSpec = null; if (isset($ignore['paths'])) { foreach ($ignore['paths'] as $path) { $ignoreSpec = $this->orSpec($this->inPath($path), $ignoreSpec); } } if (isset($ignore['hidden']) && $ignore['hidden'] === true) { $ignoreSpec = $this->orSpec(new IsHidden(), $ignoreSpec); } return $this->andSpec( $pathSpec, $this->andSpec(new HasExtension($extensions), $this->notSpec($ignoreSpec)) ); }
php
public function create(array $paths, array $ignore, array $extensions): SpecificationInterface { $pathSpec = null; foreach ($paths as $path) { $pathSpec = $this->orSpec($this->inPath($path), $pathSpec); } $ignoreSpec = null; if (isset($ignore['paths'])) { foreach ($ignore['paths'] as $path) { $ignoreSpec = $this->orSpec($this->inPath($path), $ignoreSpec); } } if (isset($ignore['hidden']) && $ignore['hidden'] === true) { $ignoreSpec = $this->orSpec(new IsHidden(), $ignoreSpec); } return $this->andSpec( $pathSpec, $this->andSpec(new HasExtension($extensions), $this->notSpec($ignoreSpec)) ); }
[ "public", "function", "create", "(", "array", "$", "paths", ",", "array", "$", "ignore", ",", "array", "$", "extensions", ")", ":", "SpecificationInterface", "{", "$", "pathSpec", "=", "null", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "$", "pathSpec", "=", "$", "this", "->", "orSpec", "(", "$", "this", "->", "inPath", "(", "$", "path", ")", ",", "$", "pathSpec", ")", ";", "}", "$", "ignoreSpec", "=", "null", ";", "if", "(", "isset", "(", "$", "ignore", "[", "'paths'", "]", ")", ")", "{", "foreach", "(", "$", "ignore", "[", "'paths'", "]", "as", "$", "path", ")", "{", "$", "ignoreSpec", "=", "$", "this", "->", "orSpec", "(", "$", "this", "->", "inPath", "(", "$", "path", ")", ",", "$", "ignoreSpec", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "ignore", "[", "'hidden'", "]", ")", "&&", "$", "ignore", "[", "'hidden'", "]", "===", "true", ")", "{", "$", "ignoreSpec", "=", "$", "this", "->", "orSpec", "(", "new", "IsHidden", "(", ")", ",", "$", "ignoreSpec", ")", ";", "}", "return", "$", "this", "->", "andSpec", "(", "$", "pathSpec", ",", "$", "this", "->", "andSpec", "(", "new", "HasExtension", "(", "$", "extensions", ")", ",", "$", "this", "->", "notSpec", "(", "$", "ignoreSpec", ")", ")", ")", ";", "}" ]
Creates a SpecificationInterface object based on the ignore and extension parameters.
[ "Creates", "a", "SpecificationInterface", "object", "based", "on", "the", "ignore", "and", "extension", "parameters", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Infrastructure/Parser/SpecificationFactory.php#L36-L58
phpDocumentor/phpDocumentor2
src/phpDocumentor/Infrastructure/Parser/SpecificationFactory.php
SpecificationFactory.orSpec
private function orSpec(SpecificationInterface $or, SpecificationInterface $spec = null): SpecificationInterface { if ($spec === null) { return $or; } return new OrSpecification($spec, $or); }
php
private function orSpec(SpecificationInterface $or, SpecificationInterface $spec = null): SpecificationInterface { if ($spec === null) { return $or; } return new OrSpecification($spec, $or); }
[ "private", "function", "orSpec", "(", "SpecificationInterface", "$", "or", ",", "SpecificationInterface", "$", "spec", "=", "null", ")", ":", "SpecificationInterface", "{", "if", "(", "$", "spec", "===", "null", ")", "{", "return", "$", "or", ";", "}", "return", "new", "OrSpecification", "(", "$", "spec", ",", "$", "or", ")", ";", "}" ]
Will return an OrSpecification when $or and $spec are both not null. @param SpecificationInterface|null $spec @return OrSpecification|SpecificationInterface
[ "Will", "return", "an", "OrSpecification", "when", "$or", "and", "$spec", "are", "both", "not", "null", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Infrastructure/Parser/SpecificationFactory.php#L66-L73
phpDocumentor/phpDocumentor2
src/phpDocumentor/Configuration/Factory/Version3.php
Version3.buildVersion
private function buildVersion(SimpleXMLElement $version): array { $apis = []; $guides = []; foreach ($version->children() as $child) { switch ($child->getName()) { case 'api': $apis[] = $this->buildApi($child); break; case 'guide': $guides[] = $this->buildGuide($child); break; default: break; } } $version = [ 'folder' => (string) $version->folder, ]; if (count($apis) > 0) { $version['api'] = $apis; } if (count($guides) > 0) { $version['guide'] = $guides; } return $version; }
php
private function buildVersion(SimpleXMLElement $version): array { $apis = []; $guides = []; foreach ($version->children() as $child) { switch ($child->getName()) { case 'api': $apis[] = $this->buildApi($child); break; case 'guide': $guides[] = $this->buildGuide($child); break; default: break; } } $version = [ 'folder' => (string) $version->folder, ]; if (count($apis) > 0) { $version['api'] = $apis; } if (count($guides) > 0) { $version['guide'] = $guides; } return $version; }
[ "private", "function", "buildVersion", "(", "SimpleXMLElement", "$", "version", ")", ":", "array", "{", "$", "apis", "=", "[", "]", ";", "$", "guides", "=", "[", "]", ";", "foreach", "(", "$", "version", "->", "children", "(", ")", "as", "$", "child", ")", "{", "switch", "(", "$", "child", "->", "getName", "(", ")", ")", "{", "case", "'api'", ":", "$", "apis", "[", "]", "=", "$", "this", "->", "buildApi", "(", "$", "child", ")", ";", "break", ";", "case", "'guide'", ":", "$", "guides", "[", "]", "=", "$", "this", "->", "buildGuide", "(", "$", "child", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}", "$", "version", "=", "[", "'folder'", "=>", "(", "string", ")", "$", "version", "->", "folder", ",", "]", ";", "if", "(", "count", "(", "$", "apis", ")", ">", "0", ")", "{", "$", "version", "[", "'api'", "]", "=", "$", "apis", ";", "}", "if", "(", "count", "(", "$", "guides", ")", ">", "0", ")", "{", "$", "version", "[", "'guide'", "]", "=", "$", "guides", ";", "}", "return", "$", "version", ";", "}" ]
Builds the versions part of the array from the configuration xml.
[ "Builds", "the", "versions", "part", "of", "the", "array", "from", "the", "configuration", "xml", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L100-L130
phpDocumentor/phpDocumentor2
src/phpDocumentor/Configuration/Factory/Version3.php
Version3.buildApi
private function buildApi(SimpleXMLElement $api): array { $extensions = []; foreach ($api->extensions->children() as $extension) { if ((string) $extension !== '') { $extensions[] = (string) $extension; } } $ignoreHidden = filter_var($api->ignore->attributes()->hidden, FILTER_VALIDATE_BOOLEAN); return [ 'format' => ((string) $api->attributes()->format) ?: 'php', 'source' => [ 'dsn' => ((string) $api->source->attributes()->dsn) ?: 'file://.', 'paths' => ((array) $api->source->path) ?: ['.'], ], 'ignore' => [ 'hidden' => $ignoreHidden, 'paths' => (array) $api->ignore->path, ], 'extensions' => $extensions, 'visibility' => (array) $api->visibility, 'default-package-name' => ((string) $api->{'default-package-name'}) ?: 'Default', 'markers' => (array) $api->markers->children()->marker, ]; }
php
private function buildApi(SimpleXMLElement $api): array { $extensions = []; foreach ($api->extensions->children() as $extension) { if ((string) $extension !== '') { $extensions[] = (string) $extension; } } $ignoreHidden = filter_var($api->ignore->attributes()->hidden, FILTER_VALIDATE_BOOLEAN); return [ 'format' => ((string) $api->attributes()->format) ?: 'php', 'source' => [ 'dsn' => ((string) $api->source->attributes()->dsn) ?: 'file: 'paths' => ((array) $api->source->path) ?: ['.'], ], 'ignore' => [ 'hidden' => $ignoreHidden, 'paths' => (array) $api->ignore->path, ], 'extensions' => $extensions, 'visibility' => (array) $api->visibility, 'default-package-name' => ((string) $api->{'default-package-name'}) ?: 'Default', 'markers' => (array) $api->markers->children()->marker, ]; }
[ "private", "function", "buildApi", "(", "SimpleXMLElement", "$", "api", ")", ":", "array", "{", "$", "extensions", "=", "[", "]", ";", "foreach", "(", "$", "api", "->", "extensions", "->", "children", "(", ")", "as", "$", "extension", ")", "{", "if", "(", "(", "string", ")", "$", "extension", "!==", "''", ")", "{", "$", "extensions", "[", "]", "=", "(", "string", ")", "$", "extension", ";", "}", "}", "$", "ignoreHidden", "=", "filter_var", "(", "$", "api", "->", "ignore", "->", "attributes", "(", ")", "->", "hidden", ",", "FILTER_VALIDATE_BOOLEAN", ")", ";", "return", "[", "'format'", "=>", "(", "(", "string", ")", "$", "api", "->", "attributes", "(", ")", "->", "format", ")", "?", ":", "'php'", ",", "'source'", "=>", "[", "'dsn'", "=>", "(", "(", "string", ")", "$", "api", "->", "source", "->", "attributes", "(", ")", "->", "dsn", ")", "?", ":", "'file://.'", ",", "'paths'", "=>", "(", "(", "array", ")", "$", "api", "->", "source", "->", "path", ")", "?", ":", "[", "'.'", "]", ",", "]", ",", "'ignore'", "=>", "[", "'hidden'", "=>", "$", "ignoreHidden", ",", "'paths'", "=>", "(", "array", ")", "$", "api", "->", "ignore", "->", "path", ",", "]", ",", "'extensions'", "=>", "$", "extensions", ",", "'visibility'", "=>", "(", "array", ")", "$", "api", "->", "visibility", ",", "'default-package-name'", "=>", "(", "(", "string", ")", "$", "api", "->", "{", "'default-package-name'", "}", ")", "?", ":", "'Default'", ",", "'markers'", "=>", "(", "array", ")", "$", "api", "->", "markers", "->", "children", "(", ")", "->", "marker", ",", "]", ";", "}" ]
Builds the api part of the array from the configuration xml.
[ "Builds", "the", "api", "part", "of", "the", "array", "from", "the", "configuration", "xml", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L135-L161
phpDocumentor/phpDocumentor2
src/phpDocumentor/Configuration/Factory/Version3.php
Version3.buildGuide
private function buildGuide(SimpleXMLElement $guide): array { return [ 'format' => ((string) $guide->attributes()->format) ?: 'rst', 'source' => [ 'dsn' => ((string) $guide->source->attributes()->dsn) ?: 'file://.', 'paths' => ((array) $guide->source->path) ?: [''], ], ]; }
php
private function buildGuide(SimpleXMLElement $guide): array { return [ 'format' => ((string) $guide->attributes()->format) ?: 'rst', 'source' => [ 'dsn' => ((string) $guide->source->attributes()->dsn) ?: 'file: 'paths' => ((array) $guide->source->path) ?: [''], ], ]; }
[ "private", "function", "buildGuide", "(", "SimpleXMLElement", "$", "guide", ")", ":", "array", "{", "return", "[", "'format'", "=>", "(", "(", "string", ")", "$", "guide", "->", "attributes", "(", ")", "->", "format", ")", "?", ":", "'rst'", ",", "'source'", "=>", "[", "'dsn'", "=>", "(", "(", "string", ")", "$", "guide", "->", "source", "->", "attributes", "(", ")", "->", "dsn", ")", "?", ":", "'file://.'", ",", "'paths'", "=>", "(", "(", "array", ")", "$", "guide", "->", "source", "->", "path", ")", "?", ":", "[", "''", "]", ",", "]", ",", "]", ";", "}" ]
Builds the guide part of the array from the configuration xml.
[ "Builds", "the", "guide", "part", "of", "the", "array", "from", "the", "configuration", "xml", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L166-L175
phpDocumentor/phpDocumentor2
src/phpDocumentor/Configuration/Factory/Version3.php
Version3.buildTemplate
private function buildTemplate(SimpleXMLElement $template): array { if ((array) $template === []) { return $this->defaultTemplate(); } $attributes = []; foreach ($template->attributes() as $attribute) { $attributes[$attribute->getName()] = (string) $attribute; } return $attributes; }
php
private function buildTemplate(SimpleXMLElement $template): array { if ((array) $template === []) { return $this->defaultTemplate(); } $attributes = []; foreach ($template->attributes() as $attribute) { $attributes[$attribute->getName()] = (string) $attribute; } return $attributes; }
[ "private", "function", "buildTemplate", "(", "SimpleXMLElement", "$", "template", ")", ":", "array", "{", "if", "(", "(", "array", ")", "$", "template", "===", "[", "]", ")", "{", "return", "$", "this", "->", "defaultTemplate", "(", ")", ";", "}", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "template", "->", "attributes", "(", ")", "as", "$", "attribute", ")", "{", "$", "attributes", "[", "$", "attribute", "->", "getName", "(", ")", "]", "=", "(", "string", ")", "$", "attribute", ";", "}", "return", "$", "attributes", ";", "}" ]
Builds the template part of the array from the configuration xml.
[ "Builds", "the", "template", "part", "of", "the", "array", "from", "the", "configuration", "xml", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L180-L192
phpDocumentor/phpDocumentor2
src/phpDocumentor/Configuration/Factory/Version3.php
Version3.validate
private function validate(SimpleXMLElement $phpDocumentor): void { libxml_clear_errors(); $priorSetting = libxml_use_internal_errors(true); $dom = new \DOMDocument(); $domElement = dom_import_simplexml($phpDocumentor); $domElement = $dom->importNode($domElement, true); $dom->appendChild($domElement); $dom->schemaValidate($this->schemaPath); $error = libxml_get_last_error(); if ($error !== false) { throw new InvalidArgumentException(trim($error->message)); } libxml_use_internal_errors($priorSetting); }
php
private function validate(SimpleXMLElement $phpDocumentor): void { libxml_clear_errors(); $priorSetting = libxml_use_internal_errors(true); $dom = new \DOMDocument(); $domElement = dom_import_simplexml($phpDocumentor); $domElement = $dom->importNode($domElement, true); $dom->appendChild($domElement); $dom->schemaValidate($this->schemaPath); $error = libxml_get_last_error(); if ($error !== false) { throw new InvalidArgumentException(trim($error->message)); } libxml_use_internal_errors($priorSetting); }
[ "private", "function", "validate", "(", "SimpleXMLElement", "$", "phpDocumentor", ")", ":", "void", "{", "libxml_clear_errors", "(", ")", ";", "$", "priorSetting", "=", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "dom", "=", "new", "\\", "DOMDocument", "(", ")", ";", "$", "domElement", "=", "dom_import_simplexml", "(", "$", "phpDocumentor", ")", ";", "$", "domElement", "=", "$", "dom", "->", "importNode", "(", "$", "domElement", ",", "true", ")", ";", "$", "dom", "->", "appendChild", "(", "$", "domElement", ")", ";", "$", "dom", "->", "schemaValidate", "(", "$", "this", "->", "schemaPath", ")", ";", "$", "error", "=", "libxml_get_last_error", "(", ")", ";", "if", "(", "$", "error", "!==", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", "trim", "(", "$", "error", "->", "message", ")", ")", ";", "}", "libxml_use_internal_errors", "(", "$", "priorSetting", ")", ";", "}" ]
Validates the configuration xml structure against the schema defined in the schemaPath. @throws InvalidArgumentException if the xml structure is not valid.
[ "Validates", "the", "configuration", "xml", "structure", "against", "the", "schema", "defined", "in", "the", "schemaPath", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L261-L280
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Collection.php
Collection.get
public function get($index, $valueIfEmpty = null) { if (!$this->offsetExists($index) && $valueIfEmpty !== null) { $this->offsetSet($index, $valueIfEmpty); } return $this->offsetGet($index); }
php
public function get($index, $valueIfEmpty = null) { if (!$this->offsetExists($index) && $valueIfEmpty !== null) { $this->offsetSet($index, $valueIfEmpty); } return $this->offsetGet($index); }
[ "public", "function", "get", "(", "$", "index", ",", "$", "valueIfEmpty", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "$", "index", ")", "&&", "$", "valueIfEmpty", "!==", "null", ")", "{", "$", "this", "->", "offsetSet", "(", "$", "index", ",", "$", "valueIfEmpty", ")", ";", "}", "return", "$", "this", "->", "offsetGet", "(", "$", "index", ")", ";", "}" ]
Retrieves a specific item from the Collection with its index. Please note that this method (intentionally) has the side effect that whenever a key does not exist that it will be created with the value provided by the $valueIfEmpty argument. This will allow for easy initialization during tree building operations. @param string|integer $index @param mixed $valueIfEmpty If the index does not exist it will be created with this value and returned. @return mixed The contents of the element with the given index and the provided default if the key doesn't exist.
[ "Retrieves", "a", "specific", "item", "from", "the", "Collection", "with", "its", "index", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Collection.php#L72-L79
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Collection.php
Collection.offsetSet
public function offsetSet($offset, $value) { if ($offset === '' || $offset === null) { throw new \InvalidArgumentException('The key of a collection must always be set'); } $this->items[$offset] = $value; }
php
public function offsetSet($offset, $value) { if ($offset === '' || $offset === null) { throw new \InvalidArgumentException('The key of a collection must always be set'); } $this->items[$offset] = $value; }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "if", "(", "$", "offset", "===", "''", "||", "$", "offset", "===", "null", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The key of a collection must always be set'", ")", ";", "}", "$", "this", "->", "items", "[", "$", "offset", "]", "=", "$", "value", ";", "}" ]
Sets an item at the given index. @param string|integer $offset The offset to assign the value to. @param mixed $value The value to set. @throws \InvalidArgumentException if the key is null or an empty string.
[ "Sets", "an", "item", "at", "the", "given", "index", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Collection.php#L163-L170
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Router/Rule.php
Rule.generate
public function generate($node) { $callable = $this->generator; $generatedPathAsUtf8 = $callable($node); return $generatedPathAsUtf8 ? $this->translateToUrlEncodedPath($generatedPathAsUtf8) : false; }
php
public function generate($node) { $callable = $this->generator; $generatedPathAsUtf8 = $callable($node); return $generatedPathAsUtf8 ? $this->translateToUrlEncodedPath($generatedPathAsUtf8) : false; }
[ "public", "function", "generate", "(", "$", "node", ")", "{", "$", "callable", "=", "$", "this", "->", "generator", ";", "$", "generatedPathAsUtf8", "=", "$", "callable", "(", "$", "node", ")", ";", "return", "$", "generatedPathAsUtf8", "?", "$", "this", "->", "translateToUrlEncodedPath", "(", "$", "generatedPathAsUtf8", ")", ":", "false", ";", "}" ]
Generates an URL for the given node. @param string|DescriptorAbstract $node The node for which to generate an URL. @return string|false a well-formed relative or absolute URL, or false if no URL could be generated.
[ "Generates", "an", "URL", "for", "the", "given", "node", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/Rule.php#L69-L75
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/Metadata/Assets.php
Assets.copyTo
public function copyTo($destination) { foreach ($this as $source_path => $asset_path) { if (!is_readable($source_path)) { if ($this->logger) { $this->logger->error('Asset "' . $source_path . '" could not be found or is not readable'); } continue; } $destination_path = $destination . '/' . $asset_path; if (!file_exists(dirname($destination_path))) { mkdir(dirname($destination_path), 0777, true); } copy($source_path, $destination_path); } }
php
public function copyTo($destination) { foreach ($this as $source_path => $asset_path) { if (!is_readable($source_path)) { if ($this->logger) { $this->logger->error('Asset "' . $source_path . '" could not be found or is not readable'); } continue; } $destination_path = $destination . '/' . $asset_path; if (!file_exists(dirname($destination_path))) { mkdir(dirname($destination_path), 0777, true); } copy($source_path, $destination_path); } }
[ "public", "function", "copyTo", "(", "$", "destination", ")", "{", "foreach", "(", "$", "this", "as", "$", "source_path", "=>", "$", "asset_path", ")", "{", "if", "(", "!", "is_readable", "(", "$", "source_path", ")", ")", "{", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "'Asset \"'", ".", "$", "source_path", ".", "'\" could not be found or is not readable'", ")", ";", "}", "continue", ";", "}", "$", "destination_path", "=", "$", "destination", ".", "'/'", ".", "$", "asset_path", ";", "if", "(", "!", "file_exists", "(", "dirname", "(", "$", "destination_path", ")", ")", ")", "{", "mkdir", "(", "dirname", "(", "$", "destination_path", ")", ",", "0777", ",", "true", ")", ";", "}", "copy", "(", "$", "source_path", ",", "$", "destination_path", ")", ";", "}", "}" ]
Copies all assets in this collection to their given destination location. @param string $destination
[ "Copies", "all", "assets", "in", "this", "collection", "to", "their", "given", "destination", "location", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Metadata/Assets.php#L83-L101
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Linker/Linker.php
Linker.findAlias
public function findAlias(string $fqsen, $container = null) { $fqsen = $this->replacePseudoTypes($fqsen, $container); if ($this->isContextMarkerInFqsen($fqsen) && $container instanceof DescriptorAbstract) { // first exchange `@context::element` for `\My\Class::element` and if it exists, return that $classMember = $this->fetchElementByFqsen($this->getTypeWithClassAsContext($fqsen, $container)); if ($classMember) { return $classMember; } // otherwise exchange `@context::element` for `\My\element` and if it exists, return that $namespaceContext = $this->getTypeWithNamespaceAsContext($fqsen, $container); $namespaceMember = $this->fetchElementByFqsen($namespaceContext); if ($namespaceMember) { return $namespaceMember; } // otherwise check if the element exists in the global namespace and if it exists, return that $globalNamespaceContext = $this->getTypeWithGlobalNamespaceAsContext($fqsen); $globalNamespaceMember = $this->fetchElementByFqsen($globalNamespaceContext); if ($globalNamespaceMember) { return $globalNamespaceMember; } // Otherwise we assume it is an undocumented class/interface/trait and return `\My\element` so // that the name containing the marker may be replaced by the class reference as string return $namespaceContext; } return $this->fetchElementByFqsen($fqsen); }
php
public function findAlias(string $fqsen, $container = null) { $fqsen = $this->replacePseudoTypes($fqsen, $container); if ($this->isContextMarkerInFqsen($fqsen) && $container instanceof DescriptorAbstract) { $classMember = $this->fetchElementByFqsen($this->getTypeWithClassAsContext($fqsen, $container)); if ($classMember) { return $classMember; } $namespaceContext = $this->getTypeWithNamespaceAsContext($fqsen, $container); $namespaceMember = $this->fetchElementByFqsen($namespaceContext); if ($namespaceMember) { return $namespaceMember; } $globalNamespaceContext = $this->getTypeWithGlobalNamespaceAsContext($fqsen); $globalNamespaceMember = $this->fetchElementByFqsen($globalNamespaceContext); if ($globalNamespaceMember) { return $globalNamespaceMember; } return $namespaceContext; } return $this->fetchElementByFqsen($fqsen); }
[ "public", "function", "findAlias", "(", "string", "$", "fqsen", ",", "$", "container", "=", "null", ")", "{", "$", "fqsen", "=", "$", "this", "->", "replacePseudoTypes", "(", "$", "fqsen", ",", "$", "container", ")", ";", "if", "(", "$", "this", "->", "isContextMarkerInFqsen", "(", "$", "fqsen", ")", "&&", "$", "container", "instanceof", "DescriptorAbstract", ")", "{", "// first exchange `@context::element` for `\\My\\Class::element` and if it exists, return that", "$", "classMember", "=", "$", "this", "->", "fetchElementByFqsen", "(", "$", "this", "->", "getTypeWithClassAsContext", "(", "$", "fqsen", ",", "$", "container", ")", ")", ";", "if", "(", "$", "classMember", ")", "{", "return", "$", "classMember", ";", "}", "// otherwise exchange `@context::element` for `\\My\\element` and if it exists, return that", "$", "namespaceContext", "=", "$", "this", "->", "getTypeWithNamespaceAsContext", "(", "$", "fqsen", ",", "$", "container", ")", ";", "$", "namespaceMember", "=", "$", "this", "->", "fetchElementByFqsen", "(", "$", "namespaceContext", ")", ";", "if", "(", "$", "namespaceMember", ")", "{", "return", "$", "namespaceMember", ";", "}", "// otherwise check if the element exists in the global namespace and if it exists, return that", "$", "globalNamespaceContext", "=", "$", "this", "->", "getTypeWithGlobalNamespaceAsContext", "(", "$", "fqsen", ")", ";", "$", "globalNamespaceMember", "=", "$", "this", "->", "fetchElementByFqsen", "(", "$", "globalNamespaceContext", ")", ";", "if", "(", "$", "globalNamespaceMember", ")", "{", "return", "$", "globalNamespaceMember", ";", "}", "// Otherwise we assume it is an undocumented class/interface/trait and return `\\My\\element` so", "// that the name containing the marker may be replaced by the class reference as string", "return", "$", "namespaceContext", ";", "}", "return", "$", "this", "->", "fetchElementByFqsen", "(", "$", "fqsen", ")", ";", "}" ]
Attempts to find a Descriptor object alias with the FQSEN of the element it represents. This method will try to fetch an element after normalizing the provided FQSEN. The FQSEN may contain references (bindings) that can only be resolved during linking (such as `self`) or it may contain a context marker {@see CONTEXT_MARKER}. If there is a context marker then this method will see if a child of the given container exists that matches the element following the marker. If such a child does not exist in the current container then the namespace is queried if a child exists there that matches. For example: Given the Fqsen `@context::myFunction()` and the lastContainer `\My\Class` will this method first check to see if `\My\Class::myFunction()` exists; if it doesn't it will then check if `\My\myFunction()` exists. If neither element exists then this method assumes it is an undocumented class/trait/interface and change the given FQSEN by returning the namespaced element name (thus in the example above that would be `\My\myFunction()`). The calling method {@see substitute()} will then replace the value of the field containing the context marker with this normalized string. @param DescriptorAbstract|null $container @return DescriptorAbstract|string|null
[ "Attempts", "to", "find", "a", "Descriptor", "object", "alias", "with", "the", "FQSEN", "of", "the", "element", "it", "represents", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Linker/Linker.php#L207-L238