add strict_types and typehints

This commit is contained in:
TomasVotruba
2017-11-30 10:27:01 +01:00
committed by Jaap van Otterdijk
parent 94fd000123
commit d874c4d14a
38 changed files with 230 additions and 215 deletions
+9 -10
View File
@@ -1,4 +1,5 @@
<?php
<?php declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
@@ -29,7 +30,6 @@ final class DocBlockFactory implements DocBlockFactoryInterface
/**
* Initializes this factory with the required subcontractors.
*
* @param DescriptionFactory $descriptionFactory
* @param TagFactory $tagFactory
*/
public function __construct(DescriptionFactory $descriptionFactory, TagFactory $tagFactory)
@@ -45,7 +45,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*
* @return DocBlockFactory
*/
public static function createInstance(array $additionalTags = [])
public static function createInstance(array $additionalTags = []): DocBlockFactory
{
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
@@ -65,12 +65,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface
/**
* @param object|string $docblock A string containing the DocBlock to parse or an object supporting the
* getDocComment method (such as a ReflectionClass object).
* @param Types\Context $context
* @param Location $location
*
* @return DocBlock
*/
public function create($docblock, Types\Context $context = null, Location $location = null)
public function create($docblock, Types\Context $context = null, Location $location = null): DocBlock
{
if (is_object($docblock)) {
if (!method_exists($docblock, 'getDocComment')) {
@@ -115,7 +114,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*
* @return string
*/
private function stripDocComment($comment)
private function stripDocComment(string $comment): string
{
$comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment));
@@ -137,7 +136,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($comment)
private function splitDocBlock(string $comment)
{
// 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
@@ -219,7 +218,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*
* @return DocBlock\Tag[]
*/
private function parseTagBlock($tags, Types\Context $context)
private function parseTagBlock(string $tags, Types\Context $context)
{
$tags = $this->filterTagBlock($tags);
if (!$tags) {
@@ -239,7 +238,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*
* @return string[]
*/
private function splitTagBlockIntoTagLines($tags)
private function splitTagBlockIntoTagLines(string $tags)
{
$result = [];
foreach (explode("\n", $tags) as $tag_line) {
@@ -257,7 +256,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
* @param $tags
* @return string
*/
private function filterTagBlock($tags)
private function filterTagBlock($tags): string
{
$tags = trim($tags);
if (!$tags) {