@@ -44,13 +44,13 @@ |
||
44 | 44 | $this->indent(); |
45 | 45 | $this->addLine(':maxdepth: 1')->addLine(); |
46 | 46 | foreach ($this->namespaces as $namespace) { |
47 | - $namespaceString = (string) $namespace->getFqsen(); |
|
47 | + $namespaceString = (string)$namespace->getFqsen(); |
|
48 | 48 | $subPath = $namespaceString; |
49 | - $path = substr(str_replace('\\', '/', $subPath), 1).'/index'; |
|
49 | + $path = substr(str_replace('\\', '/', $subPath), 1) . '/index'; |
|
50 | 50 | if ($namespaceString === '\\') { |
51 | 51 | $path = 'index'; |
52 | 52 | } |
53 | - $this->addLine($namespace->getFqsen().' <'.$path.'>'); |
|
53 | + $this->addLine($namespace->getFqsen() . ' <' . $path . '>'); |
|
54 | 54 | } |
55 | 55 | $this->addLine(); |
56 | 56 | $this->addLine(); |
@@ -70,19 +70,19 @@ discard block |
||
70 | 70 | */ |
71 | 71 | private function findChildNamespaces() |
72 | 72 | { |
73 | - $currentNamespaceFqsen = (string) $this->currentNamespace->getFqsen(); |
|
73 | + $currentNamespaceFqsen = (string)$this->currentNamespace->getFqsen(); |
|
74 | 74 | /** @var Namespace_ $namespace */ |
75 | 75 | foreach ($this->namespaces as $namespace) { |
76 | 76 | // check if not root and doesn't start with current namespace |
77 | - if ($currentNamespaceFqsen !== '\\' && strpos((string) $namespace->getFqsen(), |
|
78 | - $currentNamespaceFqsen.'\\') !== 0) { |
|
77 | + if ($currentNamespaceFqsen !== '\\' && strpos((string)$namespace->getFqsen(), |
|
78 | + $currentNamespaceFqsen . '\\') !== 0) { |
|
79 | 79 | continue; |
80 | 80 | } |
81 | - if ((string) $namespace->getFqsen() !== $currentNamespaceFqsen && strpos((string) $namespace->getFqsen(), |
|
81 | + if ((string)$namespace->getFqsen() !== $currentNamespaceFqsen && strpos((string)$namespace->getFqsen(), |
|
82 | 82 | $currentNamespaceFqsen) === 0) { |
83 | 83 | // only keep first level children |
84 | - $childrenPath = substr((string) $namespace->getFqsen(), |
|
85 | - strlen((string) $this->currentNamespace->getFqsen()) + 1); |
|
84 | + $childrenPath = substr((string)$namespace->getFqsen(), |
|
85 | + strlen((string)$this->currentNamespace->getFqsen()) + 1); |
|
86 | 86 | if (strpos($childrenPath, '\\') === false) { |
87 | 87 | $this->childNamespaces[] = $namespace; |
88 | 88 | } |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | |
93 | 93 | public function render() |
94 | 94 | { |
95 | - $currentNamespaceFqsen = (string) $this->currentNamespace->getFqsen(); |
|
95 | + $currentNamespaceFqsen = (string)$this->currentNamespace->getFqsen(); |
|
96 | 96 | if ($currentNamespaceFqsen !== '\\') { |
97 | 97 | $label = str_replace('\\', '-', $currentNamespaceFqsen); |
98 | - $this->addLine('.. _namespace'.$label.':')->addLine(); |
|
98 | + $this->addLine('.. _namespace' . $label . ':')->addLine(); |
|
99 | 99 | $this->addH1(RstBuilder::escape($this->currentNamespace->getName())); |
100 | 100 | $this->addLine(self::escape($currentNamespaceFqsen))->addLine(); |
101 | 101 | } else { |
102 | 102 | $label = 'root-namespace'; |
103 | - $this->addLine('.. _namespace-'.$label.':')->addLine(); |
|
103 | + $this->addLine('.. _namespace-' . $label . ':')->addLine(); |
|
104 | 104 | $this->addH1(RstBuilder::escape('\\')); |
105 | 105 | } |
106 | 106 | $this->addLine(); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | continue; |
130 | 130 | } |
131 | 131 | if ($type === self::RENDER_INDEX_NAMESPACE) { |
132 | - $this->addLine($entry->getName().' <'.$entry->getName().'/index>'); |
|
132 | + $this->addLine($entry->getName() . ' <' . $entry->getName() . '/index>'); |
|
133 | 133 | } else { |
134 | 134 | $this->addElementTocEntry($entry); |
135 | 135 | } |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | |
201 | 201 | private function addElementTocEntry(Fqsen $entry) |
202 | 202 | { |
203 | - $currentNamespaceFqsen = (string) $this->currentNamespace->getFqsen(); |
|
203 | + $currentNamespaceFqsen = (string)$this->currentNamespace->getFqsen(); |
|
204 | 204 | $subPath = $entry; |
205 | 205 | if ($currentNamespaceFqsen !== '\\' && substr($entry, 0, |
206 | 206 | strlen($currentNamespaceFqsen)) === $currentNamespaceFqsen) { |
207 | 207 | $subPath = substr($entry, strlen($currentNamespaceFqsen)); |
208 | 208 | } |
209 | 209 | $path = substr(str_replace('\\', '/', $subPath), 1); |
210 | - $this->addLine($entry->getName().' <'.$path.'>'); |
|
210 | + $this->addLine($entry->getName() . ' <' . $path . '>'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | private function addFunctions() |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | /** @var Argument $argument */ |
234 | 234 | foreach ($function->getArguments() as $argument) { |
235 | 235 | // TODO: defaults, types |
236 | - $args .= '$'.$argument->getName().', '; |
|
236 | + $args .= '$' . $argument->getName() . ', '; |
|
237 | 237 | } |
238 | 238 | $args = substr($args, 0, -2); |
239 | - $this->beginPhpDomain('function', $function->getName().'('.$args.')'); |
|
239 | + $this->beginPhpDomain('function', $function->getName() . '(' . $args . ')'); |
|
240 | 240 | $this->addDocBlockDescription($function); |
241 | 241 | if (!empty($params)) { |
242 | 242 | foreach ($function->getArguments() as $argument) { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | /** @var Param $param */ |
245 | 245 | $param = $params[$argument->getName()]; |
246 | 246 | if ($param !== null) { |
247 | - $this->addMultiline(':param '.self::escape($param->getType()).' $'.$argument->getName().': '.$param->getDescription(), |
|
247 | + $this->addMultiline(':param ' . self::escape($param->getType()) . ' $' . $argument->getName() . ': ' . $param->getDescription(), |
|
248 | 248 | true); |
249 | 249 | } |
250 | 250 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | { |
59 | 59 | $implementedInterfaces = ''; |
60 | 60 | foreach ($element->getInterfaces() as $int) { |
61 | - $implementedInterfaces .= $this->getLink('interface', $int).' '; |
|
61 | + $implementedInterfaces .= $this->getLink('interface', $int) . ' '; |
|
62 | 62 | } |
63 | 63 | if ($implementedInterfaces !== '') { |
64 | 64 | $this->addFieldList('Implements', $implementedInterfaces); |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | class PhpDomainBuilder extends RstBuilder |
45 | 45 | { |
46 | - const SECTION_BEFORE_DESCRIPTION = self::class.'::SECTION_BEFORE_DESCRIPTION'; |
|
47 | - const SECTION_AFTER_DESCRIPTION = self::class.'::SECTION_AFTER_DESCRIPTION'; |
|
48 | - const SECTION_AFTER_TITLE = self::class.'::SECTION_AFTER_TITLE'; |
|
49 | - const SECTION_AFTER_INTRODUCTION = self::class.'::SECTION_AFTER_INTRODUCTION'; |
|
46 | + const SECTION_BEFORE_DESCRIPTION = self::class . '::SECTION_BEFORE_DESCRIPTION'; |
|
47 | + const SECTION_AFTER_DESCRIPTION = self::class . '::SECTION_AFTER_DESCRIPTION'; |
|
48 | + const SECTION_AFTER_TITLE = self::class . '::SECTION_AFTER_TITLE'; |
|
49 | + const SECTION_AFTER_INTRODUCTION = self::class . '::SECTION_AFTER_INTRODUCTION'; |
|
50 | 50 | |
51 | 51 | use ExtensionBuilder { |
52 | 52 | ExtensionBuilder::__construct as private __extensionConstructor; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function __construct($extensions) |
56 | 56 | { |
57 | 57 | $this->__extensionConstructor($extensions); |
58 | - $this->addMultiline('.. role:: php(code)'.PHP_EOL.':language: php', true); |
|
58 | + $this->addMultiline('.. role:: php(code)' . PHP_EOL . ':language: php', true); |
|
59 | 59 | $this->addLine(); |
60 | 60 | } |
61 | 61 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $modifiers = $element->isAbstract() ? ' abstract' : ''; |
75 | 75 | $modifiers = $element->isFinal() ? ' final' : $modifiers; |
76 | 76 | if ($modifiers !== '') { |
77 | - $this->addLine('.. rst-class:: '.$modifiers)->addLine(); |
|
77 | + $this->addLine('.. rst-class:: ' . $modifiers)->addLine(); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public static function getNamespace(Element $element) |
95 | 95 | { |
96 | - return substr($element->getFqsen(), 0, strlen($element->getFqsen()) - strlen('\\'.$element->getName())); |
|
96 | + return substr($element->getFqsen(), 0, strlen($element->getFqsen()) - strlen('\\' . $element->getName())); |
|
97 | 97 | //return str_replace('\\' . $element->getName(), '', $element->getFqsen()); |
98 | 98 | } |
99 | 99 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | public function beginPhpDomain($type, $name, $indent = true) |
106 | 106 | { |
107 | 107 | // FIXME: Add checks if it is properly ended |
108 | - $this->addLine('.. php:'.$type.':: '.$name)->addLine(); |
|
108 | + $this->addLine('.. php:' . $type . ':: ' . $name)->addLine(); |
|
109 | 109 | if ($indent === true) { |
110 | 110 | $this->indent(); |
111 | 111 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | private function addConstant(Constant $constant) |
170 | 170 | { |
171 | - $this->beginPhpDomain('const', $constant->getName().' = '.self::escape($constant->getValue())); |
|
171 | + $this->beginPhpDomain('const', $constant->getName() . ' = ' . self::escape($constant->getValue())); |
|
172 | 172 | $docBlock = $constant->getDocBlock(); |
173 | 173 | $this->addDocBlockDescription($constant); |
174 | 174 | if ($docBlock) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $this->addLine('.. rst-class:: phpdoc-description')->addLine(); |
196 | 196 | $this->indent(); |
197 | 197 | $this->addMultilineWithoutRendering(RstBuilder::escape($docBlock->getSummary()))->addLine(); |
198 | - if ((string) $docBlock->getDescription() !== '') { |
|
198 | + if ((string)$docBlock->getDescription() !== '') { |
|
199 | 199 | $this->addMultilineWithoutRendering(RstBuilder::escape($docBlock->getDescription()))->addLine(); |
200 | 200 | } |
201 | 201 | $this->unindent(); |
@@ -235,44 +235,44 @@ discard block |
||
235 | 235 | case 'return': |
236 | 236 | /** @var Return_ $return */ |
237 | 237 | $return = $tags[0]; |
238 | - $this->addMultiline(':Returns: '.self::typesToRst($return->getType()).' '.RstBuilder::escape($return->getDescription()), |
|
238 | + $this->addMultiline(':Returns: ' . self::typesToRst($return->getType()) . ' ' . RstBuilder::escape($return->getDescription()), |
|
239 | 239 | true); |
240 | 240 | break; |
241 | 241 | case 'var': |
242 | 242 | /** @var DocBlock\Tags\Var_ $return */ |
243 | 243 | $return = $tags[0]; |
244 | - $this->addMultiline(':Type: '.self::typesToRst($return->getType()).' '.RstBuilder::escape($return->getDescription()), |
|
244 | + $this->addMultiline(':Type: ' . self::typesToRst($return->getType()) . ' ' . RstBuilder::escape($return->getDescription()), |
|
245 | 245 | true); |
246 | 246 | break; |
247 | 247 | case 'throws': |
248 | 248 | /** @var Throws $tag */ |
249 | 249 | foreach ($tags as $tag) { |
250 | - $this->addMultiline(':Throws: '.self::typesToRst($tag->getType()).' '.RstBuilder::escape($tag->getDescription()), |
|
250 | + $this->addMultiline(':Throws: ' . self::typesToRst($tag->getType()) . ' ' . RstBuilder::escape($tag->getDescription()), |
|
251 | 251 | true); |
252 | 252 | } |
253 | 253 | break; |
254 | 254 | case 'since': |
255 | 255 | /** @var Since $return */ |
256 | 256 | $return = $tags[0]; |
257 | - $this->addMultiline(':Since: '.$return->getVersion().' '.RstBuilder::escape($return->getDescription()), |
|
257 | + $this->addMultiline(':Since: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), |
|
258 | 258 | true); |
259 | 259 | break; |
260 | 260 | case 'deprecated': |
261 | 261 | /** @var Deprecated $return */ |
262 | 262 | $return = $tags[0]; |
263 | - $this->addMultiline(':Deprecated: '.$return->getVersion().' '.RstBuilder::escape($return->getDescription()), |
|
263 | + $this->addMultiline(':Deprecated: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), |
|
264 | 264 | true); |
265 | 265 | break; |
266 | 266 | case 'see': |
267 | 267 | /** @var See $return */ |
268 | 268 | $return = $tags[0]; |
269 | - $this->addMultiline(':See: '.self::typesToRst($return->getReference()).' '.RstBuilder::escape($return->getDescription()), |
|
269 | + $this->addMultiline(':See: ' . self::typesToRst($return->getReference()) . ' ' . RstBuilder::escape($return->getDescription()), |
|
270 | 270 | true); |
271 | 271 | break; |
272 | 272 | case 'license': |
273 | 273 | /** @var DocBlock\Tags\BaseTag $return */ |
274 | 274 | $return = $tags[0]; |
275 | - $this->addMultiline(':License: '.RstBuilder::escape($return->getDescription()), true); |
|
275 | + $this->addMultiline(':License: ' . RstBuilder::escape($return->getDescription()), true); |
|
276 | 276 | break; |
277 | 277 | } |
278 | 278 | } |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | foreach ($types as $typeFull) { |
312 | 312 | $type = str_replace('[]', '', $typeFull); |
313 | 313 | if (in_array($type, $whitelist, true)) { |
314 | - $result .= $typeFull.' | '; |
|
314 | + $result .= $typeFull . ' | '; |
|
315 | 315 | continue; |
316 | 316 | } |
317 | 317 | if (0 === strpos($type, '\\')) { |
318 | 318 | $type = substr($type, 1); |
319 | 319 | } |
320 | - $result .= ':any:`'.RstBuilder::escape($typeFull).' <'.RstBuilder::escape($type).'>` | '; |
|
320 | + $result .= ':any:`' . RstBuilder::escape($typeFull) . ' <' . RstBuilder::escape($type) . '>` | '; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | return substr($result, 0, -3); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | private function addProperty(Property $property) |
356 | 356 | { |
357 | 357 | $modifiers = $property->isStatic() ? '' : ' static'; |
358 | - $this->beginPhpDomain('attr', $property->getVisibility().$modifiers.' '.$property->getName()); |
|
358 | + $this->beginPhpDomain('attr', $property->getVisibility() . $modifiers . ' ' . $property->getName()); |
|
359 | 359 | $docBlock = $property->getDocBlock(); |
360 | 360 | $this->addDocBlockDescription($property); |
361 | 361 | if ($docBlock) { |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | public static function getLink($type, $fqsen, $description = '') |
395 | 395 | { |
396 | 396 | if ($description !== '') { |
397 | - return ':php:'.$type.':`'.RstBuilder::escape($description).'<'.RstBuilder::escape(substr($fqsen, |
|
398 | - 1)).'>`'; |
|
397 | + return ':php:' . $type . ':`' . RstBuilder::escape($description) . '<' . RstBuilder::escape(substr($fqsen, |
|
398 | + 1)) . '>`'; |
|
399 | 399 | } |
400 | 400 | |
401 | - return ':php:'.$type.':`'.RstBuilder::escape(substr($fqsen, 1)).'`'; |
|
401 | + return ':php:' . $type . ':`' . RstBuilder::escape(substr($fqsen, 1)) . '`'; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | { |
409 | 409 | $usedTraits = ''; |
410 | 410 | foreach ($element->getUsedTraits() as $trait) { |
411 | - $usedTraits .= $this->getLink('trait', $trait).' '; |
|
411 | + $usedTraits .= $this->getLink('trait', $trait) . ' '; |
|
412 | 412 | } |
413 | 413 | if ($usedTraits !== '') { |
414 | 414 | $this->addFieldList('Used traits', $usedTraits); |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | $modifiers .= $method->isFinal() ? ' final' : ''; |
450 | 450 | $modifiers .= $method->isStatic() ? ' static' : ''; |
451 | 451 | $deprecated = count($deprecated) > 0 ? ' deprecated' : ''; |
452 | - $this->addLine('.. rst-class:: '.$modifiers.$deprecated)->addLine(); |
|
452 | + $this->addLine('.. rst-class:: ' . $modifiers . $deprecated)->addLine(); |
|
453 | 453 | $this->indent(); |
454 | 454 | |
455 | 455 | $args = $this->processMethodArgumentTypes($method); |
456 | - $this->beginPhpDomain('method', $modifiers.' '.$method->getName().'('.$args.')'); |
|
456 | + $this->beginPhpDomain('method', $modifiers . ' ' . $method->getName() . '(' . $args . ')'); |
|
457 | 457 | $this->addDocBlockDescription($method); |
458 | 458 | $this->addLine(); |
459 | 459 | if (!empty($params)) { |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | if ($argument->isVariadic()) { |
496 | 496 | $paramItem .= '...'; |
497 | 497 | } |
498 | - $paramItem .= '$'.$argument->getName().'** '; |
|
498 | + $paramItem .= '$' . $argument->getName() . '** '; |
|
499 | 499 | if ($typString !== null) { |
500 | - $paramItem .= '('.self::typesToRst($typString).') '; |
|
500 | + $paramItem .= '(' . self::typesToRst($typString) . ') '; |
|
501 | 501 | } |
502 | - $paramItem .= ' '.$param->getDescription(); |
|
503 | - $parameterDetails .= $paramItem.PHP_EOL; |
|
502 | + $paramItem .= ' ' . $param->getDescription(); |
|
503 | + $parameterDetails .= $paramItem . PHP_EOL; |
|
504 | 504 | } |
505 | 505 | } |
506 | 506 | |
@@ -533,20 +533,20 @@ discard block |
||
533 | 533 | private function processMethodArgumentType(Argument $argument, string $args): string |
534 | 534 | { |
535 | 535 | foreach ($argument->getType() as $type) { |
536 | - $args .= self::escape($type).'|'; |
|
536 | + $args .= self::escape($type) . '|'; |
|
537 | 537 | } |
538 | - $args = substr($args, 0, -1).' '; |
|
538 | + $args = substr($args, 0, -1) . ' '; |
|
539 | 539 | if ($argument->isVariadic()) { |
540 | 540 | $args .= '...'; |
541 | 541 | } |
542 | 542 | if ($argument->isByReference()) { |
543 | 543 | $args .= '&'; |
544 | 544 | } |
545 | - $args .= '$'.$argument->getName(); |
|
545 | + $args .= '$' . $argument->getName(); |
|
546 | 546 | $default = $argument->getDefault(); |
547 | 547 | if ($default !== null) { |
548 | 548 | $default = $default === '' ? '""' : $default; |
549 | - $args .= '='.self::escape($default); |
|
549 | + $args .= '=' . self::escape($default); |
|
550 | 550 | } |
551 | 551 | $args .= ', '; |
552 | 552 |