repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
phpDocumentor/phpDocumentor2 | src/phpDocumentor/DomainModel/Dsn.php | Dsn.parseHostAndPath | private function parseHostAndPath(array $locationParts): void
{
$path = $locationParts['path'] ?? '';
$host = $locationParts['host'] ?? '';
if ($this->getScheme() === 'file') {
$this->path = $host . $path;
} else {
$this->host = $host;
$this->path = $path;
}
} | php | private function parseHostAndPath(array $locationParts): void
{
$path = $locationParts['path'] ?? '';
$host = $locationParts['host'] ?? '';
if ($this->getScheme() === 'file') {
$this->path = $host . $path;
} else {
$this->host = $host;
$this->path = $path;
}
} | [
"private",
"function",
"parseHostAndPath",
"(",
"array",
"$",
"locationParts",
")",
":",
"void",
"{",
"$",
"path",
"=",
"$",
"locationParts",
"[",
"'path'",
"]",
"??",
"''",
";",
"$",
"host",
"=",
"$",
"locationParts",
"[",
"'host'",
"]",
"??",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"getScheme",
"(",
")",
"===",
"'file'",
")",
"{",
"$",
"this",
"->",
"path",
"=",
"$",
"host",
".",
"$",
"path",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"host",
"=",
"$",
"host",
";",
"$",
"this",
"->",
"path",
"=",
"$",
"path",
";",
"}",
"}"
] | Validates and sets the host and path properties
@param string[] $locationParts | [
"Validates",
"and",
"sets",
"the",
"host",
"and",
"path",
"properties"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L230-L241 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/DomainModel/Dsn.php | Dsn.parsePort | private function parsePort(array $locationParts): void
{
if (! isset($locationParts['port'])) {
if ($this->getScheme() === 'git+http') {
$this->port = 80;
} elseif ($this->getScheme() === 'git+https') {
$this->port = 443;
} else {
$this->port = 0;
}
} else {
$this->port = (int) $locationParts['port'];
}
} | php | private function parsePort(array $locationParts): void
{
if (! isset($locationParts['port'])) {
if ($this->getScheme() === 'git+http') {
$this->port = 80;
} elseif ($this->getScheme() === 'git+https') {
$this->port = 443;
} else {
$this->port = 0;
}
} else {
$this->port = (int) $locationParts['port'];
}
} | [
"private",
"function",
"parsePort",
"(",
"array",
"$",
"locationParts",
")",
":",
"void",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"locationParts",
"[",
"'port'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getScheme",
"(",
")",
"===",
"'git+http'",
")",
"{",
"$",
"this",
"->",
"port",
"=",
"80",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getScheme",
"(",
")",
"===",
"'git+https'",
")",
"{",
"$",
"this",
"->",
"port",
"=",
"443",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"port",
"=",
"0",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"port",
"=",
"(",
"int",
")",
"$",
"locationParts",
"[",
"'port'",
"]",
";",
"}",
"}"
] | Validates and sets the port property
@param string[] $locationParts | [
"Validates",
"and",
"sets",
"the",
"port",
"property"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L248-L261 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/DomainModel/Dsn.php | Dsn.parseQuery | private function parseQuery(array $locationParts): void
{
if (isset($locationParts['query'])) {
$queryParts = explode('&', $locationParts['query']);
foreach ($queryParts as $part) {
$option = $this->splitKeyValuePair($part);
$this->query[$option[0]] = $option[1];
}
}
} | php | private function parseQuery(array $locationParts): void
{
if (isset($locationParts['query'])) {
$queryParts = explode('&', $locationParts['query']);
foreach ($queryParts as $part) {
$option = $this->splitKeyValuePair($part);
$this->query[$option[0]] = $option[1];
}
}
} | [
"private",
"function",
"parseQuery",
"(",
"array",
"$",
"locationParts",
")",
":",
"void",
"{",
"if",
"(",
"isset",
"(",
"$",
"locationParts",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"queryParts",
"=",
"explode",
"(",
"'&'",
",",
"$",
"locationParts",
"[",
"'query'",
"]",
")",
";",
"foreach",
"(",
"$",
"queryParts",
"as",
"$",
"part",
")",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"splitKeyValuePair",
"(",
"$",
"part",
")",
";",
"$",
"this",
"->",
"query",
"[",
"$",
"option",
"[",
"0",
"]",
"]",
"=",
"$",
"option",
"[",
"1",
"]",
";",
"}",
"}",
"}"
] | validates and sets the query property
@param string[] $locationParts | [
"validates",
"and",
"sets",
"the",
"query",
"property"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L268-L278 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/DomainModel/Dsn.php | Dsn.parseParameters | private function parseParameters(array $dsnParts): void
{
foreach ($dsnParts as $part) {
$option = $this->splitKeyValuePair($part);
$this->parameters[$option[0]] = $option[1];
}
} | php | private function parseParameters(array $dsnParts): void
{
foreach ($dsnParts as $part) {
$option = $this->splitKeyValuePair($part);
$this->parameters[$option[0]] = $option[1];
}
} | [
"private",
"function",
"parseParameters",
"(",
"array",
"$",
"dsnParts",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"dsnParts",
"as",
"$",
"part",
")",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"splitKeyValuePair",
"(",
"$",
"part",
")",
";",
"$",
"this",
"->",
"parameters",
"[",
"$",
"option",
"[",
"0",
"]",
"]",
"=",
"$",
"option",
"[",
"1",
"]",
";",
"}",
"}"
] | validates and sets the parameters property
@param string[] $dsnParts | [
"validates",
"and",
"sets",
"the",
"parameters",
"property"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L285-L292 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/DomainModel/Dsn.php | Dsn.splitKeyValuePair | private function splitKeyValuePair(string $pair): array
{
$option = explode('=', $pair);
if (count($option) !== 2) {
throw new InvalidArgumentException(
sprintf('"%s" is not a valid query or parameter.', $pair)
);
}
return $option;
} | php | private function splitKeyValuePair(string $pair): array
{
$option = explode('=', $pair);
if (count($option) !== 2) {
throw new InvalidArgumentException(
sprintf('"%s" is not a valid query or parameter.', $pair)
);
}
return $option;
} | [
"private",
"function",
"splitKeyValuePair",
"(",
"string",
"$",
"pair",
")",
":",
"array",
"{",
"$",
"option",
"=",
"explode",
"(",
"'='",
",",
"$",
"pair",
")",
";",
"if",
"(",
"count",
"(",
"$",
"option",
")",
"!==",
"2",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"%s\" is not a valid query or parameter.'",
",",
"$",
"pair",
")",
")",
";",
"}",
"return",
"$",
"option",
";",
"}"
] | Splits a key-value pair
@return string[]
@throws InvalidArgumentException | [
"Splits",
"a",
"key",
"-",
"value",
"pair"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L300-L310 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Core/Transformer/Writer/Pathfinder.php | Pathfinder.find | public function find($object, $query)
{
if ($query) {
$node = $this->walkObjectTree($object, $query);
if (!is_array($node) && (!$node instanceof \Traversable)) {
$node = [$node];
}
return $node;
}
return [$object];
} | php | public function find($object, $query)
{
if ($query) {
$node = $this->walkObjectTree($object, $query);
if (!is_array($node) && (!$node instanceof \Traversable)) {
$node = [$node];
}
return $node;
}
return [$object];
} | [
"public",
"function",
"find",
"(",
"$",
"object",
",",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"query",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"walkObjectTree",
"(",
"$",
"object",
",",
"$",
"query",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"node",
")",
"&&",
"(",
"!",
"$",
"node",
"instanceof",
"\\",
"Traversable",
")",
")",
"{",
"$",
"node",
"=",
"[",
"$",
"node",
"]",
";",
"}",
"return",
"$",
"node",
";",
"}",
"return",
"[",
"$",
"object",
"]",
";",
"}"
] | Combines the query and an object to retrieve a list of nodes that are to be used as node-point in a template.
This method interprets the provided query string and walks through the given object to find the correct
element. This method will silently fail if an invalid query was provided; in such a case the given object
is returned.
@param object $object
@param string $query
@return \Traversable|array | [
"Combines",
"the",
"query",
"and",
"an",
"object",
"to",
"retrieve",
"a",
"list",
"of",
"nodes",
"that",
"are",
"to",
"be",
"used",
"as",
"node",
"-",
"point",
"in",
"a",
"template",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Pathfinder.php#L32-L45 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Transformer/Transformer.php | Transformer.setTarget | public function setTarget(string $target): void
{
$path = realpath($target);
if (false === $path) {
if (@mkdir($target, 0755, true)) {
$path = realpath($target);
} else {
throw new InvalidArgumentException(
'Target directory (' . $target . ') does not exist and could not be created'
);
}
}
if (!is_dir($path) || !is_writable($path)) {
throw new InvalidArgumentException('Given target (' . $target . ') is not a writable directory');
}
$this->target = $path;
} | php | public function setTarget(string $target): void
{
$path = realpath($target);
if (false === $path) {
if (@mkdir($target, 0755, true)) {
$path = realpath($target);
} else {
throw new InvalidArgumentException(
'Target directory (' . $target . ') does not exist and could not be created'
);
}
}
if (!is_dir($path) || !is_writable($path)) {
throw new InvalidArgumentException('Given target (' . $target . ') is not a writable directory');
}
$this->target = $path;
} | [
"public",
"function",
"setTarget",
"(",
"string",
"$",
"target",
")",
":",
"void",
"{",
"$",
"path",
"=",
"realpath",
"(",
"$",
"target",
")",
";",
"if",
"(",
"false",
"===",
"$",
"path",
")",
"{",
"if",
"(",
"@",
"mkdir",
"(",
"$",
"target",
",",
"0755",
",",
"true",
")",
")",
"{",
"$",
"path",
"=",
"realpath",
"(",
"$",
"target",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Target directory ('",
".",
"$",
"target",
".",
"') does not exist and could not be created'",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
"||",
"!",
"is_writable",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Given target ('",
".",
"$",
"target",
".",
"') is not a writable directory'",
")",
";",
"}",
"$",
"this",
"->",
"target",
"=",
"$",
"path",
";",
"}"
] | Sets the target location where to output the artifacts.
@param string $target The target location where to output the artifacts.
@throws InvalidArgumentException if the target is not a valid writable directory. | [
"Sets",
"the",
"target",
"location",
"where",
"to",
"output",
"the",
"artifacts",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Transformer.php#L91-L109 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php | BaseConverter.setOption | public function setOption(string $name, string $value): void
{
$this->options[$name] = $value;
} | php | public function setOption(string $name, string $value): void
{
$this->options[$name] = $value;
} | [
"public",
"function",
"setOption",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
")",
":",
"void",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] | Sets an option with the given name. | [
"Sets",
"an",
"option",
"with",
"the",
"given",
"name",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php#L106-L109 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php | BaseConverter.getDestinationFilename | protected function getDestinationFilename(Metadata\TableOfContents\File $file): string
{
return $this->definition->getOutputFormat()->convertFilename($file->getRealPath());
} | php | protected function getDestinationFilename(Metadata\TableOfContents\File $file): string
{
return $this->definition->getOutputFormat()->convertFilename($file->getRealPath());
} | [
"protected",
"function",
"getDestinationFilename",
"(",
"Metadata",
"\\",
"TableOfContents",
"\\",
"File",
"$",
"file",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"definition",
"->",
"getOutputFormat",
"(",
")",
"->",
"convertFilename",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"}"
] | Returns the filename used for the output path. | [
"Returns",
"the",
"filename",
"used",
"for",
"the",
"output",
"path",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php#L199-L202 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/PropertyDescriptor.php | PropertyDescriptor.getInheritedElement | public function getInheritedElement()
{
/** @var ClassDescriptor|InterfaceDescriptor|null $associatedClass */
$associatedClass = $this->getParent();
if (($associatedClass instanceof ClassDescriptor || $associatedClass instanceof InterfaceDescriptor)
&& ($associatedClass->getParent() instanceof ClassDescriptor
|| $associatedClass->getParent() instanceof InterfaceDescriptor
)
) {
/** @var ClassDescriptor|InterfaceDescriptor $parentClass */
$parentClass = $associatedClass->getParent();
return $parentClass->getProperties()->get($this->getName());
}
return null;
} | php | public function getInheritedElement()
{
/** @var ClassDescriptor|InterfaceDescriptor|null $associatedClass */
$associatedClass = $this->getParent();
if (($associatedClass instanceof ClassDescriptor || $associatedClass instanceof InterfaceDescriptor)
&& ($associatedClass->getParent() instanceof ClassDescriptor
|| $associatedClass->getParent() instanceof InterfaceDescriptor
)
) {
/** @var ClassDescriptor|InterfaceDescriptor $parentClass */
$parentClass = $associatedClass->getParent();
return $parentClass->getProperties()->get($this->getName());
}
return null;
} | [
"public",
"function",
"getInheritedElement",
"(",
")",
"{",
"/** @var ClassDescriptor|InterfaceDescriptor|null $associatedClass */",
"$",
"associatedClass",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"(",
"$",
"associatedClass",
"instanceof",
"ClassDescriptor",
"||",
"$",
"associatedClass",
"instanceof",
"InterfaceDescriptor",
")",
"&&",
"(",
"$",
"associatedClass",
"->",
"getParent",
"(",
")",
"instanceof",
"ClassDescriptor",
"||",
"$",
"associatedClass",
"->",
"getParent",
"(",
")",
"instanceof",
"InterfaceDescriptor",
")",
")",
"{",
"/** @var ClassDescriptor|InterfaceDescriptor $parentClass */",
"$",
"parentClass",
"=",
"$",
"associatedClass",
"->",
"getParent",
"(",
")",
";",
"return",
"$",
"parentClass",
"->",
"getProperties",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the property from which this one should inherit, if any.
@return PropertyDescriptor|null | [
"Returns",
"the",
"property",
"from",
"which",
"this",
"one",
"should",
"inherit",
"if",
"any",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/PropertyDescriptor.php#L174-L191 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Configuration/ConfigurationFactory.php | ConfigurationFactory.fromDefaultLocations | public function fromDefaultLocations(): Configuration
{
foreach ($this->defaultFiles as $file) {
try {
return $this->fromUri(new Uri($file));
} catch (\InvalidArgumentException $e) {
continue;
}
}
return new Configuration($this->applyMiddleware(Version3::buildDefault()));
} | php | public function fromDefaultLocations(): Configuration
{
foreach ($this->defaultFiles as $file) {
try {
return $this->fromUri(new Uri($file));
} catch (\InvalidArgumentException $e) {
continue;
}
}
return new Configuration($this->applyMiddleware(Version3::buildDefault()));
} | [
"public",
"function",
"fromDefaultLocations",
"(",
")",
":",
"Configuration",
"{",
"foreach",
"(",
"$",
"this",
"->",
"defaultFiles",
"as",
"$",
"file",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"fromUri",
"(",
"new",
"Uri",
"(",
"$",
"file",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"}",
"return",
"new",
"Configuration",
"(",
"$",
"this",
"->",
"applyMiddleware",
"(",
"Version3",
"::",
"buildDefault",
"(",
")",
")",
")",
";",
"}"
] | Attempts to load a configuration from the default locations for phpDocumentor
@return Configuration | [
"Attempts",
"to",
"load",
"a",
"configuration",
"from",
"the",
"default",
"locations",
"for",
"phpDocumentor"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/ConfigurationFactory.php#L75-L86 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Configuration/ConfigurationFactory.php | ConfigurationFactory.fromUri | public function fromUri(Uri $uri): Configuration
{
$filename = (string) $uri;
if (!file_exists($filename)) {
throw new \InvalidArgumentException(sprintf('File %s could not be found', $filename));
}
$xml = new \SimpleXMLElement($filename, 0, true);
foreach ($this->strategies as $strategy) {
if ($strategy->supports($xml) !== true) {
continue;
}
return new Configuration($this->applyMiddleware($strategy->convert($xml)));
}
throw new RuntimeException('No supported configuration files were found');
} | php | public function fromUri(Uri $uri): Configuration
{
$filename = (string) $uri;
if (!file_exists($filename)) {
throw new \InvalidArgumentException(sprintf('File %s could not be found', $filename));
}
$xml = new \SimpleXMLElement($filename, 0, true);
foreach ($this->strategies as $strategy) {
if ($strategy->supports($xml) !== true) {
continue;
}
return new Configuration($this->applyMiddleware($strategy->convert($xml)));
}
throw new RuntimeException('No supported configuration files were found');
} | [
"public",
"function",
"fromUri",
"(",
"Uri",
"$",
"uri",
")",
":",
"Configuration",
"{",
"$",
"filename",
"=",
"(",
"string",
")",
"$",
"uri",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'File %s could not be found'",
",",
"$",
"filename",
")",
")",
";",
"}",
"$",
"xml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"$",
"filename",
",",
"0",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"strategies",
"as",
"$",
"strategy",
")",
"{",
"if",
"(",
"$",
"strategy",
"->",
"supports",
"(",
"$",
"xml",
")",
"!==",
"true",
")",
"{",
"continue",
";",
"}",
"return",
"new",
"Configuration",
"(",
"$",
"this",
"->",
"applyMiddleware",
"(",
"$",
"strategy",
"->",
"convert",
"(",
"$",
"xml",
")",
")",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"'No supported configuration files were found'",
")",
";",
"}"
] | Converts the phpDocumentor configuration xml to an array.
@param Uri $uri The location of the file to be loaded.
@return Configuration
@throws RuntimeException if no matching strategy can be found. | [
"Converts",
"the",
"phpDocumentor",
"configuration",
"xml",
"to",
"an",
"array",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/ConfigurationFactory.php#L96-L114 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Configuration/ConfigurationFactory.php | ConfigurationFactory.applyMiddleware | private function applyMiddleware(array $configuration): array
{
foreach ($this->middlewares as $middleware) {
$configuration = $middleware($configuration);
}
return $configuration;
} | php | private function applyMiddleware(array $configuration): array
{
foreach ($this->middlewares as $middleware) {
$configuration = $middleware($configuration);
}
return $configuration;
} | [
"private",
"function",
"applyMiddleware",
"(",
"array",
"$",
"configuration",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"this",
"->",
"middlewares",
"as",
"$",
"middleware",
")",
"{",
"$",
"configuration",
"=",
"$",
"middleware",
"(",
"$",
"configuration",
")",
";",
"}",
"return",
"$",
"configuration",
";",
"}"
] | Applies all middleware callbacks onto the configuration.
@param array $configuration
@return array | [
"Applies",
"all",
"middleware",
"callbacks",
"onto",
"the",
"configuration",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/ConfigurationFactory.php#L133-L140 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php | FileAssembler.addClasses | protected function addClasses(array $classes, FileDescriptor $fileDescriptor): void
{
foreach ($classes as $class) {
$classDescriptor = $this->getBuilder()->buildDescriptor($class);
if ($classDescriptor) {
$classDescriptor->setLocation($fileDescriptor, $class->getLocation()->getLineNumber());
if (count($classDescriptor->getTags()->get('package', new Collection())) === 0) {
$classDescriptor->getTags()->set(
'package',
$fileDescriptor->getTags()->get('package', new Collection())
);
}
$fileDescriptor->getClasses()->set(
(string) ($classDescriptor->getFullyQualifiedStructuralElementName()),
$classDescriptor
);
}
}
} | php | protected function addClasses(array $classes, FileDescriptor $fileDescriptor): void
{
foreach ($classes as $class) {
$classDescriptor = $this->getBuilder()->buildDescriptor($class);
if ($classDescriptor) {
$classDescriptor->setLocation($fileDescriptor, $class->getLocation()->getLineNumber());
if (count($classDescriptor->getTags()->get('package', new Collection())) === 0) {
$classDescriptor->getTags()->set(
'package',
$fileDescriptor->getTags()->get('package', new Collection())
);
}
$fileDescriptor->getClasses()->set(
(string) ($classDescriptor->getFullyQualifiedStructuralElementName()),
$classDescriptor
);
}
}
} | [
"protected",
"function",
"addClasses",
"(",
"array",
"$",
"classes",
",",
"FileDescriptor",
"$",
"fileDescriptor",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"$",
"classDescriptor",
"=",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"buildDescriptor",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"classDescriptor",
")",
"{",
"$",
"classDescriptor",
"->",
"setLocation",
"(",
"$",
"fileDescriptor",
",",
"$",
"class",
"->",
"getLocation",
"(",
")",
"->",
"getLineNumber",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"classDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
"===",
"0",
")",
"{",
"$",
"classDescriptor",
"->",
"getTags",
"(",
")",
"->",
"set",
"(",
"'package'",
",",
"$",
"fileDescriptor",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'package'",
",",
"new",
"Collection",
"(",
")",
")",
")",
";",
"}",
"$",
"fileDescriptor",
"->",
"getClasses",
"(",
")",
"->",
"set",
"(",
"(",
"string",
")",
"(",
"$",
"classDescriptor",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
")",
",",
"$",
"classDescriptor",
")",
";",
"}",
"}",
"}"
] | Registers the child classes with the generated File Descriptor.
@param Class_[] $classes | [
"Registers",
"the",
"child",
"classes",
"with",
"the",
"generated",
"File",
"Descriptor",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L122-L141 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/ProjectDescriptor.php | ProjectDescriptor.isVisibilityAllowed | public function isVisibilityAllowed($visibility)
{
$visibilityAllowed = $this->getSettings()
? $this->getSettings()->getVisibility()
: Settings::VISIBILITY_DEFAULT;
return (bool) ($visibilityAllowed & $visibility);
} | php | public function isVisibilityAllowed($visibility)
{
$visibilityAllowed = $this->getSettings()
? $this->getSettings()->getVisibility()
: Settings::VISIBILITY_DEFAULT;
return (bool) ($visibilityAllowed & $visibility);
} | [
"public",
"function",
"isVisibilityAllowed",
"(",
"$",
"visibility",
")",
"{",
"$",
"visibilityAllowed",
"=",
"$",
"this",
"->",
"getSettings",
"(",
")",
"?",
"$",
"this",
"->",
"getSettings",
"(",
")",
"->",
"getVisibility",
"(",
")",
":",
"Settings",
"::",
"VISIBILITY_DEFAULT",
";",
"return",
"(",
"bool",
")",
"(",
"$",
"visibilityAllowed",
"&",
"$",
"visibility",
")",
";",
"}"
] | Checks whether the Project supports the given visibility.
@param integer $visibility One of the VISIBILITY_* constants of the Settings class.
@see Settings for a list of the available VISIBILITY_* constants.
@return boolean | [
"Checks",
"whether",
"the",
"Project",
"supports",
"the",
"given",
"visibility",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptor.php#L198-L205 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Scrybe/Converter/Definition/Factory.php | Factory.get | public function get($input_format, $output_format)
{
return new Definition(
$this->format_collection[$input_format],
$this->format_collection[$output_format]
);
} | php | public function get($input_format, $output_format)
{
return new Definition(
$this->format_collection[$input_format],
$this->format_collection[$output_format]
);
} | [
"public",
"function",
"get",
"(",
"$",
"input_format",
",",
"$",
"output_format",
")",
"{",
"return",
"new",
"Definition",
"(",
"$",
"this",
"->",
"format_collection",
"[",
"$",
"input_format",
"]",
",",
"$",
"this",
"->",
"format_collection",
"[",
"$",
"output_format",
"]",
")",
";",
"}"
] | Creates a definition of the given input and output formats.
@param string $input_format
@param string $output_format
@return Definition | [
"Creates",
"a",
"definition",
"of",
"the",
"given",
"input",
"and",
"output",
"formats",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Definition/Factory.php#L44-L50 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/ConstantDescriptor.php | ConstantDescriptor.setParent | public function setParent($parent)
{
if (!$parent instanceof ClassDescriptor && !$parent instanceof InterfaceDescriptor && $parent !== null) {
throw new \InvalidArgumentException('Constants can only have an interface or class as parent');
}
$fqsen = $parent !== null
? $parent->getFullyQualifiedStructuralElementName() . '::' . $this->getName()
: $this->getName();
$this->setFullyQualifiedStructuralElementName($fqsen);
$this->parent = $parent;
} | php | public function setParent($parent)
{
if (!$parent instanceof ClassDescriptor && !$parent instanceof InterfaceDescriptor && $parent !== null) {
throw new \InvalidArgumentException('Constants can only have an interface or class as parent');
}
$fqsen = $parent !== null
? $parent->getFullyQualifiedStructuralElementName() . '::' . $this->getName()
: $this->getName();
$this->setFullyQualifiedStructuralElementName($fqsen);
$this->parent = $parent;
} | [
"public",
"function",
"setParent",
"(",
"$",
"parent",
")",
"{",
"if",
"(",
"!",
"$",
"parent",
"instanceof",
"ClassDescriptor",
"&&",
"!",
"$",
"parent",
"instanceof",
"InterfaceDescriptor",
"&&",
"$",
"parent",
"!==",
"null",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Constants can only have an interface or class as parent'",
")",
";",
"}",
"$",
"fqsen",
"=",
"$",
"parent",
"!==",
"null",
"?",
"$",
"parent",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
".",
"'::'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
":",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"setFullyQualifiedStructuralElementName",
"(",
"$",
"fqsen",
")",
";",
"$",
"this",
"->",
"parent",
"=",
"$",
"parent",
";",
"}"
] | Registers a parent class or interface with this constant.
@param ClassDescriptor|InterfaceDescriptor|null $parent
@throws \InvalidArgumentException if anything other than a class, interface or null was passed. | [
"Registers",
"a",
"parent",
"class",
"or",
"interface",
"with",
"this",
"constant",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ConstantDescriptor.php#L42-L55 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php | AssemblerFactory.register | public function register(callable $matcher, AssemblerInterface $assembler): void
{
$this->assemblers[] = new AssemblerMatcher($matcher, $assembler);
} | php | public function register(callable $matcher, AssemblerInterface $assembler): void
{
$this->assemblers[] = new AssemblerMatcher($matcher, $assembler);
} | [
"public",
"function",
"register",
"(",
"callable",
"$",
"matcher",
",",
"AssemblerInterface",
"$",
"assembler",
")",
":",
"void",
"{",
"$",
"this",
"->",
"assemblers",
"[",
"]",
"=",
"new",
"AssemblerMatcher",
"(",
"$",
"matcher",
",",
"$",
"assembler",
")",
";",
"}"
] | Registers an assembler instance to this factory.
@param callable $matcher A callback function accepting the criteria as only parameter and which must
return a boolean.
@param AssemblerInterface $assembler An instance of the Assembler that will be returned if the callback returns
true with the provided criteria. | [
"Registers",
"an",
"assembler",
"instance",
"to",
"this",
"factory",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php#L89-L92 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php | AssemblerFactory.registerFallback | public function registerFallback(callable $matcher, AssemblerInterface $assembler): void
{
$this->fallbackAssemblers[] = new AssemblerMatcher($matcher, $assembler);
} | php | public function registerFallback(callable $matcher, AssemblerInterface $assembler): void
{
$this->fallbackAssemblers[] = new AssemblerMatcher($matcher, $assembler);
} | [
"public",
"function",
"registerFallback",
"(",
"callable",
"$",
"matcher",
",",
"AssemblerInterface",
"$",
"assembler",
")",
":",
"void",
"{",
"$",
"this",
"->",
"fallbackAssemblers",
"[",
"]",
"=",
"new",
"AssemblerMatcher",
"(",
"$",
"matcher",
",",
"$",
"assembler",
")",
";",
"}"
] | Registers an assembler instance to this factory that is to be executed after all other assemblers have been
checked.
@param callable $matcher A callback function accepting the criteria as only parameter and which must
return a boolean.
@param AssemblerInterface $assembler An instance of the Assembler that will be returned if the callback returns
true with the provided criteria. | [
"Registers",
"an",
"assembler",
"instance",
"to",
"this",
"factory",
"that",
"is",
"to",
"be",
"executed",
"after",
"all",
"other",
"assemblers",
"have",
"been",
"checked",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php#L103-L106 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php | MethodAssembler.addVariadicArgument | protected function addVariadicArgument(Method $data, MethodDescriptor $methodDescriptor): void
{
if (!$data->getDocBlock()) {
return;
}
$paramTags = $data->getDocBlock()->getTagsByName('param');
/** @var Param $lastParamTag */
$lastParamTag = end($paramTags);
if (!$lastParamTag) {
return;
}
if ($lastParamTag->isVariadic()
&& array_key_exists($lastParamTag->getVariableName(), $methodDescriptor->getArguments()->getAll())
) {
$types = $lastParamTag->getType();
$argument = new ArgumentDescriptor();
$argument->setName($lastParamTag->getVariableName());
$argument->setType($types);
$argument->setDescription($lastParamTag->getDescription());
$argument->setLine($methodDescriptor->getLine());
$argument->setVariadic(true);
$methodDescriptor->getArguments()->set($argument->getName(), $argument);
}
} | php | protected function addVariadicArgument(Method $data, MethodDescriptor $methodDescriptor): void
{
if (!$data->getDocBlock()) {
return;
}
$paramTags = $data->getDocBlock()->getTagsByName('param');
/** @var Param $lastParamTag */
$lastParamTag = end($paramTags);
if (!$lastParamTag) {
return;
}
if ($lastParamTag->isVariadic()
&& array_key_exists($lastParamTag->getVariableName(), $methodDescriptor->getArguments()->getAll())
) {
$types = $lastParamTag->getType();
$argument = new ArgumentDescriptor();
$argument->setName($lastParamTag->getVariableName());
$argument->setType($types);
$argument->setDescription($lastParamTag->getDescription());
$argument->setLine($methodDescriptor->getLine());
$argument->setVariadic(true);
$methodDescriptor->getArguments()->set($argument->getName(), $argument);
}
} | [
"protected",
"function",
"addVariadicArgument",
"(",
"Method",
"$",
"data",
",",
"MethodDescriptor",
"$",
"methodDescriptor",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"paramTags",
"=",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
"->",
"getTagsByName",
"(",
"'param'",
")",
";",
"/** @var Param $lastParamTag */",
"$",
"lastParamTag",
"=",
"end",
"(",
"$",
"paramTags",
")",
";",
"if",
"(",
"!",
"$",
"lastParamTag",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"lastParamTag",
"->",
"isVariadic",
"(",
")",
"&&",
"array_key_exists",
"(",
"$",
"lastParamTag",
"->",
"getVariableName",
"(",
")",
",",
"$",
"methodDescriptor",
"->",
"getArguments",
"(",
")",
"->",
"getAll",
"(",
")",
")",
")",
"{",
"$",
"types",
"=",
"$",
"lastParamTag",
"->",
"getType",
"(",
")",
";",
"$",
"argument",
"=",
"new",
"ArgumentDescriptor",
"(",
")",
";",
"$",
"argument",
"->",
"setName",
"(",
"$",
"lastParamTag",
"->",
"getVariableName",
"(",
")",
")",
";",
"$",
"argument",
"->",
"setType",
"(",
"$",
"types",
")",
";",
"$",
"argument",
"->",
"setDescription",
"(",
"$",
"lastParamTag",
"->",
"getDescription",
"(",
")",
")",
";",
"$",
"argument",
"->",
"setLine",
"(",
"$",
"methodDescriptor",
"->",
"getLine",
"(",
")",
")",
";",
"$",
"argument",
"->",
"setVariadic",
"(",
"true",
")",
";",
"$",
"methodDescriptor",
"->",
"getArguments",
"(",
")",
"->",
"set",
"(",
"$",
"argument",
"->",
"getName",
"(",
")",
",",
"$",
"argument",
")",
";",
"}",
"}"
] | Checks if there is a variadic argument in the `@param` tags and adds it to the list of Arguments in
the Descriptor unless there is already one present. | [
"Checks",
"if",
"there",
"is",
"a",
"variadic",
"argument",
"in",
"the"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L111-L139 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Transformer/Writer/Collection.php | Collection.offsetSet | public function offsetSet($index, $newval)
{
if (!$newval instanceof WriterAbstract) {
throw new \InvalidArgumentException(
'The Writer Collection may only contain objects descending from WriterAbstract'
);
}
if (!preg_match('/^[a-zA-Z0-9\-\_\/]{3,}$/', $index)) {
throw new \InvalidArgumentException(
'The name of a Writer may only contain alphanumeric characters, one or more hyphens, underscores and '
. 'forward slashes and must be at least three characters wide'
);
}
// if the writer supports routes, provide them with the router queue
if ($newval instanceof Routable) {
$newval->setRouters($this->routers);
}
parent::offsetSet($index, $newval);
} | php | public function offsetSet($index, $newval)
{
if (!$newval instanceof WriterAbstract) {
throw new \InvalidArgumentException(
'The Writer Collection may only contain objects descending from WriterAbstract'
);
}
if (!preg_match('/^[a-zA-Z0-9\-\_\/]{3,}$/', $index)) {
throw new \InvalidArgumentException(
'The name of a Writer may only contain alphanumeric characters, one or more hyphens, underscores and '
. 'forward slashes and must be at least three characters wide'
);
}
// if the writer supports routes, provide them with the router queue
if ($newval instanceof Routable) {
$newval->setRouters($this->routers);
}
parent::offsetSet($index, $newval);
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"index",
",",
"$",
"newval",
")",
"{",
"if",
"(",
"!",
"$",
"newval",
"instanceof",
"WriterAbstract",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The Writer Collection may only contain objects descending from WriterAbstract'",
")",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-zA-Z0-9\\-\\_\\/]{3,}$/'",
",",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The name of a Writer may only contain alphanumeric characters, one or more hyphens, underscores and '",
".",
"'forward slashes and must be at least three characters wide'",
")",
";",
"}",
"// if the writer supports routes, provide them with the router queue",
"if",
"(",
"$",
"newval",
"instanceof",
"Routable",
")",
"{",
"$",
"newval",
"->",
"setRouters",
"(",
"$",
"this",
"->",
"routers",
")",
";",
"}",
"parent",
"::",
"offsetSet",
"(",
"$",
"index",
",",
"$",
"newval",
")",
";",
"}"
] | Registers a writer with a given name.
@param string $index a Writer's name, must be at least 3
characters, alphanumeric and/or contain one or more hyphens,
underscores and forward slashes.
@param WriterAbstract $newval The Writer object to register to this name.
@throws \InvalidArgumentException if either of the above restrictions is
not met. | [
"Registers",
"a",
"writer",
"with",
"a",
"given",
"name",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Writer/Collection.php#L56-L77 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Transformer/Writer/Collection.php | Collection.offsetGet | public function offsetGet($index)
{
if (!$this->offsetExists($index)) {
throw new \InvalidArgumentException('Writer "' . $index . '" does not exist');
}
return parent::offsetGet($index);
} | php | public function offsetGet($index)
{
if (!$this->offsetExists($index)) {
throw new \InvalidArgumentException('Writer "' . $index . '" does not exist');
}
return parent::offsetGet($index);
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Writer \"'",
".",
"$",
"index",
".",
"'\" does not exist'",
")",
";",
"}",
"return",
"parent",
"::",
"offsetGet",
"(",
"$",
"index",
")",
";",
"}"
] | Retrieves a writer from the collection.
@param string $index the name of the writer to retrieve.
@throws \InvalidArgumentException if the writer is not in the collection.
@return WriterAbstract | [
"Retrieves",
"a",
"writer",
"from",
"the",
"collection",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Writer/Collection.php#L88-L95 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Document.php | Document.logStats | public function logStats($fatal, Logger $logger)
{
if (!$this->getErrors() && !$fatal) {
return;
}
/** @var \Exception $error */
foreach ($this->getErrors() as $error) {
$logger->warning(' ' . $error->getMessage());
}
if ($fatal) {
$logger->error(' ' . $fatal->getMessage());
}
} | php | public function logStats($fatal, Logger $logger)
{
if (!$this->getErrors() && !$fatal) {
return;
}
/** @var \Exception $error */
foreach ($this->getErrors() as $error) {
$logger->warning(' ' . $error->getMessage());
}
if ($fatal) {
$logger->error(' ' . $fatal->getMessage());
}
} | [
"public",
"function",
"logStats",
"(",
"$",
"fatal",
",",
"Logger",
"$",
"logger",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getErrors",
"(",
")",
"&&",
"!",
"$",
"fatal",
")",
"{",
"return",
";",
"}",
"/** @var \\Exception $error */",
"foreach",
"(",
"$",
"this",
"->",
"getErrors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"logger",
"->",
"warning",
"(",
"' '",
".",
"$",
"error",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"fatal",
")",
"{",
"$",
"logger",
"->",
"error",
"(",
"' '",
".",
"$",
"fatal",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Sends the errors of the given Rst document to the logger as a block.
If a fatal error occurred then this can be passed as the $fatal argument and is shown as such.
@param \Exception|null $fatal | [
"Sends",
"the",
"errors",
"of",
"the",
"given",
"Rst",
"document",
"to",
"the",
"logger",
"as",
"a",
"block",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Document.php#L114-L128 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php | Statistics.appendPhpdocStatsElement | protected function appendPhpdocStatsElement(\DOMDocument $document)
{
$stats = $document->createElement('phpdoc-stats');
$stats->setAttribute('version', Application::VERSION());
$document->appendChild($stats);
return $document;
} | php | protected function appendPhpdocStatsElement(\DOMDocument $document)
{
$stats = $document->createElement('phpdoc-stats');
$stats->setAttribute('version', Application::VERSION());
$document->appendChild($stats);
return $document;
} | [
"protected",
"function",
"appendPhpdocStatsElement",
"(",
"\\",
"DOMDocument",
"$",
"document",
")",
"{",
"$",
"stats",
"=",
"$",
"document",
"->",
"createElement",
"(",
"'phpdoc-stats'",
")",
";",
"$",
"stats",
"->",
"setAttribute",
"(",
"'version'",
",",
"Application",
"::",
"VERSION",
"(",
")",
")",
";",
"$",
"document",
"->",
"appendChild",
"(",
"$",
"stats",
")",
";",
"return",
"$",
"document",
";",
"}"
] | Append phpdoc-stats element to the document.
@return \DOMDocument | [
"Append",
"phpdoc",
"-",
"stats",
"element",
"to",
"the",
"document",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L78-L85 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php | Statistics.appendStatElement | protected function appendStatElement(\DOMDocument $document, ProjectDescriptor $project, $date)
{
$stat = $document->createDocumentFragment();
$stat->appendXML(
<<<STAT
<stat date="${date}">
<counters>
<files>{$this->getFilesCounter($project)}</files>
<deprecated>{$this->getDeprecatedCounter($project)}</deprecated>
<errors>{$this->getErrorCounter($project)}</errors>
<markers>{$this->getMarkerCounter($project)}</markers>
</counters>
</stat>
STAT
);
$document->documentElement->appendChild($stat);
return $document;
} | php | protected function appendStatElement(\DOMDocument $document, ProjectDescriptor $project, $date)
{
$stat = $document->createDocumentFragment();
$stat->appendXML(
<<<STAT
<stat date="${date}">
<counters>
<files>{$this->getFilesCounter($project)}</files>
<deprecated>{$this->getDeprecatedCounter($project)}</deprecated>
<errors>{$this->getErrorCounter($project)}</errors>
<markers>{$this->getMarkerCounter($project)}</markers>
</counters>
</stat>
STAT
);
$document->documentElement->appendChild($stat);
return $document;
} | [
"protected",
"function",
"appendStatElement",
"(",
"\\",
"DOMDocument",
"$",
"document",
",",
"ProjectDescriptor",
"$",
"project",
",",
"$",
"date",
")",
"{",
"$",
"stat",
"=",
"$",
"document",
"->",
"createDocumentFragment",
"(",
")",
";",
"$",
"stat",
"->",
"appendXML",
"(",
"\n <<<STAT\n<stat date=\"${date}\">\n <counters>\n <files>{$this->getFilesCounter($project)}</files>\n <deprecated>{$this->getDeprecatedCounter($project)}</deprecated>\n <errors>{$this->getErrorCounter($project)}</errors>\n <markers>{$this->getMarkerCounter($project)}</markers>\n </counters>\n</stat>\nSTAT",
")",
";",
"$",
"document",
"->",
"documentElement",
"->",
"appendChild",
"(",
"$",
"stat",
")",
";",
"return",
"$",
"document",
";",
"}"
] | Appends a stat fragment.
@param string $date
@return \DOMDocument | [
"Appends",
"a",
"stat",
"fragment",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L93-L111 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php | Statistics.getErrorCounter | protected function getErrorCounter(ProjectDescriptor $project)
{
$errorCounter = 0;
/* @var FileDescriptor $fileDescriptor */
foreach ($project->getFiles()->getAll() as $fileDescriptor) {
$errorCounter += count($fileDescriptor->getAllErrors()->getAll());
}
return $errorCounter;
} | php | protected function getErrorCounter(ProjectDescriptor $project)
{
$errorCounter = 0;
/* @var FileDescriptor $fileDescriptor */
foreach ($project->getFiles()->getAll() as $fileDescriptor) {
$errorCounter += count($fileDescriptor->getAllErrors()->getAll());
}
return $errorCounter;
} | [
"protected",
"function",
"getErrorCounter",
"(",
"ProjectDescriptor",
"$",
"project",
")",
"{",
"$",
"errorCounter",
"=",
"0",
";",
"/* @var FileDescriptor $fileDescriptor */",
"foreach",
"(",
"$",
"project",
"->",
"getFiles",
"(",
")",
"->",
"getAll",
"(",
")",
"as",
"$",
"fileDescriptor",
")",
"{",
"$",
"errorCounter",
"+=",
"count",
"(",
"$",
"fileDescriptor",
"->",
"getAllErrors",
"(",
")",
"->",
"getAll",
"(",
")",
")",
";",
"}",
"return",
"$",
"errorCounter",
";",
"}"
] | Get number of errors.
@return int | [
"Get",
"number",
"of",
"errors",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L147-L157 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php | Statistics.getMarkerCounter | protected function getMarkerCounter(ProjectDescriptor $project)
{
$markerCounter = 0;
/* @var $fileDescriptor FileDescriptor */
foreach ($project->getFiles()->getAll() as $fileDescriptor) {
$markerCounter += $fileDescriptor->getMarkers()->count();
}
return $markerCounter;
} | php | protected function getMarkerCounter(ProjectDescriptor $project)
{
$markerCounter = 0;
/* @var $fileDescriptor FileDescriptor */
foreach ($project->getFiles()->getAll() as $fileDescriptor) {
$markerCounter += $fileDescriptor->getMarkers()->count();
}
return $markerCounter;
} | [
"protected",
"function",
"getMarkerCounter",
"(",
"ProjectDescriptor",
"$",
"project",
")",
"{",
"$",
"markerCounter",
"=",
"0",
";",
"/* @var $fileDescriptor FileDescriptor */",
"foreach",
"(",
"$",
"project",
"->",
"getFiles",
"(",
")",
"->",
"getAll",
"(",
")",
"as",
"$",
"fileDescriptor",
")",
"{",
"$",
"markerCounter",
"+=",
"$",
"fileDescriptor",
"->",
"getMarkers",
"(",
")",
"->",
"count",
"(",
")",
";",
"}",
"return",
"$",
"markerCounter",
";",
"}"
] | Get number of markers.
@return int | [
"Get",
"number",
"of",
"markers",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L164-L174 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/PropertyConverter.php | PropertyConverter.convert | public function convert(\DOMElement $parent, PropertyDescriptor $property)
{
$fullyQualifiedNamespaceName = $property->getNamespace() instanceof NamespaceDescriptor
? $property->getNamespace()->getFullyQualifiedStructuralElementName()
: $parent->getAttribute('namespace');
$child = new \DOMElement('property');
$parent->appendChild($child);
$child->setAttribute('static', var_export($property->isStatic(), true));
$child->setAttribute('visibility', $property->getVisibility());
$child->setAttribute('namespace', $fullyQualifiedNamespaceName);
$child->setAttribute('line', (string) $property->getLine());
$child->appendChild(new \DOMElement('name', '$' . $property->getName()));
$child->appendChild(new \DOMElement('full_name', (string) $property->getFullyQualifiedStructuralElementName()));
$child->appendChild(new \DOMElement('default'))->appendChild(new \DOMText((string) $property->getDefault()));
$this->docBlockConverter->convert($child, $property);
return $child;
} | php | public function convert(\DOMElement $parent, PropertyDescriptor $property)
{
$fullyQualifiedNamespaceName = $property->getNamespace() instanceof NamespaceDescriptor
? $property->getNamespace()->getFullyQualifiedStructuralElementName()
: $parent->getAttribute('namespace');
$child = new \DOMElement('property');
$parent->appendChild($child);
$child->setAttribute('static', var_export($property->isStatic(), true));
$child->setAttribute('visibility', $property->getVisibility());
$child->setAttribute('namespace', $fullyQualifiedNamespaceName);
$child->setAttribute('line', (string) $property->getLine());
$child->appendChild(new \DOMElement('name', '$' . $property->getName()));
$child->appendChild(new \DOMElement('full_name', (string) $property->getFullyQualifiedStructuralElementName()));
$child->appendChild(new \DOMElement('default'))->appendChild(new \DOMText((string) $property->getDefault()));
$this->docBlockConverter->convert($child, $property);
return $child;
} | [
"public",
"function",
"convert",
"(",
"\\",
"DOMElement",
"$",
"parent",
",",
"PropertyDescriptor",
"$",
"property",
")",
"{",
"$",
"fullyQualifiedNamespaceName",
"=",
"$",
"property",
"->",
"getNamespace",
"(",
")",
"instanceof",
"NamespaceDescriptor",
"?",
"$",
"property",
"->",
"getNamespace",
"(",
")",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
":",
"$",
"parent",
"->",
"getAttribute",
"(",
"'namespace'",
")",
";",
"$",
"child",
"=",
"new",
"\\",
"DOMElement",
"(",
"'property'",
")",
";",
"$",
"parent",
"->",
"appendChild",
"(",
"$",
"child",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'static'",
",",
"var_export",
"(",
"$",
"property",
"->",
"isStatic",
"(",
")",
",",
"true",
")",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'visibility'",
",",
"$",
"property",
"->",
"getVisibility",
"(",
")",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'namespace'",
",",
"$",
"fullyQualifiedNamespaceName",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'line'",
",",
"(",
"string",
")",
"$",
"property",
"->",
"getLine",
"(",
")",
")",
";",
"$",
"child",
"->",
"appendChild",
"(",
"new",
"\\",
"DOMElement",
"(",
"'name'",
",",
"'$'",
".",
"$",
"property",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"child",
"->",
"appendChild",
"(",
"new",
"\\",
"DOMElement",
"(",
"'full_name'",
",",
"(",
"string",
")",
"$",
"property",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
")",
")",
";",
"$",
"child",
"->",
"appendChild",
"(",
"new",
"\\",
"DOMElement",
"(",
"'default'",
")",
")",
"->",
"appendChild",
"(",
"new",
"\\",
"DOMText",
"(",
"(",
"string",
")",
"$",
"property",
"->",
"getDefault",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"docBlockConverter",
"->",
"convert",
"(",
"$",
"child",
",",
"$",
"property",
")",
";",
"return",
"$",
"child",
";",
"}"
] | Export the given reflected property definition to the provided parent element.
@param \DOMElement $parent Element to augment.
@param PropertyDescriptor $property Element to export.
@return \DOMElement | [
"Export",
"the",
"given",
"reflected",
"property",
"definition",
"to",
"the",
"provided",
"parent",
"element",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/PropertyConverter.php#L47-L68 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php | Xsl.setProcessorParameters | public function setProcessorParameters(TransformationObject $transformation, $proc)
{
foreach ($this->xsl_variables as $key => $variable) {
// XSL does not allow both single and double quotes in a string
if ((strpos($variable, '"') !== false)
&& ((strpos($variable, "'") !== false))
) {
$this->logger->warning(
'XSLT does not allow both double and single quotes in '
. 'a variable; transforming single quotes to a character '
. 'encoded version in variable: ' . $key
);
$variable = str_replace("'", ''', $variable);
}
$proc->setParameter('', $key, $variable);
}
// add / overwrite the parameters with those defined in the
// transformation entry
$parameters = $transformation->getParameters();
if (isset($parameters['variables'])) {
/** @var \DOMElement $variable */
foreach ($parameters['variables'] as $key => $value) {
$proc->setParameter('', $key, $value);
}
}
} | php | public function setProcessorParameters(TransformationObject $transformation, $proc)
{
foreach ($this->xsl_variables as $key => $variable) {
// XSL does not allow both single and double quotes in a string
if ((strpos($variable, '"') !== false)
&& ((strpos($variable, "'") !== false))
) {
$this->logger->warning(
'XSLT does not allow both double and single quotes in '
. 'a variable; transforming single quotes to a character '
. 'encoded version in variable: ' . $key
);
$variable = str_replace("'", ''', $variable);
}
$proc->setParameter('', $key, $variable);
}
// add / overwrite the parameters with those defined in the
// transformation entry
$parameters = $transformation->getParameters();
if (isset($parameters['variables'])) {
/** @var \DOMElement $variable */
foreach ($parameters['variables'] as $key => $value) {
$proc->setParameter('', $key, $value);
}
}
} | [
"public",
"function",
"setProcessorParameters",
"(",
"TransformationObject",
"$",
"transformation",
",",
"$",
"proc",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xsl_variables",
"as",
"$",
"key",
"=>",
"$",
"variable",
")",
"{",
"// XSL does not allow both single and double quotes in a string",
"if",
"(",
"(",
"strpos",
"(",
"$",
"variable",
",",
"'\"'",
")",
"!==",
"false",
")",
"&&",
"(",
"(",
"strpos",
"(",
"$",
"variable",
",",
"\"'\"",
")",
"!==",
"false",
")",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"'XSLT does not allow both double and single quotes in '",
".",
"'a variable; transforming single quotes to a character '",
".",
"'encoded version in variable: '",
".",
"$",
"key",
")",
";",
"$",
"variable",
"=",
"str_replace",
"(",
"\"'\"",
",",
"'''",
",",
"$",
"variable",
")",
";",
"}",
"$",
"proc",
"->",
"setParameter",
"(",
"''",
",",
"$",
"key",
",",
"$",
"variable",
")",
";",
"}",
"// add / overwrite the parameters with those defined in the",
"// transformation entry",
"$",
"parameters",
"=",
"$",
"transformation",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"'variables'",
"]",
")",
")",
"{",
"/** @var \\DOMElement $variable */",
"foreach",
"(",
"$",
"parameters",
"[",
"'variables'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"proc",
"->",
"setParameter",
"(",
"''",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"}"
] | Sets the parameters of the XSLT processor.
@param XSLTProcessor $proc XSLTProcessor. | [
"Sets",
"the",
"parameters",
"of",
"the",
"XSLT",
"processor",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php#L184-L211 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php#L304-L309 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptor/Settings.php#L88-L95 | train |
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);
/** @var Transformation $transformation */
foreach ($template as $transformation) {
/** @var WriterAbstract $writer */
$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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Collection.php#L49-L63 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Collection.php#L70-L80 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Filter/StripOnVisibility.php#L46-L55 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/ClassAssembler.php#L74-L83 | train |
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",
".."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Example/Finder.php#L129-L132 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Example/Finder.php#L137-L145 | train |
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)
{
/** @var RouterAbstract $router */
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/Queue.php#L32-L43 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php#L104-L115 | train |
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()
{
/** @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;
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Factory.php#L64-L84 | train |
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)
{
/** @var Template $template */
$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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template/Factory.php#L115-L122 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Parser/Parser.php#L299-L308 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Parser/Parser.php#L313-L323 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php#L57-L66 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php#L76-L86 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/LegacyNamespaceConverter/LegacyNamespaceFilter.php#L95-L103 | train |
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
{
/** @var Collection|DescriptorAbstract[] $elementCollection */
$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"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L69-L77 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L192-L202 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L210-L221 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptorBuilder.php#L86-L104 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Event/Dispatcher.php#L47-L54 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Event/Dispatcher.php#L59-L62 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L108-L131 | train |
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,
// 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;
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L136-L167 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L172-L184 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L317-L322 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/MethodConverter.php#L52-L78 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/FileDescriptor.php#L281-L332 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php#L59-L105 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php#L160-L166 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/BaseConvertCommand.php#L173-L176 | train |
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 {
// 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);
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Discover.php#L75-L104 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Discover.php#L115-L119 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php#L64-L73 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template.php#L136-L146 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template.php#L183-L193 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Template.php#L269-L274 | train |
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();
/** @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
);
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Factory.php#L71-L94 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Factory.php#L103-L114 | train |
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
{
// 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;
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Transformation.php#L161-L204 | train |
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;
}
// 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();
}
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php#L75-L104 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Figure.php#L42-L46 | train |
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();
// 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);
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Figure.php#L81-L104 | train |
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(
'~//[\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));
}
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ResolveInlineMarkers.php#L34-L58 | train |
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"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L98-L122 | train |
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)
{
// 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);
} | [
"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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L398-L428 | train |
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"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L483-L490 | train |
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/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);
} | [
"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"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L501-L515 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Command/Manual/ToLatexCommand.php#L95-L109 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Infrastructure/Parser/SpecificationFactory.php#L36-L58 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L100-L130 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L135-L161 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L166-L175 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/Factory/Version3.php#L261-L280 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Collection.php#L72-L79 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Collection.php#L163-L170 | train |
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",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Metadata/Assets.php#L83-L101 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/Filter/StripInternal.php | StripInternal.filter | public function filter($value)
{
$isInternalAllowed = $this->builder->isVisibilityAllowed(Settings::VISIBILITY_INTERNAL);
if ($isInternalAllowed) {
$value->setDescription(preg_replace('/\{@internal\s(.+?)\}\}/', '$1', $value->getDescription()));
return $value;
}
// remove inline @internal tags
$value->setDescription(preg_replace('/\{@internal\s(.+?)\}\}/', '', $value->getDescription()));
// if internal elements are not allowed; filter this element
if ($value->getTags()->get('internal')) {
return null;
}
return $value;
} | php | public function filter($value)
{
$isInternalAllowed = $this->builder->isVisibilityAllowed(Settings::VISIBILITY_INTERNAL);
if ($isInternalAllowed) {
$value->setDescription(preg_replace('/\{@internal\s(.+?)\}\}/', '$1', $value->getDescription()));
return $value;
}
// remove inline @internal tags
$value->setDescription(preg_replace('/\{@internal\s(.+?)\}\}/', '', $value->getDescription()));
// if internal elements are not allowed; filter this element
if ($value->getTags()->get('internal')) {
return null;
}
return $value;
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"$",
"isInternalAllowed",
"=",
"$",
"this",
"->",
"builder",
"->",
"isVisibilityAllowed",
"(",
"Settings",
"::",
"VISIBILITY_INTERNAL",
")",
";",
"if",
"(",
"$",
"isInternalAllowed",
")",
"{",
"$",
"value",
"->",
"setDescription",
"(",
"preg_replace",
"(",
"'/\\{@internal\\s(.+?)\\}\\}/'",
",",
"'$1'",
",",
"$",
"value",
"->",
"getDescription",
"(",
")",
")",
")",
";",
"return",
"$",
"value",
";",
"}",
"// remove inline @internal tags",
"$",
"value",
"->",
"setDescription",
"(",
"preg_replace",
"(",
"'/\\{@internal\\s(.+?)\\}\\}/'",
",",
"''",
",",
"$",
"value",
"->",
"getDescription",
"(",
")",
")",
")",
";",
"// if internal elements are not allowed; filter this element",
"if",
"(",
"$",
"value",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"'internal'",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | If the ProjectDescriptor's settings allow internal tags then return the Descriptor, otherwise null to filter it.
@param DescriptorAbstract $value
@return DescriptorAbstract|null | [
"If",
"the",
"ProjectDescriptor",
"s",
"settings",
"allow",
"internal",
"tags",
"then",
"return",
"the",
"Descriptor",
"otherwise",
"null",
"to",
"filter",
"it",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Filter/StripInternal.php#L54-L72 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Creator.php | Creator.getFilename | public function getFilename()
{
/** @var BaseConverter $converter */
$converter = $this->getDocument()->getConverter();
return $converter->getDestinationFilenameRelativeToProjectRoot($this->getDocument()->getFile());
} | php | public function getFilename()
{
/** @var BaseConverter $converter */
$converter = $this->getDocument()->getConverter();
return $converter->getDestinationFilenameRelativeToProjectRoot($this->getDocument()->getFile());
} | [
"public",
"function",
"getFilename",
"(",
")",
"{",
"/** @var BaseConverter $converter */",
"$",
"converter",
"=",
"$",
"this",
"->",
"getDocument",
"(",
")",
"->",
"getConverter",
"(",
")",
";",
"return",
"$",
"converter",
"->",
"getDestinationFilenameRelativeToProjectRoot",
"(",
"$",
"this",
"->",
"getDocument",
"(",
")",
"->",
"getFile",
"(",
")",
")",
";",
"}"
] | Returns the filename for this visitor.
@return string | [
"Returns",
"the",
"filename",
"for",
"this",
"visitor",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Creator.php#L45-L50 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Creator.php | Creator.getFilenameWithoutExtension | public function getFilenameWithoutExtension()
{
$filename = $this->getDocument()->getFile()->getFilename();
return substr($filename, 0, strrpos($filename, '.'));
} | php | public function getFilenameWithoutExtension()
{
$filename = $this->getDocument()->getFile()->getFilename();
return substr($filename, 0, strrpos($filename, '.'));
} | [
"public",
"function",
"getFilenameWithoutExtension",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getDocument",
"(",
")",
"->",
"getFile",
"(",
")",
"->",
"getFilename",
"(",
")",
";",
"return",
"substr",
"(",
"$",
"filename",
",",
"0",
",",
"strrpos",
"(",
"$",
"filename",
",",
"'.'",
")",
")",
";",
"}"
] | Returns the filename for this visitor without an extension.
@return string | [
"Returns",
"the",
"filename",
"for",
"this",
"visitor",
"without",
"an",
"extension",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Visitors/Creator.php#L57-L62 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Transformer/Router/Renderer.php | Renderer.convertToRootPath | public function convertToRootPath($relative_path): ?string
{
// get the path to the root directory
$path_parts = explode(DIRECTORY_SEPARATOR, $this->getDestination());
$path_to_root = (count($path_parts) > 1)
? implode('/', array_fill(0, count($path_parts) - 1, '..')) . '/'
: '';
// append the relative path to the root
if (is_string($relative_path) && ($relative_path[0] !== '@')) {
return $path_to_root . ltrim($relative_path, '/');
}
$rule = $this->routers->match($relative_path);
if (!$rule) {
return null;
}
$generatedPath = $rule->generate($relative_path);
return $generatedPath ? $path_to_root . ltrim($generatedPath, '/') : null;
} | php | public function convertToRootPath($relative_path): ?string
{
// get the path to the root directory
$path_parts = explode(DIRECTORY_SEPARATOR, $this->getDestination());
$path_to_root = (count($path_parts) > 1)
? implode('/', array_fill(0, count($path_parts) - 1, '..')) . '/'
: '';
// append the relative path to the root
if (is_string($relative_path) && ($relative_path[0] !== '@')) {
return $path_to_root . ltrim($relative_path, '/');
}
$rule = $this->routers->match($relative_path);
if (!$rule) {
return null;
}
$generatedPath = $rule->generate($relative_path);
return $generatedPath ? $path_to_root . ltrim($generatedPath, '/') : null;
} | [
"public",
"function",
"convertToRootPath",
"(",
"$",
"relative_path",
")",
":",
"?",
"string",
"{",
"// get the path to the root directory",
"$",
"path_parts",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"getDestination",
"(",
")",
")",
";",
"$",
"path_to_root",
"=",
"(",
"count",
"(",
"$",
"path_parts",
")",
">",
"1",
")",
"?",
"implode",
"(",
"'/'",
",",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"path_parts",
")",
"-",
"1",
",",
"'..'",
")",
")",
".",
"'/'",
":",
"''",
";",
"// append the relative path to the root",
"if",
"(",
"is_string",
"(",
"$",
"relative_path",
")",
"&&",
"(",
"$",
"relative_path",
"[",
"0",
"]",
"!==",
"'@'",
")",
")",
"{",
"return",
"$",
"path_to_root",
".",
"ltrim",
"(",
"$",
"relative_path",
",",
"'/'",
")",
";",
"}",
"$",
"rule",
"=",
"$",
"this",
"->",
"routers",
"->",
"match",
"(",
"$",
"relative_path",
")",
";",
"if",
"(",
"!",
"$",
"rule",
")",
"{",
"return",
"null",
";",
"}",
"$",
"generatedPath",
"=",
"$",
"rule",
"->",
"generate",
"(",
"$",
"relative_path",
")",
";",
"return",
"$",
"generatedPath",
"?",
"$",
"path_to_root",
".",
"ltrim",
"(",
"$",
"generatedPath",
",",
"'/'",
")",
":",
"null",
";",
"}"
] | Converts the given path to be relative to the root of the documentation
target directory.
It is not possible to use absolute paths in documentation templates since
they may be used locally, or in a subfolder. As such we need to calculate
the number of levels to go up from the current document's directory and
then append the given path.
For example:
Suppose you are in <root>/classes/my/class.html and you want open
<root>/my/index.html then you provide 'my/index.html' to this method
and it will convert it into ../../my/index.html (<root>/classes/my is
two nesting levels until the root).
This method does not try to normalize or optimize the paths in order to
save on development time and performance, and because it adds no real
value.
@param string $relative_path
@return string|null | [
"Converts",
"the",
"given",
"path",
"to",
"be",
"relative",
"to",
"the",
"root",
"of",
"the",
"documentation",
"target",
"directory",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/Renderer.php#L141-L162 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Transformer/Router/Renderer.php | Renderer.renderASeriesOfLinks | protected function renderASeriesOfLinks($value, $presentation): array
{
if ($value instanceof Collection) {
$value = $value->getAll();
}
$result = [];
foreach ($value as $path) {
$result[] = $this->render($path, $presentation);
}
return $result;
} | php | protected function renderASeriesOfLinks($value, $presentation): array
{
if ($value instanceof Collection) {
$value = $value->getAll();
}
$result = [];
foreach ($value as $path) {
$result[] = $this->render($path, $presentation);
}
return $result;
} | [
"protected",
"function",
"renderASeriesOfLinks",
"(",
"$",
"value",
",",
"$",
"presentation",
")",
":",
"array",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Collection",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"getAll",
"(",
")",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"path",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"path",
",",
"$",
"presentation",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns a series of anchors and strings for the given collection of routable items.
@param array|\Traversable|Collection $value
@param string $presentation
@return string[] | [
"Returns",
"a",
"series",
"of",
"anchors",
"and",
"strings",
"for",
"the",
"given",
"collection",
"of",
"routable",
"items",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/Renderer.php#L172-L184 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Transformer/Router/Renderer.php | Renderer.renderTypeCollection | protected function renderTypeCollection($value, $presentation)
{
$baseType = $this->render($value->getBaseType(), $presentation);
$keyTypes = $this->render($value->getKeyTypes(), $presentation);
$types = $this->render($value->getTypes(), $presentation);
$arguments = [];
if ($keyTypes) {
$arguments[] = implode('|', $keyTypes);
}
$arguments[] = implode('|', $types);
if ($value->getName() === 'array' && count($value->getKeyTypes()) === 0) {
$typeString = (count($types) > 1) ? '(' . reset($arguments) . ')' : reset($arguments);
$collection = $typeString . '[]';
} else {
$collection = ($baseType ?: $value->getName()) . '<' . implode(',', $arguments) . '>';
}
return $collection;
} | php | protected function renderTypeCollection($value, $presentation)
{
$baseType = $this->render($value->getBaseType(), $presentation);
$keyTypes = $this->render($value->getKeyTypes(), $presentation);
$types = $this->render($value->getTypes(), $presentation);
$arguments = [];
if ($keyTypes) {
$arguments[] = implode('|', $keyTypes);
}
$arguments[] = implode('|', $types);
if ($value->getName() === 'array' && count($value->getKeyTypes()) === 0) {
$typeString = (count($types) > 1) ? '(' . reset($arguments) . ')' : reset($arguments);
$collection = $typeString . '[]';
} else {
$collection = ($baseType ?: $value->getName()) . '<' . implode(',', $arguments) . '>';
}
return $collection;
} | [
"protected",
"function",
"renderTypeCollection",
"(",
"$",
"value",
",",
"$",
"presentation",
")",
"{",
"$",
"baseType",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"value",
"->",
"getBaseType",
"(",
")",
",",
"$",
"presentation",
")",
";",
"$",
"keyTypes",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"value",
"->",
"getKeyTypes",
"(",
")",
",",
"$",
"presentation",
")",
";",
"$",
"types",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"value",
"->",
"getTypes",
"(",
")",
",",
"$",
"presentation",
")",
";",
"$",
"arguments",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"keyTypes",
")",
"{",
"$",
"arguments",
"[",
"]",
"=",
"implode",
"(",
"'|'",
",",
"$",
"keyTypes",
")",
";",
"}",
"$",
"arguments",
"[",
"]",
"=",
"implode",
"(",
"'|'",
",",
"$",
"types",
")",
";",
"if",
"(",
"$",
"value",
"->",
"getName",
"(",
")",
"===",
"'array'",
"&&",
"count",
"(",
"$",
"value",
"->",
"getKeyTypes",
"(",
")",
")",
"===",
"0",
")",
"{",
"$",
"typeString",
"=",
"(",
"count",
"(",
"$",
"types",
")",
">",
"1",
")",
"?",
"'('",
".",
"reset",
"(",
"$",
"arguments",
")",
".",
"')'",
":",
"reset",
"(",
"$",
"arguments",
")",
";",
"$",
"collection",
"=",
"$",
"typeString",
".",
"'[]'",
";",
"}",
"else",
"{",
"$",
"collection",
"=",
"(",
"$",
"baseType",
"?",
":",
"$",
"value",
"->",
"getName",
"(",
")",
")",
".",
"'<'",
".",
"implode",
"(",
"','",
",",
"$",
"arguments",
")",
".",
"'>'",
";",
"}",
"return",
"$",
"collection",
";",
"}"
] | Renders the view representation for an array or collection.
@param CollectionDescriptor $value
@param string $presentation
@return string | [
"Renders",
"the",
"view",
"representation",
"for",
"an",
"array",
"or",
"collection",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/Renderer.php#L194-L215 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Infrastructure/FlySystemFactory.php | FlySystemFactory.create | public function create(Dsn $dsn)
{
$dsnId = hash('md5', (string) $dsn);
try {
$filesystem = $this->mountManager->getFilesystem($dsnId);
} catch (LogicException $e) {
if ($dsn->getScheme() === 'file') {
$path = $dsn->getPath();
$filesystem = new Filesystem(new Local($path, LOCK_EX, Local::SKIP_LINKS));
} else {
//This will be implemented as soon as the CloneRemoteGitToLocal adapter is finished
throw new \InvalidArgumentException('http and https are not supported yet');
}
$this->mountManager->mountFilesystem($dsnId, $filesystem);
}
$filesystem->addPlugin(new Finder());
return $filesystem;
} | php | public function create(Dsn $dsn)
{
$dsnId = hash('md5', (string) $dsn);
try {
$filesystem = $this->mountManager->getFilesystem($dsnId);
} catch (LogicException $e) {
if ($dsn->getScheme() === 'file') {
$path = $dsn->getPath();
$filesystem = new Filesystem(new Local($path, LOCK_EX, Local::SKIP_LINKS));
} else {
//This will be implemented as soon as the CloneRemoteGitToLocal adapter is finished
throw new \InvalidArgumentException('http and https are not supported yet');
}
$this->mountManager->mountFilesystem($dsnId, $filesystem);
}
$filesystem->addPlugin(new Finder());
return $filesystem;
} | [
"public",
"function",
"create",
"(",
"Dsn",
"$",
"dsn",
")",
"{",
"$",
"dsnId",
"=",
"hash",
"(",
"'md5'",
",",
"(",
"string",
")",
"$",
"dsn",
")",
";",
"try",
"{",
"$",
"filesystem",
"=",
"$",
"this",
"->",
"mountManager",
"->",
"getFilesystem",
"(",
"$",
"dsnId",
")",
";",
"}",
"catch",
"(",
"LogicException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"dsn",
"->",
"getScheme",
"(",
")",
"===",
"'file'",
")",
"{",
"$",
"path",
"=",
"$",
"dsn",
"->",
"getPath",
"(",
")",
";",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
"new",
"Local",
"(",
"$",
"path",
",",
"LOCK_EX",
",",
"Local",
"::",
"SKIP_LINKS",
")",
")",
";",
"}",
"else",
"{",
"//This will be implemented as soon as the CloneRemoteGitToLocal adapter is finished",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'http and https are not supported yet'",
")",
";",
"}",
"$",
"this",
"->",
"mountManager",
"->",
"mountFilesystem",
"(",
"$",
"dsnId",
",",
"$",
"filesystem",
")",
";",
"}",
"$",
"filesystem",
"->",
"addPlugin",
"(",
"new",
"Finder",
"(",
")",
")",
";",
"return",
"$",
"filesystem",
";",
"}"
] | Returns a Filesystem instance based on the scheme of the provided Dsn
@return FilesystemInterface | [
"Returns",
"a",
"Filesystem",
"instance",
"based",
"on",
"the",
"scheme",
"of",
"the",
"provided",
"Dsn"
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Infrastructure/FlySystemFactory.php#L44-L64 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Compiler/Pass/ElementsIndexBuilder.php | ElementsIndexBuilder.getSubElements | protected function getSubElements(DescriptorAbstract $element): array
{
$subElements = [];
if ($element instanceof ClassInterface) {
$subElements = array_merge(
$element->getMethods()->getAll(),
$element->getConstants()->getAll(),
$element->getProperties()->getAll()
);
}
if ($element instanceof InterfaceInterface) {
$subElements = array_merge(
$element->getMethods()->getAll(),
$element->getConstants()->getAll()
);
}
if ($element instanceof TraitInterface) {
$subElements = array_merge(
$element->getMethods()->getAll(),
$element->getProperties()->getAll()
);
}
return $subElements;
} | php | protected function getSubElements(DescriptorAbstract $element): array
{
$subElements = [];
if ($element instanceof ClassInterface) {
$subElements = array_merge(
$element->getMethods()->getAll(),
$element->getConstants()->getAll(),
$element->getProperties()->getAll()
);
}
if ($element instanceof InterfaceInterface) {
$subElements = array_merge(
$element->getMethods()->getAll(),
$element->getConstants()->getAll()
);
}
if ($element instanceof TraitInterface) {
$subElements = array_merge(
$element->getMethods()->getAll(),
$element->getProperties()->getAll()
);
}
return $subElements;
} | [
"protected",
"function",
"getSubElements",
"(",
"DescriptorAbstract",
"$",
"element",
")",
":",
"array",
"{",
"$",
"subElements",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"element",
"instanceof",
"ClassInterface",
")",
"{",
"$",
"subElements",
"=",
"array_merge",
"(",
"$",
"element",
"->",
"getMethods",
"(",
")",
"->",
"getAll",
"(",
")",
",",
"$",
"element",
"->",
"getConstants",
"(",
")",
"->",
"getAll",
"(",
")",
",",
"$",
"element",
"->",
"getProperties",
"(",
")",
"->",
"getAll",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"element",
"instanceof",
"InterfaceInterface",
")",
"{",
"$",
"subElements",
"=",
"array_merge",
"(",
"$",
"element",
"->",
"getMethods",
"(",
")",
"->",
"getAll",
"(",
")",
",",
"$",
"element",
"->",
"getConstants",
"(",
")",
"->",
"getAll",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"element",
"instanceof",
"TraitInterface",
")",
"{",
"$",
"subElements",
"=",
"array_merge",
"(",
"$",
"element",
"->",
"getMethods",
"(",
")",
"->",
"getAll",
"(",
")",
",",
"$",
"element",
"->",
"getProperties",
"(",
")",
"->",
"getAll",
"(",
")",
")",
";",
"}",
"return",
"$",
"subElements",
";",
"}"
] | Returns any sub-elements for the given element.
This method checks whether the given element is a class, interface or trait and returns
their methods, properties and constants accordingly, or an empty array if no sub-elements
are applicable.
@return DescriptorAbstract[] | [
"Returns",
"any",
"sub",
"-",
"elements",
"for",
"the",
"given",
"element",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ElementsIndexBuilder.php#L82-L109 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Compiler/Pass/ElementsIndexBuilder.php | ElementsIndexBuilder.addElementsToIndexes | protected function addElementsToIndexes($elements, array $indexes): void
{
if (!is_array($elements)) {
$elements = [$elements];
}
/** @var DescriptorAbstract $element */
foreach ($elements as $element) {
/** @var Collection $collection */
foreach ($indexes as $collection) {
$collection->set($this->getIndexKey($element), $element);
}
}
} | php | protected function addElementsToIndexes($elements, array $indexes): void
{
if (!is_array($elements)) {
$elements = [$elements];
}
/** @var DescriptorAbstract $element */
foreach ($elements as $element) {
/** @var Collection $collection */
foreach ($indexes as $collection) {
$collection->set($this->getIndexKey($element), $element);
}
}
} | [
"protected",
"function",
"addElementsToIndexes",
"(",
"$",
"elements",
",",
"array",
"$",
"indexes",
")",
":",
"void",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"elements",
")",
")",
"{",
"$",
"elements",
"=",
"[",
"$",
"elements",
"]",
";",
"}",
"/** @var DescriptorAbstract $element */",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"element",
")",
"{",
"/** @var Collection $collection */",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"collection",
")",
"{",
"$",
"collection",
"->",
"set",
"(",
"$",
"this",
"->",
"getIndexKey",
"(",
"$",
"element",
")",
",",
"$",
"element",
")",
";",
"}",
"}",
"}"
] | Adds a series of descriptors to the given list of collections.
@param DescriptorAbstract|DescriptorAbstract[] $elements
@param Collection[] $indexes | [
"Adds",
"a",
"series",
"of",
"descriptors",
"to",
"the",
"given",
"list",
"of",
"collections",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/ElementsIndexBuilder.php#L117-L130 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Application.php | Application.defineIniSettings | protected function defineIniSettings(): void
{
$this->setTimezone();
ini_set('memory_limit', '-1');
if (extension_loaded('Zend OPcache') && ini_get('opcache.enable') && ini_get('opcache.enable_cli')) {
if (ini_get('opcache.save_comments')) {
ini_set('opcache.load_comments', '1');
} else {
ini_set('opcache.enable', '0');
}
}
if (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.save_comments') === 0) {
throw new RuntimeException('Please enable zend_optimizerplus.save_comments in php.ini.');
}
} | php | protected function defineIniSettings(): void
{
$this->setTimezone();
ini_set('memory_limit', '-1');
if (extension_loaded('Zend OPcache') && ini_get('opcache.enable') && ini_get('opcache.enable_cli')) {
if (ini_get('opcache.save_comments')) {
ini_set('opcache.load_comments', '1');
} else {
ini_set('opcache.enable', '0');
}
}
if (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.save_comments') === 0) {
throw new RuntimeException('Please enable zend_optimizerplus.save_comments in php.ini.');
}
} | [
"protected",
"function",
"defineIniSettings",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"setTimezone",
"(",
")",
";",
"ini_set",
"(",
"'memory_limit'",
",",
"'-1'",
")",
";",
"if",
"(",
"extension_loaded",
"(",
"'Zend OPcache'",
")",
"&&",
"ini_get",
"(",
"'opcache.enable'",
")",
"&&",
"ini_get",
"(",
"'opcache.enable_cli'",
")",
")",
"{",
"if",
"(",
"ini_get",
"(",
"'opcache.save_comments'",
")",
")",
"{",
"ini_set",
"(",
"'opcache.load_comments'",
",",
"'1'",
")",
";",
"}",
"else",
"{",
"ini_set",
"(",
"'opcache.enable'",
",",
"'0'",
")",
";",
"}",
"}",
"if",
"(",
"extension_loaded",
"(",
"'Zend Optimizer+'",
")",
"&&",
"ini_get",
"(",
"'zend_optimizerplus.save_comments'",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Please enable zend_optimizerplus.save_comments in php.ini.'",
")",
";",
"}",
"}"
] | Adjust php.ini settings.
@throws RuntimeException | [
"Adjust",
"php",
".",
"ini",
"settings",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application.php#L78-L94 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php | FunctionAssembler.addArgumentsToFunctionDescriptor | protected function addArgumentsToFunctionDescriptor(array $arguments, FunctionDescriptor $functionDescriptor): void
{
foreach ($arguments as $argument) {
$this->addArgumentDescriptorToFunction(
$functionDescriptor,
$this->createArgumentDescriptor($functionDescriptor, $argument)
);
}
} | php | protected function addArgumentsToFunctionDescriptor(array $arguments, FunctionDescriptor $functionDescriptor): void
{
foreach ($arguments as $argument) {
$this->addArgumentDescriptorToFunction(
$functionDescriptor,
$this->createArgumentDescriptor($functionDescriptor, $argument)
);
}
} | [
"protected",
"function",
"addArgumentsToFunctionDescriptor",
"(",
"array",
"$",
"arguments",
",",
"FunctionDescriptor",
"$",
"functionDescriptor",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"argument",
")",
"{",
"$",
"this",
"->",
"addArgumentDescriptorToFunction",
"(",
"$",
"functionDescriptor",
",",
"$",
"this",
"->",
"createArgumentDescriptor",
"(",
"$",
"functionDescriptor",
",",
"$",
"argument",
")",
")",
";",
"}",
"}"
] | Converts each argument reflector to an argument descriptor and adds it to the function descriptor.
@param Argument[] $arguments | [
"Converts",
"each",
"argument",
"reflector",
"to",
"an",
"argument",
"descriptor",
"and",
"adds",
"it",
"to",
"the",
"function",
"descriptor",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php#L91-L99 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php | FunctionAssembler.addArgumentDescriptorToFunction | protected function addArgumentDescriptorToFunction(
FunctionDescriptor $functionDescriptor,
ArgumentDescriptor $argumentDescriptor
): void {
$functionDescriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor);
} | php | protected function addArgumentDescriptorToFunction(
FunctionDescriptor $functionDescriptor,
ArgumentDescriptor $argumentDescriptor
): void {
$functionDescriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor);
} | [
"protected",
"function",
"addArgumentDescriptorToFunction",
"(",
"FunctionDescriptor",
"$",
"functionDescriptor",
",",
"ArgumentDescriptor",
"$",
"argumentDescriptor",
")",
":",
"void",
"{",
"$",
"functionDescriptor",
"->",
"getArguments",
"(",
")",
"->",
"set",
"(",
"$",
"argumentDescriptor",
"->",
"getName",
"(",
")",
",",
"$",
"argumentDescriptor",
")",
";",
"}"
] | Adds the given argument to the function. | [
"Adds",
"the",
"given",
"argument",
"to",
"the",
"function",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php#L104-L109 | train |
phpDocumentor/phpDocumentor2 | src/phpDocumentor/Transformer/Router/UrlGenerator/Standard/QualifiedNameToUrlConverter.php | QualifiedNameToUrlConverter.fromNamespace | public function fromNamespace($fqnn)
{
$name = str_replace('\\', '.', ltrim((string) $fqnn, '\\'));
// convert root namespace to default; default is a keyword and no namespace CAN be named as such
if ($name === '') {
$name = 'default';
}
return $name;
} | php | public function fromNamespace($fqnn)
{
$name = str_replace('\\', '.', ltrim((string) $fqnn, '\\'));
// convert root namespace to default; default is a keyword and no namespace CAN be named as such
if ($name === '') {
$name = 'default';
}
return $name;
} | [
"public",
"function",
"fromNamespace",
"(",
"$",
"fqnn",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'.'",
",",
"ltrim",
"(",
"(",
"string",
")",
"$",
"fqnn",
",",
"'\\\\'",
")",
")",
";",
"// convert root namespace to default; default is a keyword and no namespace CAN be named as such",
"if",
"(",
"$",
"name",
"===",
"''",
")",
"{",
"$",
"name",
"=",
"'default'",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Converts the provided FQCN into a file name by replacing all slashes with dots.
@param string $fqnn
@return string | [
"Converts",
"the",
"provided",
"FQCN",
"into",
"a",
"file",
"name",
"by",
"replacing",
"all",
"slashes",
"with",
"dots",
"."
] | 7a835fd03ff40244ff557c3e0ce32239e478def0 | https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/UrlGenerator/Standard/QualifiedNameToUrlConverter.php#L49-L59 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.