diff --git a/.gitignore b/.gitignore
index a2453b55..10650b55 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,5 @@ tmp/
zf-mkdoc-theme/
clover.xml
coveralls-upload.json
-phpcs.xml
phpunit.xml
vendor
diff --git a/composer.json b/composer.json
index ee159636..f9fc9b64 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
"ext-phar": "*",
"doctrine/annotations": "~1.0",
"zendframework/zend-stdlib": "^2.7 || ^3.0",
- "squizlabs/php_codesniffer": "^2.5",
+ "zendframework/zend-coding-standard": "dev-feature/sniffs",
"phpunit/PHPUnit": "^4.8.21"
},
"suggest": {
diff --git a/composer.lock b/composer.lock
index 21982846..ce2ecd0a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "88ffb754c378b6610da240d3adcc3770",
- "content-hash": "af1206ea85a3ce06d326cab55fe68657",
+ "content-hash": "89675d1680857d308cb6908879f028ab",
"packages": [
{
"name": "zendframework/zend-eventmanager",
@@ -59,7 +58,7 @@
"events",
"zf2"
],
- "time": "2016-02-18 20:53:00"
+ "time": "2016-02-18T20:53:00+00:00"
}
],
"packages-dev": [
@@ -129,7 +128,7 @@
"docblock",
"parser"
],
- "time": "2015-08-31 12:32:49"
+ "time": "2015-08-31T12:32:49+00:00"
},
{
"name": "doctrine/instantiator",
@@ -183,7 +182,7 @@
"constructor",
"instantiate"
],
- "time": "2015-06-14 21:17:01"
+ "time": "2015-06-14T21:17:01+00:00"
},
{
"name": "doctrine/lexer",
@@ -237,7 +236,7 @@
"lexer",
"parser"
],
- "time": "2014-09-09 13:34:57"
+ "time": "2014-09-09T13:34:57+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
@@ -286,7 +285,7 @@
"email": "mike.vanriel@naenius.com"
}
],
- "time": "2015-02-03 12:10:50"
+ "time": "2015-02-03T12:10:50+00:00"
},
{
"name": "phpspec/prophecy",
@@ -348,7 +347,7 @@
"spy",
"stub"
],
- "time": "2016-02-15 07:46:21"
+ "time": "2016-02-15T07:46:21+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -410,7 +409,7 @@
"testing",
"xunit"
],
- "time": "2015-10-06 15:47:00"
+ "time": "2015-10-06T15:47:00+00:00"
},
{
"name": "phpunit/php-file-iterator",
@@ -457,7 +456,7 @@
"filesystem",
"iterator"
],
- "time": "2015-06-21 13:08:43"
+ "time": "2015-06-21T13:08:43+00:00"
},
{
"name": "phpunit/php-text-template",
@@ -498,7 +497,7 @@
"keywords": [
"template"
],
- "time": "2015-06-21 13:50:34"
+ "time": "2015-06-21T13:50:34+00:00"
},
{
"name": "phpunit/php-timer",
@@ -542,7 +541,7 @@
"keywords": [
"timer"
],
- "time": "2016-05-12 18:03:57"
+ "time": "2016-05-12T18:03:57+00:00"
},
{
"name": "phpunit/php-token-stream",
@@ -591,7 +590,7 @@
"keywords": [
"tokenizer"
],
- "time": "2015-09-15 10:49:45"
+ "time": "2015-09-15T10:49:45+00:00"
},
{
"name": "phpunit/phpunit",
@@ -663,7 +662,7 @@
"testing",
"xunit"
],
- "time": "2016-05-17 03:09:28"
+ "time": "2016-05-17T03:09:28+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
@@ -719,7 +718,7 @@
"mock",
"xunit"
],
- "time": "2015-10-02 06:51:40"
+ "time": "2015-10-02T06:51:40+00:00"
},
{
"name": "sebastian/comparator",
@@ -783,7 +782,7 @@
"compare",
"equality"
],
- "time": "2015-07-26 15:48:44"
+ "time": "2015-07-26T15:48:44+00:00"
},
{
"name": "sebastian/diff",
@@ -835,7 +834,7 @@
"keywords": [
"diff"
],
- "time": "2015-12-08 07:14:41"
+ "time": "2015-12-08T07:14:41+00:00"
},
{
"name": "sebastian/environment",
@@ -885,7 +884,7 @@
"environment",
"hhvm"
],
- "time": "2016-05-17 03:18:57"
+ "time": "2016-05-17T03:18:57+00:00"
},
{
"name": "sebastian/exporter",
@@ -951,7 +950,7 @@
"export",
"exporter"
],
- "time": "2015-06-21 07:55:53"
+ "time": "2015-06-21T07:55:53+00:00"
},
{
"name": "sebastian/global-state",
@@ -1002,7 +1001,7 @@
"keywords": [
"global state"
],
- "time": "2015-10-12 03:26:01"
+ "time": "2015-10-12T03:26:01+00:00"
},
{
"name": "sebastian/recursion-context",
@@ -1055,7 +1054,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "time": "2015-11-11 19:50:13"
+ "time": "2015-11-11T19:50:13+00:00"
},
{
"name": "sebastian/version",
@@ -1090,68 +1089,41 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
- "time": "2015-06-21 13:59:46"
+ "time": "2015-06-21T13:59:46+00:00"
},
{
"name": "squizlabs/php_codesniffer",
- "version": "2.6.0",
+ "version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
- "reference": "1bcdf03b068a530ac1962ce671dead356eeba43b"
+ "reference": "f9eaf037edf22fdfccf04cb0ab57ebcb1e166219"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1bcdf03b068a530ac1962ce671dead356eeba43b",
- "reference": "1bcdf03b068a530ac1962ce671dead356eeba43b",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/f9eaf037edf22fdfccf04cb0ab57ebcb1e166219",
+ "reference": "f9eaf037edf22fdfccf04cb0ab57ebcb1e166219",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
- "php": ">=5.1.2"
+ "php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"bin": [
- "scripts/phpcs",
- "scripts/phpcbf"
+ "bin/phpcs",
+ "bin/phpcbf"
],
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.x-dev"
+ "dev-master": "3.x-dev"
}
},
- "autoload": {
- "classmap": [
- "CodeSniffer.php",
- "CodeSniffer/CLI.php",
- "CodeSniffer/Exception.php",
- "CodeSniffer/File.php",
- "CodeSniffer/Fixer.php",
- "CodeSniffer/Report.php",
- "CodeSniffer/Reporting.php",
- "CodeSniffer/Sniff.php",
- "CodeSniffer/Tokens.php",
- "CodeSniffer/Reports/",
- "CodeSniffer/Tokenizers/",
- "CodeSniffer/DocGenerators/",
- "CodeSniffer/Standards/AbstractPatternSniff.php",
- "CodeSniffer/Standards/AbstractScopeSniff.php",
- "CodeSniffer/Standards/AbstractVariableSniff.php",
- "CodeSniffer/Standards/IncorrectPatternException.php",
- "CodeSniffer/Standards/Generic/Sniffs/",
- "CodeSniffer/Standards/MySource/Sniffs/",
- "CodeSniffer/Standards/PEAR/Sniffs/",
- "CodeSniffer/Standards/PSR1/Sniffs/",
- "CodeSniffer/Standards/PSR2/Sniffs/",
- "CodeSniffer/Standards/Squiz/Sniffs/",
- "CodeSniffer/Standards/Zend/Sniffs/"
- ]
- },
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
@@ -1168,7 +1140,7 @@
"phpcs",
"standards"
],
- "time": "2016-04-03 22:58:34"
+ "time": "2017-06-14T01:23:49+00:00"
},
{
"name": "symfony/yaml",
@@ -1217,7 +1189,44 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
- "time": "2016-03-04 07:55:57"
+ "time": "2016-03-04T07:55:57+00:00"
+ },
+ {
+ "name": "zendframework/zend-coding-standard",
+ "version": "dev-feature/sniffs",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/zendframework/zend-coding-standard.git",
+ "reference": "5127e4ff81e5be9b66d0e22dc711af739cea84bc"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/zendframework/zend-coding-standard/zipball/5127e4ff81e5be9b66d0e22dc711af739cea84bc",
+ "reference": "5127e4ff81e5be9b66d0e22dc711af739cea84bc",
+ "shasum": ""
+ },
+ "require": {
+ "squizlabs/php_codesniffer": "3.0.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.2.2 || ^5.7.20"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "ZendCodingStandard\\": "src/ZendCodingStandard/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "description": "Zend Framework coding standard",
+ "keywords": [
+ "Coding Standard",
+ "zf"
+ ],
+ "time": "2017-06-23T18:25:41+00:00"
},
{
"name": "zendframework/zend-stdlib",
@@ -1262,12 +1271,14 @@
"stdlib",
"zf2"
],
- "time": "2016-04-12 21:19:36"
+ "time": "2016-04-12T21:19:36+00:00"
}
],
"aliases": [],
"minimum-stability": "dev",
- "stability-flags": [],
+ "stability-flags": {
+ "zendframework/zend-coding-standard": 20
+ },
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 00000000..c2ed9121
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+ 0
+
+
+
+ src/Scanner/AnnotationScanner.php
+ src/Scanner/ClassScanner.php
+ src/Scanner/DocBlockScanner.php
+ src/Scanner/MethodScanner.php
+ src/Scanner/TokenArrayScanner.php
+
+
+
+ src
+ test
+ */TestAsset/*
+ */_files/*
+
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
deleted file mode 100644
index 914f41c2..00000000
--- a/phpcs.xml.dist
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
- Zend Framework coding standard
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
- 0
-
-
-
-
- src
- test
- */TestAsset/*
- */_files/*
-
diff --git a/src/Annotation/AnnotationManager.php b/src/Annotation/AnnotationManager.php
index 3326dc5c..b8e60603 100644
--- a/src/Annotation/AnnotationManager.php
+++ b/src/Annotation/AnnotationManager.php
@@ -99,11 +99,11 @@ public function createAnnotation(array $annotationData)
$eventManager = $this->getEventManager();
$results = $eventManager->triggerEventUntil(function ($r) {
- return (is_object($r));
+ return is_object($r);
}, $event);
$annotation = $results->last();
- return (is_object($annotation) ? $annotation : false);
+ return is_object($annotation) ? $annotation : false;
}
}
diff --git a/src/Annotation/Parser/DoctrineAnnotationParser.php b/src/Annotation/Parser/DoctrineAnnotationParser.php
index adef137c..fe7faccc 100644
--- a/src/Annotation/Parser/DoctrineAnnotationParser.php
+++ b/src/Annotation/Parser/DoctrineAnnotationParser.php
@@ -65,7 +65,7 @@ public function setDocParser(DocParser $docParser)
*/
public function getDocParser()
{
- if (!$this->docParser instanceof DocParser) {
+ if (! $this->docParser instanceof DocParser) {
$this->setDocParser(new DocParser());
}
@@ -81,16 +81,16 @@ public function getDocParser()
public function onCreateAnnotation(EventInterface $e)
{
$annotationClass = $e->getParam('class', false);
- if (!$annotationClass) {
+ if (! $annotationClass) {
return false;
}
- if (!isset($this->allowedAnnotations[$annotationClass])) {
+ if (! isset($this->allowedAnnotations[$annotationClass])) {
return false;
}
$annotationString = $e->getParam('raw', false);
- if (!$annotationString) {
+ if (! $annotationString) {
return false;
}
@@ -107,7 +107,7 @@ public function onCreateAnnotation(EventInterface $e)
}
$annotation = array_shift($annotations);
- if (!is_object($annotation)) {
+ if (! is_object($annotation)) {
return false;
}
@@ -136,11 +136,11 @@ public function registerAnnotation($annotation)
*/
public function registerAnnotations($annotations)
{
- if (!is_array($annotations) && !$annotations instanceof Traversable) {
+ if (! is_array($annotations) && ! $annotations instanceof Traversable) {
throw new Exception\InvalidArgumentException(sprintf(
'%s: expects an array or Traversable; received "%s"',
__METHOD__,
- (is_object($annotations) ? get_class($annotations) : gettype($annotations))
+ is_object($annotations) ? get_class($annotations) : gettype($annotations)
));
}
diff --git a/src/Annotation/Parser/GenericAnnotationParser.php b/src/Annotation/Parser/GenericAnnotationParser.php
index 6592e4f4..d84b63cb 100644
--- a/src/Annotation/Parser/GenericAnnotationParser.php
+++ b/src/Annotation/Parser/GenericAnnotationParser.php
@@ -53,7 +53,7 @@ class GenericAnnotationParser implements ParserInterface
public function onCreateAnnotation(EventInterface $e)
{
$class = $e->getParam('class', false);
- if (!$class || !$this->hasAnnotation($class)) {
+ if (! $class || ! $this->hasAnnotation($class)) {
return false;
}
@@ -80,7 +80,7 @@ public function onCreateAnnotation(EventInterface $e)
*
* @param string|AnnotationInterface $annotation String class name of an
* AnnotationInterface implementation, or actual instance
- * @return GenericAnnotationParser
+ * @return void
* @throws Exception\InvalidArgumentException
*/
public function registerAnnotation($annotation)
@@ -91,12 +91,12 @@ public function registerAnnotation($annotation)
$annotation = new $annotation();
}
- if (!$annotation instanceof AnnotationInterface) {
+ if (! $annotation instanceof AnnotationInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'%s: expects an instance of %s\AnnotationInterface; received "%s"',
__METHOD__,
__NAMESPACE__,
- (is_object($annotation) ? get_class($annotation) : gettype($annotation))
+ is_object($annotation) ? get_class($annotation) : gettype($annotation)
));
}
@@ -122,11 +122,11 @@ public function registerAnnotation($annotation)
*/
public function registerAnnotations($annotations)
{
- if (!is_array($annotations) && !$annotations instanceof Traversable) {
+ if (! is_array($annotations) && ! $annotations instanceof Traversable) {
throw new Exception\InvalidArgumentException(sprintf(
'%s: expects an array or Traversable; received "%s"',
__METHOD__,
- (is_object($annotations) ? get_class($annotations) : gettype($annotations))
+ is_object($annotations) ? get_class($annotations) : gettype($annotations)
));
}
@@ -166,7 +166,7 @@ public function hasAnnotation($class)
*/
public function setAlias($alias, $class)
{
- if (!in_array($class, $this->annotationNames) && !$this->hasAlias($class)) {
+ if (! in_array($class, $this->annotationNames) && ! $this->hasAlias($class)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s: Cannot alias "%s" to "%s", as class "%s" is not currently a registered annotation or alias',
__METHOD__,
@@ -203,7 +203,7 @@ protected function hasAlias($alias)
{
$alias = $this->normalizeAlias($alias);
- return (isset($this->aliases[$alias]));
+ return isset($this->aliases[$alias]);
}
/**
diff --git a/src/Generator/AbstractGenerator.php b/src/Generator/AbstractGenerator.php
index 546e3183..17aed586 100644
--- a/src/Generator/AbstractGenerator.php
+++ b/src/Generator/AbstractGenerator.php
@@ -31,7 +31,7 @@ abstract class AbstractGenerator implements GeneratorInterface
/**
* @var string
*/
- protected $sourceContent = null;
+ protected $sourceContent;
/**
* @param array $options
@@ -104,11 +104,11 @@ public function getSourceContent()
*/
public function setOptions($options)
{
- if (!is_array($options) && !$options instanceof Traversable) {
+ if (! is_array($options) && ! $options instanceof Traversable) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an array or Traversable object; received "%s"',
__METHOD__,
- (is_object($options) ? get_class($options) : gettype($options))
+ is_object($options) ? get_class($options) : gettype($options)
));
}
diff --git a/src/Generator/AbstractMemberGenerator.php b/src/Generator/AbstractMemberGenerator.php
index 11046128..f47ca44c 100644
--- a/src/Generator/AbstractMemberGenerator.php
+++ b/src/Generator/AbstractMemberGenerator.php
@@ -34,12 +34,12 @@ abstract class AbstractMemberGenerator extends AbstractGenerator
/**
* @var DocBlockGenerator
*/
- protected $docBlock = null;
+ protected $docBlock;
/**
* @var string
*/
- protected $name = null;
+ protected $name;
/**
* @var int
@@ -91,7 +91,7 @@ public function removeFlag($flag)
*/
public function setAbstract($isAbstract)
{
- return (($isAbstract) ? $this->addFlag(self::FLAG_ABSTRACT) : $this->removeFlag(self::FLAG_ABSTRACT));
+ return $isAbstract ? $this->addFlag(self::FLAG_ABSTRACT) : $this->removeFlag(self::FLAG_ABSTRACT);
}
/**
@@ -108,7 +108,7 @@ public function isAbstract()
*/
public function setInterface($isInterface)
{
- return (($isInterface) ? $this->addFlag(self::FLAG_INTERFACE) : $this->removeFlag(self::FLAG_INTERFACE));
+ return $isInterface ? $this->addFlag(self::FLAG_INTERFACE) : $this->removeFlag(self::FLAG_INTERFACE);
}
/**
@@ -125,7 +125,7 @@ public function isInterface()
*/
public function setFinal($isFinal)
{
- return (($isFinal) ? $this->addFlag(self::FLAG_FINAL) : $this->removeFlag(self::FLAG_FINAL));
+ return $isFinal ? $this->addFlag(self::FLAG_FINAL) : $this->removeFlag(self::FLAG_FINAL);
}
/**
@@ -142,7 +142,7 @@ public function isFinal()
*/
public function setStatic($isStatic)
{
- return (($isStatic) ? $this->addFlag(self::FLAG_STATIC) : $this->removeFlag(self::FLAG_STATIC));
+ return $isStatic ? $this->addFlag(self::FLAG_STATIC) : $this->removeFlag(self::FLAG_STATIC);
}
/**
@@ -183,9 +183,9 @@ public function setVisibility($visibility)
public function getVisibility()
{
switch (true) {
- case ($this->flags & self::FLAG_PROTECTED):
+ case $this->flags & self::FLAG_PROTECTED:
return self::VISIBILITY_PROTECTED;
- case ($this->flags & self::FLAG_PRIVATE):
+ case $this->flags & self::FLAG_PRIVATE:
return self::VISIBILITY_PRIVATE;
default:
return self::VISIBILITY_PUBLIC;
@@ -219,7 +219,7 @@ public function setDocBlock($docBlock)
{
if (is_string($docBlock)) {
$docBlock = new DocBlockGenerator($docBlock);
- } elseif (!$docBlock instanceof DocBlockGenerator) {
+ } elseif (! $docBlock instanceof DocBlockGenerator) {
throw new Exception\InvalidArgumentException(sprintf(
'%s is expecting either a string, array or an instance of %s\DocBlockGenerator',
__METHOD__,
diff --git a/src/Generator/BodyGenerator.php b/src/Generator/BodyGenerator.php
index b199fe81..aecd799f 100644
--- a/src/Generator/BodyGenerator.php
+++ b/src/Generator/BodyGenerator.php
@@ -14,7 +14,7 @@ class BodyGenerator extends AbstractGenerator
/**
* @var string
*/
- protected $content = null;
+ protected $content;
/**
* @param string $content
diff --git a/src/Generator/ClassGenerator.php b/src/Generator/ClassGenerator.php
index fefe41e7..1ef7ca8e 100644
--- a/src/Generator/ClassGenerator.php
+++ b/src/Generator/ClassGenerator.php
@@ -11,10 +11,10 @@
use Zend\Code\Reflection\ClassReflection;
-class ClassGenerator extends AbstractGenerator
+class ClassGenerator extends AbstractGenerator implements TraitUsageInterface
{
- const OBJECT_TYPE = "class";
- const IMPLEMENTS_KEYWORD = "implements";
+ const OBJECT_TYPE = 'class';
+ const IMPLEMENTS_KEYWORD = 'implements';
const FLAG_ABSTRACT = 0x01;
const FLAG_FINAL = 0x02;
@@ -22,22 +22,22 @@ class ClassGenerator extends AbstractGenerator
/**
* @var FileGenerator
*/
- protected $containingFileGenerator = null;
+ protected $containingFileGenerator;
/**
* @var string
*/
- protected $namespaceName = null;
+ protected $namespaceName;
/**
* @var DocBlockGenerator
*/
- protected $docBlock = null;
+ protected $docBlock;
/**
* @var string
*/
- protected $name = null;
+ protected $name;
/**
* @var bool
@@ -47,7 +47,7 @@ class ClassGenerator extends AbstractGenerator
/**
* @var string
*/
- protected $extendedClass = null;
+ protected $extendedClass;
/**
* @var array Array of string names
@@ -131,7 +131,7 @@ public static function fromReflection(ClassReflection $classReflection)
foreach ($classReflection->getConstants() as $name => $value) {
$constants[] = [
'name' => $name,
- 'value' => $value
+ 'value' => $value,
];
}
@@ -140,7 +140,7 @@ public static function fromReflection(ClassReflection $classReflection)
$methods = [];
foreach ($classReflection->getMethods() as $reflectionMethod) {
- $className = ($cg->getNamespaceName()) ? $cg->getNamespaceName() . "\\" . $cg->getName() : $cg->getName();
+ $className = $cg->getNamespaceName() ? $cg->getNamespaceName() . '\\' . $cg->getName() : $cg->getName();
if ($reflectionMethod->getDeclaringClass()->getName() == $className) {
$methods[] = MethodGenerator::fromReflection($reflectionMethod);
@@ -171,7 +171,7 @@ public static function fromReflection(ClassReflection $classReflection)
*/
public static function fromArray(array $array)
{
- if (!isset($array['name'])) {
+ if (! isset($array['name'])) {
throw new Exception\InvalidArgumentException(
'Class generator requires that a name is provided for this object'
);
@@ -188,7 +188,7 @@ public static function fromArray(array $array)
$cg->setNamespaceName($value);
break;
case 'docblock':
- $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $docBlock = $value instanceof DocBlockGenerator ? $value : DocBlockGenerator::fromArray($value);
$cg->setDocBlock($docBlock);
break;
case 'flags':
@@ -383,7 +383,7 @@ public function removeFlag($flag)
*/
public function setAbstract($isAbstract)
{
- return (($isAbstract) ? $this->addFlag(self::FLAG_ABSTRACT) : $this->removeFlag(self::FLAG_ABSTRACT));
+ return $isAbstract ? $this->addFlag(self::FLAG_ABSTRACT) : $this->removeFlag(self::FLAG_ABSTRACT);
}
/**
@@ -400,7 +400,7 @@ public function isAbstract()
*/
public function setFinal($isFinal)
{
- return (($isFinal) ? $this->addFlag(self::FLAG_FINAL) : $this->removeFlag(self::FLAG_FINAL));
+ return $isFinal ? $this->addFlag(self::FLAG_FINAL) : $this->removeFlag(self::FLAG_FINAL);
}
/**
@@ -408,7 +408,7 @@ public function setFinal($isFinal)
*/
public function isFinal()
{
- return ($this->flags & self::FLAG_FINAL);
+ return $this->flags & self::FLAG_FINAL;
}
/**
@@ -434,7 +434,7 @@ public function getExtendedClass()
*/
public function hasExtentedClass()
{
- return !empty($this->extendedClass);
+ return ! empty($this->extendedClass);
}
/**
@@ -479,7 +479,7 @@ public function hasImplementedInterface($implementedInterface)
}
/**
- * @param $implementedInterface
+ * @param string $implementedInterface
* @return self
*/
public function removeImplementedInterface($implementedInterface)
@@ -563,8 +563,8 @@ public function addConstantFromGenerator(PropertyGenerator $constant)
/**
* Add Constant
*
- * @param string $name non-empty string
- * @param string|int|null|float|array $value scalar
+ * @param string $name Non-empty string
+ * @param string|int|null|float|array $value Scalar
*
* @throws Exception\InvalidArgumentException
*
@@ -572,7 +572,7 @@ public function addConstantFromGenerator(PropertyGenerator $constant)
*/
public function addConstant($name, $value)
{
- if (empty($name) || !is_string($name)) {
+ if (empty($name) || ! is_string($name)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects string for name',
__METHOD__
@@ -638,7 +638,7 @@ public function addProperties(array $properties)
*/
public function addProperty($name, $defaultValue = null, $flags = PropertyGenerator::FLAG_PUBLIC)
{
- if (!is_string($name)) {
+ if (! is_string($name)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s::%s expects string for name',
get_class($this),
@@ -748,7 +748,7 @@ public function hasUseAlias($use)
}
/**
- * @param $use
+ * @param string $use
* @return self
*/
public function removeUseAlias($use)
@@ -767,7 +767,6 @@ public function getUses()
return $this->traitUsageGenerator->getUses();
}
-
/**
* @param string $propertyName
* @return self
@@ -827,7 +826,7 @@ public function addMethod(
$body = null,
$docBlock = null
) {
- if (!is_string($name)) {
+ if (! is_string($name)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s::%s expects string for name',
get_class($this),
@@ -898,7 +897,7 @@ public function hasMethod($methodName)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addTrait($trait)
{
@@ -907,7 +906,7 @@ public function addTrait($trait)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addTraits(array $traits)
{
@@ -916,7 +915,7 @@ public function addTraits(array $traits)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function hasTrait($traitName)
{
@@ -924,7 +923,7 @@ public function hasTrait($traitName)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function getTraits()
{
@@ -932,7 +931,7 @@ public function getTraits()
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function removeTrait($traitName)
{
@@ -940,7 +939,7 @@ public function removeTrait($traitName)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addTraitAlias($method, $alias, $visibility = null)
{
@@ -949,7 +948,7 @@ public function addTraitAlias($method, $alias, $visibility = null)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function getTraitAliases()
{
@@ -957,7 +956,7 @@ public function getTraitAliases()
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addTraitOverride($method, $traitsToReplace)
{
@@ -966,7 +965,7 @@ public function addTraitOverride($method, $traitsToReplace)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function removeTraitOverride($method, $overridesToRemove = null)
{
@@ -976,7 +975,7 @@ public function removeTraitOverride($method, $overridesToRemove = null)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function getTraitOverrides()
{
@@ -1008,13 +1007,13 @@ public function isSourceDirty()
}
/**
- * @inherit Zend\Code\Generator\GeneratorInterface
+ * @inheritDoc
*/
public function generate()
{
- if (!$this->isSourceDirty()) {
+ if (! $this->isSourceDirty()) {
$output = $this->getSourceContent();
- if (!empty($output)) {
+ if (! empty($output)) {
return $output;
}
}
@@ -1028,7 +1027,7 @@ public function generate()
$uses = $this->getUses();
- if (!empty($uses)) {
+ if (! empty($uses)) {
foreach ($uses as $use) {
$output .= 'use ' . $use . ';' . self::LINE_FEED;
}
@@ -1049,13 +1048,13 @@ public function generate()
$output .= static::OBJECT_TYPE . ' ' . $this->getName();
- if (!empty($this->extendedClass)) {
- $output .= ' extends ' . $this->generateShortOrCompleteClassname($this->extendedClass);
+ if (! empty($this->extendedClass)) {
+ $output .= ' extends ' . $this->generateShortOrCompleteClassname($this->extendedClass);
}
$implemented = $this->getImplementedInterfaces();
- if (!empty($implemented)) {
+ if (! empty($implemented)) {
$implemented = array_map([$this, 'generateShortOrCompleteClassname'], $implemented);
$output .= ' ' . static::IMPLEMENTS_KEYWORD . ' ' . implode(', ', $implemented);
}
diff --git a/src/Generator/DocBlock/Tag/AbstractTypeableTag.php b/src/Generator/DocBlock/Tag/AbstractTypeableTag.php
index 490e049c..111ae212 100644
--- a/src/Generator/DocBlock/Tag/AbstractTypeableTag.php
+++ b/src/Generator/DocBlock/Tag/AbstractTypeableTag.php
@@ -14,6 +14,7 @@
/**
* This abstract class can be used as parent for all tags
* that use a type part in their content.
+ *
* @see http://www.phpdoc.org/docs/latest/for-users/phpdoc/types.html
*/
abstract class AbstractTypeableTag extends AbstractGenerator
@@ -21,7 +22,7 @@ abstract class AbstractTypeableTag extends AbstractGenerator
/**
* @var string
*/
- protected $description = null;
+ protected $description;
/**
* @var array
@@ -34,11 +35,11 @@ abstract class AbstractTypeableTag extends AbstractGenerator
*/
public function __construct($types = [], $description = null)
{
- if (!empty($types)) {
+ if (! empty($types)) {
$this->setTypes($types);
}
- if (!empty($description)) {
+ if (! empty($description)) {
$this->setDescription($description);
}
}
diff --git a/src/Generator/DocBlock/Tag/AuthorTag.php b/src/Generator/DocBlock/Tag/AuthorTag.php
index b97a5cb6..b4bd916d 100644
--- a/src/Generator/DocBlock/Tag/AuthorTag.php
+++ b/src/Generator/DocBlock/Tag/AuthorTag.php
@@ -18,12 +18,12 @@ class AuthorTag extends AbstractGenerator implements TagInterface
/**
* @var string
*/
- protected $authorName = null;
+ protected $authorName;
/**
* @var string
*/
- protected $authorEmail = null;
+ protected $authorEmail;
/**
* @param string $authorName
@@ -31,11 +31,11 @@ class AuthorTag extends AbstractGenerator implements TagInterface
*/
public function __construct($authorName = null, $authorEmail = null)
{
- if (!empty($authorName)) {
+ if (! empty($authorName)) {
$this->setAuthorName($authorName);
}
- if (!empty($authorEmail)) {
+ if (! empty($authorEmail)) {
$this->setAuthorEmail($authorEmail);
}
}
@@ -102,8 +102,8 @@ public function getAuthorName()
public function generate()
{
$output = '@author'
- . ((!empty($this->authorName)) ? ' ' . $this->authorName : '')
- . ((!empty($this->authorEmail)) ? ' <' . $this->authorEmail . '>' : '');
+ . (! empty($this->authorName) ? ' ' . $this->authorName : '')
+ . (! empty($this->authorEmail) ? ' <' . $this->authorEmail . '>' : '');
return $output;
}
diff --git a/src/Generator/DocBlock/Tag/GenericTag.php b/src/Generator/DocBlock/Tag/GenericTag.php
index 173e9272..7fcdf6dc 100644
--- a/src/Generator/DocBlock/Tag/GenericTag.php
+++ b/src/Generator/DocBlock/Tag/GenericTag.php
@@ -17,12 +17,12 @@ class GenericTag extends AbstractGenerator implements TagInterface, PrototypeGen
/**
* @var string
*/
- protected $name = null;
+ protected $name;
/**
* @var string
*/
- protected $content = null;
+ protected $content;
/**
* @param string $name
@@ -30,11 +30,11 @@ class GenericTag extends AbstractGenerator implements TagInterface, PrototypeGen
*/
public function __construct($name = null, $content = null)
{
- if (!empty($name)) {
+ if (! empty($name)) {
$this->setName($name);
}
- if (!empty($content)) {
+ if (! empty($content)) {
$this->setContent($content);
}
}
@@ -81,7 +81,7 @@ public function getContent()
public function generate()
{
$output = '@' . $this->name
- . ((!empty($this->content)) ? ' ' . $this->content : '');
+ . (! empty($this->content) ? ' ' . $this->content : '');
return $output;
}
diff --git a/src/Generator/DocBlock/Tag/LicenseTag.php b/src/Generator/DocBlock/Tag/LicenseTag.php
index e41fec38..6e6d2d5a 100644
--- a/src/Generator/DocBlock/Tag/LicenseTag.php
+++ b/src/Generator/DocBlock/Tag/LicenseTag.php
@@ -18,12 +18,12 @@ class LicenseTag extends AbstractGenerator implements TagInterface
/**
* @var string
*/
- protected $url = null;
+ protected $url;
/**
* @var string
*/
- protected $licenseName = null;
+ protected $licenseName;
/**
* @param string $url
@@ -31,11 +31,11 @@ class LicenseTag extends AbstractGenerator implements TagInterface
*/
public function __construct($url = null, $licenseName = null)
{
- if (!empty($url)) {
+ if (! empty($url)) {
$this->setUrl($url);
}
- if (!empty($licenseName)) {
+ if (! empty($licenseName)) {
$this->setLicenseName($licenseName);
}
}
@@ -102,8 +102,8 @@ public function getLicenseName()
public function generate()
{
$output = '@license'
- . ((!empty($this->url)) ? ' ' . $this->url : '')
- . ((!empty($this->licenseName)) ? ' ' . $this->licenseName : '');
+ . (! empty($this->url) ? ' ' . $this->url : '')
+ . (! empty($this->licenseName) ? ' ' . $this->licenseName : '');
return $output;
}
diff --git a/src/Generator/DocBlock/Tag/MethodTag.php b/src/Generator/DocBlock/Tag/MethodTag.php
index 0e4c9438..ff4520a7 100644
--- a/src/Generator/DocBlock/Tag/MethodTag.php
+++ b/src/Generator/DocBlock/Tag/MethodTag.php
@@ -14,7 +14,7 @@ class MethodTag extends AbstractTypeableTag implements TagInterface
/**
* @var string
*/
- protected $methodName = null;
+ protected $methodName;
/**
* @var bool
@@ -29,7 +29,7 @@ class MethodTag extends AbstractTypeableTag implements TagInterface
*/
public function __construct($methodName = null, $types = [], $description = null, $isStatic = false)
{
- if (!empty($methodName)) {
+ if (! empty($methodName)) {
$this->setMethodName($methodName);
}
@@ -47,7 +47,7 @@ public function getName()
}
/**
- * @param boolean $isStatic
+ * @param bool $isStatic
* @return MethodTag
*/
public function setIsStatic($isStatic)
@@ -57,7 +57,7 @@ public function setIsStatic($isStatic)
}
/**
- * @return boolean
+ * @return bool
*/
public function isStatic()
{
@@ -88,10 +88,10 @@ public function getMethodName()
public function generate()
{
$output = '@method'
- . (($this->isStatic) ? ' static' : '')
- . ((!empty($this->types)) ? ' ' . $this->getTypesAsString() : '')
- . ((!empty($this->methodName)) ? ' ' . $this->methodName . '()' : '')
- . ((!empty($this->description)) ? ' ' . $this->description : '');
+ . ($this->isStatic ? ' static' : '')
+ . (! empty($this->types) ? ' ' . $this->getTypesAsString() : '')
+ . (! empty($this->methodName) ? ' ' . $this->methodName . '()' : '')
+ . (! empty($this->description) ? ' ' . $this->description : '');
return $output;
}
diff --git a/src/Generator/DocBlock/Tag/ParamTag.php b/src/Generator/DocBlock/Tag/ParamTag.php
index 04f413ee..45b05c5f 100644
--- a/src/Generator/DocBlock/Tag/ParamTag.php
+++ b/src/Generator/DocBlock/Tag/ParamTag.php
@@ -17,7 +17,7 @@ class ParamTag extends AbstractTypeableTag implements TagInterface
/**
* @var string
*/
- protected $variableName = null;
+ protected $variableName;
/**
* @param string $variableName
@@ -26,7 +26,7 @@ class ParamTag extends AbstractTypeableTag implements TagInterface
*/
public function __construct($variableName = null, $types = [], $description = null)
{
- if (!empty($variableName)) {
+ if (! empty($variableName)) {
$this->setVariableName($variableName);
}
@@ -115,9 +115,9 @@ public function getParamName()
public function generate()
{
$output = '@param'
- . ((!empty($this->types)) ? ' ' . $this->getTypesAsString() : '')
- . ((!empty($this->variableName)) ? ' $' . $this->variableName : '')
- . ((!empty($this->description)) ? ' ' . $this->description : '');
+ . (! empty($this->types) ? ' ' . $this->getTypesAsString() : '')
+ . (! empty($this->variableName) ? ' $' . $this->variableName : '')
+ . (! empty($this->description) ? ' ' . $this->description : '');
return $output;
}
diff --git a/src/Generator/DocBlock/Tag/PropertyTag.php b/src/Generator/DocBlock/Tag/PropertyTag.php
index def0368c..b342f718 100644
--- a/src/Generator/DocBlock/Tag/PropertyTag.php
+++ b/src/Generator/DocBlock/Tag/PropertyTag.php
@@ -14,7 +14,7 @@ class PropertyTag extends AbstractTypeableTag implements TagInterface
/**
* @var string
*/
- protected $propertyName = null;
+ protected $propertyName;
/**
* @param string $propertyName
@@ -23,7 +23,7 @@ class PropertyTag extends AbstractTypeableTag implements TagInterface
*/
public function __construct($propertyName = null, $types = [], $description = null)
{
- if (!empty($propertyName)) {
+ if (! empty($propertyName)) {
$this->setPropertyName($propertyName);
}
@@ -62,9 +62,9 @@ public function getPropertyName()
public function generate()
{
$output = '@property'
- . ((!empty($this->types)) ? ' ' . $this->getTypesAsString() : '')
- . ((!empty($this->propertyName)) ? ' $' . $this->propertyName : '')
- . ((!empty($this->description)) ? ' ' . $this->description : '');
+ . (! empty($this->types) ? ' ' . $this->getTypesAsString() : '')
+ . (! empty($this->propertyName) ? ' $' . $this->propertyName : '')
+ . (! empty($this->description) ? ' ' . $this->description : '');
return $output;
}
diff --git a/src/Generator/DocBlock/Tag/ReturnTag.php b/src/Generator/DocBlock/Tag/ReturnTag.php
index f7796708..2f2b774d 100644
--- a/src/Generator/DocBlock/Tag/ReturnTag.php
+++ b/src/Generator/DocBlock/Tag/ReturnTag.php
@@ -60,7 +60,7 @@ public function generate()
{
$output = '@return '
. $this->getTypesAsString()
- . ((!empty($this->description)) ? ' ' . $this->description : '');
+ . (! empty($this->description) ? ' ' . $this->description : '');
return $output;
}
diff --git a/src/Generator/DocBlock/Tag/ThrowsTag.php b/src/Generator/DocBlock/Tag/ThrowsTag.php
index e68dff2f..a117f98e 100644
--- a/src/Generator/DocBlock/Tag/ThrowsTag.php
+++ b/src/Generator/DocBlock/Tag/ThrowsTag.php
@@ -25,8 +25,8 @@ public function getName()
public function generate()
{
$output = '@throws'
- . ((!empty($this->types)) ? ' ' . $this->getTypesAsString() : '')
- . ((!empty($this->description)) ? ' ' . $this->description : '');
+ . (! empty($this->types) ? ' ' . $this->getTypesAsString() : '')
+ . (! empty($this->description) ? ' ' . $this->description : '');
return $output;
}
diff --git a/src/Generator/DocBlockGenerator.php b/src/Generator/DocBlockGenerator.php
index 218bbfb4..52368187 100644
--- a/src/Generator/DocBlockGenerator.php
+++ b/src/Generator/DocBlockGenerator.php
@@ -19,12 +19,12 @@ class DocBlockGenerator extends AbstractGenerator
/**
* @var string
*/
- protected $shortDescription = null;
+ protected $shortDescription;
/**
* @var string
*/
- protected $longDescription = null;
+ protected $longDescription;
/**
* @var array
@@ -101,7 +101,7 @@ public static function fromArray(array $array)
protected static function getTagManager()
{
- if (!isset(static::$tagManager)) {
+ if (! isset(static::$tagManager)) {
static::$tagManager = new TagManager();
static::$tagManager->initializeDefaultTags();
}
@@ -187,7 +187,7 @@ public function setTag($tag)
$genericTag = new Tag();
$genericTag->setOptions($tag);
$tag = $genericTag;
- } elseif (!$tag instanceof TagInterface) {
+ } elseif (! $tag instanceof TagInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects either an array of method options or an instance of %s\DocBlock\Tag\TagInterface',
__METHOD__,
@@ -230,7 +230,7 @@ public function getWordWrap()
*/
public function generate()
{
- if (!$this->isSourceDirty()) {
+ if (! $this->isSourceDirty()) {
return $this->docCommentize(trim($this->getSourceContent()));
}
@@ -263,7 +263,7 @@ protected function docCommentize($content)
foreach ($lines as $line) {
$output .= $indent . ' *';
if ($line) {
- $output .= " $line";
+ $output .= ' ' . $line;
}
$output .= self::LINE_FEED;
}
diff --git a/src/Generator/FileGenerator.php b/src/Generator/FileGenerator.php
index 1f646459..c9432250 100644
--- a/src/Generator/FileGenerator.php
+++ b/src/Generator/FileGenerator.php
@@ -17,12 +17,12 @@ class FileGenerator extends AbstractGenerator
/**
* @var string
*/
- protected $filename = null;
+ protected $filename;
/**
* @var DocBlockGenerator
*/
- protected $docBlock = null;
+ protected $docBlock;
/**
* @var array
@@ -32,7 +32,7 @@ class FileGenerator extends AbstractGenerator
/**
* @var string
*/
- protected $namespace = null;
+ protected $namespace;
/**
* @var array
@@ -47,7 +47,7 @@ class FileGenerator extends AbstractGenerator
/**
* @var string
*/
- protected $body = null;
+ protected $body;
/**
* Passes $options to {@link setOptions()}.
@@ -113,7 +113,7 @@ public static function fromReflection(FileReflection $fileReflection)
$file->setUses($uses);
}
- if (($fileReflection->getDocComment() != '')) {
+ if ($fileReflection->getDocComment() != '') {
$docBlock = $fileReflection->getDocBlock();
$file->setDocBlock(DocBlockGenerator::fromReflection($docBlock));
}
@@ -127,7 +127,7 @@ public static function fromReflection(FileReflection $fileReflection)
*/
public static function fromArray(array $values)
{
- $fileGenerator = new static;
+ $fileGenerator = new static();
foreach ($values as $name => $value) {
switch (strtolower(str_replace(['.', '-', '_'], '', $name))) {
case 'filename':
@@ -135,7 +135,7 @@ public static function fromArray(array $values)
continue;
case 'class':
$fileGenerator->setClass(
- ($value instanceof ClassGenerator)
+ $value instanceof ClassGenerator
? $value
: ClassGenerator::fromArray($value)
);
@@ -168,7 +168,7 @@ public function setDocBlock($docBlock)
if (is_array($docBlock)) {
$docBlock = new DocBlockGenerator($docBlock);
- } elseif (!$docBlock instanceof DocBlockGenerator) {
+ } elseif (! $docBlock instanceof DocBlockGenerator) {
throw new Exception\InvalidArgumentException(sprintf(
'%s is expecting either a string, array or an instance of %s\DocBlockGenerator',
__METHOD__,
@@ -281,7 +281,7 @@ public function setUses(array $uses)
*/
public function setUse($use, $as = null)
{
- if (!in_array([$use, $as], $this->uses)) {
+ if (! in_array([$use, $as], $this->uses)) {
$this->uses[] = [$use, $as];
}
return $this;
@@ -326,7 +326,7 @@ public function setClass($class)
$class = ClassGenerator::fromArray($class);
} elseif (is_string($class)) {
$class = new ClassGenerator($class);
- } elseif (!$class instanceof ClassGenerator) {
+ } elseif (! $class instanceof ClassGenerator) {
throw new Exception\InvalidArgumentException(sprintf(
'%s is expecting either a string, array or an instance of %s\ClassGenerator',
__METHOD__,
@@ -429,8 +429,7 @@ public function generate()
if (preg_match('#/\* Zend_Code_Generator_Php_File-(.*?)Marker:#m', $body)) {
$tokens = token_get_all($body);
foreach ($tokens as $token) {
- if (is_array($token) && in_array($token[0], [T_OPEN_TAG, T_COMMENT, T_DOC_COMMENT, T_WHITESPACE])
- ) {
+ if (is_array($token) && in_array($token[0], [T_OPEN_TAG, T_COMMENT, T_DOC_COMMENT, T_WHITESPACE])) {
$output .= $token[1];
}
}
@@ -472,7 +471,7 @@ public function generate()
// process required files
// @todo marker replacement for required files
$requiredFiles = $this->getRequiredFiles();
- if (!empty($requiredFiles)) {
+ if (! empty($requiredFiles)) {
foreach ($requiredFiles as $requiredFile) {
$output .= 'require_once \'' . $requiredFile . '\';' . self::LINE_FEED;
}
@@ -486,14 +485,14 @@ public function generate()
foreach ($classes as $class) {
//check for duplicate use statements
$uses = $class->getUses();
- if (!empty($uses) && is_array($uses)) {
+ if (! empty($uses) && is_array($uses)) {
$classUses = array_merge($classUses, $uses);
}
}
// process import statements
$uses = $this->getUses();
- if (!empty($uses)) {
+ if (! empty($uses)) {
$useOutput = '';
foreach ($uses as $use) {
@@ -505,8 +504,8 @@ public function generate()
}
//don't duplicate use statements
- if (!in_array($tempOutput, $classUses)) {
- $useOutput .= "use ". $tempOutput .";";
+ if (! in_array($tempOutput, $classUses)) {
+ $useOutput .= 'use ' . $tempOutput . ';';
$useOutput .= self::LINE_FEED;
}
}
@@ -525,7 +524,7 @@ public function generate()
}
// process classes
- if (!empty($classes)) {
+ if (! empty($classes)) {
foreach ($classes as $class) {
// @codingStandardsIgnoreStart
$regex = str_replace('&', $class->getName(), '/\* Zend_Code_Generator_Php_File-ClassMarker: \{[A-Za-z0-9\\\]+?&\} \*/');
@@ -541,9 +540,9 @@ public function generate()
}
}
- if (!empty($body)) {
+ if (! empty($body)) {
// add an extra space between classes and
- if (!empty($classes)) {
+ if (! empty($classes)) {
$output .= self::LINE_FEED;
}
@@ -559,7 +558,7 @@ public function generate()
*/
public function write()
{
- if ($this->filename == '' || !is_writable(dirname($this->filename))) {
+ if ($this->filename == '' || ! is_writable(dirname($this->filename))) {
throw new Exception\RuntimeException('This code generator object is not writable.');
}
file_put_contents($this->filename, $this->generate());
diff --git a/src/Generator/InterfaceGenerator.php b/src/Generator/InterfaceGenerator.php
index 63781da3..f5b3117c 100644
--- a/src/Generator/InterfaceGenerator.php
+++ b/src/Generator/InterfaceGenerator.php
@@ -24,7 +24,7 @@ class InterfaceGenerator extends ClassGenerator
*/
public static function fromReflection(ClassReflection $classReflection)
{
- if (!$classReflection->isInterface()) {
+ if (! $classReflection->isInterface()) {
throw new Exception\InvalidArgumentException(sprintf(
'Class %s is not a interface',
$classReflection->getName()
@@ -48,7 +48,7 @@ public static function fromReflection(ClassReflection $classReflection)
}
foreach ($classReflection->getMethods() as $reflectionMethod) {
- $className = ($cg->getNamespaceName())
+ $className = $cg->getNamespaceName()
? $cg->getNamespaceName() . '\\' . $cg->getName()
: $cg->getName();
@@ -99,7 +99,7 @@ public static function fromArray(array $array)
$cg->setNamespaceName($value);
break;
case 'docblock':
- $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $docBlock = $value instanceof DocBlockGenerator ? $value : DocBlockGenerator::fromArray($value);
$cg->setDocBlock($docBlock);
break;
case 'methods':
@@ -115,7 +115,7 @@ public static function fromArray(array $array)
}
/**
- * {@inheritdoc}
+ * {@inheritDoc}
*/
public function addPropertyFromGenerator(PropertyGenerator $property)
{
@@ -123,7 +123,7 @@ public function addPropertyFromGenerator(PropertyGenerator $property)
}
/**
- * {@inheritdoc}
+ * {@inheritDoc}
*/
public function addMethodFromGenerator(MethodGenerator $method)
{
@@ -133,7 +133,7 @@ public function addMethodFromGenerator(MethodGenerator $method)
}
/**
- * {@inheritdoc}
+ * {@inheritDoc}
*/
public function setExtendedClass($extendedClass)
{
@@ -141,7 +141,7 @@ public function setExtendedClass($extendedClass)
}
/**
- * {@inheritdoc}
+ * {@inheritDoc}
*/
public function setAbstract($isAbstract)
{
diff --git a/src/Generator/MethodGenerator.php b/src/Generator/MethodGenerator.php
index 59af8221..bc2d06d1 100644
--- a/src/Generator/MethodGenerator.php
+++ b/src/Generator/MethodGenerator.php
@@ -17,7 +17,7 @@ class MethodGenerator extends AbstractMemberGenerator
/**
* @var DocBlockGenerator
*/
- protected $docBlock = null;
+ protected $docBlock;
/**
* @var ParameterGenerator[]
@@ -27,7 +27,7 @@ class MethodGenerator extends AbstractMemberGenerator
/**
* @var string
*/
- protected $body = null;
+ protected $body;
/**
* @var null|TypeGenerator
@@ -128,7 +128,7 @@ protected static function clearBodyIndention($body)
*/
public static function fromArray(array $array)
{
- if (!isset($array['name'])) {
+ if (! isset($array['name'])) {
throw new Exception\InvalidArgumentException(
'Method generator requires that a name is provided for this object'
);
@@ -139,7 +139,7 @@ public static function fromArray(array $array)
// normalize key
switch (strtolower(str_replace(['.', '-', '_'], '', $name))) {
case 'docblock':
- $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $docBlock = $value instanceof DocBlockGenerator ? $value : DocBlockGenerator::fromArray($value);
$method->setDocBlock($docBlock);
break;
case 'flags':
@@ -234,7 +234,7 @@ public function setParameter($parameter)
$parameter = ParameterGenerator::fromArray($parameter);
}
- if (!$parameter instanceof ParameterGenerator) {
+ if (! $parameter instanceof ParameterGenerator) {
throw new Exception\InvalidArgumentException(sprintf(
'%s is expecting either a string, array or an instance of %s\ParameterGenerator',
__METHOD__,
@@ -274,7 +274,7 @@ public function getBody()
}
/**
- * @param string|null
+ * @param string|null $returnType
*
* @return MethodGenerator
*/
@@ -326,17 +326,17 @@ public function generate()
if ($this->isAbstract()) {
$output .= 'abstract ';
} else {
- $output .= (($this->isFinal()) ? 'final ' : '');
+ $output .= $this->isFinal() ? 'final ' : '';
}
$output .= $this->getVisibility()
- . (($this->isStatic()) ? ' static' : '')
+ . ($this->isStatic() ? ' static' : '')
. ' function '
. ($this->returnsReference ? '& ' : '')
. $this->getName() . '(';
$parameters = $this->getParameters();
- if (!empty($parameters)) {
+ if (! empty($parameters)) {
foreach ($parameters as $parameter) {
$parameterOutput[] = $parameter->generate();
}
diff --git a/src/Generator/ParameterGenerator.php b/src/Generator/ParameterGenerator.php
index f5f2bc2a..d45ab8db 100644
--- a/src/Generator/ParameterGenerator.php
+++ b/src/Generator/ParameterGenerator.php
@@ -17,22 +17,22 @@ class ParameterGenerator extends AbstractGenerator
/**
* @var string
*/
- protected $name = null;
+ protected $name;
/**
* @var TypeGenerator|null
*/
- protected $type = null;
+ protected $type;
/**
* @var string|ValueGenerator
*/
- protected $defaultValue = null;
+ protected $defaultValue;
/**
* @var int
*/
- protected $position = null;
+ protected $position;
/**
* @var bool
@@ -95,7 +95,7 @@ public static function fromReflection(ParameterReflection $reflectionParameter)
*/
public static function fromArray(array $array)
{
- if (!isset($array['name'])) {
+ if (! isset($array['name'])) {
throw new Exception\InvalidArgumentException(
'Paramerer generator requires that a name is provided for this object'
);
@@ -212,7 +212,7 @@ public function getName()
*/
public function setDefaultValue($defaultValue)
{
- if (!($defaultValue instanceof ValueGenerator)) {
+ if (! $defaultValue instanceof ValueGenerator) {
$defaultValue = new ValueGenerator($defaultValue);
}
$this->defaultValue = $defaultValue;
@@ -387,8 +387,6 @@ private static function expandLiteralParameterType($literalParameterType, Reflec
}
/**
- * @param string|null $type
- *
* @return string
*/
private function generateTypeHint()
diff --git a/src/Generator/PropertyGenerator.php b/src/Generator/PropertyGenerator.php
index bead534b..c243f74f 100644
--- a/src/Generator/PropertyGenerator.php
+++ b/src/Generator/PropertyGenerator.php
@@ -18,12 +18,12 @@ class PropertyGenerator extends AbstractMemberGenerator
/**
* @var bool
*/
- protected $isConst = null;
+ protected $isConst;
/**
* @var PropertyValueGenerator
*/
- protected $defaultValue = null;
+ protected $defaultValue;
/**
* @param PropertyReflection $reflectionProperty
@@ -78,7 +78,7 @@ public static function fromReflection(PropertyReflection $reflectionProperty)
*/
public static function fromArray(array $array)
{
- if (!isset($array['name'])) {
+ if (! isset($array['name'])) {
throw new Exception\InvalidArgumentException(
'Property generator requires that a name is provided for this object'
);
@@ -95,7 +95,7 @@ public static function fromArray(array $array)
$property->setDefaultValue($value);
break;
case 'docblock':
- $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $docBlock = $value instanceof DocBlockGenerator ? $value : DocBlockGenerator::fromArray($value);
$property->setDocBlock($docBlock);
break;
case 'flags':
@@ -173,7 +173,7 @@ public function setDefaultValue(
$defaultValueType = PropertyValueGenerator::TYPE_AUTO,
$defaultValueOutputMode = PropertyValueGenerator::OUTPUT_MULTIPLE_LINE
) {
- if (!($defaultValue instanceof PropertyValueGenerator)) {
+ if (! $defaultValue instanceof PropertyValueGenerator) {
$defaultValue = new PropertyValueGenerator($defaultValue, $defaultValueType, $defaultValueOutputMode);
}
@@ -207,7 +207,7 @@ public function generate()
}
if ($this->isConst()) {
- if ($defaultValue !== null && !$defaultValue->isValidConstantType()) {
+ if ($defaultValue !== null && ! $defaultValue->isValidConstantType()) {
throw new Exception\RuntimeException(sprintf(
'The property %s is said to be '
. 'constant but does not have a valid constant value.',
@@ -215,13 +215,13 @@ public function generate()
));
}
$output .= $this->indentation . 'const ' . $name . ' = '
- . (($defaultValue !== null) ? $defaultValue->generate() : 'null;');
+ . ($defaultValue !== null ? $defaultValue->generate() : 'null;');
} else {
$output .= $this->indentation
. $this->getVisibility()
- . (($this->isStatic()) ? ' static' : '')
+ . ($this->isStatic() ? ' static' : '')
. ' $' . $name . ' = '
- . (($defaultValue !== null) ? $defaultValue->generate() : 'null;');
+ . ($defaultValue !== null ? $defaultValue->generate() : 'null;');
}
return $output;
diff --git a/src/Generator/TraitGenerator.php b/src/Generator/TraitGenerator.php
index fc014b58..9b76b6bb 100644
--- a/src/Generator/TraitGenerator.php
+++ b/src/Generator/TraitGenerator.php
@@ -48,7 +48,7 @@ public static function fromReflection(ClassReflection $classReflection)
$methods = [];
foreach ($classReflection->getMethods() as $reflectionMethod) {
- $className = ($cg->getNamespaceName())
+ $className = $cg->getNamespaceName()
? $cg->getNamespaceName() . '\\' . $cg->getName()
: $cg->getName();
if ($reflectionMethod->getDeclaringClass()->getName() == $className) {
@@ -93,7 +93,7 @@ public static function fromArray(array $array)
$cg->setNamespaceName($value);
break;
case 'docblock':
- $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $docBlock = $value instanceof DocBlockGenerator ? $value : DocBlockGenerator::fromArray($value);
$cg->setDocBlock($docBlock);
break;
case 'properties':
diff --git a/src/Generator/TraitUsageGenerator.php b/src/Generator/TraitUsageGenerator.php
index 8329d4a0..c2c70956 100644
--- a/src/Generator/TraitUsageGenerator.php
+++ b/src/Generator/TraitUsageGenerator.php
@@ -6,12 +6,13 @@
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
+
namespace Zend\Code\Generator;
use Reflection;
use ReflectionMethod;
-class TraitUsageGenerator extends AbstractGenerator
+class TraitUsageGenerator extends AbstractGenerator implements TraitUsageInterface
{
/**
* @var ClassGenerator
@@ -44,7 +45,7 @@ public function __construct(ClassGenerator $classGenerator)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addUse($use, $useAlias = null)
{
@@ -59,7 +60,7 @@ public function addUse($use, $useAlias = null)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function getUses()
{
@@ -67,7 +68,7 @@ public function getUses()
}
/**
- * @param $use
+ * @param string $use
* @return bool
*/
public function hasUse($use)
@@ -83,23 +84,23 @@ public function hasUse($use)
}
/**
- * @param $use
+ * @param string $use
* @return bool
*/
public function hasUseAlias($use)
{
foreach ($this->uses as $key => $value) {
$parts = explode(' as ', $value);
- if ($parts[0] === $use and count($parts) == 2) {
+ if ($parts[0] === $use && count($parts) == 2) {
return true;
}
- };
+ }
return false;
}
/**
- * @param $use
+ * @param string $use
* @return TraitUsageGenerator
*/
public function removeUse($use)
@@ -109,29 +110,29 @@ public function removeUse($use)
if ($parts[0] === $use) {
unset($this->uses[$value]);
}
- };
+ }
return $this;
}
/**
- * @param $use
+ * @param string $use
* @return TraitUsageGenerator
*/
public function removeUseAlias($use)
{
foreach ($this->uses as $key => $value) {
$parts = explode(' as ', $value);
- if ($parts[0] === $use and count($parts) == 2) {
+ if ($parts[0] === $use && count($parts) == 2) {
unset($this->uses[$value]);
}
- };
+ }
return $this;
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addTrait($trait)
{
@@ -163,7 +164,7 @@ public function addTrait($trait)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addTraits(array $traits)
{
@@ -175,7 +176,7 @@ public function addTraits(array $traits)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function hasTrait($traitName)
{
@@ -183,7 +184,7 @@ public function hasTrait($traitName)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function getTraits()
{
@@ -191,7 +192,7 @@ public function getTraits()
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function removeTrait($traitName)
{
@@ -204,7 +205,7 @@ public function removeTrait($traitName)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addTraitAlias($method, $alias, $visibility = null)
{
@@ -222,7 +223,7 @@ public function addTraitAlias($method, $alias, $visibility = null)
}
// Validations
- if (false === strpos($traitAndMethod, "::")) {
+ if (false === strpos($traitAndMethod, '::')) {
throw new Exception\InvalidArgumentException(
'Invalid Format: $method must be in the format of trait::method'
);
@@ -251,14 +252,14 @@ public function addTraitAlias($method, $alias, $visibility = null)
$this->traitAliases[$traitAndMethod] = [
'alias' => $alias,
- 'visibility' => $visibility
+ 'visibility' => $visibility,
];
return $this;
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function getTraitAliases()
{
@@ -266,7 +267,7 @@ public function getTraitAliases()
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function addTraitOverride($method, $traitsToReplace)
{
@@ -288,13 +289,13 @@ public function addTraitOverride($method, $traitsToReplace)
}
// Validations
- if (false === strpos($traitAndMethod, "::")) {
+ if (false === strpos($traitAndMethod, '::')) {
throw new Exception\InvalidArgumentException(
'Invalid Format: $method must be in the format of trait::method'
);
}
- list($trait, $method) = explode("::", $traitAndMethod);
+ list($trait, $method) = explode('::', $traitAndMethod);
if (! $this->hasTrait($trait)) {
throw new Exception\InvalidArgumentException('Invalid trait: Trait does not exists on this class');
}
@@ -319,7 +320,7 @@ public function addTraitOverride($method, $traitsToReplace)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function removeTraitOverride($method, $overridesToRemove = null)
{
@@ -332,7 +333,7 @@ public function removeTraitOverride($method, $overridesToRemove = null)
return $this;
}
- $overridesToRemove = (! is_array($overridesToRemove))
+ $overridesToRemove = ! is_array($overridesToRemove)
? [$overridesToRemove]
: $overridesToRemove;
foreach ($overridesToRemove as $traitToRemove) {
@@ -345,7 +346,7 @@ public function removeTraitOverride($method, $overridesToRemove = null)
}
/**
- * @inherit Zend\Code\Generator\TraitUsageInterface
+ * @inheritDoc
*/
public function getTraitOverrides()
{
@@ -353,7 +354,7 @@ public function getTraitOverrides()
}
/**
- * @inherit Zend\Code\Generator\GeneratorInterface
+ * @inheritDoc
*/
public function generate()
{
@@ -370,13 +371,13 @@ public function generate()
$aliases = $this->getTraitAliases();
$overrides = $this->getTraitOverrides();
if (empty($aliases) && empty($overrides)) {
- $output .= ";" . self::LINE_FEED . self::LINE_FEED;
+ $output .= ';' . self::LINE_FEED . self::LINE_FEED;
return $output;
}
$output .= ' {' . self::LINE_FEED;
foreach ($aliases as $method => $alias) {
- $visibility = (null !== $alias['visibility'])
+ $visibility = null !== $alias['visibility']
? current(Reflection::getModifierNames($alias['visibility'])) . ' '
: '';
diff --git a/src/Generator/TraitUsageInterface.php b/src/Generator/TraitUsageInterface.php
index 560f0530..1ae9cf55 100644
--- a/src/Generator/TraitUsageInterface.php
+++ b/src/Generator/TraitUsageInterface.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
+
namespace Zend\Code\Generator;
interface TraitUsageInterface
@@ -50,7 +51,7 @@ public function addTrait($trait);
* Add multiple traits. Trait can be an array of trait names or array of trait
* configurations
*
- * @param array $traitName Array of string names or configurations (@see addTrait)
+ * @param array $traits Array of string names or configurations (@see addTrait)
* @return self
*/
public function addTraits(array $traits);
@@ -58,7 +59,7 @@ public function addTraits(array $traits);
/**
* Check to see if the class has a trait defined
*
- * @param strint $traitName
+ * @param string $traitName
* @return bool
*/
public function hasTrait($traitName);
@@ -73,7 +74,7 @@ public function getTraits();
/**
* Remove a trait by its name
*
- * @param $traitName
+ * @param string $traitName
*/
public function removeTrait($traitName);
@@ -91,11 +92,11 @@ public function removeTrait($traitName);
* Alias is a string representing the new method name.
*
* $visibilty:
- * ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PRIVATE| ReflectionMethod::IS_PROTECTED
+ * ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PRIVATE | ReflectionMethod::IS_PROTECTED
*
* @param mixed $method String or Array
* @param string $alias
- * @param int $visiblity
+ * @param null|int $visibility
*/
public function addTraitAlias($method, $alias, $visibility = null);
@@ -123,7 +124,7 @@ public function getTraitAliases();
* Option 2: Array of strings of traits to replace
* @param mixed $method
- * @param mixed $traitToReplace
+ * @param mixed $traitsToReplace
*/
public function addTraitOverride($method, $traitsToReplace);
@@ -144,9 +145,9 @@ public function addTraitOverride($method, $traitsToReplace);
* Option 1: String of trait to replace
* Option 2: Array of strings of traits to replace
*
- * @param $traitAndMethod
- * @param null $overridesToRemove
- * @return $this
+ * @param mixed $method
+ * @param mixed $overridesToRemove
+ * @return self
*/
public function removeTraitOverride($method, $overridesToRemove = null);
diff --git a/src/Generator/ValueGenerator.php b/src/Generator/ValueGenerator.php
index 24a2983a..2fa729a2 100644
--- a/src/Generator/ValueGenerator.php
+++ b/src/Generator/ValueGenerator.php
@@ -42,7 +42,7 @@ class ValueGenerator extends AbstractGenerator
/**
* @var mixed
*/
- protected $value = null;
+ protected $value;
/**
* @var string
@@ -62,9 +62,11 @@ class ValueGenerator extends AbstractGenerator
/**
* @var array
*/
- protected $allowedTypes = null;
+ protected $allowedTypes;
+
/**
* Autodetectable constants
+ *
* @var SplArrayObject|StdlibArrayObject
*/
protected $constants;
@@ -93,7 +95,7 @@ public function __construct(
}
if ($constants === null) {
$constants = new SplArrayObject();
- } elseif (!(($constants instanceof SplArrayObject) || ($constants instanceof StdlibArrayObject))) {
+ } elseif (! ($constants instanceof SplArrayObject || $constants instanceof StdlibArrayObject)) {
throw new InvalidArgumentException(
'$constants must be an instance of ArrayObject or Zend\Stdlib\ArrayObject'
);
@@ -115,7 +117,7 @@ public function initEnvironmentConstants()
'__METHOD__',
'__FUNCTION__',
'__NAMESPACE__',
- '::'
+ '::',
];
$constants = array_merge($constants, array_keys(get_defined_constants()), $this->constants->getArrayCopy());
$this->constants->exchangeArray($constants);
@@ -185,7 +187,7 @@ public function isValidConstantType()
self::TYPE_DOUBLE,
self::TYPE_STRING,
self::TYPE_CONSTANT,
- self::TYPE_NULL
+ self::TYPE_NULL,
];
return in_array($type, $validConstantTypes);
@@ -267,7 +269,7 @@ protected function getValidatedType($type)
self::TYPE_CONSTANT,
self::TYPE_NULL,
self::TYPE_OBJECT,
- self::TYPE_OTHER
+ self::TYPE_OTHER,
];
if (in_array($type, $types)) {
@@ -350,7 +352,7 @@ public function generate()
switch ($type) {
case self::TYPE_BOOLEAN:
case self::TYPE_BOOL:
- $output .= ($value ? 'true' : 'false');
+ $output .= $value ? 'true' : 'false';
break;
case self::TYPE_STRING:
$output .= self::escape($value);
@@ -403,7 +405,7 @@ public function generate()
$outputParts[] = (is_int($n) ? $n : self::escape($n)) . ' => ' . $partV;
}
}
- $padding = ($this->outputMode == self::OUTPUT_MULTIPLE_LINE)
+ $padding = $this->outputMode == self::OUTPUT_MULTIPLE_LINE
? self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth + 1)
: ' ';
$output .= implode(',' . $padding, $outputParts);
diff --git a/src/Generic/Prototype/PrototypeClassFactory.php b/src/Generic/Prototype/PrototypeClassFactory.php
index 58c28e07..9426681a 100644
--- a/src/Generic/Prototype/PrototypeClassFactory.php
+++ b/src/Generic/Prototype/PrototypeClassFactory.php
@@ -32,7 +32,7 @@ class PrototypeClassFactory
/**
* @var PrototypeGenericInterface
*/
- protected $genericPrototype = null;
+ protected $genericPrototype;
/**
* @param PrototypeInterface[] $prototypes
@@ -40,7 +40,7 @@ class PrototypeClassFactory
*/
public function __construct($prototypes = [], PrototypeGenericInterface $genericPrototype = null)
{
- foreach ((array)$prototypes as $prototype) {
+ foreach ((array) $prototypes as $prototype) {
$this->addPrototype($prototype);
}
@@ -105,11 +105,11 @@ public function getClonedPrototype($prototypeName)
{
$prototypeName = $this->normalizeName($prototypeName);
- if (!$this->hasPrototype($prototypeName) && !isset($this->genericPrototype)) {
+ if (! $this->hasPrototype($prototypeName) && ! isset($this->genericPrototype)) {
throw new Exception\RuntimeException('This tag name is not supported by this tag manager');
}
- if (!$this->hasPrototype($prototypeName)) {
+ if (! $this->hasPrototype($prototypeName)) {
$newPrototype = clone $this->genericPrototype;
$newPrototype->setName($prototypeName);
} else {
diff --git a/src/NameInformation.php b/src/NameInformation.php
index 6e7eb988..e27dab17 100644
--- a/src/NameInformation.php
+++ b/src/NameInformation.php
@@ -14,7 +14,7 @@ class NameInformation
/**
* @var string
*/
- protected $namespace = null;
+ protected $namespace;
/**
* @var array
@@ -58,7 +58,7 @@ public function getNamespace()
*/
public function hasNamespace()
{
- return ($this->namespace !== null);
+ return $this->namespace !== null;
}
/**
@@ -128,11 +128,11 @@ public function getUses()
*/
public function resolveName($name)
{
- if ($this->namespace && !$this->uses && strlen($name) > 0 && $name{0} != '\\') {
+ if ($this->namespace && ! $this->uses && strlen($name) > 0 && $name{0} != '\\') {
return $this->namespace . '\\' . $name;
}
- if (!$this->uses || strlen($name) <= 0 || $name{0} == '\\') {
+ if (! $this->uses || strlen($name) <= 0 || $name{0} == '\\') {
return ltrim($name, '\\');
}
diff --git a/src/Reflection/ClassReflection.php b/src/Reflection/ClassReflection.php
index 42f122c2..76407257 100644
--- a/src/Reflection/ClassReflection.php
+++ b/src/Reflection/ClassReflection.php
@@ -20,12 +20,12 @@ class ClassReflection extends ReflectionClass implements ReflectionInterface
/**
* @var AnnotationScanner
*/
- protected $annotations = null;
+ protected $annotations;
/**
* @var DocBlockReflection
*/
- protected $docBlock = null;
+ protected $docBlock;
/**
* Return the reflection file of the declaring file.
@@ -79,7 +79,7 @@ public function getAnnotations(AnnotationManager $annotationManager)
$fileScanner = $this->createFileScanner($this->getFileName());
$nameInformation = $fileScanner->getClassNameInformation($this->getName());
- if (!$nameInformation) {
+ if (! $nameInformation) {
return false;
}
@@ -123,7 +123,7 @@ public function getContents($includeDocBlock = true)
// Ensure we get between the open and close braces
$lines = array_slice($filelines, $startnum, $endnum);
- array_unshift($lines, $filelines[$startnum-1]);
+ array_unshift($lines, $filelines[$startnum - 1]);
return strstr(implode('', $lines), '{');
}
@@ -180,7 +180,7 @@ public function getMethods($filter = -1)
/**
* Returns an array of reflection classes of traits used by this class.
*
- * @return array|null
+ * @return void|array
*/
public function getTraits()
{
diff --git a/src/Reflection/DocBlock/Tag/AuthorTag.php b/src/Reflection/DocBlock/Tag/AuthorTag.php
index d6c54db8..a3087103 100644
--- a/src/Reflection/DocBlock/Tag/AuthorTag.php
+++ b/src/Reflection/DocBlock/Tag/AuthorTag.php
@@ -14,12 +14,12 @@ class AuthorTag implements TagInterface
/**
* @var string
*/
- protected $authorName = null;
+ protected $authorName;
/**
* @var string
*/
- protected $authorEmail = null;
+ protected $authorEmail;
/**
* @return string
@@ -38,7 +38,7 @@ public function initialize($tagDocblockLine)
{
$match = [];
- if (!preg_match('/^([^\<]*)(\<([^\>]*)\>)?(.*)$/u', $tagDocblockLine, $match)) {
+ if (! preg_match('/^([^\<]*)(\<([^\>]*)\>)?(.*)$/u', $tagDocblockLine, $match)) {
return;
}
diff --git a/src/Reflection/DocBlock/Tag/GenericTag.php b/src/Reflection/DocBlock/Tag/GenericTag.php
index 4543f2b2..573f1cb9 100644
--- a/src/Reflection/DocBlock/Tag/GenericTag.php
+++ b/src/Reflection/DocBlock/Tag/GenericTag.php
@@ -16,17 +16,17 @@ class GenericTag implements TagInterface, PrototypeGenericInterface
/**
* @var string
*/
- protected $name = null;
+ protected $name;
/**
* @var string
*/
- protected $content = null;
+ protected $content;
/**
* @var null|string
*/
- protected $contentSplitCharacter = null;
+ protected $contentSplitCharacter;
/**
* @var array
diff --git a/src/Reflection/DocBlock/Tag/LicenseTag.php b/src/Reflection/DocBlock/Tag/LicenseTag.php
index 1c844d01..61018108 100644
--- a/src/Reflection/DocBlock/Tag/LicenseTag.php
+++ b/src/Reflection/DocBlock/Tag/LicenseTag.php
@@ -14,12 +14,12 @@ class LicenseTag implements TagInterface
/**
* @var string
*/
- protected $url = null;
+ protected $url;
/**
* @var string
*/
- protected $licenseName = null;
+ protected $licenseName;
/**
* @return string
@@ -38,7 +38,7 @@ public function initialize($tagDocblockLine)
{
$match = [];
- if (!preg_match('#^([\S]*)(?:\s+(.*))?$#m', $tagDocblockLine, $match)) {
+ if (! preg_match('#^([\S]*)(?:\s+(.*))?$#m', $tagDocblockLine, $match)) {
return;
}
diff --git a/src/Reflection/DocBlock/Tag/MethodTag.php b/src/Reflection/DocBlock/Tag/MethodTag.php
index d92e18d4..db274a74 100644
--- a/src/Reflection/DocBlock/Tag/MethodTag.php
+++ b/src/Reflection/DocBlock/Tag/MethodTag.php
@@ -21,12 +21,12 @@ class MethodTag implements TagInterface, PhpDocTypedTagInterface
/**
* @var string
*/
- protected $methodName = null;
+ protected $methodName;
/**
* @var string
*/
- protected $description = null;
+ protected $description;
/**
* Is static method
@@ -52,7 +52,7 @@ public function initialize($tagDocblockLine)
{
$match = [];
- if (!preg_match('#^(static[\s]+)?(.+[\s]+)?(.+\(\))[\s]*(.*)$#m', $tagDocblockLine, $match)) {
+ if (! preg_match('#^(static[\s]+)?(.+[\s]+)?(.+\(\))[\s]*(.*)$#m', $tagDocblockLine, $match)) {
return;
}
@@ -74,7 +74,7 @@ public function initialize($tagDocblockLine)
/**
* Get return value type
*
- * @return null|string
+ * @return void|string
* @deprecated 2.0.4 use getTypes instead
*/
public function getReturnType()
diff --git a/src/Reflection/DocBlock/Tag/ParamTag.php b/src/Reflection/DocBlock/Tag/ParamTag.php
index 1d3ccaae..577a5c21 100644
--- a/src/Reflection/DocBlock/Tag/ParamTag.php
+++ b/src/Reflection/DocBlock/Tag/ParamTag.php
@@ -19,12 +19,12 @@ class ParamTag implements TagInterface, PhpDocTypedTagInterface
/**
* @var string
*/
- protected $variableName = null;
+ protected $variableName;
/**
* @var string
*/
- protected $description = null;
+ protected $description;
/**
* @return string
@@ -43,7 +43,7 @@ public function initialize($tagDocBlockLine)
{
$matches = [];
- if (!preg_match('#((?:[\w|\\\]+(?:\[\])*\|?)+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocBlockLine, $matches)) {
+ if (! preg_match('#((?:[\w|\\\]+(?:\[\])*\|?)+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocBlockLine, $matches)) {
return;
}
diff --git a/src/Reflection/DocBlock/Tag/PropertyTag.php b/src/Reflection/DocBlock/Tag/PropertyTag.php
index 7f6c57b9..90f58118 100644
--- a/src/Reflection/DocBlock/Tag/PropertyTag.php
+++ b/src/Reflection/DocBlock/Tag/PropertyTag.php
@@ -19,12 +19,12 @@ class PropertyTag implements TagInterface, PhpDocTypedTagInterface
/**
* @var string
*/
- protected $propertyName = null;
+ protected $propertyName;
/**
* @var string
*/
- protected $description = null;
+ protected $description;
/**
* @return string
@@ -42,7 +42,7 @@ public function getName()
public function initialize($tagDocblockLine)
{
$match = [];
- if (!preg_match('#^(.+)?(\$[\S]+)[\s]*(.*)$#m', $tagDocblockLine, $match)) {
+ if (! preg_match('#^(.+)?(\$[\S]+)[\s]*(.*)$#m', $tagDocblockLine, $match)) {
return;
}
@@ -60,7 +60,7 @@ public function initialize($tagDocblockLine)
}
/**
- * @return null|string
+ * @return void|string
* @deprecated 2.0.4 use getTypes instead
*/
public function getType()
diff --git a/src/Reflection/DocBlock/Tag/ReturnTag.php b/src/Reflection/DocBlock/Tag/ReturnTag.php
index 9da77d1a..c4f7d84c 100644
--- a/src/Reflection/DocBlock/Tag/ReturnTag.php
+++ b/src/Reflection/DocBlock/Tag/ReturnTag.php
@@ -19,7 +19,7 @@ class ReturnTag implements TagInterface, PhpDocTypedTagInterface
/**
* @var string
*/
- protected $description = null;
+ protected $description;
/**
* @return string
@@ -36,7 +36,7 @@ public function getName()
public function initialize($tagDocBlockLine)
{
$matches = [];
- if (!preg_match('#((?:[\w|\\\]+(?:\[\])*\|?)+)(?:\s+(.*))?#s', $tagDocBlockLine, $matches)) {
+ if (! preg_match('#((?:[\w|\\\]+(?:\[\])*\|?)+)(?:\s+(.*))?#s', $tagDocBlockLine, $matches)) {
return;
}
diff --git a/src/Reflection/DocBlock/Tag/ThrowsTag.php b/src/Reflection/DocBlock/Tag/ThrowsTag.php
index aa9cff1f..f0419aed 100644
--- a/src/Reflection/DocBlock/Tag/ThrowsTag.php
+++ b/src/Reflection/DocBlock/Tag/ThrowsTag.php
@@ -19,7 +19,7 @@ class ThrowsTag implements TagInterface, PhpDocTypedTagInterface
/**
* @var string
*/
- protected $description = null;
+ protected $description;
/**
* @return string
diff --git a/src/Reflection/DocBlockReflection.php b/src/Reflection/DocBlockReflection.php
index 32fbd323..82537a1c 100644
--- a/src/Reflection/DocBlockReflection.php
+++ b/src/Reflection/DocBlockReflection.php
@@ -19,39 +19,42 @@ class DocBlockReflection implements ReflectionInterface
/**
* @var Reflector
*/
- protected $reflector = null;
+ protected $reflector;
/**
* @var string
*/
- protected $docComment = null;
+ protected $docComment;
/**
* @var DocBlockTagManager
*/
- protected $tagManager = null;
+ protected $tagManager;
- /**#@+
+ /**
+ * @var int
+ */
+ protected $startLine;
+
+ /**
* @var int
*/
- protected $startLine = null;
- protected $endLine = null;
- /**#@-*/
+ protected $endLine;
/**
* @var string
*/
- protected $cleanDocComment = null;
+ protected $cleanDocComment;
/**
* @var string
*/
- protected $longDescription = null;
+ protected $longDescription;
/**
* @var string
*/
- protected $shortDescription = null;
+ protected $shortDescription;
/**
* @var array
@@ -83,7 +86,7 @@ public static function export()
*/
public function __construct($commentOrReflector, DocBlockTagManager $tagManager = null)
{
- if (!$tagManager) {
+ if (! $tagManager) {
$tagManager = new DocBlockTagManager();
$tagManager->initializeDefaultTags();
}
@@ -91,7 +94,7 @@ public function __construct($commentOrReflector, DocBlockTagManager $tagManager
if ($commentOrReflector instanceof Reflector) {
$this->reflector = $commentOrReflector;
- if (!method_exists($commentOrReflector, 'getDocComment')) {
+ if (! method_exists($commentOrReflector, 'getDocComment')) {
throw new Exception\InvalidArgumentException('Reflector must contain method "getDocComment"');
}
/* @var MethodReflection $commentOrReflector */
@@ -222,7 +225,7 @@ public function getTag($name)
public function getTags($filter = null)
{
$this->reflect();
- if ($filter === null || !is_string($filter)) {
+ if ($filter === null || ! is_string($filter)) {
return $this->tags;
}
@@ -271,15 +274,15 @@ protected function reflect()
*/
public function toString()
{
- $str = "DocBlock [ /* DocBlock */ ] {" . "\n" . "\n";
- $str .= " - Tags [" . count($this->tags) . "] {" . "\n";
+ $str = 'DocBlock [ /* DocBlock */ ] {' . "\n\n";
+ $str .= ' - Tags [' . count($this->tags) . '] {' . "\n";
foreach ($this->tags as $tag) {
- $str .= " " . $tag;
+ $str .= ' ' . $tag;
}
- $str .= " }" . "\n";
- $str .= "}" . "\n";
+ $str .= ' }' . "\n";
+ $str .= '}' . "\n";
return $str;
}
diff --git a/src/Reflection/FileReflection.php b/src/Reflection/FileReflection.php
index 9f3c7489..590cc048 100644
--- a/src/Reflection/FileReflection.php
+++ b/src/Reflection/FileReflection.php
@@ -16,12 +16,12 @@ class FileReflection implements ReflectionInterface
/**
* @var string
*/
- protected $filePath = null;
+ protected $filePath;
/**
* @var string
*/
- protected $docComment = null;
+ protected $docComment;
/**
* @var int
@@ -31,7 +31,7 @@ class FileReflection implements ReflectionInterface
/**
* @var int
*/
- protected $endLine = null;
+ protected $endLine;
/**
* @var string[]
@@ -61,7 +61,7 @@ class FileReflection implements ReflectionInterface
/**
* @var string
*/
- protected $contents = null;
+ protected $contents;
/**
* @param string $filename
@@ -75,15 +75,15 @@ public function __construct($filename, $includeIfNotAlreadyIncluded = false)
$fileRealPath = stream_resolve_include_path($filename);
}
- if (!$fileRealPath) {
+ if (! $fileRealPath) {
throw new Exception\InvalidArgumentException(sprintf(
'No file for %s was found.',
$filename
));
}
- if (!in_array($fileRealPath, get_included_files())) {
- if (!$includeIfNotAlreadyIncluded) {
+ if (! in_array($fileRealPath, get_included_files())) {
+ if (! $includeIfNotAlreadyIncluded) {
throw new Exception\RuntimeException(sprintf(
'File %s must be required before it can be reflected',
$filename
@@ -101,11 +101,10 @@ public function __construct($filename, $includeIfNotAlreadyIncluded = false)
* Required by the Reflector interface.
*
* @todo What should this do?
- * @return null
+ * @return void
*/
public static function export()
{
- return;
}
/**
@@ -151,7 +150,7 @@ public function getDocComment()
*/
public function getDocBlock()
{
- if (!($docComment = $this->getDocComment())) {
+ if (! ($docComment = $this->getDocComment())) {
return false;
}
@@ -169,7 +168,7 @@ public function getNamespaces()
}
/**
- * @return string
+ * @return void|string
*/
public function getNamespace()
{
diff --git a/src/Reflection/FunctionReflection.php b/src/Reflection/FunctionReflection.php
index b5b36979..e205af97 100644
--- a/src/Reflection/FunctionReflection.php
+++ b/src/Reflection/FunctionReflection.php
@@ -85,7 +85,7 @@ public function getContents($includeDocBlock = true)
$lines = array_slice(
file($fileName, FILE_IGNORE_NEW_LINES),
$startLine - 1,
- ($endLine - ($startLine - 1)),
+ $endLine - ($startLine - 1),
true
);
@@ -98,7 +98,7 @@ public function getContents($includeDocBlock = true)
$content = $matches[0];
}
} else {
- $name = substr($this->getName(), strrpos($this->getName(), '\\')+1);
+ $name = substr($this->getName(), strrpos($this->getName(), '\\') + 1);
preg_match(
'#function\s+' . preg_quote($name) . '\s*\([^\)]*\)\s*{([^{}]+({[^}]+})*[^}]+)?}#',
$functionLine,
@@ -117,6 +117,7 @@ public function getContents($includeDocBlock = true)
/**
* Get method prototype
*
+ * @param string $format
* @return array
*/
public function getPrototype($format = FunctionReflection::PROTOTYPE_AS_ARRAY)
@@ -140,7 +141,7 @@ public function getPrototype($format = FunctionReflection::PROTOTYPE_AS_ARRAY)
foreach ($parameters as $parameter) {
$prototype['arguments'][$parameter->getName()] = [
'type' => $parameter->detectType(),
- 'required' => !$parameter->isOptional(),
+ 'required' => ! $parameter->isOptional(),
'by_ref' => $parameter->isPassedByReference(),
'default' => $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null,
];
@@ -153,7 +154,7 @@ public function getPrototype($format = FunctionReflection::PROTOTYPE_AS_ARRAY)
$argsLine = ($argument['type']
? $argument['type'] . ' '
: '') . ($argument['by_ref'] ? '&' : '') . '$' . $name;
- if (!$argument['required']) {
+ if (! $argument['required']) {
$argsLine .= ' = ' . var_export($argument['default'], true);
}
$args[] = $argsLine;
@@ -195,7 +196,7 @@ public function getParameters()
public function getReturn()
{
$docBlock = $this->getDocBlock();
- if (!$docBlock->hasTag('return')) {
+ if (! $docBlock->hasTag('return')) {
throw new Exception\InvalidArgumentException(
'Function does not specify an @return annotation tag; cannot determine return type'
);
@@ -232,7 +233,7 @@ public function getBody()
$lines = array_slice(
file($fileName, FILE_IGNORE_NEW_LINES),
$startLine - 1,
- ($endLine - ($startLine - 1)),
+ $endLine - ($startLine - 1),
true
);
@@ -245,7 +246,7 @@ public function getBody()
$body = $matches[2];
}
} else {
- $name = substr($this->getName(), strrpos($this->getName(), '\\')+1);
+ $name = substr($this->getName(), strrpos($this->getName(), '\\') + 1);
preg_match('#function\s+' . $name . '\s*\([^\)]*\)\s*{([^{}]+({[^}]+})*[^}]+)}#', $functionLine, $matches);
if (isset($matches[1])) {
$body = $matches[1];
diff --git a/src/Reflection/MethodReflection.php b/src/Reflection/MethodReflection.php
index b0d9d50a..d8fc887a 100644
--- a/src/Reflection/MethodReflection.php
+++ b/src/Reflection/MethodReflection.php
@@ -29,7 +29,7 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac
/**
* @var AnnotationScanner
*/
- protected $annotations = null;
+ protected $annotations;
/**
* Retrieve method DocBlock reflection
@@ -64,7 +64,7 @@ public function getAnnotations(AnnotationManager $annotationManager)
$cachingFileScanner = $this->createFileScanner($this->getFileName());
$nameInformation = $cachingFileScanner->getClassNameInformation($this->getDeclaringClass()->getName());
- if (!$nameInformation) {
+ if (! $nameInformation) {
return false;
}
@@ -107,6 +107,7 @@ public function getDeclaringClass()
/**
* Get method prototype
*
+ * @param string $format
* @return array
*/
public function getPrototype($format = MethodReflection::PROTOTYPE_AS_ARRAY)
@@ -124,7 +125,7 @@ public function getPrototype($format = MethodReflection::PROTOTYPE_AS_ARRAY)
'namespace' => $declaringClass->getNamespaceName(),
'class' => substr($declaringClass->getName(), strlen($declaringClass->getNamespaceName()) + 1),
'name' => $this->getName(),
- 'visibility' => ($this->isPublic() ? 'public' : ($this->isPrivate() ? 'private' : 'protected')),
+ 'visibility' => $this->isPublic() ? 'public' : ($this->isPrivate() ? 'private' : 'protected'),
'return' => $returnType,
'arguments' => [],
];
@@ -133,7 +134,7 @@ public function getPrototype($format = MethodReflection::PROTOTYPE_AS_ARRAY)
foreach ($parameters as $parameter) {
$prototype['arguments'][$parameter->getName()] = [
'type' => $parameter->detectType(),
- 'required' => !$parameter->isOptional(),
+ 'required' => ! $parameter->isOptional(),
'by_ref' => $parameter->isPassedByReference(),
'default' => $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null,
];
@@ -146,7 +147,7 @@ public function getPrototype($format = MethodReflection::PROTOTYPE_AS_ARRAY)
$argsLine = ($argument['type'] ?
$argument['type'] . ' '
: '') . ($argument['by_ref'] ? '&' : '') . '$' . $name;
- if (!$argument['required']) {
+ if (! $argument['required']) {
$argsLine .= ' = ' . var_export($argument['default'], true);
}
$args[] = $argsLine;
@@ -191,7 +192,7 @@ public function getParameters()
public function getContents($includeDocBlock = true)
{
$docComment = $this->getDocComment();
- $content = ($includeDocBlock && !empty($docComment)) ? $docComment . "\n" : '';
+ $content = $includeDocBlock && ! empty($docComment) ? $docComment . "\n" : '';
$content .= $this->extractMethodContents();
return $content;
@@ -224,17 +225,17 @@ protected function extractMethodContents($bodyOnly = false)
$lines = array_slice(
file($fileName, FILE_IGNORE_NEW_LINES),
$this->getStartLine() - 1,
- ($this->getEndLine() - ($this->getStartLine() - 1)),
+ $this->getEndLine() - ($this->getStartLine() - 1),
true
);
$functionLine = implode("\n", $lines);
- $tokens = token_get_all(" $token) {
- $tokenType = (is_array($token)) ? token_name($token[0]) : $token;
- $tokenValue = (is_array($token)) ? $token[1] : $token;
+ $tokenType = is_array($token) ? token_name($token[0]) : $token;
+ $tokenValue = is_array($token) ? $token[1] : $token;
switch ($tokenType) {
- case "T_FINAL":
- case "T_ABSTRACT":
- case "T_PUBLIC":
- case "T_PROTECTED":
- case "T_PRIVATE":
- case "T_STATIC":
- case "T_FUNCTION":
+ case 'T_FINAL':
+ case 'T_ABSTRACT':
+ case 'T_PUBLIC':
+ case 'T_PROTECTED':
+ case 'T_PRIVATE':
+ case 'T_STATIC':
+ case 'T_FUNCTION':
// check to see if we have a valid function
// then check if we are inside function and have a closure
if ($this->isValidFunction($tokens, $key, $this->getName())) {
@@ -269,7 +270,7 @@ protected function extractMethodContents($bodyOnly = false)
$capture = true;
} else {
//closure test
- if ($firstBrace && $tokenType == "T_FUNCTION") {
+ if ($firstBrace && $tokenType == 'T_FUNCTION') {
$body .= $tokenValue;
continue;
}
@@ -278,7 +279,7 @@ protected function extractMethodContents($bodyOnly = false)
}
break;
- case "{":
+ case '{':
if ($capture === false) {
continue;
}
@@ -293,7 +294,7 @@ protected function extractMethodContents($bodyOnly = false)
$body .= $tokenValue;
break;
- case "}":
+ case '}':
if ($capture === false) {
continue;
}
@@ -341,16 +342,16 @@ protected function extractPrefixedWhitespace($haystack, $position)
{
$content = '';
$count = count($haystack);
- if ($position+1 == $count) {
+ if ($position + 1 == $count) {
return $content;
}
- for ($i = $position-1; $i >= 0; $i--) {
- $tokenType = (is_array($haystack[$i])) ? token_name($haystack[$i][0]) : $haystack[$i];
- $tokenValue = (is_array($haystack[$i])) ? $haystack[$i][1] : $haystack[$i];
+ for ($i = $position - 1; $i >= 0; $i--) {
+ $tokenType = is_array($haystack[$i]) ? token_name($haystack[$i][0]) : $haystack[$i];
+ $tokenValue = is_array($haystack[$i]) ? $haystack[$i][1] : $haystack[$i];
//search only for whitespace
- if ($tokenType == "T_WHITESPACE") {
+ if ($tokenType == 'T_WHITESPACE') {
$content .= $tokenValue;
} else {
break;
@@ -372,24 +373,24 @@ protected function isEndingBrace($haystack, $position)
$count = count($haystack);
//advance one position
- $position = $position+1;
+ $position = $position + 1;
if ($position == $count) {
return true;
}
for ($i = $position; $i < $count; $i++) {
- $tokenType = (is_array($haystack[$i])) ? token_name($haystack[$i][0]) : $haystack[$i];
+ $tokenType = is_array($haystack[$i]) ? token_name($haystack[$i][0]) : $haystack[$i];
switch ($tokenType) {
- case "T_FINAL":
- case "T_ABSTRACT":
- case "T_PUBLIC":
- case "T_PROTECTED":
- case "T_PRIVATE":
- case "T_STATIC":
+ case 'T_FINAL':
+ case 'T_ABSTRACT':
+ case 'T_PUBLIC':
+ case 'T_PROTECTED':
+ case 'T_PRIVATE':
+ case 'T_STATIC':
return true;
- case "T_FUNCTION":
+ case 'T_FUNCTION':
// If a function is encountered and that function is not a closure
// then return true. otherwise the function is a closure, return false
if ($this->isValidFunction($haystack, $i)) {
@@ -397,31 +398,31 @@ protected function isEndingBrace($haystack, $position)
}
return false;
- case "}":
- case ";":
- case "T_BREAK":
- case "T_CATCH":
- case "T_DO":
- case "T_ECHO":
- case "T_ELSE":
- case "T_ELSEIF":
- case "T_EVAL":
- case "T_EXIT":
- case "T_FINALLY":
- case "T_FOR":
- case "T_FOREACH":
- case "T_GOTO":
- case "T_IF":
- case "T_INCLUDE":
- case "T_INCLUDE_ONCE":
- case "T_PRINT":
- case "T_STRING":
- case "T_STRING_VARNAME":
- case "T_THROW":
- case "T_USE":
- case "T_VARIABLE":
- case "T_WHILE":
- case "T_YIELD":
+ case '}':
+ case ';':
+ case 'T_BREAK':
+ case 'T_CATCH':
+ case 'T_DO':
+ case 'T_ECHO':
+ case 'T_ELSE':
+ case 'T_ELSEIF':
+ case 'T_EVAL':
+ case 'T_EXIT':
+ case 'T_FINALLY':
+ case 'T_FOR':
+ case 'T_FOREACH':
+ case 'T_GOTO':
+ case 'T_IF':
+ case 'T_INCLUDE':
+ case 'T_INCLUDE_ONCE':
+ case 'T_PRINT':
+ case 'T_STRING':
+ case 'T_STRING_VARNAME':
+ case 'T_THROW':
+ case 'T_USE':
+ case 'T_VARIABLE':
+ case 'T_WHILE':
+ case 'T_YIELD':
return false;
}
}
@@ -440,12 +441,12 @@ protected function isValidFunction($haystack, $position, $functionName = null)
{
$isValid = false;
$count = count($haystack);
- for ($i = $position+1; $i < $count; $i++) {
- $tokenType = (is_array($haystack[$i])) ? token_name($haystack[$i][0]) : $haystack[$i];
- $tokenValue = (is_array($haystack[$i])) ? $haystack[$i][1] : $haystack[$i];
+ for ($i = $position + 1; $i < $count; $i++) {
+ $tokenType = is_array($haystack[$i]) ? token_name($haystack[$i][0]) : $haystack[$i];
+ $tokenValue = is_array($haystack[$i]) ? $haystack[$i][1] : $haystack[$i];
//check for occurance of ( or
- if ($tokenType == "T_STRING") {
+ if ($tokenType == 'T_STRING') {
//check to see if function name is passed, if so validate against that
if ($functionName !== null && $tokenValue != $functionName) {
$isValid = false;
@@ -454,7 +455,7 @@ protected function isValidFunction($haystack, $position, $functionName = null)
$isValid = true;
break;
- } elseif ($tokenValue == "(") {
+ } elseif ($tokenValue == '(') {
break;
}
}
diff --git a/src/Reflection/ParameterReflection.php b/src/Reflection/ParameterReflection.php
index e9dc31ee..d3a73a2f 100644
--- a/src/Reflection/ParameterReflection.php
+++ b/src/Reflection/ParameterReflection.php
@@ -35,7 +35,7 @@ public function getDeclaringClass()
/**
* Get class reflection object
*
- * @return ClassReflection
+ * @return void|ClassReflection
*/
public function getClass()
{
diff --git a/src/Reflection/PropertyReflection.php b/src/Reflection/PropertyReflection.php
index 6cadc027..33066ac1 100644
--- a/src/Reflection/PropertyReflection.php
+++ b/src/Reflection/PropertyReflection.php
@@ -53,7 +53,7 @@ public function getDocComment()
*/
public function getDocBlock()
{
- if (!($docComment = $this->getDocComment())) {
+ if (! ($docComment = $this->getDocComment())) {
return false;
}
@@ -80,7 +80,7 @@ public function getAnnotations(AnnotationManager $annotationManager)
$cachingFileScanner = $this->createFileScanner($class->getFileName());
$nameInformation = $cachingFileScanner->getClassNameInformation($class->getName());
- if (!$nameInformation) {
+ if (! $nameInformation) {
return false;
}
diff --git a/src/Scanner/AggregateDirectoryScanner.php b/src/Scanner/AggregateDirectoryScanner.php
index cef16be6..43ffaf91 100644
--- a/src/Scanner/AggregateDirectoryScanner.php
+++ b/src/Scanner/AggregateDirectoryScanner.php
@@ -27,11 +27,6 @@ public function getNamespaces($returnScannerClass = false)
// @todo
}
- /*
- public function getUses($returnScannerClass = false)
- {}
- */
-
public function getIncludes($returnScannerClass = false)
{
}
@@ -65,7 +60,7 @@ public function hasClass($class)
}
}
- return (isset($scanner));
+ return isset($scanner);
}
/**
@@ -85,7 +80,7 @@ public function getClass($class, $returnScannerClass = true, $returnDerivedScann
}
}
- if (!isset($scanner)) {
+ if (! isset($scanner)) {
throw new Exception\RuntimeException('Class by that name was not found.');
}
@@ -101,7 +96,7 @@ public function getFunctions($returnScannerClass = false)
{
$this->scan();
- if (!$returnScannerClass) {
+ if (! $returnScannerClass) {
$functions = [];
foreach ($this->infos as $info) {
if ($info['type'] == 'function') {
diff --git a/src/Scanner/AnnotationScanner.php b/src/Scanner/AnnotationScanner.php
index af333bbb..f2865b15 100644
--- a/src/Scanner/AnnotationScanner.php
+++ b/src/Scanner/AnnotationScanner.php
@@ -23,17 +23,17 @@ class AnnotationScanner extends AnnotationCollection implements ScannerInterface
/**
* @var string
*/
- protected $docComment = null;
+ protected $docComment;
/**
* @var NameInformation
*/
- protected $nameInformation = null;
+ protected $nameInformation;
/**
* @var AnnotationManager
*/
- protected $annotationManager = null;
+ protected $annotationManager;
/**
* @var array
@@ -97,7 +97,7 @@ protected function scan(array $tokens)
case 'ANNOTATION_CONTENT':
case 'ANNOTATION_WHITESPACE':
case 'ANNOTATION_NEWLINE':
- if (!$contentEnd
+ if (! $contentEnd
&& isset($annotations[$annotationIndex])
&& is_string($annotations[$annotationIndex][1])
) {
@@ -157,22 +157,22 @@ protected function tokenize()
&$currentWord,
&$currentLine
) {
- $positionsForward = ($positionsForward > 0) ? $positionsForward : 1;
- $streamIndex = ($streamIndex === null) ? 0 : $streamIndex + $positionsForward;
- if (!isset($stream[$streamIndex])) {
+ $positionsForward = $positionsForward > 0 ? $positionsForward : 1;
+ $streamIndex = $streamIndex === null ? 0 : $streamIndex + $positionsForward;
+ if (! isset($stream[$streamIndex])) {
$currentChar = false;
return false;
}
$currentChar = $stream[$streamIndex];
$matches = [];
- $currentLine = (preg_match('#(.*?)(?:\n|\r\n?)#', $stream, $matches, null, $streamIndex) === 1)
+ $currentLine = preg_match('#(.*?)(?:\n|\r\n?)#', $stream, $matches, null, $streamIndex) === 1
? $matches[1]
: substr($stream, $streamIndex);
if ($currentChar === ' ') {
- $currentWord = (preg_match('#( +)#', $currentLine, $matches) === 1) ? $matches[1] : $currentLine;
+ $currentWord = preg_match('#( +)#', $currentLine, $matches) === 1 ? $matches[1] : $currentLine;
} else {
- $currentWord = (($matches = strpos($currentLine, ' ')) !== false)
+ $currentWord = ($matches = strpos($currentLine, ' ')) !== false
? substr($currentLine, 0, $matches)
: $currentLine;
}
@@ -186,7 +186,7 @@ protected function tokenize()
return $MACRO_STREAM_ADVANCE_CHAR(strlen($currentLine));
};
$MACRO_TOKEN_ADVANCE = function () use (&$tokenIndex, &$tokens) {
- $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
+ $tokenIndex = $tokenIndex === null ? 0 : $tokenIndex + 1;
$tokens[$tokenIndex] = ['ANNOTATION_UNKNOWN', ''];
};
$MACRO_TOKEN_SET_TYPE = function ($type) use (&$tokenIndex, &$tokens) {
@@ -202,7 +202,7 @@ protected function tokenize()
$tokens[$tokenIndex][1] .= $currentLine;
};
$MACRO_HAS_CONTEXT = function ($which) use (&$context) {
- return (($context & $which) === $which);
+ return ($context & $which) === $which;
};
$MACRO_STREAM_ADVANCE_CHAR();
@@ -264,7 +264,7 @@ protected function tokenize()
if ($currentChar === ' ') {
$MACRO_TOKEN_SET_TYPE(
- ($MACRO_HAS_CONTEXT($CONTEXT_ASTERISK))
+ $MACRO_HAS_CONTEXT($CONTEXT_ASTERISK)
? 'ANNOTATION_WHITESPACE'
: 'ANNOTATION_WHITESPACE_INDENT'
);
diff --git a/src/Scanner/CachingFileScanner.php b/src/Scanner/CachingFileScanner.php
index 10945896..68265968 100644
--- a/src/Scanner/CachingFileScanner.php
+++ b/src/Scanner/CachingFileScanner.php
@@ -23,7 +23,7 @@ class CachingFileScanner extends FileScanner
/**
* @var null|FileScanner
*/
- protected $fileScanner = null;
+ protected $fileScanner;
/**
* @param string $file
@@ -32,7 +32,7 @@ class CachingFileScanner extends FileScanner
*/
public function __construct($file, AnnotationManager $annotationManager = null)
{
- if (!file_exists($file)) {
+ if (! file_exists($file)) {
throw new Exception\InvalidArgumentException(sprintf(
'File "%s" not found',
$file
@@ -41,9 +41,9 @@ public function __construct($file, AnnotationManager $annotationManager = null)
$file = realpath($file);
- $cacheId = md5($file) . '/' . ((isset($annotationManager)
+ $cacheId = md5($file) . '/' . (isset($annotationManager)
? spl_object_hash($annotationManager)
- : 'no-annotation'));
+ : 'no-annotation');
if (isset(static::$cache[$cacheId])) {
$this->fileScanner = static::$cache[$cacheId];
diff --git a/src/Scanner/ClassScanner.php b/src/Scanner/ClassScanner.php
index 7069d5e9..dacf854e 100644
--- a/src/Scanner/ClassScanner.php
+++ b/src/Scanner/ClassScanner.php
@@ -24,27 +24,27 @@ class ClassScanner implements ScannerInterface
/**
* @var string
*/
- protected $docComment = null;
+ protected $docComment;
/**
* @var string
*/
- protected $name = null;
+ protected $name;
/**
* @var string
*/
- protected $shortName = null;
+ protected $shortName;
/**
* @var int
*/
- protected $lineStart = null;
+ protected $lineStart;
/**
* @var int
*/
- protected $lineEnd = null;
+ protected $lineEnd;
/**
* @var bool
@@ -69,12 +69,12 @@ class ClassScanner implements ScannerInterface
/**
* @var string
*/
- protected $parentClass = null;
+ protected $parentClass;
/**
* @var string
*/
- protected $shortParentClass = null;
+ protected $shortParentClass;
/**
* @var array
@@ -94,7 +94,7 @@ class ClassScanner implements ScannerInterface
/**
* @var NameInformation
*/
- protected $nameInformation = null;
+ protected $nameInformation;
/**
* @var array
@@ -156,7 +156,7 @@ public function getDocComment()
*/
public function getDocBlock()
{
- if (!$docComment = $this->getDocComment()) {
+ if (! $docComment = $this->getDocComment()) {
return false;
}
@@ -220,6 +220,7 @@ public function isFinal()
/**
* Verify if class is a trait
+ *
* @return bool
*/
public function isTrait()
@@ -236,7 +237,7 @@ public function isTrait()
public function isInstantiable()
{
$this->scan();
- return (!$this->isAbstract && !$this->isInterface && !$this->isTrait);
+ return ! $this->isAbstract && ! $this->isInterface && ! $this->isTrait;
}
/**
@@ -269,7 +270,7 @@ public function isInterface()
public function hasParentClass()
{
$this->scan();
- return ($this->parentClass !== null);
+ return $this->parentClass !== null;
}
/**
@@ -366,7 +367,7 @@ public function getConstant($constantNameOrInfoIndex)
break;
}
}
- if (!$constantFound) {
+ if (! $constantFound) {
return false;
}
} else {
@@ -374,7 +375,7 @@ public function getConstant($constantNameOrInfoIndex)
'Invalid constant name of info index type. Must be of type int or string'
);
}
- if (!isset($info)) {
+ if (! isset($info)) {
return false;
}
$p = new ConstantScanner(
@@ -471,7 +472,7 @@ public function getProperty($propertyNameOrInfoIndex)
break;
}
}
- if (!$propertyFound) {
+ if (! $propertyFound) {
return false;
}
} else {
@@ -479,7 +480,7 @@ public function getProperty($propertyNameOrInfoIndex)
'Invalid property name of info index type. Must be of type int or string'
);
}
- if (!isset($info)) {
+ if (! isset($info)) {
return false;
}
$p = new PropertyScanner(
@@ -715,7 +716,7 @@ public function getMethods()
}
// Merge in trait methods
- if ($info['type'] === "use") {
+ if ($info['type'] === 'use') {
$traitMethods = [];
$traits = $this->getTraits();
$insteadof = $this->getBlockedTraitMethods();
@@ -849,14 +850,13 @@ protected function scan()
return;
}
- if (!$this->tokens) {
+ if (! $this->tokens) {
throw new Exception\RuntimeException('No tokens were provided');
}
/**
* Variables & Setup
*/
-
$tokens = &$this->tokens; // localize
$infos = &$this->infos; // localize
$tokenIndex = null;
@@ -880,8 +880,8 @@ protected function scan()
&$tokenLine
) {
static $lastTokenArray = null;
- $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
- if (!isset($tokens[$tokenIndex])) {
+ $tokenIndex = $tokenIndex === null ? 0 : $tokenIndex + 1;
+ if (! isset($tokens[$tokenIndex])) {
$token = false;
$tokenContent = false;
$tokenType = false;
@@ -916,7 +916,6 @@ protected function scan()
/**
* START FINITE STATE MACHINE FOR SCANNING TOKENS
*/
-
// Initialize token
$MACRO_TOKEN_ADVANCE();
@@ -1003,7 +1002,7 @@ protected function scan()
$classContext = $tokenType;
if (($this->isInterface && $classContext === T_EXTENDS) || $classContext === T_IMPLEMENTS) {
$this->shortInterfaces[$classInterfaceIndex] = '';
- } elseif (!$this->isInterface && $classContext === T_EXTENDS) {
+ } elseif (! $this->isInterface && $classContext === T_EXTENDS) {
$this->shortParentClass = '';
}
goto SCANNER_CLASS_INFO_CONTINUE;
@@ -1011,7 +1010,8 @@ protected function scan()
case null:
if (($classContext == T_IMPLEMENTS && $tokenContent == ',')
- || ($classContext == T_EXTENDS && $tokenContent == ',' && $this->isInterface)) {
+ || ($classContext == T_EXTENDS && $tokenContent == ',' && $this->isInterface)
+ ) {
$classInterfaceIndex++;
$this->shortInterfaces[$classInterfaceIndex] = '';
}
@@ -1112,16 +1112,16 @@ protected function scan()
SCANNER_USE_TOP:
if ($tokenType === null) {
- if ($tokenContent === "{") {
+ if ($tokenContent === '{') {
$useStatementIndex = 0;
$useAliasContext = true;
$infos[$infoIndex]['aliases'][$useStatementIndex] = [
'original' => null,
'alias' => null,
'visibility' => null,
- 'type' => 'as'
+ 'type' => 'as',
];
- } elseif ($tokenContent === "}") {
+ } elseif ($tokenContent === '}') {
$useAliasContext = false;
goto SCANNER_USE_END;
} elseif ($tokenContent === ';') {
@@ -1154,13 +1154,13 @@ protected function scan()
'original' => null,
'visibility' => null,
'alias' => null,
- 'type' => null
+ 'type' => null,
];
}
if ($tokenType == T_AS || $tokenType == T_INSTEADOF) {
$useAsContext = true;
- $infos[$infoIndex]['aliases'][$useStatementIndex]['type'] = ($tokenType == T_INSTEADOF)
+ $infos[$infoIndex]['aliases'][$useStatementIndex]['type'] = $tokenType == T_INSTEADOF
? 'insteadof'
: 'as';
goto SCANNER_USE_CONTINUE;
@@ -1341,7 +1341,5 @@ protected function scan()
}
$this->isScanned = true;
-
- return;
}
}
diff --git a/src/Scanner/ConstantScanner.php b/src/Scanner/ConstantScanner.php
index 31e245c9..b9b8b379 100644
--- a/src/Scanner/ConstantScanner.php
+++ b/src/Scanner/ConstantScanner.php
@@ -156,7 +156,7 @@ protected function scan()
return;
}
- if (!$this->tokens) {
+ if (! $this->tokens) {
throw new Exception\RuntimeException('No tokens were provided');
}
@@ -171,7 +171,7 @@ protected function scan()
$token = current($tokens);
- if (!is_string($token)) {
+ if (! is_string($token)) {
list($tokenType, $tokenContent, $tokenLine) = $token;
switch ($tokenType) {
@@ -183,7 +183,7 @@ protected function scan()
// fall-through
case T_STRING:
- $string = (is_string($token)) ? $token : $tokenContent;
+ $string = is_string($token) ? $token : $tokenContent;
if (null === $this->name) {
$this->name = $string;
@@ -207,7 +207,7 @@ protected function scan()
case T_CONSTANT_ENCAPSED_STRING:
case T_DNUMBER:
case T_LNUMBER:
- $string = (is_string($token)) ? $token : $tokenContent;
+ $string = is_string($token) ? $token : $tokenContent;
if (substr($string, 0, 1) === '"' || substr($string, 0, 1) === "'") {
$this->value = substr($string, 1, -1); // Remove quotes
diff --git a/src/Scanner/DerivedClassScanner.php b/src/Scanner/DerivedClassScanner.php
index f4f01c94..926ef3cc 100644
--- a/src/Scanner/DerivedClassScanner.php
+++ b/src/Scanner/DerivedClassScanner.php
@@ -16,12 +16,12 @@ class DerivedClassScanner extends ClassScanner
/**
* @var DirectoryScanner
*/
- protected $directoryScanner = null;
+ protected $directoryScanner;
/**
* @var ClassScanner
*/
- protected $classScanner = null;
+ protected $classScanner;
/**
* @var array
@@ -123,7 +123,7 @@ public function getParentClasses()
*/
public function hasParentClass()
{
- return ($this->classScanner->getParentClass() !== null);
+ return $this->classScanner->getParentClass() !== null;
}
/**
diff --git a/src/Scanner/DirectoryScanner.php b/src/Scanner/DirectoryScanner.php
index e561be0d..f250b5ce 100644
--- a/src/Scanner/DirectoryScanner.php
+++ b/src/Scanner/DirectoryScanner.php
@@ -33,7 +33,7 @@ class DirectoryScanner implements ScannerInterface
/**
* @var array
*/
- protected $classToFileScanner = null;
+ protected $classToFileScanner;
/**
* @param null|string|array $directory
@@ -62,7 +62,7 @@ public function addDirectory($directory)
$this->directories[] = $directory;
} elseif (is_string($directory)) {
$realDir = realpath($directory);
- if (!$realDir || !is_dir($realDir)) {
+ if (! $realDir || ! is_dir($realDir)) {
throw new Exception\InvalidArgumentException(sprintf(
'Directory "%s" does not exist',
$realDir
@@ -141,7 +141,7 @@ public function getFiles($returnFileScanners = false)
$return = [];
foreach ($this->fileScanners as $fileScanner) {
- $return[] = ($returnFileScanners) ? $fileScanner : $fileScanner->getFile();
+ $return[] = $returnFileScanners ? $fileScanner : $fileScanner->getFile();
}
return $return;
@@ -197,7 +197,7 @@ public function hasClass($class)
$this->createClassToFileScannerCache();
}
- return (isset($this->classToFileScanner[$class]));
+ return isset($this->classToFileScanner[$class]);
}
/**
@@ -214,7 +214,7 @@ public function getClass($class, $returnDerivedScannerClass = false)
$this->createClassToFileScannerCache();
}
- if (!isset($this->classToFileScanner[$class])) {
+ if (! isset($this->classToFileScanner[$class])) {
throw new Exception\InvalidArgumentException('Class not found.');
}
@@ -222,7 +222,7 @@ public function getClass($class, $returnDerivedScannerClass = false)
$fs = $this->fileScanners[$this->classToFileScanner[$class]];
$returnClass = $fs->getClass($class);
- if (($returnClass instanceof ClassScanner) && $returnDerivedScannerClass) {
+ if ($returnClass instanceof ClassScanner && $returnDerivedScannerClass) {
return new DerivedClassScanner($returnClass, $this);
}
@@ -241,6 +241,7 @@ protected function createClassToFileScannerCache()
}
$this->classToFileScanner = [];
+
/** @var FileScanner $fileScanner */
foreach ($this->fileScanners as $fsIndex => $fileScanner) {
$fsClasses = $fileScanner->getClassNames();
diff --git a/src/Scanner/DocBlockScanner.php b/src/Scanner/DocBlockScanner.php
index 228ce9ff..351ef8ee 100644
--- a/src/Scanner/DocBlockScanner.php
+++ b/src/Scanner/DocBlockScanner.php
@@ -22,22 +22,22 @@ class DocBlockScanner implements ScannerInterface
/**
* @var string
*/
- protected $docComment = null;
+ protected $docComment;
/**
* @var NameInformation
*/
- protected $nameInformation = null;
+ protected $nameInformation;
/**
* @var AnnotationManager
*/
- protected $annotationManager = null;
+ protected $annotationManager;
/**
* @var string
*/
- protected $shortDescription = null;
+ protected $shortDescription;
/**
* @var string
@@ -135,7 +135,7 @@ protected function scan()
case 'DOCBLOCK_WHITESPACE':
case 'DOCBLOCK_TEXT':
if ($tagIndex !== null) {
- $this->tags[$tagIndex]['value'] .= ($this->tags[$tagIndex]['value'] == '')
+ $this->tags[$tagIndex]['value'] .= $this->tags[$tagIndex]['value'] == ''
? $token[1]
: ' ' . $token[1];
goto SCANNER_CONTINUE;
@@ -149,8 +149,10 @@ protected function scan()
}
//gotos no break needed
case 'DOCBLOCK_TAG':
- array_push($this->tags, ['name' => $token[1],
- 'value' => '']);
+ array_push($this->tags, [
+ 'name' => $token[1],
+ 'value' => '',
+ ]);
end($this->tags);
$tagIndex = key($this->tags);
$mode = 3;
@@ -198,22 +200,22 @@ protected function tokenize()
&$currentWord,
&$currentLine
) {
- $positionsForward = ($positionsForward > 0) ? $positionsForward : 1;
- $streamIndex = ($streamIndex === null) ? 0 : $streamIndex + $positionsForward;
- if (!isset($stream[$streamIndex])) {
+ $positionsForward = $positionsForward > 0 ? $positionsForward : 1;
+ $streamIndex = $streamIndex === null ? 0 : $streamIndex + $positionsForward;
+ if (! isset($stream[$streamIndex])) {
$currentChar = false;
return false;
}
$currentChar = $stream[$streamIndex];
$matches = [];
- $currentLine = (preg_match('#(.*?)\r?\n#', $stream, $matches, null, $streamIndex) === 1)
+ $currentLine = preg_match('#(.*?)\r?\n#', $stream, $matches, null, $streamIndex) === 1
? $matches[1]
: substr($stream, $streamIndex);
if ($currentChar === ' ') {
- $currentWord = (preg_match('#( +)#', $currentLine, $matches) === 1) ? $matches[1] : $currentLine;
+ $currentWord = preg_match('#( +)#', $currentLine, $matches) === 1 ? $matches[1] : $currentLine;
} else {
- $currentWord = (($matches = strpos($currentLine, ' ')) !== false)
+ $currentWord = ($matches = strpos($currentLine, ' ')) !== false
? substr($currentLine, 0, $matches)
: $currentLine;
}
@@ -227,7 +229,7 @@ protected function tokenize()
return $MACRO_STREAM_ADVANCE_CHAR(strlen($currentLine));
};
$MACRO_TOKEN_ADVANCE = function () use (&$tokenIndex, &$tokens) {
- $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
+ $tokenIndex = $tokenIndex === null ? 0 : $tokenIndex + 1;
$tokens[$tokenIndex] = ['DOCBLOCK_UNKNOWN', ''];
};
$MACRO_TOKEN_SET_TYPE = function ($type) use (&$tokenIndex, &$tokens) {
@@ -276,7 +278,7 @@ protected function tokenize()
if ($currentChar === ' ' || $currentChar === "\t") {
$MACRO_TOKEN_SET_TYPE(
- ($context & $CONTEXT_INSIDE_ASTERISK)
+ $context & $CONTEXT_INSIDE_ASTERISK
? 'DOCBLOCK_WHITESPACE'
: 'DOCBLOCK_WHITESPACE_INDENT'
);
diff --git a/src/Scanner/FileScanner.php b/src/Scanner/FileScanner.php
index fed93700..9a3894a7 100644
--- a/src/Scanner/FileScanner.php
+++ b/src/Scanner/FileScanner.php
@@ -17,7 +17,7 @@ class FileScanner extends TokenArrayScanner implements ScannerInterface
/**
* @var string
*/
- protected $file = null;
+ protected $file;
/**
* @param string $file
@@ -27,7 +27,7 @@ class FileScanner extends TokenArrayScanner implements ScannerInterface
public function __construct($file, AnnotationManager $annotationManager = null)
{
$this->file = $file;
- if (!file_exists($file)) {
+ if (! file_exists($file)) {
throw new Exception\InvalidArgumentException(sprintf(
'File "%s" not found',
$file
diff --git a/src/Scanner/MethodScanner.php b/src/Scanner/MethodScanner.php
index 2f787474..9f19f54d 100644
--- a/src/Scanner/MethodScanner.php
+++ b/src/Scanner/MethodScanner.php
@@ -18,37 +18,37 @@ class MethodScanner implements ScannerInterface
/**
* @var bool
*/
- protected $isScanned = false;
+ protected $isScanned = false;
/**
* @var string
*/
- protected $docComment = null;
+ protected $docComment;
/**
* @var ClassScanner
*/
- protected $scannerClass = null;
+ protected $scannerClass;
/**
* @var string
*/
- protected $class = null;
+ protected $class;
/**
* @var string
*/
- protected $name = null;
+ protected $name;
/**
* @var int
*/
- protected $lineStart = null;
+ protected $lineStart;
/**
* @var int
*/
- protected $lineEnd = null;
+ protected $lineEnd;
/**
* @var bool
@@ -93,7 +93,7 @@ class MethodScanner implements ScannerInterface
/**
* @var NameInformation
*/
- protected $nameInformation = null;
+ protected $nameInformation;
/**
* @var array
@@ -131,7 +131,7 @@ public function setScannerClass(ClassScanner $scannerClass)
}
/**
- * @return MethodScanner
+ * @return ClassScanner
*/
public function getClassScanner()
{
@@ -255,7 +255,7 @@ public function isStatic()
* Override the given name for a method, this is necessary to
* support traits.
*
- * @param $name
+ * @param string $name
* @return self
*/
public function setName($name)
@@ -268,7 +268,7 @@ public function setName($name)
* Visibility must be of T_PUBLIC, T_PRIVATE or T_PROTECTED
* Needed to support traits
*
- * @param $visibility T_PUBLIC | T_PRIVATE | T_PROTECTED
+ * @param int $visibility T_PUBLIC | T_PRIVATE | T_PROTECTED
* @return self
* @throws \Zend\Code\Exception
*/
@@ -294,7 +294,7 @@ public function setVisibility($visibility)
break;
default:
- throw new Exception("Invalid visibility argument passed to setVisibility.");
+ throw new Exception('Invalid visibility argument passed to setVisibility.');
}
return $this;
@@ -323,7 +323,7 @@ public function getParameters($returnScanner = false)
continue;
}
- if (!$returnScanner) {
+ if (! $returnScanner) {
$return[] = $info['name'];
} else {
$return[] = $this->getParameter($info['name']);
@@ -354,7 +354,7 @@ public function getParameter($parameterNameOrInfoIndex)
}
unset($info);
}
- if (!isset($info)) {
+ if (! isset($info)) {
throw new Exception\InvalidArgumentException('Index of info offset is not about a parameter');
}
}
@@ -400,14 +400,13 @@ protected function scan()
return;
}
- if (!$this->tokens) {
+ if (! $this->tokens) {
throw new Exception\RuntimeException('No tokens were provided');
}
/**
* Variables & Setup
*/
-
$tokens = &$this->tokens; // localize
$infos = &$this->infos; // localize
$tokenIndex = null;
@@ -430,8 +429,8 @@ protected function scan()
&$tokenLine
) {
static $lastTokenArray = null;
- $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
- if (!isset($tokens[$tokenIndex])) {
+ $tokenIndex = $tokenIndex === null ? 0 : $tokenIndex + 1;
+ if (! isset($tokens[$tokenIndex])) {
$token = false;
$tokenContent = false;
$tokenType = false;
@@ -475,13 +474,12 @@ protected function scan()
/**
* START FINITE STATE MACHINE FOR SCANNING TOKENS
*/
-
// Initialize token
$MACRO_TOKEN_ADVANCE();
SCANNER_TOP:
- $this->lineStart = ($this->lineStart) ? : $tokenLine;
+ $this->lineStart = $this->lineStart ? : $tokenLine;
switch ($tokenType) {
case T_DOC_COMMENT:
@@ -523,7 +521,7 @@ protected function scan()
// goto (no break needed);
case T_NS_SEPARATOR:
- if (!isset($infos[$infoIndex])) {
+ if (! isset($infos[$infoIndex])) {
$MACRO_INFO_START();
}
goto SCANNER_CONTINUE_SIGNATURE;
@@ -536,7 +534,7 @@ protected function scan()
}
if ($parentCount === 1) {
- if (!isset($infos[$infoIndex])) {
+ if (! isset($infos[$infoIndex])) {
$MACRO_INFO_START();
}
if ($tokenType === T_VARIABLE) {
@@ -550,7 +548,7 @@ protected function scan()
case null:
switch ($tokenContent) {
case '&':
- if (!isset($infos[$infoIndex])) {
+ if (! isset($infos[$infoIndex])) {
$MACRO_INFO_START();
}
goto SCANNER_CONTINUE_SIGNATURE;
@@ -606,7 +604,5 @@ protected function scan()
SCANNER_END:
$this->isScanned = true;
-
- return;
}
}
diff --git a/src/Scanner/ParameterScanner.php b/src/Scanner/ParameterScanner.php
index 573247cf..eec5464e 100644
--- a/src/Scanner/ParameterScanner.php
+++ b/src/Scanner/ParameterScanner.php
@@ -21,42 +21,42 @@ class ParameterScanner
/**
* @var null|ClassScanner
*/
- protected $declaringScannerClass = null;
+ protected $declaringScannerClass;
/**
* @var null|string
*/
- protected $declaringClass = null;
+ protected $declaringClass;
/**
* @var null|MethodScanner
*/
- protected $declaringScannerFunction = null;
+ protected $declaringScannerFunction;
/**
* @var null|string
*/
- protected $declaringFunction = null;
+ protected $declaringFunction;
/**
* @var null|string
*/
- protected $defaultValue = null;
+ protected $defaultValue;
/**
* @var null|string
*/
- protected $class = null;
+ protected $class;
/**
* @var null|string
*/
- protected $name = null;
+ protected $name;
/**
* @var null|int
*/
- protected $position = null;
+ protected $position;
/**
* @var bool
@@ -81,12 +81,12 @@ class ParameterScanner
/**
* @var array|null
*/
- protected $tokens = null;
+ protected $tokens;
/**
* @var null|NameInformation
*/
- protected $nameInformation = null;
+ protected $nameInformation;
/**
* @param array $parameterTokens
@@ -195,7 +195,7 @@ protected function scan()
}
if ($this->name !== null) {
- $this->defaultValue .= trim((is_string($token)) ? $token : $token[1]);
+ $this->defaultValue .= trim(is_string($token) ? $token : $token[1]);
}
SCANNER_CONTINUE:
diff --git a/src/Scanner/PropertyScanner.php b/src/Scanner/PropertyScanner.php
index 5920196c..5f7ca55d 100644
--- a/src/Scanner/PropertyScanner.php
+++ b/src/Scanner/PropertyScanner.php
@@ -15,11 +15,11 @@
class PropertyScanner implements ScannerInterface
{
- const T_BOOLEAN = "boolean";
- const T_INTEGER = "int";
- const T_STRING = "string";
- const T_ARRAY = "array";
- const T_UNKNOWN = "unknown";
+ const T_BOOLEAN = 'boolean';
+ const T_INTEGER = 'int';
+ const T_STRING = 'string';
+ const T_ARRAY = 'array';
+ const T_UNKNOWN = 'unknown';
/**
* @var bool
@@ -232,7 +232,7 @@ protected function scan()
return;
}
- if (!$this->tokens) {
+ if (! $this->tokens) {
throw new Exception\RuntimeException('No tokens were provided');
}
@@ -247,7 +247,7 @@ protected function scan()
foreach ($tokens as $token) {
$tempValue = $token;
- if (!is_string($token)) {
+ if (! is_string($token)) {
list($tokenType, $tokenContent, $tokenLine) = $token;
switch ($tokenType) {
@@ -285,7 +285,7 @@ protected function scan()
}
//end value concatenation
- if (!is_array($token) && trim($token) == ";") {
+ if (! is_array($token) && trim($token) == ';') {
$concatenateValue = false;
}
@@ -294,17 +294,17 @@ protected function scan()
}
//start value concatenation
- if (!is_array($token) && trim($token) == "=") {
+ if (! is_array($token) && trim($token) == '=') {
$concatenateValue = true;
}
}
$this->valueType = self::T_UNKNOWN;
- if ($value == "false" || $value == "true") {
+ if ($value == 'false' || $value == 'true') {
$this->valueType = self::T_BOOLEAN;
} elseif (is_numeric($value)) {
$this->valueType = self::T_INTEGER;
- } elseif (0 === strpos($value, 'array') || 0 === strpos($value, "[")) {
+ } elseif (0 === strpos($value, 'array') || 0 === strpos($value, '[')) {
$this->valueType = self::T_ARRAY;
} elseif (substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'") {
$value = substr($value, 1, -1); // Remove quotes
diff --git a/src/Scanner/TokenArrayScanner.php b/src/Scanner/TokenArrayScanner.php
index ea1037a1..481aeffe 100644
--- a/src/Scanner/TokenArrayScanner.php
+++ b/src/Scanner/TokenArrayScanner.php
@@ -28,12 +28,12 @@ class TokenArrayScanner implements ScannerInterface
/**
* @var null
*/
- protected $docComment = null;
+ protected $docComment;
/**
* @var NameInformation
*/
- protected $nameInformation = null;
+ protected $nameInformation;
/**
* @var array
@@ -43,7 +43,7 @@ class TokenArrayScanner implements ScannerInterface
/**
* @var AnnotationManager
*/
- protected $annotationManager = null;
+ protected $annotationManager;
/**
* @param null|array $tokens
@@ -118,7 +118,7 @@ public function getUses($namespace = null)
}
/**
- * @return array
+ * @return void
*/
public function getIncludes()
{
@@ -189,7 +189,7 @@ public function getClass($name)
}
}
- if (!$classFound) {
+ if (! $classFound) {
return false;
}
}
@@ -198,7 +198,7 @@ public function getClass($name)
array_slice(
$this->tokens,
$info['tokenStart'],
- ($info['tokenEnd'] - $info['tokenStart'] + 1)
+ $info['tokenEnd'] - $info['tokenStart'] + 1
), // zero indexed array
new NameInformation($info['namespace'], $info['uses'])
);
@@ -220,11 +220,11 @@ public function getClassNameInformation($className)
}
}
- if (!$classFound) {
+ if (! $classFound) {
return false;
}
- if (!isset($info)) {
+ if (! isset($info)) {
return;
}
@@ -255,11 +255,11 @@ public function getFunctions()
$this->scan();
$functions = [];
- foreach ($this->infos as $info) {
- if ($info['type'] == 'function') {
- // @todo $functions[] = new FunctionScanner($info['name']);
- }
- }
+// foreach ($this->infos as $info) {
+// if ($info['type'] == 'function') {
+// // @todo $functions[] = new FunctionScanner($info['name']);
+// }
+// }
return $functions;
}
@@ -267,7 +267,7 @@ public function getFunctions()
/**
* Export
*
- * @param $tokens
+ * @param mixed $tokens
*/
public static function export($tokens)
{
@@ -294,14 +294,13 @@ protected function scan()
return;
}
- if (!$this->tokens) {
+ if (! $this->tokens) {
throw new Exception\RuntimeException('No tokens were provided');
}
/**
* Variables & Setup
*/
-
$tokens = &$this->tokens; // localize
$infos = &$this->infos; // localize
$tokenIndex = null;
@@ -324,8 +323,8 @@ protected function scan()
&$tokenContent,
&$tokenLine
) {
- $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
- if (!isset($tokens[$tokenIndex])) {
+ $tokenIndex = $tokenIndex === null ? 0 : $tokenIndex + 1;
+ if (! isset($tokens[$tokenIndex])) {
$token = false;
$tokenContent = false;
$tokenType = false;
@@ -336,7 +335,7 @@ protected function scan()
if (is_string($tokens[$tokenIndex]) && $tokens[$tokenIndex] === '"') {
do {
$tokenIndex++;
- } while (!(is_string($tokens[$tokenIndex]) && $tokens[$tokenIndex] === '"'));
+ } while (! (is_string($tokens[$tokenIndex]) && $tokens[$tokenIndex] === '"'));
}
$token = $tokens[$tokenIndex];
if (is_array($token)) {
@@ -349,7 +348,7 @@ protected function scan()
return $tokenIndex;
};
$MACRO_TOKEN_LOGICAL_START_INDEX = function () use (&$tokenIndex, &$docCommentIndex) {
- return ($docCommentIndex === false) ? $tokenIndex : $docCommentIndex;
+ return $docCommentIndex === false ? $tokenIndex : $docCommentIndex;
};
$MACRO_DOC_COMMENT_START = function () use (&$tokenIndex, &$docCommentIndex) {
$docCommentIndex = $tokenIndex;
@@ -361,7 +360,7 @@ protected function scan()
if ($validTrailingTokens === null) {
$validTrailingTokens = [T_WHITESPACE, T_FINAL, T_ABSTRACT, T_INTERFACE, T_CLASS, T_FUNCTION];
}
- if ($docCommentIndex !== false && !in_array($tokenType, $validTrailingTokens)) {
+ if ($docCommentIndex !== false && ! in_array($tokenType, $validTrailingTokens)) {
$docCommentIndex = false;
}
@@ -378,7 +377,6 @@ protected function scan()
/**
* START FINITE STATE MACHINE FOR SCANNING TOKENS
*/
-
// Initialize token
$MACRO_TOKEN_ADVANCE();
@@ -414,7 +412,7 @@ protected function scan()
SCANNER_NAMESPACE_TOP:
- if ($tokenType === null && $tokenContent === ';' || $tokenContent === '{') {
+ if (($tokenType === null && $tokenContent === ';') || $tokenContent === '{') {
goto SCANNER_NAMESPACE_END;
}
@@ -449,8 +447,12 @@ protected function scan()
'lineStart' => $tokens[$tokenIndex][2],
'lineEnd' => null,
'namespace' => $namespace,
- 'statements' => [0 => ['use' => null,
- 'as' => null]],
+ 'statements' => [
+ 0 => [
+ 'use' => null,
+ 'as' => null,
+ ],
+ ],
];
$useStatementIndex = 0;
@@ -469,8 +471,10 @@ protected function scan()
} elseif ($tokenContent === ',') {
$useAsContext = false;
$useStatementIndex++;
- $infos[$infoIndex]['statements'][$useStatementIndex] = ['use' => null,
- 'as' => null];
+ $infos[$infoIndex]['statements'][$useStatementIndex] = [
+ 'use' => null,
+ 'as' => null,
+ ];
}
}
@@ -512,7 +516,7 @@ protected function scan()
T_INCLUDE => 'include',
T_INCLUDE_ONCE => 'include_once',
T_REQUIRE => 'require',
- T_REQUIRE_ONCE => 'require_once'
+ T_REQUIRE_ONCE => 'require_once',
];
$infos[$infoIndex] = [
@@ -558,7 +562,7 @@ protected function scan()
case T_INTERFACE:
case T_TRAIT:
$infos[$infoIndex] = [
- 'type' => ($tokenType === T_FUNCTION) ? 'function' : 'class',
+ 'type' => $tokenType === T_FUNCTION ? 'function' : 'class',
'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(),
'tokenEnd' => null,
'lineStart' => $tokens[$tokenIndex][2],
@@ -586,7 +590,7 @@ protected function scan()
$infos[$infoIndex]['shortName'] = is_array($tokens[$tokenIndex + 2])
? $tokens[$tokenIndex + 2][1]
: $tokens[$tokenIndex + 2];
- $infos[$infoIndex]['name'] = (($namespace !== null)
+ $infos[$infoIndex]['name'] = ($namespace !== null
? $namespace . '\\'
: '') . $infos[$infoIndex]['shortName'];
}
@@ -629,7 +633,6 @@ protected function scan()
/**
* END FINITE STATE MACHINE FOR SCANNING TOKENS
*/
-
$this->isScanned = true;
}
@@ -653,7 +656,7 @@ public function hasNamespace($namespace)
/**
* @param string $namespace
- * @return null|array
+ * @return void|array
* @throws Exception\InvalidArgumentException
*/
protected function getUsesNoScan($namespace)
@@ -667,9 +670,9 @@ protected function getUsesNoScan($namespace)
if ($namespace === null) {
$namespace = array_shift($namespaces);
- } elseif (!is_string($namespace)) {
+ } elseif (! is_string($namespace)) {
throw new Exception\InvalidArgumentException('Invalid namespace provided');
- } elseif (!in_array($namespace, $namespaces)) {
+ } elseif (! in_array($namespace, $namespaces)) {
return;
}
diff --git a/src/Scanner/Util.php b/src/Scanner/Util.php
index dd942f52..060fe99d 100644
--- a/src/Scanner/Util.php
+++ b/src/Scanner/Util.php
@@ -28,9 +28,9 @@ class Util
*/
public static function resolveImports(&$value, $key = null, stdClass $data = null)
{
- if (!is_object($data)
- || !property_exists($data, 'uses')
- || !property_exists($data, 'namespace')
+ if (! is_object($data)
+ || ! property_exists($data, 'uses')
+ || ! property_exists($data, 'namespace')
) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a data object containing "uses" and "namespace" properties; on or both missing',
@@ -38,13 +38,13 @@ public static function resolveImports(&$value, $key = null, stdClass $data = nul
));
}
- if ($data->namespace && !$data->uses && strlen($value) > 0 && $value{0} != '\\') {
+ if ($data->namespace && ! $data->uses && strlen($value) > 0 && $value{0} != '\\') {
$value = $data->namespace . '\\' . $value;
return;
}
- if (!$data->uses || strlen($value) <= 0 || $value{0} == '\\') {
+ if (! $data->uses || strlen($value) <= 0 || $value{0} == '\\') {
$value = ltrim($value, '\\');
return;
diff --git a/test/Annotation/AnnotationManagerTest.php b/test/Annotation/AnnotationManagerTest.php
index 25ae09b5..6c5670c7 100644
--- a/test/Annotation/AnnotationManagerTest.php
+++ b/test/Annotation/AnnotationManagerTest.php
@@ -17,7 +17,7 @@ class AnnotationManagerTest extends TestCase
{
public function setUp()
{
- if (!getenv('TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT')) {
+ if (! getenv('TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT')) {
$this->markTestSkipped(
'Enable TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT to test doctrine annotation parsing'
);
diff --git a/test/Annotation/DoctrineAnnotationParserTest.php b/test/Annotation/DoctrineAnnotationParserTest.php
index f0b08880..ea1b92e4 100644
--- a/test/Annotation/DoctrineAnnotationParserTest.php
+++ b/test/Annotation/DoctrineAnnotationParserTest.php
@@ -10,7 +10,6 @@
namespace ZendTest\Code\Annotation;
use PHPUnit_Framework_TestCase as TestCase;
-use Zend\Code\Annotation;
use Zend\Code\Annotation\Parser\DoctrineAnnotationParser;
use Zend\EventManager\Event;
@@ -23,7 +22,7 @@ class DoctrineAnnotationParserTest extends TestCase
public function setUp()
{
- if (!getenv('TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT')) {
+ if (! getenv('TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT')) {
$this->markTestSkipped(
'Enable TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT to test doctrine annotation parsing'
);
diff --git a/test/Annotation/GenericAnnotationParserTest.php b/test/Annotation/GenericAnnotationParserTest.php
index 2e6f863f..560c393d 100644
--- a/test/Annotation/GenericAnnotationParserTest.php
+++ b/test/Annotation/GenericAnnotationParserTest.php
@@ -107,7 +107,7 @@ public function testAllowRegistrationOnceOnly()
public function testRegisterAnnotations()
{
- $this->parser->registerAnnotations([new TestAsset\Foo]);
+ $this->parser->registerAnnotations([new TestAsset\Foo()]);
$event = $this->getFooEvent();
$test = $this->parser->onCreateAnnotation($event);
$this->assertInstanceOf(__NAMESPACE__ . '\TestAsset\Foo', $test);
diff --git a/test/Generator/AbstractGeneratorTest.php b/test/Generator/AbstractGeneratorTest.php
index 45c001c6..3df472f2 100644
--- a/test/Generator/AbstractGeneratorTest.php
+++ b/test/Generator/AbstractGeneratorTest.php
@@ -20,7 +20,7 @@ public function testConstructor()
$generator = $this->getMockForAbstractClass('Zend\Code\Generator\AbstractGenerator', [
[
'indentation' => 'foo',
- ]
+ ],
]);
$this->assertInstanceOf('Zend\Code\Generator\GeneratorInterface', $generator);
diff --git a/test/Generator/ClassGeneratorTest.php b/test/Generator/ClassGeneratorTest.php
index f111b0c7..7bb5b1bd 100644
--- a/test/Generator/ClassGeneratorTest.php
+++ b/test/Generator/ClassGeneratorTest.php
@@ -13,8 +13,8 @@
use Zend\Code\Generator\ClassGenerator;
use Zend\Code\Generator\DocBlockGenerator;
use Zend\Code\Generator\Exception\InvalidArgumentException;
-use Zend\Code\Generator\PropertyGenerator;
use Zend\Code\Generator\MethodGenerator;
+use Zend\Code\Generator\PropertyGenerator;
use Zend\Code\Reflection\ClassReflection;
/**
@@ -109,7 +109,7 @@ public function testPropertyAccessors()
$classGenerator = new ClassGenerator();
$classGenerator->addProperties([
'propOne',
- new PropertyGenerator('propTwo')
+ new PropertyGenerator('propTwo'),
]);
$properties = $classGenerator->getProperties();
@@ -153,7 +153,7 @@ public function testMethodAccessors()
$classGenerator = new ClassGenerator();
$classGenerator->addMethods([
'methodOne',
- new MethodGenerator('methodTwo')
+ new MethodGenerator('methodTwo'),
]);
$methods = $classGenerator->getMethods();
@@ -184,9 +184,9 @@ public function testSetMethodNoMethodOrArrayThrowsException()
public function testSetMethodNameAlreadyExistsThrowsException()
{
$methodA = new MethodGenerator();
- $methodA->setName("foo");
+ $methodA->setName('foo');
$methodB = new MethodGenerator();
- $methodB->setName("foo");
+ $methodB->setName('foo');
$classGenerator = new ClassGenerator();
$classGenerator->addMethodFromGenerator($methodA);
@@ -248,11 +248,12 @@ public function testToString()
'flags' => ClassGenerator::FLAG_ABSTRACT,
'extendedClass' => 'ExtendedClassName',
'implementedInterfaces' => ['Iterator', 'Traversable'],
- 'properties' => ['foo',
- ['name' => 'bar']
+ 'properties' => [
+ 'foo',
+ ['name' => 'bar'],
],
'methods' => [
- ['name' => 'baz']
+ ['name' => 'baz'],
],
]);
@@ -617,7 +618,7 @@ public function testCanAddConstantsWithArrayOfGenerators()
$classGenerator->addConstants([
new PropertyGenerator('x', 'value1', PropertyGenerator::FLAG_CONSTANT),
- new PropertyGenerator('y', 'value2', PropertyGenerator::FLAG_CONSTANT)
+ new PropertyGenerator('y', 'value2', PropertyGenerator::FLAG_CONSTANT),
]);
$this->assertCount(2, $classGenerator->getConstants());
@@ -633,8 +634,8 @@ public function testCanAddConstantsWithArrayOfKeyValues()
$classGenerator = new ClassGenerator();
$classGenerator->addConstants([
- [ 'name'=> 'x', 'value' => 'value1'],
- ['name' => 'y', 'value' => 'value2']
+ ['name' => 'x', 'value' => 'value1'],
+ ['name' => 'y', 'value' => 'value2'],
]);
$this->assertCount(2, $classGenerator->getConstants());
@@ -761,7 +762,7 @@ public function testAddPropertiesIsBackwardsCompatibleWithConstants()
{
$constants = [
new PropertyGenerator('x', 'value1', PropertyGenerator::FLAG_CONSTANT),
- new PropertyGenerator('y', 'value2', PropertyGenerator::FLAG_CONSTANT)
+ new PropertyGenerator('y', 'value2', PropertyGenerator::FLAG_CONSTANT),
];
$classGenerator = new ClassGenerator();
@@ -825,6 +826,7 @@ public function someMethod()
$this->assertEquals($classGenerator->generate(), $contents);
}
+
/**
* @group 6253
*/
@@ -833,7 +835,7 @@ public function testHereDoc()
$reflector = new ClassReflection('ZendTest\Code\Generator\TestAsset\TestClassWithHeredoc');
$classGenerator = new ClassGenerator();
$methods = $reflector->getMethods();
- $classGenerator->setName("OutputClass");
+ $classGenerator->setName('OutputClass');
foreach ($methods as $method) {
$methodGenerator = MethodGenerator::fromReflection($method);
@@ -989,7 +991,7 @@ public function testAddTraitAliasExceptionInvalidAliasArgument()
);
$classGenerator->addTrait('myTrait');
- $classGenerator->addTraitAlias('myTrait::method', new ClassGenerator, 'public');
+ $classGenerator->addTraitAlias('myTrait::method', new ClassGenerator(), 'public');
}
public function testCanAddTraitOverride()
@@ -1145,7 +1147,7 @@ public function testTraitGenerationWithAliasesAndOverrides()
$classGenerator->addTrait('myTrait');
$classGenerator->addTrait('hisTrait');
$classGenerator->addTrait('thatTrait');
- $classGenerator->addTraitAlias("hisTrait::foo", "test", ReflectionMethod::IS_PUBLIC);
+ $classGenerator->addTraitAlias('hisTrait::foo', 'test', ReflectionMethod::IS_PUBLIC);
$classGenerator->addTraitOverride('myTrait::bar', ['hisTrait', 'thatTrait']);
$output = <<<'CODE'
@@ -1170,7 +1172,7 @@ public function testGenerateWithFinalFlag()
{
$classGenerator = ClassGenerator::fromArray([
'name' => 'SomeClass',
- 'flags' => ClassGenerator::FLAG_FINAL
+ 'flags' => ClassGenerator::FLAG_FINAL,
]);
$expectedOutput = <<setNamespaceName('SomeNamespace');
$classGenerator->addUse('Zend\Code\Generator\GeneratorInterface');
$classGenerator->setImplementedInterfaces([
- 'SomeNamespace\ClassInterface',
- 'Zend\Code\Generator\GeneratorInterface',
- 'Iteratable'
+ 'SomeNamespace\ClassInterface',
+ 'Zend\Code\Generator\GeneratorInterface',
+ 'Iteratable',
]);
$expected = 'class ClassName implements ClassInterface, GeneratorInterface, \Iteratable';
diff --git a/test/Generator/DocBlock/Tag/GenericTagTest.php b/test/Generator/DocBlock/Tag/GenericTagTest.php
index b0dd6fb0..f71c5e62 100644
--- a/test/Generator/DocBlock/Tag/GenericTagTest.php
+++ b/test/Generator/DocBlock/Tag/GenericTagTest.php
@@ -23,6 +23,7 @@ class GenericTagTest extends \PHPUnit_Framework_TestCase
* @var GenericTag
*/
protected $tag;
+
/**
* @var TagManager
*/
diff --git a/test/Generator/DocBlock/Tag/LicenseTagTest.php b/test/Generator/DocBlock/Tag/LicenseTagTest.php
index 18be9883..5ac9fd8f 100644
--- a/test/Generator/DocBlock/Tag/LicenseTagTest.php
+++ b/test/Generator/DocBlock/Tag/LicenseTagTest.php
@@ -23,6 +23,7 @@ class LicenseTagTest extends \PHPUnit_Framework_TestCase
* @var LicenseTag
*/
protected $tag;
+
/**
* @var TagManager
*/
diff --git a/test/Generator/DocBlock/Tag/MethodTagTest.php b/test/Generator/DocBlock/Tag/MethodTagTest.php
index e9b18f24..9649dc2f 100644
--- a/test/Generator/DocBlock/Tag/MethodTagTest.php
+++ b/test/Generator/DocBlock/Tag/MethodTagTest.php
@@ -76,7 +76,7 @@ public function testConstructorWithOptions()
'isStatic' => true,
'methodName' => 'method',
'types' => ['string'],
- 'description' => 'description'
+ 'description' => 'description',
]);
$tagWithOptionsFromConstructor = new MethodTag('method', ['string'], 'description', true);
$this->assertEquals($this->tag->generate(), $tagWithOptionsFromConstructor->generate());
diff --git a/test/Generator/DocBlock/Tag/ParamTagTest.php b/test/Generator/DocBlock/Tag/ParamTagTest.php
index 06ed7b4d..780bd162 100644
--- a/test/Generator/DocBlock/Tag/ParamTagTest.php
+++ b/test/Generator/DocBlock/Tag/ParamTagTest.php
@@ -23,6 +23,7 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
* @var ParamTag
*/
protected $tag;
+
/**
* @var TagManager
*/
@@ -71,7 +72,7 @@ public function testConstructorWithOptions()
$this->tag->setOptions([
'variableName' => 'foo',
'types' => ['string'],
- 'description' => 'description'
+ 'description' => 'description',
]);
$tagWithOptionsFromConstructor = new ParamTag('foo', ['string'], 'description');
$this->assertEquals($this->tag->generate(), $tagWithOptionsFromConstructor->generate());
diff --git a/test/Generator/DocBlock/Tag/PropertyTagTest.php b/test/Generator/DocBlock/Tag/PropertyTagTest.php
index 6ed0ac55..b7717597 100644
--- a/test/Generator/DocBlock/Tag/PropertyTagTest.php
+++ b/test/Generator/DocBlock/Tag/PropertyTagTest.php
@@ -23,6 +23,7 @@ class PropertyTagTest extends \PHPUnit_Framework_TestCase
* @var PropertyTag
*/
protected $tag;
+
/**
* @var TagManager
*/
@@ -47,7 +48,6 @@ public function testGetterAndSetterPersistValue()
$this->assertEquals('property', $this->tag->getPropertyName());
}
-
public function testGetterForVariableNameTrimsCorrectly()
{
$this->tag->setPropertyName('$property$');
@@ -72,7 +72,7 @@ public function testConstructorWithOptions()
$this->tag->setOptions([
'propertyName' => 'property',
'types' => ['string'],
- 'description' => 'description'
+ 'description' => 'description',
]);
$tagWithOptionsFromConstructor = new PropertyTag('property', ['string'], 'description');
$this->assertEquals($this->tag->generate(), $tagWithOptionsFromConstructor->generate());
diff --git a/test/Generator/DocBlock/Tag/ReturnTagTest.php b/test/Generator/DocBlock/Tag/ReturnTagTest.php
index a2be9671..0d174e3b 100644
--- a/test/Generator/DocBlock/Tag/ReturnTagTest.php
+++ b/test/Generator/DocBlock/Tag/ReturnTagTest.php
@@ -23,6 +23,7 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
* @var ReturnTag
*/
protected $tag;
+
/**
* @var TagManager
*/
diff --git a/test/Generator/DocBlock/Tag/ThrowsTagTest.php b/test/Generator/DocBlock/Tag/ThrowsTagTest.php
index 9c12088d..e5dcc535 100644
--- a/test/Generator/DocBlock/Tag/ThrowsTagTest.php
+++ b/test/Generator/DocBlock/Tag/ThrowsTagTest.php
@@ -23,6 +23,7 @@ class ThrowsTagTest extends \PHPUnit_Framework_TestCase
* @var ThrowsTag
*/
protected $tag;
+
/**
* @var TagManager
*/
diff --git a/test/Generator/DocBlockGeneratorTest.php b/test/Generator/DocBlockGeneratorTest.php
index 29bf5aa9..9428ca38 100644
--- a/test/Generator/DocBlockGeneratorTest.php
+++ b/test/Generator/DocBlockGeneratorTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Generator;
-use Zend\Code\Generator\DocBlockGenerator;
use Zend\Code\Generator\DocBlock\Tag;
+use Zend\Code\Generator\DocBlockGenerator;
use Zend\Code\Reflection\DocBlockReflection;
/**
@@ -49,7 +49,7 @@ protected function setUp()
public function testCanPassTagsToConstructor()
{
$docBlockGenerator = new DocBlockGenerator(null, null, [
- ['name' => 'foo']
+ ['name' => 'foo'],
]);
$tags = $docBlockGenerator->getTags();
@@ -113,7 +113,7 @@ public function testCreateFromArray()
[
'name' => 'foo',
'description' => 'bar',
- ]
+ ],
],
]);
@@ -132,7 +132,7 @@ public function testGenerateWordWrapIsEnabledByDefault()
$expected = '/**' . DocBlockGenerator::LINE_FEED
. ' * @var This is a very large string that will be wrapped if it contains more than'
- . DocBlockGenerator::LINE_FEED.' * 80 characters'. DocBlockGenerator::LINE_FEED
+ . DocBlockGenerator::LINE_FEED . ' * 80 characters' . DocBlockGenerator::LINE_FEED
. ' */' . DocBlockGenerator::LINE_FEED;
$this->assertEquals($expected, $this->docBlockGenerator->generate());
}
@@ -148,7 +148,7 @@ public function testGenerateWithWordWrapDisabled()
$expected = '/**' . DocBlockGenerator::LINE_FEED
. ' * @var This is a very large string that will not be wrapped if it contains more than'
- . ' 80 characters'. DocBlockGenerator::LINE_FEED . ' */' . DocBlockGenerator::LINE_FEED;
+ . ' 80 characters' . DocBlockGenerator::LINE_FEED . ' */' . DocBlockGenerator::LINE_FEED;
$this->assertEquals($expected, $this->docBlockGenerator->generate());
}
diff --git a/test/Generator/FileGeneratorTest.php b/test/Generator/FileGeneratorTest.php
index d3730625..96bd299e 100644
--- a/test/Generator/FileGeneratorTest.php
+++ b/test/Generator/FileGeneratorTest.php
@@ -48,11 +48,10 @@ public function testToString()
'flags' => ClassGenerator::FLAG_ABSTRACT,
'name' => 'SampleClass',
'extendedClass' => 'ExtendedClassName',
- 'implementedInterfaces' => ['Iterator', 'Traversable']
- ]
+ 'implementedInterfaces' => ['Iterator', 'Traversable'],
+ ],
]);
-
$expectedOutput = << [
- 'name' => 'SampleClass'
- ]
+ 'name' => 'SampleClass',
+ ],
]);
file_put_contents($tempFile, $codeGenFile->generate());
@@ -162,7 +161,7 @@ public function testFileLineEndingsAreAlwaysLineFeed()
$targetLength = strlen('require_once \'SampleClass.php\';');
$this->assertEquals($targetLength, strlen($lines[2]));
- $this->assertEquals(';', $lines[2]{$targetLength-1});
+ $this->assertEquals(';', $lines[2]{$targetLength - 1});
}
/**
@@ -201,8 +200,8 @@ public function testSetUsesDoesntGenerateMultipleIdenticalUseStatements()
{
$file = new FileGenerator();
$file->setUses([
- ['use' => 'Your\Bar', 'as' => 'bar'],
- ['use' => 'Your\Bar', 'as' => 'bar'],
+ ['use' => 'Your\Bar', 'as' => 'bar'],
+ ['use' => 'Your\Bar', 'as' => 'bar'],
]);
$generated = $file->generate();
$this->assertSame(strpos($generated, 'use Your\\Bar as bar;'), strrpos($generated, 'use Your\\Bar as bar;'));
@@ -212,8 +211,8 @@ public function testSetUseAllowsMultipleAliasedUseStatements()
{
$file = new FileGenerator();
$file->setUses([
- ['use' => 'Your\Bar', 'as' => 'bar'],
- ['use' => 'Your\Bar', 'as' => 'bar2'],
+ ['use' => 'Your\Bar', 'as' => 'bar'],
+ ['use' => 'Your\Bar', 'as' => 'bar2'],
]);
$generated = $file->generate();
$this->assertContains('use Your\\Bar as bar;', $generated);
@@ -224,9 +223,9 @@ public function testSetUsesWithArrays()
{
$file = new FileGenerator();
$file->setUses([
- ['use' => 'Your\\Bar', 'as' => 'bar'],
- ['use' => 'My\\Baz', 'as' => 'FooBaz']
- ]);
+ ['use' => 'Your\\Bar', 'as' => 'bar'],
+ ['use' => 'My\\Baz', 'as' => 'FooBaz'],
+ ]);
$generated = $file->generate();
$this->assertContains('use My\\Baz as FooBaz;', $generated);
$this->assertContains('use Your\\Bar as bar;', $generated);
@@ -238,7 +237,7 @@ public function testSetUsesWithString()
$file->setUses([
'Your\\Bar',
'My\\Baz',
- ['use' => 'Another\\Baz', 'as' => 'Baz2']
+ ['use' => 'Another\\Baz', 'as' => 'Baz2'],
]);
$generated = $file->generate();
$this->assertContains('use My\\Baz;', $generated);
@@ -252,7 +251,7 @@ public function testSetUsesWithGetUses()
$uses = [
'Your\\Bar',
'My\\Baz',
- ['use' => 'Another\\Baz', 'as' => 'Baz2']
+ ['use' => 'Another\\Baz', 'as' => 'Baz2'],
];
$file->setUses($uses);
$file->setUses($file->getUses());
@@ -354,7 +353,7 @@ public function testCanAppendToBodyOfReflectedFile()
$g = $g->fromReflectedFileName(__DIR__ . '/TestAsset/ClassWithUses.php');
$g->setFilename(sys_get_temp_dir() . '/result_class.php');
$g->getClass()->addMethod('added');
- $g->setBody("\$foo->bar();");
+ $g->setBody('$foo->bar();');
$g->write();
$expected = <<<'CODE'
diff --git a/test/Generator/InterfaceGeneratorTest.php b/test/Generator/InterfaceGeneratorTest.php
index b2a9e48b..bae98237 100644
--- a/test/Generator/InterfaceGeneratorTest.php
+++ b/test/Generator/InterfaceGeneratorTest.php
@@ -9,10 +9,10 @@
namespace ZendTest\Code\Generator;
-use Zend\Code\Generator\InterfaceGenerator;
use Zend\Code\Generator\DocBlockGenerator;
-use Zend\Code\Generator\PropertyGenerator;
+use Zend\Code\Generator\InterfaceGenerator;
use Zend\Code\Generator\MethodGenerator;
+use Zend\Code\Generator\PropertyGenerator;
use Zend\Code\Reflection\ClassReflection;
/**
@@ -53,10 +53,9 @@ public function testPropertyAccessors()
$classGenerator1->addProperty('prop3');
$classGenerator2->addProperties([
'propOne',
- new PropertyGenerator('propTwo')
+ new PropertyGenerator('propTwo'),
]);
-
$this->assertCount(0, $classGenerator1->getProperties());
$this->assertCount(0, $classGenerator2->getProperties());
}
@@ -66,7 +65,7 @@ public function testMethodAccessors()
$classGenerator = new InterfaceGenerator();
$classGenerator->addMethods([
'methodOne',
- new MethodGenerator('methodTwo')
+ new MethodGenerator('methodTwo'),
]);
$this->assertCount(2, $classGenerator->getMethods());
@@ -80,7 +79,7 @@ public function testToString()
$classGenerator = InterfaceGenerator::fromArray([
'name' => 'SampleInterface',
'methods' => [
- ['name' => 'baz']
+ ['name' => 'baz'],
],
]);
@@ -116,7 +115,6 @@ interface MyInterface
$this->assertEquals($expected, $classGeneratorClass->generate());
}
-
public function testSetextendedclassShouldNotIgnoreNonEmptyClassnameOnGenerate()
{
$classGeneratorClass = new InterfaceGenerator();
diff --git a/test/Generator/MethodGeneratorTest.php b/test/Generator/MethodGeneratorTest.php
index fcb72dc1..8105d44a 100644
--- a/test/Generator/MethodGeneratorTest.php
+++ b/test/Generator/MethodGeneratorTest.php
@@ -84,7 +84,6 @@ public function testDocBlockGetterAndSetter()
$this->assertSame($docblockGenerator, $method->getDocBlock());
}
-
public function testMethodFromReflection()
{
$ref = new MethodReflection('ZendTest\Code\Generator\TestAsset\TestSampleSingleClass', 'someMethod');
@@ -105,7 +104,6 @@ public function someMethod()
$this->assertEquals($target, (string) $methodGenerator);
}
-
public function testMethodFromReflectionMultiLinesIndention()
{
$ref = new MethodReflection('ZendTest\Code\Generator\TestAsset\TestSampleSingleClassMultiLines', 'someMethod');
@@ -261,7 +259,7 @@ public function testCreateInterfaceMethodFromArray()
'interface' => true,
'docblock' => [
'shortdescription' => 'Short Description',
- ]
+ ],
]);
$expected = <<<'CODE'
@@ -326,20 +324,20 @@ public function foo()
*
* @requires PHP 7.0
*
- * @dataProvider returnTypeHintClassesProvider
+ * @dataProvider returnTypeHintClasses
*
* @param string $className
* @param string $methodName
* @param string $expectedReturnSignature
*/
- public function testFrom(string $className, string $methodName, string $expectedReturnSignature)
+ public function testFrom($className, $methodName, $expectedReturnSignature)
{
$methodGenerator = MethodGenerator::fromReflection(new MethodReflection($className, $methodName));
self::assertStringMatchesFormat('%A) : ' . $expectedReturnSignature . '%A{%A', $methodGenerator->generate());
}
- public function returnTypeHintClassesProvider()
+ public function returnTypeHintClasses()
{
$parameters = [
[ReturnTypeHintedClass::class, 'voidReturn', 'void'],
diff --git a/test/Generator/ParameterGeneratorTest.php b/test/Generator/ParameterGeneratorTest.php
index 8e4ca443..43945472 100644
--- a/test/Generator/ParameterGeneratorTest.php
+++ b/test/Generator/ParameterGeneratorTest.php
@@ -148,6 +148,7 @@ public function testCallableTypeHint()
/**
* @dataProvider dataFromReflectionGenerate
+ *
* @param string $methodName
* @param string $expectedCode
*/
@@ -176,12 +177,12 @@ public function dataFromReflectionGenerate()
['defaultZero', '$number = 0'],
['defaultNumber', '$number = 1234'],
['defaultFloat', '$float = 1.34'],
- ['defaultConstant', '$con = \'foo\'']
+ ['defaultConstant', '$con = \'foo\''],
];
}
/**
- * @param string $method
+ * @param string $method
* @return \Zend\Code\Reflection\ParameterReflection
*/
protected function getFirstReflectionParameter($method)
@@ -270,12 +271,12 @@ public function testGeneratedParametersHaveEscapedDefaultValues()
*
* @requires PHP 7.0
*
- * @dataProvider simpleHintsProvider
+ * @dataProvider simpleHints
*
* @param string $type
* @param string $expectedType
*/
- public function testGeneratesSimpleHints(string $type, string $expectedType)
+ public function testGeneratesSimpleHints($type, $expectedType)
{
$parameter = new ParameterGenerator();
@@ -288,7 +289,7 @@ public function testGeneratesSimpleHints(string $type, string $expectedType)
/**
* @return string[][]
*/
- public function simpleHintsProvider()
+ public function simpleHints()
{
return [
['callable', 'callable'],
@@ -317,11 +318,11 @@ public function simpleHintsProvider()
*
* @requires PHP 7.0
*
- * @dataProvider validClassNameProvider
+ * @dataProvider validClassName
*
* @param string $className
*/
- public function testTypeHintWithValidClassName(string $className)
+ public function testTypeHintWithValidClassName($className)
{
$parameter = new ParameterGenerator();
@@ -334,7 +335,7 @@ public function testTypeHintWithValidClassName(string $className)
/**
* @return string[][]
*/
- public function validClassNameProvider()
+ public function validClassName()
{
return [
['stdClass'],
@@ -363,7 +364,7 @@ public function validClassNameProvider()
*
* @requires PHP 7.0
*
- * @dataProvider reflectionHintsProvider
+ * @dataProvider reflectionHints
*
* @param string $className
* @param string $methodName
@@ -391,7 +392,7 @@ public function testTypeHintFromReflection($className, $methodName, $parameterNa
*
* @requires PHP 7.0
*
- * @dataProvider reflectionHintsProvider
+ * @dataProvider reflectionHints
*
* @param string $className
* @param string $methodName
@@ -417,7 +418,7 @@ public function testTypeHintFromReflectionGeneratedCode($className, $methodName,
/**
* @return string[][]
*/
- public function reflectionHintsProvider()
+ public function reflectionHints()
{
$parameters = [
[InternalHintsClass::class, 'arrayParameter', 'foo', 'array'],
@@ -499,7 +500,7 @@ function (array $definition) {
*
* @requires PHP 7.0
*
- * @dataProvider variadicHintsProvider
+ * @dataProvider variadicHints
*
* @param string $className
* @param string $methodName
@@ -507,10 +508,10 @@ function (array $definition) {
* @param string $expectedGeneratedSignature
*/
public function testVariadicArgumentFromReflection(
- string $className,
- string $methodName,
- string $parameterName,
- string $expectedGeneratedSignature
+ $className,
+ $methodName,
+ $parameterName,
+ $expectedGeneratedSignature
) {
$parameter = ParameterGenerator::fromReflection(new ParameterReflection(
[$className, $methodName],
@@ -524,7 +525,7 @@ public function testVariadicArgumentFromReflection(
/**
* @return string[][]
*/
- public function variadicHintsProvider()
+ public function variadicHints()
{
return [
[VariadicParametersClass::class, 'firstVariadicParameter', 'foo', '... $foo'],
@@ -533,19 +534,19 @@ public function variadicHintsProvider()
VariadicParametersClass::class,
'typeHintedVariadicParameter',
'bar',
- '\\' . VariadicParametersClass::class . ' ... $bar'
+ '\\' . VariadicParametersClass::class . ' ... $bar',
],
[
VariadicParametersClass::class,
'byRefVariadic',
'bar',
- '&... $bar'
+ '&... $bar',
],
[
VariadicParametersClass::class,
'byRefTypeHintedVariadic',
'bar',
- '\\' . VariadicParametersClass::class . ' &... $bar'
+ '\\' . VariadicParametersClass::class . ' &... $bar',
],
];
}
@@ -554,11 +555,6 @@ public function variadicHintsProvider()
* @group zendframework/zend-code#29
*
* @requires PHP 5.6
- *
- * @param string $className
- * @param string $methodName
- * @param string $parameterName
- * @param string $expectedGeneratedSignature
*/
public function testSetGetVariadic()
{
diff --git a/test/Generator/PropertyGeneratorTest.php b/test/Generator/PropertyGeneratorTest.php
index 06c9b3d8..4acb743c 100644
--- a/test/Generator/PropertyGeneratorTest.php
+++ b/test/Generator/PropertyGeneratorTest.php
@@ -32,11 +32,11 @@ public function dataSetTypeSetValueGenerate()
{
return [
['string', 'foo', "'foo';"],
- ['int', 1, "1;"],
- ['integer', 1, "1;"],
- ['bool', true, "true;"],
- ['bool', false, "false;"],
- ['boolean', true, "true;"],
+ ['int', 1, '1;'],
+ ['integer', 1, '1;'],
+ ['bool', true, 'true;'],
+ ['bool', false, 'false;'],
+ ['boolean', true, 'true;'],
['number', 1, '1;'],
['float', 1.23, '1.23;'],
['double', 1.23, '1.23;'],
@@ -47,6 +47,7 @@ public function dataSetTypeSetValueGenerate()
/**
* @dataProvider dataSetTypeSetValueGenerate
+ *
* @param string $type
* @param mixed $value
* @param string $code
@@ -63,6 +64,7 @@ public function testSetTypeSetValueGenerate($type, $value, $code)
/**
* @dataProvider dataSetTypeSetValueGenerate
+ *
* @param string $type
* @param mixed $value
* @param string $code
@@ -74,7 +76,7 @@ public function testSetBogusTypeSetValueGenerateUseAutoDetection($type, $value,
}
$defaultValue = new PropertyValueGenerator();
- $defaultValue->setType("bogus");
+ $defaultValue->setType('bogus');
$defaultValue->setValue($value);
$this->assertEquals($code, $defaultValue->generate());
@@ -261,9 +263,9 @@ public function testPropertyDocBlockWillLoadFromReflection()
$this->assertEquals('var', $tag->getName());
}
-
/**
* @dataProvider dataSetTypeSetValueGenerate
+ *
* @param string $type
* @param mixed $value
* @param string $code
diff --git a/test/Generator/TraitGeneratorTest.php b/test/Generator/TraitGeneratorTest.php
index 5e3f9c1b..a341db67 100644
--- a/test/Generator/TraitGeneratorTest.php
+++ b/test/Generator/TraitGeneratorTest.php
@@ -9,10 +9,10 @@
namespace ZendTest\Code\Generator;
-use Zend\Code\Generator\TraitGenerator;
use Zend\Code\Generator\DocBlockGenerator;
-use Zend\Code\Generator\PropertyGenerator;
use Zend\Code\Generator\MethodGenerator;
+use Zend\Code\Generator\PropertyGenerator;
+use Zend\Code\Generator\TraitGenerator;
use Zend\Code\Reflection\ClassReflection;
/**
@@ -70,7 +70,7 @@ public function testPropertyAccessors()
$classGenerator = new TraitGenerator();
$classGenerator->addProperties([
'propOne',
- new PropertyGenerator('propTwo')
+ new PropertyGenerator('propTwo'),
]);
$properties = $classGenerator->getProperties();
@@ -114,7 +114,7 @@ public function testMethodAccessors()
$classGenerator = new TraitGenerator();
$classGenerator->addMethods([
'methodOne',
- new MethodGenerator('methodTwo')
+ new MethodGenerator('methodTwo'),
]);
$methods = $classGenerator->getMethods();
@@ -145,9 +145,9 @@ public function testSetMethodNoMethodOrArrayThrowsException()
public function testSetMethodNameAlreadyExistsThrowsException()
{
$methodA = new MethodGenerator();
- $methodA->setName("foo");
+ $methodA->setName('foo');
$methodB = new MethodGenerator();
- $methodB->setName("foo");
+ $methodB->setName('foo');
$classGenerator = new TraitGenerator();
$classGenerator->addMethodFromGenerator($methodA);
@@ -196,11 +196,12 @@ public function testToString()
{
$classGenerator = TraitGenerator::fromArray([
'name' => 'SampleClass',
- 'properties' => ['foo',
- ['name' => 'bar']
+ 'properties' => [
+ 'foo',
+ ['name' => 'bar'],
],
'methods' => [
- ['name' => 'baz']
+ ['name' => 'baz'],
],
]);
diff --git a/test/Generator/TypeGeneratorTest.php b/test/Generator/TypeGeneratorTest.php
index 8c060145..0c16940f 100644
--- a/test/Generator/TypeGeneratorTest.php
+++ b/test/Generator/TypeGeneratorTest.php
@@ -28,12 +28,12 @@ public function testIsAGenerator()
}
/**
- * @dataProvider validTypeProvider
+ * @dataProvider validType
*
* @param string $typeString
* @param string $expectedReturnType
*/
- public function testFromValidTypeString(string $typeString, string $expectedReturnType)
+ public function testFromValidTypeString($typeString, $expectedReturnType)
{
$generator = TypeGenerator::fromTypeString($typeString);
@@ -41,12 +41,12 @@ public function testFromValidTypeString(string $typeString, string $expectedRetu
}
/**
- * @dataProvider validTypeProvider
+ * @dataProvider validType
*
* @param string $typeString
* @param string $expectedReturnType
*/
- public function testStringCastFromValidTypeString(string $typeString, string $expectedReturnType)
+ public function testStringCastFromValidTypeString($typeString, $expectedReturnType)
{
$generator = TypeGenerator::fromTypeString($typeString);
@@ -54,12 +54,12 @@ public function testStringCastFromValidTypeString(string $typeString, string $ex
}
/**
- * @dataProvider validClassNameProvider
+ * @dataProvider validClassName
*
* @param string $typeString
* @param string $expectedReturnType
*/
- public function testStripsPrefixingBackslashFromClassNames(string $typeString, string $expectedReturnType)
+ public function testStripsPrefixingBackslashFromClassNames($typeString, $expectedReturnType)
{
$generator = TypeGenerator::fromTypeString('\\' . $typeString);
@@ -68,11 +68,11 @@ public function testStripsPrefixingBackslashFromClassNames(string $typeString, s
}
/**
- * @dataProvider invalidTypeProvider
+ * @dataProvider invalidType
*
* @param string $typeString
*/
- public function testRejectsInvalidTypeString(string $typeString)
+ public function testRejectsInvalidTypeString($typeString)
{
$this->setExpectedException(InvalidArgumentException::class);
@@ -82,7 +82,7 @@ public function testRejectsInvalidTypeString(string $typeString)
/**
* @return string[][]
*/
- public function validTypeProvider()
+ public function validType()
{
$valid = [
['foo', '\\foo'],
@@ -179,14 +179,14 @@ public function validTypeProvider()
}
/**
- * Valid class names - just the same as validTypeProvider, but with only those elements prefixed by '\\'
+ * Valid class names - just the same as validType, but with only those elements prefixed by '\\'
*
* @return string[][]
*/
- public function validClassNameProvider()
+ public function validClassName()
{
return array_filter(
- $this->validTypeProvider(),
+ $this->validType(),
function (array $pair) {
return 0 === strpos($pair[1], '\\');
}
@@ -196,7 +196,7 @@ function (array $pair) {
/**
* @return string[][]
*/
- public function invalidTypeProvider()
+ public function invalidType()
{
$invalid = [
[''],
diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php
index 943f8e31..5525a459 100644
--- a/test/Generator/ValueGeneratorTest.php
+++ b/test/Generator/ValueGeneratorTest.php
@@ -14,8 +14,8 @@
use Zend\Code\Exception\InvalidArgumentException;
use Zend\Code\Generator\PropertyGenerator;
use Zend\Code\Generator\PropertyValueGenerator;
-use Zend\Stdlib\ArrayObject as StdlibArrayObject;
use Zend\Code\Generator\ValueGenerator;
+use Zend\Stdlib\ArrayObject as StdlibArrayObject;
/**
* @group Zend_Code_Generator
@@ -44,7 +44,9 @@ public function testInvalidConstantsType()
}
/**
- * @dataProvider constantsTypeProvider
+ * @dataProvider constantsType
+ *
+ * @param SplArrayObject|StdlibArrayObject $constants
*/
public function testAllowedPossibleConstantsType($constants)
{
@@ -58,7 +60,7 @@ public function testAllowedPossibleConstantsType($constants)
$this->assertSame($constants, $valueGenerator->getConstants());
}
- public function constantsTypeProvider()
+ public function constantsType()
{
return [
SplArrayObject::class => [new SplArrayObject()],
@@ -68,9 +70,13 @@ public function constantsTypeProvider()
/**
* @group #94
- * @dataProvider validConstantTypesProvider
+ *
+ * @dataProvider validConstantTypes
+ *
+ * @param PropertyValueGenerator $generator
+ * @param string $expectedOutput
*/
- public function testValidConstantTypes($generator, $expectedOutput)
+ public function testValidConstantTypes(PropertyValueGenerator $generator, $expectedOutput)
{
$propertyGenerator = new PropertyGenerator('FOO', $generator);
$propertyGenerator->setConst(true);
@@ -80,12 +86,12 @@ public function testValidConstantTypes($generator, $expectedOutput)
/**
* @return array
*/
- public function validConstantTypesProvider()
+ public function validConstantTypes()
{
return [
[
new PropertyValueGenerator([], PropertyValueGenerator::TYPE_ARRAY, ValueGenerator::OUTPUT_SINGLE_LINE),
- ' const FOO = array();'
+ ' const FOO = array();',
],
[
new PropertyValueGenerator(
@@ -93,14 +99,15 @@ public function validConstantTypesProvider()
PropertyValueGenerator::TYPE_ARRAY_LONG,
ValueGenerator::OUTPUT_SINGLE_LINE
),
- ' const FOO = array();'],
+ ' const FOO = array();',
+ ],
[
new PropertyValueGenerator(
[],
PropertyValueGenerator::TYPE_ARRAY_SHORT,
ValueGenerator::OUTPUT_SINGLE_LINE
),
- ' const FOO = [];'
+ ' const FOO = [];',
],
[new PropertyValueGenerator(true, PropertyValueGenerator::TYPE_BOOL), ' const FOO = true;'],
[new PropertyValueGenerator(true, PropertyValueGenerator::TYPE_BOOLEAN), ' const FOO = true;'],
@@ -115,9 +122,11 @@ public function validConstantTypesProvider()
}
/**
+ * @param string $longOutput
+ * @param array $value
* @return array
*/
- protected function generateArrayData($longOutput, $value)
+ protected function generateArrayData($longOutput, array $value)
{
$shortOutput = str_replace(
['array(', ')'],
@@ -127,16 +136,24 @@ protected function generateArrayData($longOutput, $value)
return [
'auto' => [
- ValueGenerator::TYPE_AUTO, $value, $longOutput
+ ValueGenerator::TYPE_AUTO,
+ $value,
+ $longOutput,
],
'array' => [
- ValueGenerator::TYPE_ARRAY, $value, $longOutput
+ ValueGenerator::TYPE_ARRAY,
+ $value,
+ $longOutput,
],
'array long' => [
- ValueGenerator::TYPE_ARRAY_LONG, $value, $longOutput
+ ValueGenerator::TYPE_ARRAY_LONG,
+ $value,
+ $longOutput,
],
'array short' => [
- ValueGenerator::TYPE_ARRAY_SHORT, $value, $shortOutput
+ ValueGenerator::TYPE_ARRAY_SHORT,
+ $value,
+ $shortOutput,
],
];
}
@@ -146,7 +163,7 @@ protected function generateArrayData($longOutput, $value)
*
* @return array
*/
- public function simpleArrayProvider()
+ public function simpleArray()
{
$value = ['foo'];
@@ -164,7 +181,7 @@ public function simpleArrayProvider()
*
* @return array
*/
- public function complexArrayProvider()
+ public function complexArray()
{
$value = [
5,
@@ -179,9 +196,9 @@ public function complexArrayProvider()
'baz1',
'baz2',
'constant2' => 'ArrayObject::STD_PROP_LIST',
- ]
+ ],
],
- new ValueGenerator('PHP_EOL', 'constant')
+ new ValueGenerator('PHP_EOL', 'constant'),
];
$longOutput = << 'a',
0 => 'b',
'c',
7 => 'd',
- 3 => 'e'
+ 3 => 'e',
];
$longOutput = <<setType($type);
@@ -268,9 +289,13 @@ public function testPropertyDefaultValueCanHandleStrings()
}
/**
- * @dataProvider simpleArrayProvider
+ * @dataProvider simpleArray
+ *
+ * @param string $type
+ * @param array $value
+ * @param string $expected
*/
- public function testPropertyDefaultValueCanHandleArray($type, $value, $expected)
+ public function testPropertyDefaultValueCanHandleArray($type, array $value, $expected)
{
$valueGenerator = new ValueGenerator();
$valueGenerator->setType($type);
@@ -296,9 +321,13 @@ public function testPropertyDefaultValueCanHandleUnquotedString()
}
/**
- * @dataProvider complexArrayProvider
+ * @dataProvider complexArray
+ *
+ * @param string $type
+ * @param array $value
+ * @param string $expected
*/
- public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, $value, $expected)
+ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, array $value, $expected)
{
$valueGenerator = new ValueGenerator();
$valueGenerator->initEnvironmentConstants();
@@ -312,6 +341,9 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, $val
* @group 6023
*
* @dataProvider getEscapedParameters
+ *
+ * @param string $input
+ * @param string $expectedEscapedValue
*/
public function testEscaping($input, $expectedEscapedValue)
{
diff --git a/test/NameInformationTest.php b/test/NameInformationTest.php
index 2ea03eb2..c31113fb 100644
--- a/test/NameInformationTest.php
+++ b/test/NameInformationTest.php
@@ -44,7 +44,7 @@ public function testNamespaceResolverPersistsUseRules()
public function testNamespaceResolverCorrectlyResolvesNames()
{
- $nr = new NameInformation;
+ $nr = new NameInformation();
$nr->setNamespace('Zend\MagicComponent');
$nr->setUses([
'ArrayObject',
diff --git a/test/Reflection/ClassReflectionTest.php b/test/Reflection/ClassReflectionTest.php
index a25af5f4..140bde8d 100644
--- a/test/Reflection/ClassReflectionTest.php
+++ b/test/Reflection/ClassReflectionTest.php
@@ -13,9 +13,8 @@
use ZendTest\Code\Reflection\TestAsset\InjectableClassReflection;
/**
- *
- * @group Zend_Reflection
- * @group Zend_Reflection_Class
+ * @group Zend_Reflection
+ * @group Zend_Reflection_Class
*/
class ClassReflectionTest extends \PHPUnit_Framework_TestCase
{
@@ -174,7 +173,7 @@ public function testGetContentsReturnsEmptyContentsOnEvaldCode()
{
$className = uniqid('ClassReflectionTestGenerated');
- eval('name' . 'space ' . __NAMESPACE__ . '; cla' . 'ss ' . $className . '{}');
+ eval('namespace ' . __NAMESPACE__ . '; class ' . $className . '{}');
$reflectionClass = new ClassReflection(__NAMESPACE__ . '\\' . $className);
diff --git a/test/Reflection/DocBlockReflectionTest.php b/test/Reflection/DocBlockReflectionTest.php
index cbbdcb2c..4644865a 100644
--- a/test/Reflection/DocBlockReflectionTest.php
+++ b/test/Reflection/DocBlockReflectionTest.php
@@ -35,7 +35,6 @@ public function testDocBlockLongDescription()
$expectedOutput = 'This is a long description for the docblock of this class, it should be longer '
. 'than 3 lines. It indeed is longer than 3 lines now.';
-
$this->assertEquals($expectedOutput, $classReflection->getDocBlock()->getLongDescription());
}
diff --git a/test/Reflection/FileReflectionTest.php b/test/Reflection/FileReflectionTest.php
index 1ce2d990..9b297906 100644
--- a/test/Reflection/FileReflectionTest.php
+++ b/test/Reflection/FileReflectionTest.php
@@ -171,8 +171,8 @@ public function testFileCanReflectFileWithUses()
$expected = [
['use' => 'Zend\Config', 'as' => 'ZendConfig'],
['use' => 'FooBar\Foo\Bar', 'as' => null],
- ['use' => 'One\Two\Three\Four\Five', 'as' => 'ottff']
- ];
+ ['use' => 'One\Two\Three\Four\Five', 'as' => 'ottff'],
+ ];
$this->assertSame($expected, $reflectionFile->getUses());
}
diff --git a/test/Reflection/FunctionReflectionTest.php b/test/Reflection/FunctionReflectionTest.php
index 18dddb61..73152588 100644
--- a/test/Reflection/FunctionReflectionTest.php
+++ b/test/Reflection/FunctionReflectionTest.php
@@ -12,8 +12,8 @@
use Zend\Code\Reflection\FunctionReflection;
/**
- * @group Zend_Reflection
- * @group Zend_Reflection_Function
+ * @group Zend_Reflection
+ * @group Zend_Reflection_Function
*/
class FunctionReflectionTest extends \PHPUnit_Framework_TestCase
{
@@ -218,7 +218,7 @@ public function testFunctionContentsReturnWithoutDocBlock()
$function = new FunctionReflection('ZendTest\Code\Reflection\TestAsset\function12');
$content = $function->getContents(false);
- $this->assertEquals("function function12() {}", trim($content));
+ $this->assertEquals('function function12() {}', trim($content));
}
/**
@@ -234,7 +234,7 @@ public function testFunctionClosureContentsReturnWithoutDocBlock()
$function = new FunctionReflection($function9);
$content = $function->getContents(false);
- $this->assertEquals("function() {}", trim($content));
+ $this->assertEquals('function() {}', trim($content));
$function = new FunctionReflection($function10);
$content = $function->getContents(false);
@@ -267,7 +267,7 @@ public function testGetContentsReturnsEmptyContentsOnEvaldCode()
{
$functionName = uniqid('generatedFunction');
- eval('name' . 'space ' . __NAMESPACE__ . '; ' . 'fun' . 'ction ' . $functionName . '()' . '{}');
+ eval('namespace ' . __NAMESPACE__ . '; function ' . $functionName . '(){}');
$reflectionFunction = new FunctionReflection(__NAMESPACE__ . '\\' . $functionName);
diff --git a/test/Reflection/MethodReflectionTest.php b/test/Reflection/MethodReflectionTest.php
index 79feec4f..74bfb87c 100644
--- a/test/Reflection/MethodReflectionTest.php
+++ b/test/Reflection/MethodReflectionTest.php
@@ -102,7 +102,7 @@ public function testGetBodyReturnsCorrectBody()
'emptyFunction'
);
$body = $reflectionMethod->getBody();
- $this->assertEquals(trim($body), "");
+ $this->assertEquals(trim($body), '');
$reflectionMethod = new MethodReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass11', 'visibility');
$body = $reflectionMethod->getBody();
@@ -328,14 +328,14 @@ public function testGetAnnotationsWithNoNameInformations()
public function testGetContentsWithCoreClass()
{
$reflectionMethod = new MethodReflection('DateTime', 'format');
- $this->assertEquals("", $reflectionMethod->getContents(false));
+ $this->assertEquals('', $reflectionMethod->getContents(false));
}
public function testGetContentsReturnsEmptyContentsOnEvaldCode()
{
$className = uniqid('MethodReflectionTestGenerated');
- eval('name' . 'space ' . __NAMESPACE__ . '; cla' . 'ss ' . $className . '{fun' . 'ction foo(){}}');
+ eval('namespace ' . __NAMESPACE__ . '; class ' . $className . '{function foo(){}}');
$reflectionMethod = new MethodReflection(__NAMESPACE__ . '\\' . $className, 'foo');
@@ -354,7 +354,6 @@ public function testGetContentsReturnsEmptyContentsOnInternalCode()
*/
public function testCodeGetContentsDoesNotThrowExceptionOnDocBlock()
{
-
$contents = <<<'CONTENTS'
function getCacheKey() {
$args = func_get_args();
@@ -396,8 +395,8 @@ public function testCodeGetBodyReturnsEmptyWithCommentedFunction()
*/
public function testCanParseClassBodyWhenUsingTrait()
{
- require_once __DIR__ .'/TestAsset/TestTraitClass1.php';
- require_once __DIR__. '/TestAsset/TestTraitClass2.php';
+ require_once __DIR__ . '/TestAsset/TestTraitClass1.php';
+ require_once __DIR__ . '/TestAsset/TestTraitClass2.php';
// $method = new \Zend\Code\Reflection\ClassReflection('\FooClass');
// $traits = current($method->getTraits());
$method = new \Zend\Code\Reflection\MethodReflection('FooClass', 'getDummy');
diff --git a/test/Reflection/ParameterReflectionTest.php b/test/Reflection/ParameterReflectionTest.php
index 4bf942bd..4a41b44b 100644
--- a/test/Reflection/ParameterReflectionTest.php
+++ b/test/Reflection/ParameterReflectionTest.php
@@ -15,8 +15,8 @@
use ZendTest\Code\TestAsset\InternalHintsClass;
/**
- * @group Zend_Reflection
- * @group Zend_Reflection_Parameter
+ * @group Zend_Reflection
+ * @group Zend_Reflection_Parameter
*/
class ParameterReflectionTest extends \PHPUnit_Framework_TestCase
{
@@ -48,7 +48,10 @@ public function testClassReturn()
}
/**
- * @dataProvider paramTypeTestProvider
+ * @dataProvider paramType
+ *
+ * @param string $param
+ * @param string $type
*/
public function testTypeReturn($param, $type)
{
@@ -68,14 +71,14 @@ public function testCallableTypeHint()
$this->assertEquals('callable', $parameter->detectType());
}
- public function paramTypeTestProvider()
+ public function paramType()
{
return [
- ['one','int'],
- ['two','int'],
- ['three','string'],
- ['array','array'],
- ['class','ZendTest\Code\Reflection\TestAsset\TestSampleClass']
+ ['one', 'int'],
+ ['two', 'int'],
+ ['three', 'string'],
+ ['array', 'array'],
+ ['class', 'ZendTest\Code\Reflection\TestAsset\TestSampleClass'],
];
}
@@ -84,7 +87,7 @@ public function paramTypeTestProvider()
*
* @requires PHP 7.0
*
- * @dataProvider reflectionHintsProvider
+ * @dataProvider reflectionHints
*
* @param string $className
* @param string $methodName
@@ -109,7 +112,7 @@ public function testGetType($className, $methodName, $parameterName, $expectedTy
*
* @requires PHP 7.0
*
- * @dataProvider reflectionHintsProvider
+ * @dataProvider reflectionHints
*
* @param string $className
* @param string $methodName
@@ -134,7 +137,7 @@ public function testDetectType($className, $methodName, $parameterName, $expecte
/**
* @return string[][]
*/
- public function reflectionHintsProvider()
+ public function reflectionHints()
{
return [
[InternalHintsClass::class, 'arrayParameter', 'foo', 'array'],
@@ -156,7 +159,7 @@ public function reflectionHintsProvider()
*
* @requires PHP 7.0
*
- * @dataProvider docBlockHintsProvider
+ * @dataProvider docBlockHints
*
* @param string $className
* @param string $methodName
@@ -175,7 +178,7 @@ public function testGetTypeWithDocBlockOnlyTypes($className, $methodName, $param
/**
* @group zendframework/zend-code#29
*
- * @dataProvider docBlockHintsProvider
+ * @dataProvider docBlockHints
*
* @param string $className
* @param string $methodName
@@ -195,7 +198,7 @@ public function testDetectTypeWithDocBlockOnlyTypes($className, $methodName, $pa
/**
* @return string[][]
*/
- public function docBlockHintsProvider()
+ public function docBlockHints()
{
return [
[DocBlockOnlyHintsClass::class, 'arrayParameter', 'foo', 'array'],
diff --git a/test/Reflection/PropertyReflectionTest.php b/test/Reflection/PropertyReflectionTest.php
index 6b831075..a4d1584a 100644
--- a/test/Reflection/PropertyReflectionTest.php
+++ b/test/Reflection/PropertyReflectionTest.php
@@ -41,7 +41,7 @@ public function testAnnotationScanningIsPossible()
$this->assertTrue($annotations->hasAnnotation(TestAsset\SampleAnnotation::class));
$found = false;
foreach ($annotations as $key => $annotation) {
- if (!$annotation instanceof TestAsset\SampleAnnotation) {
+ if (! $annotation instanceof TestAsset\SampleAnnotation) {
continue;
}
$this->assertEquals(get_class($annotation) . ': {"foo":"bar"}', $annotation->content);
diff --git a/test/Reflection/ReflectionDocBlockTagTest.php b/test/Reflection/ReflectionDocBlockTagTest.php
index a93d0c00..4ac4365e 100644
--- a/test/Reflection/ReflectionDocBlockTagTest.php
+++ b/test/Reflection/ReflectionDocBlockTagTest.php
@@ -55,7 +55,6 @@ public function testToString()
$this->assertEquals($expectedString, (string) $tag);
}
-
public function testTypeParam()
{
$classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
@@ -79,13 +78,11 @@ public function testAllowsMultipleSpacesInDocBlockTagLine()
$paramTag = $classReflection->getMethod('doSomething')->getDocBlock()->getTag('param');
-
$this->assertEquals($paramTag->getType(), 'int', 'Second Match Failed');
$this->assertEquals($paramTag->getVariableName(), '$var', 'Third Match Failed');
$this->assertEquals($paramTag->getDescription(), 'Description of $var', 'Final Match Failed');
}
-
/**
* @group ZF-8307
*/
@@ -94,7 +91,6 @@ public function testNamespaceInParam()
$classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass7');
$paramTag = $classReflection->getMethod('doSomething')->getDocBlock()->getTag('param');
-
$this->assertEquals('Zend\Foo\Bar', $paramTag->getType());
$this->assertEquals('$var', $paramTag->getVariableName());
$this->assertEquals('desc', $paramTag->getDescription());
@@ -118,7 +114,6 @@ public function testAllowsMultipleSpacesInDocBlockTagLine2()
$this->assertEquals($paramTag->getDescription(), 'Description of return value', 'Final Match Failed');
}
-
/**
* @group ZF-8307
*/
diff --git a/test/Scanner/AnnotationScannerTest.php b/test/Scanner/AnnotationScannerTest.php
index 344ba380..6d78e13a 100644
--- a/test/Scanner/AnnotationScannerTest.php
+++ b/test/Scanner/AnnotationScannerTest.php
@@ -9,15 +9,17 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\AnnotationScanner;
-use Zend\Code\NameInformation;
use Zend\Code\Annotation\AnnotationManager;
use Zend\Code\Annotation\Parser\GenericAnnotationParser;
+use Zend\Code\NameInformation;
+use Zend\Code\Scanner\AnnotationScanner;
class AnnotationScannerTest extends \PHPUnit_Framework_TestCase
{
/**
- * @dataProvider scannerWorksDataProvider
+ * @dataProvider newLine
+ *
+ * @param string $newLine
*/
public function testScannerWorks($newLine)
{
@@ -25,14 +27,14 @@ public function testScannerWorks($newLine)
$parser = new GenericAnnotationParser();
$parser->registerAnnotations([
$foo = new TestAsset\Annotation\Foo(),
- $bar = new TestAsset\Annotation\Bar()
+ $bar = new TestAsset\Annotation\Bar(),
]);
$annotationManager->attach($parser);
$docComment = '/**' . $newLine
. ' * @Test\Foo(\'anything I want()' . $newLine
. ' * to be\')' . $newLine
- . ' * @Test\Bar' . $newLine . " */";
+ . ' * @Test\Bar' . $newLine . ' */';
$nameInfo = new NameInformation();
$nameInfo->addUse('ZendTest\Code\Scanner\TestAsset\Annotation', 'Test');
@@ -43,7 +45,7 @@ public function testScannerWorks($newLine)
$this->assertEquals(get_class($bar), get_class($annotationScanner[1]));
}
- public function scannerWorksDataProvider()
+ public function newLine()
{
return [
["\n"],
diff --git a/test/Scanner/CachingFileScannerTest.php b/test/Scanner/CachingFileScannerTest.php
index d72d9088..e9132f0f 100644
--- a/test/Scanner/CachingFileScannerTest.php
+++ b/test/Scanner/CachingFileScannerTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\CachingFileScanner;
use Zend\Code\Annotation\AnnotationManager;
+use Zend\Code\Scanner\CachingFileScanner;
class CachingFileScannerTest extends \PHPUnit_Framework_TestCase
{
diff --git a/test/Scanner/ClassScannerTest.php b/test/Scanner/ClassScannerTest.php
index 254cc3e2..844a43bf 100644
--- a/test/Scanner/ClassScannerTest.php
+++ b/test/Scanner/ClassScannerTest.php
@@ -13,8 +13,6 @@
use Zend\Code\Annotation;
use Zend\Code\Scanner\FileScanner;
use Zend\Stdlib\ErrorHandler;
-use ZendTest\Code\TestAsset\TraitWithSameMethods;
-use ZendTest\Code\TestAsset\TestClassWithTraitAliases;
class ClassScannerTest extends TestCase
{
@@ -229,8 +227,8 @@ public function testClassScannerCanScanClassAndGetTraitsAliases()
public function testClassScannerCanGetTraitMethodsInGetMethods()
{
//load files or test may fail due to autoload issues
- require_once(__DIR__ . '/../TestAsset/TraitWithSameMethods.php');
- require_once(__DIR__ . '/../TestAsset/BarTrait.php');
+ require_once __DIR__ . '/../TestAsset/TraitWithSameMethods.php';
+ require_once __DIR__ . '/../TestAsset/BarTrait.php';
$file = new FileScanner(__DIR__ . '/../TestAsset/TestClassWithTraitAliases.php');
@@ -249,7 +247,7 @@ public function testClassScannerCanGetTraitMethodsInGetMethods()
$this->assertEquals($class->getMethodNames(), array_keys($testMethods));
foreach ($testMethods as $methodName => $testMethod) {
- $this->assertTrue($class->hasMethod($methodName), "Cannot find method $methodName");
+ $this->assertTrue($class->hasMethod($methodName), sprintf('Cannot find method %s', $methodName));
$method = $class->getMethod($methodName);
$this->assertInstanceOf('Zend\Code\Scanner\MethodScanner', $method, $methodName . ' not found.');
@@ -257,7 +255,7 @@ public function testClassScannerCanGetTraitMethodsInGetMethods()
$this->assertTrue($method->$testMethod());
// test that we got the right ::bar method based on declaration
- if ($testMethod === "bar") {
+ if ($testMethod === 'bar') {
$this->assertEquals(trim($method->getBody), 'echo "foo";');
}
}
diff --git a/test/Scanner/ConstantScannerTest.php b/test/Scanner/ConstantScannerTest.php
index e93b24a6..78e953d0 100644
--- a/test/Scanner/ConstantScannerTest.php
+++ b/test/Scanner/ConstantScannerTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\FileScanner;
use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Code\Scanner\FileScanner;
class ConstantScannerTest extends TestCase
{
diff --git a/test/Scanner/DerivedClassScannerTest.php b/test/Scanner/DerivedClassScannerTest.php
index 2374d0dc..63b25dd4 100644
--- a/test/Scanner/DerivedClassScannerTest.php
+++ b/test/Scanner/DerivedClassScannerTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\DirectoryScanner;
use Zend\Code\Scanner\AggregateDirectoryScanner;
+use Zend\Code\Scanner\DirectoryScanner;
class DerivedClassScannerTest extends \PHPUnit_Framework_TestCase
{
diff --git a/test/Scanner/DocBlockScannerTest.php b/test/Scanner/DocBlockScannerTest.php
index 61d5bbca..273de623 100644
--- a/test/Scanner/DocBlockScannerTest.php
+++ b/test/Scanner/DocBlockScannerTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\DocBlockScanner;
use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Code\Scanner\DocBlockScanner;
/**
* @group Zend_Code_Scanner
diff --git a/test/Scanner/FileScannerTest.php b/test/Scanner/FileScannerTest.php
index 76a8d716..ea653d80 100644
--- a/test/Scanner/FileScannerTest.php
+++ b/test/Scanner/FileScannerTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\FileScanner;
use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Code\Scanner\FileScanner;
class FileScannerTest extends TestCase
{
diff --git a/test/Scanner/MethodScannerTest.php b/test/Scanner/MethodScannerTest.php
index e4c60e31..684a6fb7 100644
--- a/test/Scanner/MethodScannerTest.php
+++ b/test/Scanner/MethodScannerTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\FileScanner;
use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Code\Scanner\FileScanner;
class MethodScannerTest extends TestCase
{
diff --git a/test/Scanner/ParameterScannerTest.php b/test/Scanner/ParameterScannerTest.php
index fdedfa86..4543c4a5 100644
--- a/test/Scanner/ParameterScannerTest.php
+++ b/test/Scanner/ParameterScannerTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\FileScanner;
use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Code\Scanner\FileScanner;
class ParameterScannerTest extends TestCase
{
diff --git a/test/Scanner/PropertyScannerTest.php b/test/Scanner/PropertyScannerTest.php
index 2d7c0a2c..39843861 100644
--- a/test/Scanner/PropertyScannerTest.php
+++ b/test/Scanner/PropertyScannerTest.php
@@ -9,9 +9,9 @@
namespace ZendTest\Code\Scanner;
+use PHPUnit_Framework_TestCase as TestCase;
use Zend\Code\Scanner\FileScanner;
use Zend\Code\Scanner\TokenArrayScanner;
-use PHPUnit_Framework_TestCase as TestCase;
class PropertyScannerTest extends TestCase
{
@@ -70,30 +70,30 @@ class Foo
$value = $property->getValue();
$valueType = $property->getValueType();
switch ($property->getName()) {
- case "empty":
+ case 'empty':
$this->assertNull($value);
$this->assertEquals('unknown', $valueType);
break;
- case "string":
+ case 'string':
$this->assertEquals('string', $value);
$this->assertEquals('string', $valueType);
break;
- case "int":
+ case 'int':
$this->assertEquals('123', $value);
$this->assertEquals('int', $valueType);
break;
- case "array":
+ case 'array':
$this->assertEquals("array('test'=>2,2)", $value);
$this->assertEquals('array', $valueType);
break;
- case "arraynew":
+ case 'arraynew':
$this->assertEquals("['test'=>2,2]", $value);
$this->assertEquals('array', $valueType);
break;
- case "notarray":
+ case 'notarray':
$this->assertEquals('string', $valueType);
break;
- case "status":
+ case 'status':
$this->assertEquals('false', $value);
$this->assertEquals('boolean', $valueType);
break;
diff --git a/test/Scanner/TokenArrayScannerTest.php b/test/Scanner/TokenArrayScannerTest.php
index c0c23bf5..bf556fcc 100644
--- a/test/Scanner/TokenArrayScannerTest.php
+++ b/test/Scanner/TokenArrayScannerTest.php
@@ -9,8 +9,8 @@
namespace ZendTest\Code\Scanner;
-use Zend\Code\Scanner\TokenArrayScanner;
use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Code\Scanner\TokenArrayScanner;
class TokenArrayScannerTest extends TestCase
{