Apply new code style

This commit is contained in:
Jaapio
2019-09-20 10:54:12 +02:00
parent 8fcadfe5f8
commit aee984014b
71 changed files with 1661 additions and 1286 deletions
+22 -13
View File
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
@@ -6,14 +8,21 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2018 Mike van Riel<[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tags\Example;
use const DIRECTORY_SEPARATOR;
use function array_slice;
use function file;
use function getcwd;
use function implode;
use function is_readable;
use function rtrim;
use function sprintf;
use function trim;
/**
* Class used to find an example file's location based on a given ExampleDescriptor.
@@ -29,13 +38,13 @@ class ExampleFinder
/**
* Attempts to find the example contents for the given descriptor.
*/
public function find(Example $example): string
public function find(Example $example) : string
{
$filename = $example->getFilePath();
$file = $this->getExampleFileContents($filename);
if (!$file) {
return "** File not found : {$filename} **";
return sprintf('** File not found : %s **', $filename);
}
return implode('', array_slice($file, $example->getStartingLine() - 1, $example->getLineCount()));
@@ -44,7 +53,7 @@ class ExampleFinder
/**
* Registers the project's root directory where an 'examples' folder can be expected.
*/
public function setSourceDirectory(string $directory = ''): void
public function setSourceDirectory(string $directory = '') : void
{
$this->sourceDirectory = $directory;
}
@@ -52,7 +61,7 @@ class ExampleFinder
/**
* Returns the project's root directory where an 'examples' folder can be expected.
*/
public function getSourceDirectory(): string
public function getSourceDirectory() : string
{
return $this->sourceDirectory;
}
@@ -62,7 +71,7 @@ class ExampleFinder
*
* @param string[] $directories
*/
public function setExampleDirectories(array $directories): void
public function setExampleDirectories(array $directories) : void
{
$this->exampleDirectories = $directories;
}
@@ -72,7 +81,7 @@ class ExampleFinder
*
* @return string[]
*/
public function getExampleDirectories()
public function getExampleDirectories() : array
{
return $this->exampleDirectories;
}
@@ -88,7 +97,7 @@ class ExampleFinder
* 3. Checks the 'examples' folder in the current working directory for examples
* 4. Checks the path relative to the current working directory for the given filename
*/
private function getExampleFileContents(string $filename): ?string
private function getExampleFileContents(string $filename) : ?string
{
$normalizedPath = null;
@@ -116,7 +125,7 @@ class ExampleFinder
/**
* Get example filepath based on the example directory inside your project.
*/
private function getExamplePathFromExampleDirectory(string $file): string
private function getExamplePathFromExampleDirectory(string $file) : string
{
return getcwd() . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $file;
}
@@ -124,7 +133,7 @@ class ExampleFinder
/**
* Returns a path to the example file in the given directory..
*/
private function constructExamplePath(string $directory, string $file): string
private function constructExamplePath(string $directory, string $file) : string
{
return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file;
}
@@ -132,7 +141,7 @@ class ExampleFinder
/**
* Get example filepath based on sourcecode.
*/
private function getExamplePathFromSource(string $file): string
private function getExamplePathFromSource(string $file) : string
{
return sprintf(
'%s%s%s',