add missing typehints and return types;

This commit is contained in:
Chuck Burgess
2018-01-31 08:57:30 -06:00
parent cd3bee0c73
commit 5ea3cbf8cf
8 changed files with 17 additions and 17 deletions
+2 -2
View File
@@ -133,7 +133,7 @@ final class DocBlock
*
* @return Tag[]
*/
public function getTags()
public function getTags(): array
{
return $this->tags;
}
@@ -146,7 +146,7 @@ final class DocBlock
*
* @return Tag[]
*/
public function getTagsByName(string $name)
public function getTagsByName(string $name): array
{
$result = [];
+1 -1
View File
@@ -72,7 +72,7 @@ class Description
*
* @return Tag[]
*/
public function getTags()
public function getTags(): array
{
return $this->tags;
}
+1 -1
View File
@@ -61,7 +61,7 @@ class DescriptionFactory
*
* @return string[] A series of tokens of which the description text is composed.
*/
private function lex(string $contents)
private function lex(string $contents): array
{
$contents = $this->removeSuperfluousStartingWhitespace($contents);
+4 -4
View File
@@ -163,7 +163,7 @@ final class StandardTagFactory implements TagFactory
*
* @return string[]
*/
private function extractTagParts(string $tagLine)
private function extractTagParts(string $tagLine): array
{
$matches = [];
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
@@ -222,7 +222,7 @@ final class StandardTagFactory implements TagFactory
* @return mixed[] A series of values that can be passed to the Factory Method of the tag whose parameters
* is provided with this method.
*/
private function getArgumentsForParametersFromWiring($parameters, $locator)
private function getArgumentsForParametersFromWiring($parameters, $locator): array
{
$arguments = [];
foreach ($parameters as $index => $parameter) {
@@ -251,7 +251,7 @@ final class StandardTagFactory implements TagFactory
*
* @return \ReflectionParameter[]
*/
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName)
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName): array
{
if (! isset($this->tagHandlerParameterCache[$handlerClassName])) {
$methodReflection = new \ReflectionMethod($handlerClassName, 'create');
@@ -271,7 +271,7 @@ final class StandardTagFactory implements TagFactory
*
* @return mixed[]
*/
private function getServiceLocatorWithDynamicParameters(TypeContext $context, string $tagName, string $tagBody)
private function getServiceLocatorWithDynamicParameters(TypeContext $context, string $tagName, string $tagBody): array
{
$locator = array_merge(
$this->serviceLocator,
+1 -1
View File
@@ -81,7 +81,7 @@ final class Example extends BaseTag
/**
* {@inheritdoc}
*/
public static function create(string $body)
public static function create(string $body): ?Tag
{
// File component: File path in quotes or File URI / Source information
if (! preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) {
+5 -5
View File
@@ -92,12 +92,12 @@ final class Method extends BaseTag implements Factory\StaticMethod
)?
# Return type
(?:
(
(
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
|
(?:
(?:[\w\|_\\\\]+)
# array notation
# array notation
(?:\[\])*
)*
)
@@ -170,7 +170,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
/**
* @return string[]
*/
public function getArguments()
public function getArguments(): array
{
return $this->arguments;
}
@@ -204,7 +204,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
. ($this->description ? ' ' . $this->description->render() : ''));
}
private function filterArguments($arguments)
private function filterArguments(array $arguments = []): array
{
foreach ($arguments as &$argument) {
if (is_string($argument)) {
@@ -227,7 +227,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
return $arguments;
}
private static function stripRestArg($argument)
private static function stripRestArg(string $argument): string
{
if (strpos($argument, '...') === 0) {
$argument = trim(substr($argument, 3));
+1 -1
View File
@@ -28,7 +28,7 @@ final class Url implements Reference
/**
* Url constructor.
*/
public function __construct($uri)
public function __construct(string $uri)
{
Assert::stringNotEmpty($uri);
$this->uri = $uri;
+2 -2
View File
@@ -127,7 +127,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*
* @return string[] containing the template marker (if any), summary, description and a string containing the tags.
*/
private function splitDocBlock(string $comment)
private function splitDocBlock(string $comment): array
{
// Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
@@ -227,7 +227,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
/**
* @return string[]
*/
private function splitTagBlockIntoTagLines(string $tags)
private function splitTagBlockIntoTagLines(string $tags): array
{
$result = [];
foreach (explode("\n", $tags) as $tag_line) {