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/CONTRIBUTING.md b/CONTRIBUTING.md index 8f7185c3..97abf69c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,39 +36,30 @@ For sensitive email communications, please use [our PGP key](http://framework.ze ## RUNNING TESTS -> ### Note: testing versions prior to 2.4 -> -> This component originates with Zend Framework 2. During the lifetime of ZF2, -> testing infrastructure migrated from PHPUnit 3 to PHPUnit 4. In most cases, no -> changes were necessary. However, due to the migration, tests may not run on -> versions < 2.4. As such, you may need to change the PHPUnit dependency if -> attempting a fix on such a version. - To run tests: - Clone the repository: ```console - $ git clone git@github.com:zendframework/zend-code.git - $ cd + $ git clone git://github.com/zendframework/zend-code.git + $ cd zend-code ``` - Install dependencies via composer: ```console - $ curl -sS https://getcomposer.org/installer | php -- - $ ./composer.phar install + $ composer install ``` - If you don't have `curl` installed, you can also download `composer.phar` from https://getcomposer.org/ + If you don't have `composer` installed, please download it from https://getcomposer.org/download/ -- Run the tests via `phpunit` and the provided PHPUnit config, like in this example: +- Run the tests using the "test" command shipped in the `composer.json`: ```console - $ ./vendor/bin/phpunit + $ composer test ``` -You can turn on conditional tests with the phpunit.xml file. +You can turn on conditional tests with the `phpunit.xml` file. To do so: - Copy `phpunit.xml.dist` file to `phpunit.xml` @@ -77,24 +68,22 @@ To do so: ## Running Coding Standards Checks -This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding -standards checks, and provides configuration for our selected checks. -`php-cs-fixer` is installed by default via Composer. +First, ensure you've installed dependencies via composer, per the previous +section on running tests. -To run checks only: +To run CS checks only: ```console -$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs +$ composer cs-check ``` -To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run` -flag: +To attempt to automatically fix common CS issues: ```console -$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs +$ composer cs-fix ``` -If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure +If the above fixes any CS issues, please re-run the tests to ensure they pass, and make sure you add and commit the changes after verification. ## Recommended Workflow for Contributions @@ -103,12 +92,12 @@ Your first step is to establish a public repository from which we can pull your work into the master repository. We recommend using [GitHub](https://github.com), as that is where the component is already hosted. -1. Setup a [GitHub account](http://github.com/), if you haven't yet -2. Fork the repository (http://github.com/zendframework/zend-code) +1. Setup a [GitHub account](https://github.com/), if you haven't yet +2. Fork the repository (https://github.com/zendframework/zend-code) 3. Clone the canonical repository locally and enter it. ```console - $ git clone git://github.com:zendframework/zend-code.git + $ git clone git://github.com/zendframework/zend-code.git $ cd zend-code ``` diff --git a/composer.json b/composer.json index 59c55e52..23514872 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ "ext-phar": "*", "doctrine/annotations": "~1.0", "zendframework/zend-stdlib": "^2.7 || ^3.0", - "squizlabs/php_codesniffer": "^2.5", - "phpunit/phpunit": "^6.2.2" + "phpunit/phpunit": "^6.2.3", + "zendframework/zend-coding-standard": "~1.0.0" }, "suggest": { "doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features", diff --git a/composer.lock b/composer.lock index f0475899..ff960467 100644 --- a/composer.lock +++ b/composer.lock @@ -4,30 +4,30 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "2d329d458f0777ea887a1a01a7239c24", + "content-hash": "366da03331f61b6846b05f4068900862", "packages": [ { "name": "zendframework/zend-eventmanager", - "version": "3.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/zendframework/zend-eventmanager.git", - "reference": "5c80bdee0e952be112dcec0968bad770082c3a6e" + "reference": "c3bce7b7d47c54040b9ae51bc55491c72513b75d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/5c80bdee0e952be112dcec0968bad770082c3a6e", - "reference": "5c80bdee0e952be112dcec0968bad770082c3a6e", + "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/c3bce7b7d47c54040b9ae51bc55491c72513b75d", + "reference": "c3bce7b7d47c54040b9ae51bc55491c72513b75d", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0" + "php": "^5.6 || ^7.0" }, "require-dev": { "athletic/athletic": "^0.1", "container-interop/container-interop": "^1.1.0", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "^2.0", + "phpunit/phpunit": "^5.6", + "zendframework/zend-coding-standard": "~1.0.0", "zendframework/zend-stdlib": "^2.7.3 || ^3.0" }, "suggest": { @@ -37,8 +37,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev", - "dev-develop": "3.1-dev" + "dev-master": "3.1-dev", + "dev-develop": "3.2-dev" } }, "autoload": { @@ -58,41 +58,41 @@ "events", "zf2" ], - "time": "2016-02-18T20:53:00+00:00" + "time": "2016-12-19T21:47:12+00:00" } ], "packages-dev": [ { "name": "doctrine/annotations", - "version": "v1.2.7", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535" + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535", - "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", "shasum": "" }, "require": { "doctrine/lexer": "1.*", - "php": ">=5.3.2" + "php": "^5.6 || ^7.0" }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "^5.7" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "1.4.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Annotations\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" } }, "notification-url": "https://packagist.org/downloads/", @@ -128,7 +128,7 @@ "docblock", "parser" ], - "time": "2015-08-31T12:32:49+00:00" + "time": "2017-02-24T16:22:25+00:00" }, { "name": "doctrine/instantiator", @@ -843,16 +843,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.2.2", + "version": "6.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e" + "reference": "fa5711d0559fc4b64deba0702be52d41434cbcb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f2786490399836d2a544a34785c4a8d3ab32cf0e", - "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fa5711d0559fc4b64deba0702be52d41434cbcb7", + "reference": "fa5711d0559fc4b64deba0702be52d41434cbcb7", "shasum": "" }, "require": { @@ -923,7 +923,7 @@ "testing", "xunit" ], - "time": "2017-06-13T14:07:07+00:00" + "time": "2017-07-03T15:54:24+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -1545,16 +1545,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.6.0", + "version": "2.9.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1bcdf03b068a530ac1962ce671dead356eeba43b" + "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" }, "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/dcbed1074f8244661eecddfc2a675430d8d33f62", + "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", "shasum": "" }, "require": { @@ -1619,7 +1619,7 @@ "phpcs", "standards" ], - "time": "2016-04-03T22:58:34+00:00" + "time": "2017-05-22T02:43:20+00:00" }, { "name": "theseer/tokenizer", @@ -1711,33 +1711,62 @@ ], "time": "2016-11-23T20:04:58+00:00" }, + { + "name": "zendframework/zend-coding-standard", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-coding-standard.git", + "reference": "893316d2904e93f1c74c1384b6d7d57778299cb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-coding-standard/zipball/893316d2904e93f1c74c1384b6d7d57778299cb6", + "reference": "893316d2904e93f1c74c1384b6d7d57778299cb6", + "shasum": "" + }, + "require": { + "squizlabs/php_codesniffer": "^2.7" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Zend Framework coding standard", + "keywords": [ + "Coding Standard", + "zf" + ], + "time": "2016-11-09T21:30:43+00:00" + }, { "name": "zendframework/zend-stdlib", - "version": "3.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "8bafa58574204bdff03c275d1d618aaa601588ae" + "reference": "debedcfc373a293f9250cc9aa03cf121428c8e78" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/8bafa58574204bdff03c275d1d618aaa601588ae", - "reference": "8bafa58574204bdff03c275d1d618aaa601588ae", + "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/debedcfc373a293f9250cc9aa03cf121428c8e78", + "reference": "debedcfc373a293f9250cc9aa03cf121428c8e78", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0" + "php": "^5.6 || ^7.0" }, "require-dev": { "athletic/athletic": "~0.1", - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "^2.6.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev", - "dev-develop": "3.1-dev" + "dev-master": "3.1-dev", + "dev-develop": "3.2-dev" } }, "autoload": { @@ -1754,7 +1783,7 @@ "stdlib", "zf2" ], - "time": "2016-04-12T21:19:36+00:00" + "time": "2016-09-13T14:38:50+00:00" } ], "aliases": [], diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 00000000..d2460fd4 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,9 @@ + + + + + + src + test + */TestAsset/* + 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/Parser/DoctrineAnnotationParser.php b/src/Annotation/Parser/DoctrineAnnotationParser.php index adef137c..91832997 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,7 +136,7 @@ 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__, diff --git a/src/Annotation/Parser/GenericAnnotationParser.php b/src/Annotation/Parser/GenericAnnotationParser.php index 6592e4f4..1b3c4f1a 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; } @@ -91,7 +91,7 @@ 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__, @@ -122,7 +122,7 @@ 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__, @@ -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__, diff --git a/src/Generator/AbstractGenerator.php b/src/Generator/AbstractGenerator.php index 546e3183..fbb275b9 100644 --- a/src/Generator/AbstractGenerator.php +++ b/src/Generator/AbstractGenerator.php @@ -104,7 +104,7 @@ 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__, diff --git a/src/Generator/AbstractMemberGenerator.php b/src/Generator/AbstractMemberGenerator.php index 11046128..6a28b260 100644 --- a/src/Generator/AbstractMemberGenerator.php +++ b/src/Generator/AbstractMemberGenerator.php @@ -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/ClassGenerator.php b/src/Generator/ClassGenerator.php index fefe41e7..0354b4f9 100644 --- a/src/Generator/ClassGenerator.php +++ b/src/Generator/ClassGenerator.php @@ -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' ); @@ -434,7 +434,7 @@ public function getExtendedClass() */ public function hasExtentedClass() { - return !empty($this->extendedClass); + return ! empty($this->extendedClass); } /** @@ -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), @@ -827,7 +827,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), @@ -1012,9 +1012,9 @@ public function isSourceDirty() */ public function generate() { - if (!$this->isSourceDirty()) { + if (! $this->isSourceDirty()) { $output = $this->getSourceContent(); - if (!empty($output)) { + if (! empty($output)) { return $output; } } @@ -1028,7 +1028,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 +1049,13 @@ public function generate() $output .= static::OBJECT_TYPE . ' ' . $this->getName(); - if (!empty($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..ee61cd5f 100644 --- a/src/Generator/DocBlock/Tag/AbstractTypeableTag.php +++ b/src/Generator/DocBlock/Tag/AbstractTypeableTag.php @@ -34,11 +34,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..f746c63b 100644 --- a/src/Generator/DocBlock/Tag/AuthorTag.php +++ b/src/Generator/DocBlock/Tag/AuthorTag.php @@ -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..3d7e7353 100644 --- a/src/Generator/DocBlock/Tag/GenericTag.php +++ b/src/Generator/DocBlock/Tag/GenericTag.php @@ -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..75c28065 100644 --- a/src/Generator/DocBlock/Tag/LicenseTag.php +++ b/src/Generator/DocBlock/Tag/LicenseTag.php @@ -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..7e12a2a4 100644 --- a/src/Generator/DocBlock/Tag/MethodTag.php +++ b/src/Generator/DocBlock/Tag/MethodTag.php @@ -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); } @@ -89,9 +89,9 @@ public function generate() { $output = '@method' . (($this->isStatic) ? ' static' : '') - . ((!empty($this->types)) ? ' ' . $this->getTypesAsString() : '') - . ((!empty($this->methodName)) ? ' ' . $this->methodName . '()' : '') - . ((!empty($this->description)) ? ' ' . $this->description : ''); + . ((! 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..81fc3ce8 100644 --- a/src/Generator/DocBlock/Tag/ParamTag.php +++ b/src/Generator/DocBlock/Tag/ParamTag.php @@ -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..5ba3ab0b 100644 --- a/src/Generator/DocBlock/Tag/PropertyTag.php +++ b/src/Generator/DocBlock/Tag/PropertyTag.php @@ -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..f0e829e5 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..27bd9e23 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..603136c9 100644 --- a/src/Generator/DocBlockGenerator.php +++ b/src/Generator/DocBlockGenerator.php @@ -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())); } diff --git a/src/Generator/FileGenerator.php b/src/Generator/FileGenerator.php index 1f646459..ca792f5d 100644 --- a/src/Generator/FileGenerator.php +++ b/src/Generator/FileGenerator.php @@ -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__, @@ -472,7 +472,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 +486,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,7 +505,7 @@ public function generate() } //don't duplicate use statements - if (!in_array($tempOutput, $classUses)) { + if (! in_array($tempOutput, $classUses)) { $useOutput .= "use ". $tempOutput .";"; $useOutput .= self::LINE_FEED; } @@ -525,7 +525,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 +541,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 +559,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..baf88923 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() diff --git a/src/Generator/MethodGenerator.php b/src/Generator/MethodGenerator.php index 59af8221..da2017fc 100644 --- a/src/Generator/MethodGenerator.php +++ b/src/Generator/MethodGenerator.php @@ -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' ); @@ -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__, @@ -336,7 +336,7 @@ public function generate() . $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..dbaf917d 100644 --- a/src/Generator/ParameterGenerator.php +++ b/src/Generator/ParameterGenerator.php @@ -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; diff --git a/src/Generator/PropertyGenerator.php b/src/Generator/PropertyGenerator.php index bead534b..eadd62fb 100644 --- a/src/Generator/PropertyGenerator.php +++ b/src/Generator/PropertyGenerator.php @@ -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' ); @@ -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.', diff --git a/src/Generator/ValueGenerator.php b/src/Generator/ValueGenerator.php index 24a2983a..a572c720 100644 --- a/src/Generator/ValueGenerator.php +++ b/src/Generator/ValueGenerator.php @@ -93,7 +93,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' ); diff --git a/src/Generic/Prototype/PrototypeClassFactory.php b/src/Generic/Prototype/PrototypeClassFactory.php index 58c28e07..e5fd013f 100644 --- a/src/Generic/Prototype/PrototypeClassFactory.php +++ b/src/Generic/Prototype/PrototypeClassFactory.php @@ -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..9271987a 100644 --- a/src/NameInformation.php +++ b/src/NameInformation.php @@ -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..ad6974fb 100644 --- a/src/Reflection/ClassReflection.php +++ b/src/Reflection/ClassReflection.php @@ -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), '{'); } diff --git a/src/Reflection/DocBlock/Tag/AuthorTag.php b/src/Reflection/DocBlock/Tag/AuthorTag.php index d6c54db8..ff45646b 100644 --- a/src/Reflection/DocBlock/Tag/AuthorTag.php +++ b/src/Reflection/DocBlock/Tag/AuthorTag.php @@ -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/LicenseTag.php b/src/Reflection/DocBlock/Tag/LicenseTag.php index 1c844d01..d918e182 100644 --- a/src/Reflection/DocBlock/Tag/LicenseTag.php +++ b/src/Reflection/DocBlock/Tag/LicenseTag.php @@ -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..402dfcfd 100644 --- a/src/Reflection/DocBlock/Tag/MethodTag.php +++ b/src/Reflection/DocBlock/Tag/MethodTag.php @@ -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; } diff --git a/src/Reflection/DocBlock/Tag/ParamTag.php b/src/Reflection/DocBlock/Tag/ParamTag.php index 1d3ccaae..a8a83c2a 100644 --- a/src/Reflection/DocBlock/Tag/ParamTag.php +++ b/src/Reflection/DocBlock/Tag/ParamTag.php @@ -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..9cbfbd99 100644 --- a/src/Reflection/DocBlock/Tag/PropertyTag.php +++ b/src/Reflection/DocBlock/Tag/PropertyTag.php @@ -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; } diff --git a/src/Reflection/DocBlock/Tag/ReturnTag.php b/src/Reflection/DocBlock/Tag/ReturnTag.php index 9da77d1a..4626067b 100644 --- a/src/Reflection/DocBlock/Tag/ReturnTag.php +++ b/src/Reflection/DocBlock/Tag/ReturnTag.php @@ -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/DocBlockReflection.php b/src/Reflection/DocBlockReflection.php index 32fbd323..7de0c96e 100644 --- a/src/Reflection/DocBlockReflection.php +++ b/src/Reflection/DocBlockReflection.php @@ -83,7 +83,7 @@ public static function export() */ public function __construct($commentOrReflector, DocBlockTagManager $tagManager = null) { - if (!$tagManager) { + if (! $tagManager) { $tagManager = new DocBlockTagManager(); $tagManager->initializeDefaultTags(); } @@ -91,7 +91,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 +222,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; } diff --git a/src/Reflection/FileReflection.php b/src/Reflection/FileReflection.php index 9f3c7489..575df768 100644 --- a/src/Reflection/FileReflection.php +++ b/src/Reflection/FileReflection.php @@ -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 @@ -151,7 +151,7 @@ public function getDocComment() */ public function getDocBlock() { - if (!($docComment = $this->getDocComment())) { + if (! ($docComment = $this->getDocComment())) { return false; } diff --git a/src/Reflection/FunctionReflection.php b/src/Reflection/FunctionReflection.php index b5b36979..7ad0b980 100644 --- a/src/Reflection/FunctionReflection.php +++ b/src/Reflection/FunctionReflection.php @@ -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, @@ -140,7 +140,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 +153,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 +195,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' ); @@ -245,7 +245,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..38a268dd 100644 --- a/src/Reflection/MethodReflection.php +++ b/src/Reflection/MethodReflection.php @@ -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; } @@ -133,7 +133,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 +146,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 +191,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; @@ -234,7 +234,7 @@ protected function extractMethodContents($bodyOnly = false) //remove first entry which is php open tag array_shift($tokens); - if (!count($tokens)) { + if (! count($tokens)) { return ''; } @@ -341,11 +341,11 @@ 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--) { + 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]; @@ -372,7 +372,7 @@ protected function isEndingBrace($haystack, $position) $count = count($haystack); //advance one position - $position = $position+1; + $position = $position + 1; if ($position == $count) { return true; @@ -440,7 +440,7 @@ protected function isValidFunction($haystack, $position, $functionName = null) { $isValid = false; $count = count($haystack); - for ($i = $position+1; $i < $count; $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]; 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..afaf5be1 100644 --- a/src/Scanner/AggregateDirectoryScanner.php +++ b/src/Scanner/AggregateDirectoryScanner.php @@ -85,7 +85,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 +101,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..3890f056 100644 --- a/src/Scanner/AnnotationScanner.php +++ b/src/Scanner/AnnotationScanner.php @@ -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]) ) { @@ -159,7 +159,7 @@ protected function tokenize() ) { $positionsForward = ($positionsForward > 0) ? $positionsForward : 1; $streamIndex = ($streamIndex === null) ? 0 : $streamIndex + $positionsForward; - if (!isset($stream[$streamIndex])) { + if (! isset($stream[$streamIndex])) { $currentChar = false; return false; diff --git a/src/Scanner/CachingFileScanner.php b/src/Scanner/CachingFileScanner.php index 10945896..c3cf139d 100644 --- a/src/Scanner/CachingFileScanner.php +++ b/src/Scanner/CachingFileScanner.php @@ -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 diff --git a/src/Scanner/ClassScanner.php b/src/Scanner/ClassScanner.php index 7069d5e9..309402b6 100644 --- a/src/Scanner/ClassScanner.php +++ b/src/Scanner/ClassScanner.php @@ -156,7 +156,7 @@ public function getDocComment() */ public function getDocBlock() { - if (!$docComment = $this->getDocComment()) { + if (! $docComment = $this->getDocComment()) { return false; } @@ -236,7 +236,7 @@ public function isTrait() public function isInstantiable() { $this->scan(); - return (!$this->isAbstract && !$this->isInterface && !$this->isTrait); + return (! $this->isAbstract && ! $this->isInterface && ! $this->isTrait); } /** @@ -366,7 +366,7 @@ public function getConstant($constantNameOrInfoIndex) break; } } - if (!$constantFound) { + if (! $constantFound) { return false; } } else { @@ -374,7 +374,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 +471,7 @@ public function getProperty($propertyNameOrInfoIndex) break; } } - if (!$propertyFound) { + if (! $propertyFound) { return false; } } else { @@ -479,7 +479,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( @@ -849,7 +849,7 @@ protected function scan() return; } - if (!$this->tokens) { + if (! $this->tokens) { throw new Exception\RuntimeException('No tokens were provided'); } @@ -881,7 +881,7 @@ protected function scan() ) { static $lastTokenArray = null; $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1; - if (!isset($tokens[$tokenIndex])) { + if (! isset($tokens[$tokenIndex])) { $token = false; $tokenContent = false; $tokenType = false; @@ -1003,7 +1003,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; diff --git a/src/Scanner/ConstantScanner.php b/src/Scanner/ConstantScanner.php index 31e245c9..8d6c2d27 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) { diff --git a/src/Scanner/DirectoryScanner.php b/src/Scanner/DirectoryScanner.php index e561be0d..444ab716 100644 --- a/src/Scanner/DirectoryScanner.php +++ b/src/Scanner/DirectoryScanner.php @@ -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 @@ -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.'); } diff --git a/src/Scanner/DocBlockScanner.php b/src/Scanner/DocBlockScanner.php index 228ce9ff..5d456b5a 100644 --- a/src/Scanner/DocBlockScanner.php +++ b/src/Scanner/DocBlockScanner.php @@ -200,7 +200,7 @@ protected function tokenize() ) { $positionsForward = ($positionsForward > 0) ? $positionsForward : 1; $streamIndex = ($streamIndex === null) ? 0 : $streamIndex + $positionsForward; - if (!isset($stream[$streamIndex])) { + if (! isset($stream[$streamIndex])) { $currentChar = false; return false; diff --git a/src/Scanner/FileScanner.php b/src/Scanner/FileScanner.php index fed93700..26518723 100644 --- a/src/Scanner/FileScanner.php +++ b/src/Scanner/FileScanner.php @@ -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..868834a3 100644 --- a/src/Scanner/MethodScanner.php +++ b/src/Scanner/MethodScanner.php @@ -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,7 +400,7 @@ protected function scan() return; } - if (!$this->tokens) { + if (! $this->tokens) { throw new Exception\RuntimeException('No tokens were provided'); } @@ -431,7 +431,7 @@ protected function scan() ) { static $lastTokenArray = null; $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1; - if (!isset($tokens[$tokenIndex])) { + if (! isset($tokens[$tokenIndex])) { $token = false; $tokenContent = false; $tokenType = false; @@ -523,7 +523,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 +536,7 @@ protected function scan() } if ($parentCount === 1) { - if (!isset($infos[$infoIndex])) { + if (! isset($infos[$infoIndex])) { $MACRO_INFO_START(); } if ($tokenType === T_VARIABLE) { @@ -550,7 +550,7 @@ protected function scan() case null: switch ($tokenContent) { case '&': - if (!isset($infos[$infoIndex])) { + if (! isset($infos[$infoIndex])) { $MACRO_INFO_START(); } goto SCANNER_CONTINUE_SIGNATURE; diff --git a/src/Scanner/PropertyScanner.php b/src/Scanner/PropertyScanner.php index 5920196c..05bae38a 100644 --- a/src/Scanner/PropertyScanner.php +++ b/src/Scanner/PropertyScanner.php @@ -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,7 +294,7 @@ protected function scan() } //start value concatenation - if (!is_array($token) && trim($token) == "=") { + if (! is_array($token) && trim($token) == "=") { $concatenateValue = true; } } diff --git a/src/Scanner/TokenArrayScanner.php b/src/Scanner/TokenArrayScanner.php index ea1037a1..d4d92628 100644 --- a/src/Scanner/TokenArrayScanner.php +++ b/src/Scanner/TokenArrayScanner.php @@ -189,7 +189,7 @@ public function getClass($name) } } - if (!$classFound) { + if (! $classFound) { return false; } } @@ -220,11 +220,11 @@ public function getClassNameInformation($className) } } - if (!$classFound) { + if (! $classFound) { return false; } - if (!isset($info)) { + if (! isset($info)) { return; } @@ -294,7 +294,7 @@ protected function scan() return; } - if (!$this->tokens) { + if (! $this->tokens) { throw new Exception\RuntimeException('No tokens were provided'); } @@ -325,7 +325,7 @@ protected function scan() &$tokenLine ) { $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1; - if (!isset($tokens[$tokenIndex])) { + if (! isset($tokens[$tokenIndex])) { $token = false; $tokenContent = false; $tokenType = false; @@ -336,7 +336,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)) { @@ -361,7 +361,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; } @@ -667,9 +667,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 9b7add15..3e68963a 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 68fc3247..29be9f38 100644 --- a/test/Annotation/DoctrineAnnotationParserTest.php +++ b/test/Annotation/DoctrineAnnotationParserTest.php @@ -23,7 +23,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/Generator/ClassGeneratorTest.php b/test/Generator/ClassGeneratorTest.php index e391aa66..ef137277 100644 --- a/test/Generator/ClassGeneratorTest.php +++ b/test/Generator/ClassGeneratorTest.php @@ -630,7 +630,7 @@ public function testCanAddConstantsWithArrayOfKeyValues() $classGenerator = new ClassGenerator(); $classGenerator->addConstants([ - [ 'name'=> 'x', 'value' => 'value1'], + [ 'name' => 'x', 'value' => 'value1'], ['name' => 'y', 'value' => 'value2'] ]); diff --git a/test/Generator/FileGeneratorTest.php b/test/Generator/FileGeneratorTest.php index eb31c074..9e4d11c0 100644 --- a/test/Generator/FileGeneratorTest.php +++ b/test/Generator/FileGeneratorTest.php @@ -163,7 +163,7 @@ public function testFileLineEndingsAreAlwaysLineFeed() $targetLength = strlen('require_once \'SampleClass.php\';'); self::assertEquals($targetLength, strlen($lines[2])); - self::assertEquals(';', $lines[2]{$targetLength-1}); + self::assertEquals(';', $lines[2]{$targetLength - 1}); } /** diff --git a/test/Reflection/PropertyReflectionTest.php b/test/Reflection/PropertyReflectionTest.php index b8647a72..8ef42c0f 100644 --- a/test/Reflection/PropertyReflectionTest.php +++ b/test/Reflection/PropertyReflectionTest.php @@ -44,7 +44,7 @@ public function testAnnotationScanningIsPossible() self::assertTrue($annotations->hasAnnotation(TestAsset\SampleAnnotation::class)); $found = false; foreach ($annotations as $key => $annotation) { - if (!$annotation instanceof TestAsset\SampleAnnotation) { + if (! $annotation instanceof TestAsset\SampleAnnotation) { continue; } self::assertEquals(get_class($annotation) . ': {"foo":"bar"}', $annotation->content);