@@ -17,12 +17,12 @@ |
||
17 | 17 | * You should have received a copy of the GNU Affero General Public License |
18 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 | */ |
20 | -include __DIR__.'/../vendor/autoload.php'; |
|
20 | +include __DIR__ . '/../vendor/autoload.php'; |
|
21 | 21 | |
22 | 22 | use JuliusHaertl\PHPDocToRst\ApiDocBuilder; |
23 | 23 | |
24 | -$src = [__DIR__.'/../src']; |
|
25 | -$dst = __DIR__.'/../tests/test-project-doc'; |
|
24 | +$src = [__DIR__ . '/../src']; |
|
25 | +$dst = __DIR__ . '/../tests/test-project-doc'; |
|
26 | 26 | |
27 | 27 | $apiDocBuilder = new ApiDocBuilder($src, $dst); |
28 | 28 | $apiDocBuilder->setVerboseOutput(true); |
@@ -67,15 +67,15 @@ |
||
67 | 67 | return; |
68 | 68 | } |
69 | 69 | $filePath = $builder->getFile()->getPath(); |
70 | - $filePath = preg_replace('/^'.preg_quote($this->basePath, '/').'/', '', $filePath); |
|
70 | + $filePath = preg_replace('/^' . preg_quote($this->basePath, '/') . '/', '', $filePath); |
|
71 | 71 | $lineNumber = $element->getLocation()->getLineNumber(); |
72 | 72 | $url = $this->getGithubLink($filePath, $lineNumber, $this->branch); |
73 | - $builder->addFieldList('Source', '`'.$filePath.'#'.$lineNumber.' <'.$url.'>`_'); |
|
73 | + $builder->addFieldList('Source', '`' . $filePath . '#' . $lineNumber . ' <' . $url . '>`_'); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | private function getGithubLink($file, $line = 1, $branch = 'master') |
78 | 78 | { |
79 | - return $this->githubRepo.'/blob/'.$branch.'/'.$file.'#L'.$line; |
|
79 | + return $this->githubRepo . '/blob/' . $branch . '/' . $file . '#L' . $line; |
|
80 | 80 | } |
81 | 81 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | if ($element instanceof Method || $element instanceof Property) { |
44 | 44 | /** @var Method|Property $class */ |
45 | 45 | $class = $element; |
46 | - if ((string) $class->getVisibility() !== 'public') { |
|
46 | + if ((string)$class->getVisibility() !== 'public') { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | if ($element instanceof Class_) { |
44 | 44 | $modifiers = $element->isAbstract() ? 'abstract' : ''; |
45 | 45 | $modifiers = $element->isFinal() ? ' final' : $modifiers; |
46 | - $builder->addLine(':php:`'.$modifiers.' class '.RstBuilder::escape($builder->getElement()->getName()).' {}`'); |
|
46 | + $builder->addLine(':php:`' . $modifiers . ' class ' . RstBuilder::escape($builder->getElement()->getName()) . ' {}`'); |
|
47 | 47 | $builder->addLine(); |
48 | 48 | } |
49 | 49 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | if ($element instanceof Method || $element instanceof Property) { |
44 | 44 | /** @var Method|Property $class */ |
45 | 45 | $class = $element; |
46 | - if ((string) $class->getVisibility() === 'private') { |
|
46 | + if ((string)$class->getVisibility() === 'private') { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | } |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | foreach ($this->project->getFiles() as $file) { |
39 | 39 | foreach ($file->getClasses() as $class) { |
40 | 40 | foreach ($class->getInterfaces() as $interface) { |
41 | - if (!array_key_exists((string) $interface, $this->implementors)) { |
|
42 | - $this->implementors[(string) $interface] = []; |
|
41 | + if (!array_key_exists((string)$interface, $this->implementors)) { |
|
42 | + $this->implementors[(string)$interface] = []; |
|
43 | 43 | } |
44 | - $this->implementors[(string) $interface][] = $class->getFqsen(); |
|
44 | + $this->implementors[(string)$interface][] = $class->getFqsen(); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | /** @var Interface_ $interface */ |
62 | 62 | $interface = $builder->getElement(); |
63 | 63 | $content = ''; |
64 | - if (!array_key_exists((string) $interface->getFqsen(), $this->implementors)) { |
|
64 | + if (!array_key_exists((string)$interface->getFqsen(), $this->implementors)) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | - $implementors = $this->implementors[(string) $interface->getFqsen()]; |
|
67 | + $implementors = $this->implementors[(string)$interface->getFqsen()]; |
|
68 | 68 | if (count($implementors) === 0) { |
69 | 69 | return; |
70 | 70 | } |
71 | 71 | foreach ($implementors as $implementor) { |
72 | - $content .= ':php:class:`'.RstBuilder::escape(substr($implementor, 1)).'` '; |
|
72 | + $content .= ':php:class:`' . RstBuilder::escape(substr($implementor, 1)) . '` '; |
|
73 | 73 | } |
74 | 74 | $builder->addFieldList('Implemented by', $content); |
75 | 75 | $builder->addLine(); |
@@ -54,16 +54,16 @@ |
||
54 | 54 | /** @var Argument $argument */ |
55 | 55 | foreach ($method->getArguments() as $argument) { |
56 | 56 | // TODO: defaults, types |
57 | - $args .= '$'.$argument->getName().', '; |
|
57 | + $args .= '$' . $argument->getName() . ', '; |
|
58 | 58 | } |
59 | 59 | $args = substr($args, 0, -2); |
60 | 60 | $modifiers = $method->getVisibility(); |
61 | 61 | $modifiers .= $method->isAbstract() ? ' abstract' : ''; |
62 | 62 | $modifiers .= $method->isFinal() ? ' final' : ''; |
63 | 63 | $modifiers .= $method->isStatic() ? ' static' : ''; |
64 | - $signature = $modifiers.' '.$method->getName().'('.$args.')'; |
|
64 | + $signature = $modifiers . ' ' . $method->getName() . '(' . $args . ')'; |
|
65 | 65 | |
66 | - $builder->addLine('* '.PhpDomainBuilder::getLink('meth', $method->getFqsen(), $signature)); |
|
66 | + $builder->addLine('* ' . PhpDomainBuilder::getLink('meth', $method->getFqsen(), $signature)); |
|
67 | 67 | } |
68 | 68 | $builder->addLine()->addLine(); |
69 | 69 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | class RstBuilder |
27 | 27 | { |
28 | 28 | /** @var string */ |
29 | - protected $content = '.. rst-class:: phpdoctorst'.PHP_EOL.PHP_EOL; |
|
29 | + protected $content = '.. rst-class:: phpdoctorst' . PHP_EOL . PHP_EOL; |
|
30 | 30 | private $indentLevel = 0; |
31 | 31 | |
32 | 32 | public function getContent() |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function addFieldList($key, $value) |
38 | 38 | { |
39 | - $this->addLine(':'.self::escape($key).':'); |
|
39 | + $this->addLine(':' . self::escape($key) . ':'); |
|
40 | 40 | $this->indent()->addMultiline($value, false)->unindent(); |
41 | 41 | |
42 | 42 | return $this; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public function addLine($text = '') |
46 | 46 | { |
47 | - $this->add(str_repeat("\t", $this->indentLevel).$text.PHP_EOL); |
|
47 | + $this->add(str_repeat("\t", $this->indentLevel) . $text . PHP_EOL); |
|
48 | 48 | |
49 | 49 | return $this; |
50 | 50 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | public function addH1(string $text) |
105 | 105 | { |
106 | 106 | $this->addLine($text); |
107 | - $this->addLine(str_repeat('=', strlen((string) $text)))->addLine(); |
|
107 | + $this->addLine(str_repeat('=', strlen((string)$text)))->addLine(); |
|
108 | 108 | |
109 | 109 | return $this; |
110 | 110 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function addH2($text) |
113 | 113 | { |
114 | 114 | $this->addLine($text); |
115 | - $this->addLine(str_repeat('-', strlen((string) $text)))->addLine(); |
|
115 | + $this->addLine(str_repeat('-', strlen((string)$text)))->addLine(); |
|
116 | 116 | |
117 | 117 | return $this; |
118 | 118 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function addH3($text) |
121 | 121 | { |
122 | 122 | $this->addLine($text); |
123 | - $this->addLine(str_repeat('~', strlen((string) $text)))->addLine(); |
|
123 | + $this->addLine(str_repeat('~', strlen((string)$text)))->addLine(); |
|
124 | 124 | |
125 | 125 | return $this; |
126 | 126 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | $lines = preg_split('/$\R?^/m', $text); |
131 | 131 | foreach ($lines as $line) { |
132 | - $this->addLine('| '.$line); |
|
132 | + $this->addLine('| ' . $line); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | return $this; |
@@ -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(); |