diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 8f4dd5aa..00000000 --- a/.php_cs +++ /dev/null @@ -1,45 +0,0 @@ -in('src') - ->in('test') - ->notPath('TestAsset') - ->notPath('_files') - ->filter(function (SplFileInfo $file) { - if (strstr($file->getPath(), 'compatibility')) { - return false; - } - }); -$config = Symfony\CS\Config\Config::create(); -$config->level(null); -$config->fixers( - array( - 'braces', - 'duplicate_semicolon', - 'elseif', - 'empty_return', - 'encoding', - 'eof_ending', - 'function_call_space', - 'function_declaration', - 'indentation', - 'join_function', - 'line_after_namespace', - 'linefeed', - 'lowercase_keywords', - 'parenthesis', - 'multiple_use', - 'method_argument_space', - 'object_operator', - 'php_closing_tag', - 'remove_lines_between_uses', - 'short_array_syntax', - 'short_tag', - 'standardize_not_equal', - 'trailing_spaces', - 'unused_use', - 'visibility', - 'whitespacy_lines', - ) -); -$config->finder($finder); -return $config; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6a0e8efa..9ed8265c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,24 +77,24 @@ To do so: ## Running Coding Standards Checks -This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding +This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding standards checks, and provides configuration for our selected checks. -`php-cs-fixer` is installed by default via Composer. +`phpcs` is installed by default via Composer. To run 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: +`phpcs` also includes a tool for fixing most CS violations, `phpcbf`: + ```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 you allow `phpcbf` to fix 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 diff --git a/composer.json b/composer.json index 67c2c1e2..3ad6488c 100644 --- a/composer.json +++ b/composer.json @@ -36,8 +36,8 @@ "zendframework/zend-validator": "^2.6", "zendframework/zend-view": "^2.6.2", "zendframework/zendservice-recaptcha": "*", - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^4.8", + "zendframework/zend-coding-standard": "~1.0.0" }, "suggest": { "zendframework/zend-captcha": "^2.5.4, required for using CAPTCHA form elements", @@ -73,10 +73,10 @@ "@cs-check", "@test" ], - "upload-coverage": "coveralls -v", - "cs-check": "php-cs-fixer --version && php-cs-fixer fix -v --diff --dry-run", - "cs-fix": "php-cs-fixer fix -v", - "test": "phpunit", - "test-coverage": "phpunit --coverage-clover clover.xml" + "cs-check": "phpcs", + "cs-fix": "phpcbf", + "test": "phpunit --colors=always", + "test-coverage": "phpunit --colors=always --coverage-clover clover.xml", + "upload-coverage": "coveralls -v" } } diff --git a/composer.lock b/composer.lock index 1cec71ba..43571ff0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "bf7dc15eaa3eef472f2e2165750bbe7f", - "content-hash": "79b70447a4004b563e0370adef36c323", + "hash": "3a1a84745f82e9a8707808d082a0051d", + "content-hash": "8afc23a9480960badf7e3a0885fff1f3", "packages": [ { "name": "container-interop/container-interop", @@ -505,61 +505,6 @@ ], "time": "2014-09-09 13:34:57" }, - { - "name": "fabpot/php-cs-fixer", - "version": "v1.7.1", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "8785276c44a36ca5235a3b6133e3ffbe989ee431" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/8785276c44a36ca5235a3b6133e3ffbe989ee431", - "reference": "8785276c44a36ca5235a3b6133e3ffbe989ee431", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.6", - "sebastian/diff": "~1.1", - "symfony/console": "~2.3", - "symfony/event-dispatcher": "~2.1", - "symfony/filesystem": "~2.1", - "symfony/finder": "~2.1", - "symfony/process": "~2.3", - "symfony/stopwatch": "~2.5" - }, - "require-dev": { - "satooshi/php-coveralls": "0.7.*@dev" - }, - "bin": [ - "php-cs-fixer" - ], - "type": "application", - "autoload": { - "psr-4": { - "Symfony\\CS\\": "Symfony/CS/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "A script to automatically fix Symfony Coding Standard", - "abandoned": "friendsofphp/php-cs-fixer", - "time": "2015-05-04 16:56:09" - }, { "name": "paragonie/random_compat", "version": "v2.0.2", @@ -1560,379 +1505,82 @@ "time": "2015-06-21 13:59:46" }, { - "name": "symfony/console", - "version": "v2.8.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "5ac8bc9aa77bb2edf06af3a1bb6bc1020d23acd3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5ac8bc9aa77bb2edf06af3a1bb6bc1020d23acd3", - "reference": "5ac8bc9aa77bb2edf06af3a1bb6bc1020d23acd3", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/process": "~2.1|~3.0.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2016-06-06 15:06:25" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.8.7", + "name": "squizlabs/php_codesniffer", + "version": "2.7.0", "source": { "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "2a6b8713f8bdb582058cfda463527f195b066110" + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "571e27b6348e5b3a637b2abc82ac0d01e6d7bbed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/2a6b8713f8bdb582058cfda463527f195b066110", - "reference": "2a6b8713f8bdb582058cfda463527f195b066110", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/571e27b6348e5b3a637b2abc82ac0d01e6d7bbed", + "reference": "571e27b6348e5b3a637b2abc82ac0d01e6d7bbed", "shasum": "" }, "require": { - "php": ">=5.3.9" + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.1.2" }, "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5|~3.0.0", - "symfony/dependency-injection": "~2.6|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/stopwatch": "~2.3|~3.0.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2016-06-06 11:11:27" - }, - { - "name": "symfony/filesystem", - "version": "v2.8.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "dee379131dceed90a429e951546b33edfe7dccbb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/dee379131dceed90a429e951546b33edfe7dccbb", - "reference": "dee379131dceed90a429e951546b33edfe7dccbb", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2016-04-12 18:01:21" - }, - { - "name": "symfony/finder", - "version": "v2.8.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "3ec095fab1800222732ca522a95dce8fa124007b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/3ec095fab1800222732ca522a95dce8fa124007b", - "reference": "3ec095fab1800222732ca522a95dce8fa124007b", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "phpunit/phpunit": "~4.0" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } + "bin": [ + "scripts/phpcs", + "scripts/phpcbf" ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2016-06-06 11:11:27" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "2.x-dev" } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" + "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": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Greg Sherwood", + "role": "lead" } ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" + "phpcs", + "standards" ], - "time": "2016-05-18 14:26:46" - }, - { - "name": "symfony/process", - "version": "v2.8.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "115347d00c342198cdc52a7bd8bc15b5ab43500c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/115347d00c342198cdc52a7bd8bc15b5ab43500c", - "reference": "115347d00c342198cdc52a7bd8bc15b5ab43500c", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "https://symfony.com", - "time": "2016-06-06 11:11:27" - }, - { - "name": "symfony/stopwatch", - "version": "v2.8.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/stopwatch.git", - "reference": "5e628055488bcc42dbace3af65be435d094e37e4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/5e628055488bcc42dbace3af65be435d094e37e4", - "reference": "5e628055488bcc42dbace3af65be435d094e37e4", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Stopwatch Component", - "homepage": "https://symfony.com", - "time": "2016-06-06 11:11:27" + "time": "2016-09-01 23:53:02" }, { "name": "symfony/yaml", @@ -2211,6 +1859,35 @@ ], "time": "2016-04-20 17:34:49" }, + { + "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-09 21:30:43" + }, { "name": "zendframework/zend-escaper", "version": "2.5.1", diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 00000000..561c28e4 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,8 @@ + + + + + + src + test + \ No newline at end of file diff --git a/src/Annotation/AbstractAnnotationsListener.php b/src/Annotation/AbstractAnnotationsListener.php index acdae220..8f945b7c 100644 --- a/src/Annotation/AbstractAnnotationsListener.php +++ b/src/Annotation/AbstractAnnotationsListener.php @@ -34,12 +34,12 @@ public function handleNameAnnotation($e) { $annotations = $e->getParam('annotations'); - if (!$annotations->hasAnnotation('Zend\Form\Annotation\Name')) { + if (! $annotations->hasAnnotation('Zend\Form\Annotation\Name')) { return false; } foreach ($annotations as $annotation) { - if (!$annotation instanceof Name) { + if (! $annotation instanceof Name) { continue; } return $annotation->getName(); diff --git a/src/Annotation/AbstractArrayAnnotation.php b/src/Annotation/AbstractArrayAnnotation.php index 87c28971..cf6f6f28 100644 --- a/src/Annotation/AbstractArrayAnnotation.php +++ b/src/Annotation/AbstractArrayAnnotation.php @@ -26,7 +26,7 @@ abstract class AbstractArrayAnnotation */ public function __construct(array $data) { - if (!isset($data['value']) || !is_array($data['value'])) { + if (! isset($data['value']) || ! is_array($data['value'])) { throw new Exception\DomainException(sprintf( '%s expects the annotation to define an array; received "%s"', get_class($this), diff --git a/src/Annotation/AbstractArrayOrStringAnnotation.php b/src/Annotation/AbstractArrayOrStringAnnotation.php index 221f57be..5af5d4e9 100644 --- a/src/Annotation/AbstractArrayOrStringAnnotation.php +++ b/src/Annotation/AbstractArrayOrStringAnnotation.php @@ -26,7 +26,7 @@ abstract class AbstractArrayOrStringAnnotation */ public function __construct(array $data) { - if (!isset($data['value']) || (!is_array($data['value']) && !is_string($data['value']))) { + if (! isset($data['value']) || (! is_array($data['value']) && ! is_string($data['value']))) { throw new Exception\DomainException(sprintf( '%s expects the annotation to define an array or string; received "%s"', get_class($this), diff --git a/src/Annotation/AbstractStringAnnotation.php b/src/Annotation/AbstractStringAnnotation.php index b8e8c897..bc60612e 100644 --- a/src/Annotation/AbstractStringAnnotation.php +++ b/src/Annotation/AbstractStringAnnotation.php @@ -26,7 +26,7 @@ abstract class AbstractStringAnnotation */ public function __construct(array $data) { - if (!isset($data['value']) || !is_string($data['value'])) { + if (! isset($data['value']) || ! is_string($data['value'])) { throw new Exception\DomainException(sprintf( '%s expects the annotation to define a string; received "%s"', get_class($this), diff --git a/src/Annotation/AllowEmpty.php b/src/Annotation/AllowEmpty.php index be58287c..71a235e0 100644 --- a/src/Annotation/AllowEmpty.php +++ b/src/Annotation/AllowEmpty.php @@ -34,13 +34,13 @@ class AllowEmpty */ public function __construct(array $data) { - if (!isset($data['value'])) { + if (! isset($data['value'])) { $data['value'] = false; } $allowEmpty = $data['value']; - if (!is_bool($allowEmpty)) { + if (! is_bool($allowEmpty)) { $filter = new BooleanFilter(); $allowEmpty = $filter->filter($allowEmpty); } diff --git a/src/Annotation/AnnotationBuilder.php b/src/Annotation/AnnotationBuilder.php index b339a32f..8ee32a46 100644 --- a/src/Annotation/AnnotationBuilder.php +++ b/src/Annotation/AnnotationBuilder.php @@ -192,9 +192,9 @@ public function getEventManager() */ public function getFormSpecification($entity) { - if (!is_object($entity)) { - if ((is_string($entity) && (!class_exists($entity))) // non-existent class - || (!is_string($entity)) // not an object or string + if (! is_object($entity)) { + if ((is_string($entity) && (! class_exists($entity))) // non-existent class + || (! is_string($entity)) // not an object or string ) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an object or valid class name; received "%s"', @@ -224,7 +224,7 @@ public function getFormSpecification($entity) } } - if (!isset($formSpec['input_filter'])) { + if (! isset($formSpec['input_filter'])) { $formSpec['input_filter'] = $filterSpec; } elseif (is_array($formSpec['input_filter'])) { $formSpec['input_filter'] = ArrayUtils::merge($filterSpec->getArrayCopy(), $formSpec['input_filter']); @@ -348,13 +348,13 @@ protected function configureElement($annotations, $reflection, $formSpec, $filte // Compose as a fieldset or an element, based on specification type. // If preserve defined order is true, all elements are composed as elements to keep their ordering - if (!$this->preserveDefinedOrder() && is_subclass_of($type, 'Zend\Form\FieldsetInterface')) { - if (!isset($formSpec['fieldsets'])) { + if (! $this->preserveDefinedOrder() && is_subclass_of($type, 'Zend\Form\FieldsetInterface')) { + if (! isset($formSpec['fieldsets'])) { $formSpec['fieldsets'] = []; } $formSpec['fieldsets'][] = $elementSpec; } else { - if (!isset($formSpec['elements'])) { + if (! isset($formSpec['elements'])) { $formSpec['elements'] = []; } $formSpec['elements'][] = $elementSpec; @@ -398,7 +398,7 @@ protected function discoverName($annotations, $reflection) $results = $this->getEventManager()->triggerEventUntil( function ($r) { - return (is_string($r) && !empty($r)); + return (is_string($r) && ! empty($r)); }, $event ); diff --git a/src/Annotation/ElementAnnotationsListener.php b/src/Annotation/ElementAnnotationsListener.php index a66aa094..7e9b5057 100644 --- a/src/Annotation/ElementAnnotationsListener.php +++ b/src/Annotation/ElementAnnotationsListener.php @@ -73,7 +73,7 @@ public function attach(EventManagerInterface $events, $priority = 1) public function handleAllowEmptyAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof AllowEmpty) { + if (! $annotation instanceof AllowEmpty) { return; } @@ -92,7 +92,7 @@ public function handleAllowEmptyAnnotation($e) public function handleAttributesAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Attributes) { + if (! $annotation instanceof Attributes) { return; } @@ -117,7 +117,7 @@ public function handleAttributesAnnotation($e) public function handleComposedObjectAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof ComposedObject) { + if (! $annotation instanceof ComposedObject) { return; } @@ -130,7 +130,7 @@ public function handleComposedObjectAnnotation($e) if ($annotation->isCollection()) { // Compose specification as a fieldset into parent form/fieldset - if (!isset($specification['type'])) { + if (! isset($specification['type'])) { //use input filter provider fieldset so we can compose the input filter into the fieldset //it is assumed that if someone uses a custom fieldset, they will take care of the input //filtering themselves or consume the input_filter_spec option. @@ -138,7 +138,7 @@ public function handleComposedObjectAnnotation($e) } $inputFilter = $specification['input_filter']; - if (!isset($inputFilter['type'])) { + if (! isset($inputFilter['type'])) { $inputFilter['type'] = 'Zend\InputFilter\InputFilter'; } unset($specification['input_filter']); @@ -155,14 +155,14 @@ public function handleComposedObjectAnnotation($e) } else { // Compose input filter into parent input filter $inputFilter = $specification['input_filter']; - if (!isset($inputFilter['type'])) { + if (! isset($inputFilter['type'])) { $inputFilter['type'] = 'Zend\InputFilter\InputFilter'; } $e->setParam('inputSpec', $inputFilter); unset($specification['input_filter']); // Compose specification as a fieldset into parent form/fieldset - if (!isset($specification['type'])) { + if (! isset($specification['type'])) { $specification['type'] = 'Zend\Form\Fieldset'; } @@ -189,7 +189,7 @@ public function handleComposedObjectAnnotation($e) public function handleContinueIfEmptyAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof ContinueIfEmpty) { + if (! $annotation instanceof ContinueIfEmpty) { return; } @@ -208,7 +208,7 @@ public function handleContinueIfEmptyAnnotation($e) public function handleErrorMessageAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof ErrorMessage) { + if (! $annotation instanceof ErrorMessage) { return; } @@ -242,12 +242,12 @@ public function handleExcludeAnnotation($e) public function handleFilterAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Filter) { + if (! $annotation instanceof Filter) { return; } $inputSpec = $e->getParam('inputSpec'); - if (!isset($inputSpec['filters'])) { + if (! isset($inputSpec['filters'])) { $inputSpec['filters'] = []; } $inputSpec['filters'][] = $annotation->getFilter(); @@ -265,7 +265,7 @@ public function handleFilterAnnotation($e) public function handleFlagsAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Flags) { + if (! $annotation instanceof Flags) { return; } @@ -284,7 +284,7 @@ public function handleFlagsAnnotation($e) public function handleHydratorAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Hydrator) { + if (! $annotation instanceof Hydrator) { return; } @@ -304,7 +304,7 @@ public function handleHydratorAnnotation($e) public function handleInputAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Input) { + if (! $annotation instanceof Input) { return; } @@ -344,7 +344,7 @@ public function handleObjectAnnotation($e) public function handleOptionsAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Options) { + if (! $annotation instanceof Options) { return; } @@ -363,7 +363,7 @@ public function handleOptionsAnnotation($e) public function handleRequiredAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Required) { + if (! $annotation instanceof Required) { return; } @@ -373,7 +373,7 @@ public function handleRequiredAnnotation($e) if ($required) { $elementSpec = $e->getParam('elementSpec'); - if (!isset($elementSpec['spec']['attributes'])) { + if (! isset($elementSpec['spec']['attributes'])) { $elementSpec['spec']['attributes'] = []; } @@ -392,7 +392,7 @@ public function handleRequiredAnnotation($e) public function handleTypeAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Type) { + if (! $annotation instanceof Type) { return; } @@ -411,12 +411,12 @@ public function handleTypeAnnotation($e) public function handleValidatorAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Validator) { + if (! $annotation instanceof Validator) { return; } $inputSpec = $e->getParam('inputSpec'); - if (!isset($inputSpec['validators'])) { + if (! isset($inputSpec['validators'])) { $inputSpec['validators'] = []; } $inputSpec['validators'][] = $annotation->getValidator(); diff --git a/src/Annotation/FormAnnotationsListener.php b/src/Annotation/FormAnnotationsListener.php index 832f71b6..9e702169 100644 --- a/src/Annotation/FormAnnotationsListener.php +++ b/src/Annotation/FormAnnotationsListener.php @@ -63,7 +63,7 @@ public function attach(EventManagerInterface $events, $priority = 1) public function handleAttributesAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Attributes) { + if (! $annotation instanceof Attributes) { return; } @@ -82,7 +82,7 @@ public function handleAttributesAnnotation($e) public function handleFlagsAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Flags) { + if (! $annotation instanceof Flags) { return; } @@ -101,7 +101,7 @@ public function handleFlagsAnnotation($e) public function handleHydratorAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Hydrator) { + if (! $annotation instanceof Hydrator) { return; } @@ -120,7 +120,7 @@ public function handleHydratorAnnotation($e) public function handleInputFilterAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof InputFilter) { + if (! $annotation instanceof InputFilter) { return; } @@ -160,7 +160,7 @@ public function handleObjectAnnotation($e) public function handleOptionsAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Options) { + if (! $annotation instanceof Options) { return; } @@ -179,7 +179,7 @@ public function handleOptionsAnnotation($e) public function handleTypeAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof Type) { + if (! $annotation instanceof Type) { return; } @@ -198,7 +198,7 @@ public function handleTypeAnnotation($e) public function handleValidationGroupAnnotation($e) { $annotation = $e->getParam('annotation'); - if (!$annotation instanceof ValidationGroup) { + if (! $annotation instanceof ValidationGroup) { return; } diff --git a/src/Annotation/Required.php b/src/Annotation/Required.php index b3f1fe9e..a59f6b6a 100644 --- a/src/Annotation/Required.php +++ b/src/Annotation/Required.php @@ -35,13 +35,13 @@ class Required */ public function __construct(array $data) { - if (!isset($data['value'])) { + if (! isset($data['value'])) { $data['value'] = false; } $required = $data['value']; - if (!is_bool($required)) { + if (! is_bool($required)) { $filter = new BooleanFilter(); $required = $filter->filter($required); } diff --git a/src/Element.php b/src/Element.php index 1aa95ffd..22112ea0 100644 --- a/src/Element.php +++ b/src/Element.php @@ -67,7 +67,7 @@ public function __construct($name = null, $options = []) $this->setName($name); } - if (!empty($options)) { + if (! empty($options)) { $this->setOptions($options); } } @@ -118,7 +118,7 @@ public function setOptions($options) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); - } elseif (!is_array($options)) { + } elseif (! is_array($options)) { throw new Exception\InvalidArgumentException( 'The options parameter must be an array or a Traversable' ); @@ -159,7 +159,7 @@ public function getOptions() */ public function getOption($option) { - if (!isset($this->options[$option])) { + if (! isset($this->options[$option])) { return; } @@ -205,7 +205,7 @@ public function setAttribute($key, $value) */ public function getAttribute($key) { - if (!isset($this->attributes[$key])) { + if (! isset($this->attributes[$key])) { return; } @@ -246,7 +246,7 @@ public function hasAttribute($key) */ public function setAttributes($arrayOrTraversable) { - if (!is_array($arrayOrTraversable) && !$arrayOrTraversable instanceof Traversable) { + if (! is_array($arrayOrTraversable) && ! $arrayOrTraversable instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable argument; received "%s"', __METHOD__, @@ -375,7 +375,7 @@ public function getLabelAttributes() */ public function setLabelOptions($arrayOrTraversable) { - if (!is_array($arrayOrTraversable) && !$arrayOrTraversable instanceof Traversable) { + if (! is_array($arrayOrTraversable) && ! $arrayOrTraversable instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable argument; received "%s"', __METHOD__, @@ -445,7 +445,7 @@ public function setLabelOption($key, $value) */ public function getLabelOption($key) { - if (!isset($this->labelOptions[$key])) { + if (! isset($this->labelOptions[$key])) { return; } @@ -484,7 +484,7 @@ public function hasLabelOption($key) */ public function setMessages($messages) { - if (!is_array($messages) && !$messages instanceof Traversable) { + if (! is_array($messages) && ! $messages instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable object of validation error messages; received "%s"', __METHOD__, diff --git a/src/Element/Captcha.php b/src/Element/Captcha.php index c458d5f8..30935ba0 100644 --- a/src/Element/Captcha.php +++ b/src/Element/Captcha.php @@ -51,9 +51,10 @@ public function setCaptcha($captcha) { if (is_array($captcha) || $captcha instanceof Traversable) { $captcha = ZendCaptcha\Factory::factory($captcha); - } elseif (!$captcha instanceof ZendCaptcha\AdapterInterface) { + } elseif (! $captcha instanceof ZendCaptcha\AdapterInterface) { throw new Exception\InvalidArgumentException(sprintf( - '%s expects either a Zend\Captcha\AdapterInterface or specification to pass to Zend\Captcha\Factory; received "%s"', + '%s expects either a Zend\Captcha\AdapterInterface or specification to pass to Zend\Captcha\Factory; ' + . 'received "%s"', __METHOD__, (is_object($captcha) ? get_class($captcha) : gettype($captcha)) )); diff --git a/src/Element/Collection.php b/src/Element/Collection.php index fbb793ed..108af222 100644 --- a/src/Element/Collection.php +++ b/src/Element/Collection.php @@ -163,7 +163,7 @@ public function allowObjectBinding($object) */ public function setObject($object) { - if (!is_array($object) && !$object instanceof Traversable) { + if (! is_array($object) && ! $object instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable object argument; received "%s"', __METHOD__, @@ -187,7 +187,7 @@ public function setObject($object) */ public function populateValues($data) { - if (!is_array($data) && !$data instanceof Traversable) { + if (! is_array($data) && ! $data instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable set of data; received "%s"', __METHOD__, @@ -195,7 +195,7 @@ public function populateValues($data) )); } - if (!$this->allowRemove && count($data) < $this->count) { + if (! $this->allowRemove && count($data) < $this->count) { throw new Exception\DomainException(sprintf( 'There are fewer elements than specified in the collection (%s). Either set the allow_remove option ' . 'to true, or re-submit the form.', @@ -210,7 +210,7 @@ public function populateValues($data) continue; } - if (!$this->allowRemove) { + if (! $this->allowRemove) { throw new Exception\DomainException(sprintf( 'Elements have been removed from the collection (%s) but the allow_remove option is not true.', get_class($this) @@ -242,7 +242,7 @@ public function populateValues($data) } } - if (!$this->createNewObjects()) { + if (! $this->createNewObjects()) { $this->replaceTemplateObjects(); } } @@ -313,13 +313,13 @@ public function getCount() public function setTargetElement($elementOrFieldset) { if (is_array($elementOrFieldset) - || ($elementOrFieldset instanceof Traversable && !$elementOrFieldset instanceof ElementInterface) + || ($elementOrFieldset instanceof Traversable && ! $elementOrFieldset instanceof ElementInterface) ) { $factory = $this->getFormFactory(); $elementOrFieldset = $factory->create($elementOrFieldset); } - if (!$elementOrFieldset instanceof ElementInterface) { + if (! $elementOrFieldset instanceof ElementInterface) { throw new Exception\InvalidArgumentException(sprintf( '%s requires that $elementOrFieldset be an object implementing %s; received "%s"', __METHOD__, @@ -508,7 +508,7 @@ public function extract() $this->object = ArrayUtils::iteratorToArray($this->object, false); } - if (!is_array($this->object)) { + if (! is_array($this->object)) { return []; } @@ -530,7 +530,7 @@ public function extract() $targetElement = clone $this->targetElement; $targetElement->setObject($value); $values[$key] = $targetElement->extract(); - if (!$this->createNewObjects() && $this->has($key)) { + if (! $this->createNewObjects() && $this->has($key)) { $this->get($key)->setObject($value); } continue; @@ -539,7 +539,7 @@ public function extract() // If the target element is a non-fieldset element, just use the value if ($this->targetElement instanceof ElementInterface) { $values[$key] = $value; - if (!$this->createNewObjects() && $this->has($key)) { + if (! $this->createNewObjects() && $this->has($key)) { $this->get($key)->setValue($value); } continue; @@ -575,7 +575,7 @@ protected function addNewTargetElementInstance($name) $this->add($elementOrFieldset); - if (!$this->allowAdd && $this->count() > $this->count) { + if (! $this->allowAdd && $this->count() > $this->count) { throw new Exception\DomainException(sprintf( 'There are more elements than specified in the collection (%s). Either set the allow_add option ' . 'to true, or re-submit the form.', @@ -593,7 +593,7 @@ protected function addNewTargetElementInstance($name) */ protected function createTemplateElement() { - if (!$this->shouldCreateTemplate) { + if (! $this->shouldCreateTemplate) { return; } @@ -617,7 +617,7 @@ protected function replaceTemplateObjects() { $fieldsets = $this->getFieldsets(); - if (!count($fieldsets) || !$this->object) { + if (! count($fieldsets) || ! $this->object) { return; } diff --git a/src/Element/DateTime.php b/src/Element/DateTime.php index 8be075a8..e2805936 100644 --- a/src/Element/DateTime.php +++ b/src/Element/DateTime.php @@ -77,7 +77,7 @@ public function setOptions($options) public function getValue($returnFormattedValue = true) { $value = parent::getValue(); - if (!$value instanceof PhpDateTime || !$returnFormattedValue) { + if (! $value instanceof PhpDateTime || ! $returnFormattedValue) { return $value; } $format = $this->getFormat(); @@ -132,7 +132,7 @@ protected function getValidators() 'inclusive' => true, ]); } - if (!isset($this->attributes['step']) + if (! isset($this->attributes['step']) || 'any' !== $this->attributes['step'] ) { $validators[] = $this->getStepValidator(); diff --git a/src/Element/MultiCheckbox.php b/src/Element/MultiCheckbox.php index d8b7c05b..805f4bc1 100644 --- a/src/Element/MultiCheckbox.php +++ b/src/Element/MultiCheckbox.php @@ -159,7 +159,7 @@ public function disableInArrayValidator() */ protected function getValidator() { - if (null === $this->validator && !$this->disableInArrayValidator()) { + if (null === $this->validator && ! $this->disableInArrayValidator()) { $inArrayValidator = new InArrayValidator([ 'haystack' => $this->getValueOptionsValues(), 'strict' => false, diff --git a/src/Element/Number.php b/src/Element/Number.php index 5db3980e..e3e1191f 100644 --- a/src/Element/Number.php +++ b/src/Element/Number.php @@ -68,11 +68,11 @@ protected function getValidators() ]); } - if (!isset($this->attributes['step']) + if (! isset($this->attributes['step']) || 'any' !== $this->attributes['step'] ) { $validators[] = new StepValidator([ - 'baseValue' => (isset($this->attributes['min'])) ? $this->attributes['min'] : 0, + 'baseValue' => (isset($this->attributes['min'])) ? $this->attributes['min'] : 0, 'step' => (isset($this->attributes['step'])) ? $this->attributes['step'] : 1, ]); } diff --git a/src/Element/Radio.php b/src/Element/Radio.php index aba940c7..1c79e38f 100644 --- a/src/Element/Radio.php +++ b/src/Element/Radio.php @@ -29,7 +29,7 @@ class Radio extends MultiCheckbox */ protected function getValidator() { - if (null === $this->validator && !$this->disableInArrayValidator()) { + if (null === $this->validator && ! $this->disableInArrayValidator()) { $this->validator = new InArrayValidator([ 'haystack' => $this->getValueOptionsValues(), 'strict' => false, diff --git a/src/Element/Range.php b/src/Element/Range.php index 0c3c4653..812b5aff 100644 --- a/src/Element/Range.php +++ b/src/Element/Range.php @@ -41,7 +41,7 @@ protected function getValidators() $validators[] = new NumberValidator(); $inclusive = true; - if (!empty($this->attributes['inclusive'])) { + if (! empty($this->attributes['inclusive'])) { $inclusive = $this->attributes['inclusive']; } @@ -55,7 +55,7 @@ protected function getValidators() 'inclusive' => $inclusive ]); - if (!isset($this->attributes['step']) + if (! isset($this->attributes['step']) || 'any' !== $this->attributes['step'] ) { $validators[] = new StepValidator([ diff --git a/src/Element/Select.php b/src/Element/Select.php index 25dcd5f6..9b6b447c 100644 --- a/src/Element/Select.php +++ b/src/Element/Select.php @@ -86,7 +86,7 @@ public function setValueOptions(array $options) ) { $validator = $this->validator->getValidator(); } - if (!empty($validator)) { + if (! empty($validator)) { $validator->setHaystack($this->getValueOptionsValues()); } } @@ -218,7 +218,7 @@ public function getEmptyOption() */ protected function getValidator() { - if (null === $this->validator && !$this->disableInArrayValidator()) { + if (null === $this->validator && ! $this->disableInArrayValidator()) { $validator = new InArrayValidator([ 'haystack' => $this->getValueOptionsValues(), 'strict' => false diff --git a/src/ElementFactory.php b/src/ElementFactory.php index bfd6dd76..eb9c633c 100644 --- a/src/ElementFactory.php +++ b/src/ElementFactory.php @@ -106,7 +106,8 @@ public function createService(ServiceLocatorInterface $serviceLocator, $canonica } throw new InvalidServiceException(sprintf( - '%s requires that the requested name is provided on invocation; please update your tests or consuming container', + '%s requires that the requested name is provided on invocation; please update your tests or ' + . 'consuming container', __CLASS__ )); } diff --git a/src/Factory.php b/src/Factory.php index 439ecafc..593bd509 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -140,7 +140,7 @@ public function create($spec) */ public function createElement($spec) { - if (!isset($spec['type'])) { + if (! isset($spec['type'])) { $spec['type'] = Element::class; } @@ -155,7 +155,7 @@ public function createElement($spec) */ public function createFieldset($spec) { - if (!isset($spec['type'])) { + if (! isset($spec['type'])) { $spec['type'] = Fieldset::class; } @@ -170,7 +170,7 @@ public function createFieldset($spec) */ public function createForm($spec) { - if (!isset($spec['type'])) { + if (! isset($spec['type'])) { $spec['type'] = Form::class; } @@ -196,8 +196,8 @@ public function configureElement(ElementInterface $element, $spec) { $spec = $this->validateSpecification($spec, __METHOD__); - $name = isset($spec['name']) ? $spec['name'] : null; - $options = isset($spec['options']) ? $spec['options'] : null; + $name = isset($spec['name']) ? $spec['name'] : null; + $options = isset($spec['options']) ? $spec['options'] : null; $attributes = isset($spec['attributes']) ? $spec['attributes'] : null; if ($name !== null && $name !== '') { @@ -312,7 +312,7 @@ protected function validateSpecification($spec, $method) return $spec; } - if (!$spec instanceof ArrayAccess) { + if (! $spec instanceof ArrayAccess) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array, or object implementing Traversable or ArrayAccess; received "%s"', $method, @@ -341,9 +341,9 @@ protected function prepareAndInjectElements($elements, FieldsetInterface $fields } $flags = isset($elementSpecification['flags']) ? $elementSpecification['flags'] : []; - $spec = isset($elementSpecification['spec']) ? $elementSpecification['spec'] : []; + $spec = isset($elementSpecification['spec']) ? $elementSpecification['spec'] : []; - if (!isset($spec['type'])) { + if (! isset($spec['type'])) { $spec['type'] = 'Zend\Form\Element'; } @@ -366,7 +366,7 @@ public function prepareAndInjectFieldsets($fieldsets, FieldsetInterface $masterF foreach ($fieldsets as $fieldsetSpecification) { $flags = isset($fieldsetSpecification['flags']) ? $fieldsetSpecification['flags'] : []; - $spec = isset($fieldsetSpecification['spec']) ? $fieldsetSpecification['spec'] : []; + $spec = isset($fieldsetSpecification['spec']) ? $fieldsetSpecification['spec'] : []; $fieldset = $this->createFieldset($spec); $masterFieldset->add($fieldset, $flags); @@ -387,7 +387,7 @@ public function prepareAndInjectFieldsets($fieldsets, FieldsetInterface $masterF */ protected function prepareAndInjectObject($objectName, FieldsetInterface $fieldset, $method) { - if (!is_string($objectName)) { + if (! is_string($objectName)) { throw new Exception\DomainException(sprintf( '%s expects string class name; received "%s"', $method, @@ -395,7 +395,7 @@ protected function prepareAndInjectObject($objectName, FieldsetInterface $fields )); } - if (!class_exists($objectName)) { + if (! class_exists($objectName)) { throw new Exception\DomainException(sprintf( '%s expects string class name to be a valid class name; received "%s"', $method, @@ -427,7 +427,7 @@ protected function prepareAndInjectHydrator($hydratorOrName, FieldsetInterface $ } if (is_array($hydratorOrName)) { - if (!isset($hydratorOrName['type'])) { + if (! isset($hydratorOrName['type'])) { throw new Exception\DomainException(sprintf( '%s expects array specification to have a type value', $method @@ -443,7 +443,7 @@ protected function prepareAndInjectHydrator($hydratorOrName, FieldsetInterface $ $hydrator = $this->getFormElementManager()->getHydratorFromName($hydratorOrName); } - if (! isset($hydrator) || !$hydrator instanceof Hydrator\HydratorInterface) { + if (! isset($hydrator) || ! $hydrator instanceof Hydrator\HydratorInterface) { throw new Exception\DomainException(sprintf( '%s expects a valid implementation of Zend\Hydrator\HydratorInterface; received "%s"', $method, @@ -451,7 +451,7 @@ protected function prepareAndInjectHydrator($hydratorOrName, FieldsetInterface $ )); } - if (!empty($hydratorOptions) && $hydrator instanceof Hydrator\HydratorOptionsInterface) { + if (! empty($hydratorOptions) && $hydrator instanceof Hydrator\HydratorOptionsInterface) { $hydrator->setOptions($hydratorOptions); } @@ -474,7 +474,7 @@ protected function prepareAndInjectHydrator($hydratorOrName, FieldsetInterface $ protected function prepareAndInjectFactory($factoryOrName, FieldsetInterface $fieldset, $method) { if (is_array($factoryOrName)) { - if (!isset($factoryOrName['type'])) { + if (! isset($factoryOrName['type'])) { throw new Exception\DomainException(sprintf( '%s expects array specification to have a type value', $method @@ -487,7 +487,7 @@ protected function prepareAndInjectFactory($factoryOrName, FieldsetInterface $fi $factoryOrName = $this->getFormElementManager()->getFactoryFromName($factoryOrName); } - if (!$factoryOrName instanceof Factory) { + if (! $factoryOrName instanceof Factory) { throw new Exception\DomainException(sprintf( '%s expects a valid extention of Zend\Form\Factory; received "%s"', $method, @@ -522,7 +522,7 @@ protected function prepareAndInjectInputFilter($spec, FormInterface $form, $meth } if (is_string($spec)) { - if (!class_exists($spec)) { + if (! class_exists($spec)) { throw new Exception\DomainException(sprintf( '%s expects string input filter names to be valid class names; received "%s"', $method, @@ -530,7 +530,7 @@ protected function prepareAndInjectInputFilter($spec, FormInterface $form, $meth )); } $filter = new $spec; - if (!$filter instanceof InputFilterInterface) { + if (! $filter instanceof InputFilterInterface) { throw new Exception\DomainException(sprintf( '%s expects a valid implementation of Zend\InputFilter\InputFilterInterface; received "%s"', $method, @@ -562,8 +562,8 @@ protected function prepareAndInjectInputFilter($spec, FormInterface $form, $meth */ protected function prepareAndInjectValidationGroup($spec, FormInterface $form, $method) { - if (!is_array($spec)) { - if (!class_exists($spec)) { + if (! is_array($spec)) { + if (! class_exists($spec)) { throw new Exception\DomainException(sprintf( '%s expects an array for validation group; received "%s"', $method, diff --git a/src/Fieldset.php b/src/Fieldset.php index 409d878d..cf6b4b40 100644 --- a/src/Fieldset.php +++ b/src/Fieldset.php @@ -149,13 +149,13 @@ public function getFormFactory() public function add($elementOrFieldset, array $flags = []) { if (is_array($elementOrFieldset) - || ($elementOrFieldset instanceof Traversable && !$elementOrFieldset instanceof ElementInterface) + || ($elementOrFieldset instanceof Traversable && ! $elementOrFieldset instanceof ElementInterface) ) { $factory = $this->getFormFactory(); $elementOrFieldset = $factory->create($elementOrFieldset); } - if (!$elementOrFieldset instanceof ElementInterface) { + if (! $elementOrFieldset instanceof ElementInterface) { throw new Exception\InvalidArgumentException(sprintf( '%s requires that $elementOrFieldset be an object implementing %s; received "%s"', __METHOD__, @@ -166,7 +166,7 @@ public function add($elementOrFieldset, array $flags = []) $name = $elementOrFieldset->getName(); if ((null === $name || '' === $name) - && (!array_key_exists('name', $flags) || $flags['name'] === '') + && (! array_key_exists('name', $flags) || $flags['name'] === '') ) { throw new Exception\InvalidArgumentException(sprintf( '%s: element or fieldset provided is not named, and no name provided in flags', @@ -215,7 +215,7 @@ public function has($elementOrFieldset) */ public function get($elementOrFieldset) { - if (!$this->has($elementOrFieldset)) { + if (! $this->has($elementOrFieldset)) { throw new Exception\InvalidElementException(sprintf( "No element by the name of [%s] found in form", $elementOrFieldset @@ -232,7 +232,7 @@ public function get($elementOrFieldset) */ public function remove($elementOrFieldset) { - if (!$this->has($elementOrFieldset)) { + if (! $this->has($elementOrFieldset)) { return $this; } @@ -293,7 +293,7 @@ public function getFieldsets() */ public function setMessages($messages) { - if (!is_array($messages) && !$messages instanceof Traversable) { + if (! is_array($messages) && ! $messages instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable object of messages; received "%s"', __METHOD__, @@ -302,7 +302,7 @@ public function setMessages($messages) } foreach ($messages as $key => $messageSet) { - if (!$this->has($key)) { + if (! $this->has($key)) { continue; } $element = $this->get($key); @@ -329,8 +329,8 @@ public function getMessages($elementName = null) $messages = []; foreach ($this->iterator as $name => $element) { $messageSet = $element->getMessages(); - if (!is_array($messageSet) - && !$messageSet instanceof Traversable + if (! is_array($messageSet) + && ! $messageSet instanceof Traversable || empty($messageSet)) { continue; } @@ -339,7 +339,7 @@ public function getMessages($elementName = null) return $messages; } - if (!$this->has($elementName)) { + if (! $this->has($elementName)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid element name "%s" provided to %s', $elementName, @@ -381,7 +381,7 @@ public function prepareElement(FormInterface $form) */ public function populateValues($data) { - if (!is_array($data) && !$data instanceof Traversable) { + if (! is_array($data) && ! $data instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable set of data; received "%s"', __METHOD__, @@ -446,7 +446,7 @@ public function getIterator() */ public function setObject($object) { - if (!is_object($object)) { + if (! is_object($object)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an object argument; received "%s"', __METHOD__, @@ -533,7 +533,7 @@ public function setHydrator(HydratorInterface $hydrator) */ public function getHydrator() { - if (!$this->hydrator instanceof HydratorInterface) { + if (! $this->hydrator instanceof HydratorInterface) { if ($this->object instanceof HydratorAwareInterface) { $this->setHydrator($this->object->getHydrator()); } else { @@ -570,12 +570,14 @@ public function bindValues(array $values = [], array $validationGroup = null) foreach ($this->iterator as $element) { $name = $element->getName(); - if ($validationGroup && (!array_key_exists($name, $validationGroup) && !in_array($name, $validationGroup))) { + if ($validationGroup + && (! array_key_exists($name, $validationGroup) && ! in_array($name, $validationGroup)) + ) { continue; } - if (!array_key_exists($name, $values)) { - if (!($element instanceof Collection)) { + if (! array_key_exists($name, $values)) { + if (! ($element instanceof Collection)) { continue; } @@ -589,14 +591,14 @@ public function bindValues(array $values = [], array $validationGroup = null) } // skip post values for disabled elements, get old value from object - if (!$element->getAttribute('disabled')) { + if (! $element->getAttribute('disabled')) { $hydratableData[$name] = $value; } elseif (array_key_exists($name, $objectData)) { $hydratableData[$name] = $objectData[$name]; } } - if (!empty($hydratableData)) { + if (! empty($hydratableData)) { $this->object = $hydrator->hydrate($hydratableData, $this->object); } @@ -632,18 +634,18 @@ public function useAsBaseFieldset() */ protected function extract() { - if (!is_object($this->object)) { + if (! is_object($this->object)) { return []; } $hydrator = $this->getHydrator(); - if (!$hydrator instanceof Hydrator\HydratorInterface) { + if (! $hydrator instanceof Hydrator\HydratorInterface) { return []; } $values = $hydrator->extract($this->object); - if (!is_array($values)) { + if (! is_array($values)) { // Do nothing if the hydrator returned a non-array return []; } diff --git a/src/FieldsetInterface.php b/src/FieldsetInterface.php index 47c20e5d..2633373e 100644 --- a/src/FieldsetInterface.php +++ b/src/FieldsetInterface.php @@ -26,8 +26,9 @@ interface FieldsetInterface extends * $flags could contain metadata such as the alias under which to register * the element or fieldset, order in which to prioritize it, etc. * - * @param array|\Traversable|ElementInterface $elementOrFieldset Typically, only allow objects implementing ElementInterface; - * however, keeping it flexible to allow a factory-based form + * @param array|\Traversable|ElementInterface $elementOrFieldset Typically, only allow objects implementing + * ElementInterface; however, keeping it flexible + * to allow a factory-based form * implementation as well * @param array $flags * @return FieldsetInterface diff --git a/src/Form.php b/src/Form.php index 87736634..960b7b92 100644 --- a/src/Form.php +++ b/src/Form.php @@ -167,10 +167,10 @@ public function setOptions($options) */ public function add($elementOrFieldset, array $flags = []) { - // TODO: find a better solution than duplicating the factory code, the problem being that if $elementOrFieldset is an array, - // it is passed by value, and we don't get back the concrete ElementInterface + // TODO: find a better solution than duplicating the factory code, the problem being that if + // $elementOrFieldset is an array, it is passed by value, and we don't get back the concrete ElementInterface if (is_array($elementOrFieldset) - || ($elementOrFieldset instanceof Traversable && !$elementOrFieldset instanceof ElementInterface) + || ($elementOrFieldset instanceof Traversable && ! $elementOrFieldset instanceof ElementInterface) ) { $factory = $this->getFormFactory(); $elementOrFieldset = $factory->create($elementOrFieldset); @@ -256,7 +256,7 @@ public function setData($data) if ($data instanceof Traversable) { $data = ArrayUtils::iteratorToArray($data); } - if (!is_array($data)) { + if (! is_array($data)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable argument; received "%s"', __METHOD__, @@ -283,7 +283,7 @@ public function setData($data) */ public function bind($object, $flags = FormInterface::VALUES_NORMALIZED) { - if (!in_array($flags, [FormInterface::VALUES_NORMALIZED, FormInterface::VALUES_RAW])) { + if (! in_array($flags, [FormInterface::VALUES_NORMALIZED, FormInterface::VALUES_RAW])) { throw new Exception\InvalidArgumentException(sprintf( '%s expects the $flags argument to be one of "%s" or "%s"; received "%s"', __METHOD__, @@ -330,17 +330,17 @@ public function setHydrator(HydratorInterface $hydrator) */ public function bindValues(array $values = []) { - if (!is_object($this->object)) { + if (! is_object($this->object)) { if ($this->baseFieldset === null || $this->baseFieldset->allowValueBinding() == false) { return; } } - if (!$this->hasValidated() && !empty($values)) { + if (! $this->hasValidated() && ! empty($values)) { $this->setData($values); - if (!$this->isValid()) { + if (! $this->isValid()) { return; } - } elseif (!$this->isValid) { + } elseif (! $this->isValid) { return; } @@ -379,7 +379,7 @@ protected function prepareBindData(array $values, array $match) { $data = []; foreach ($values as $name => $value) { - if (!array_key_exists($name, $match)) { + if (! array_key_exists($name, $match)) { continue; } @@ -401,7 +401,7 @@ protected function prepareBindData(array $values, array $match) */ public function setBindOnValidate($bindOnValidateFlag) { - if (!in_array($bindOnValidateFlag, [self::BIND_ON_VALIDATE, self::BIND_MANUAL])) { + if (! in_array($bindOnValidateFlag, [self::BIND_ON_VALIDATE, self::BIND_MANUAL])) { throw new Exception\InvalidArgumentException(sprintf( '%s expects the flag to be one of %s::%s or %s::%s', __METHOD__, @@ -474,17 +474,17 @@ public function isValid() $this->isValid = false; - if (!is_array($this->data) && !is_object($this->object)) { + if (! is_array($this->data) && ! is_object($this->object)) { throw new Exception\DomainException(sprintf( '%s is unable to validate as there is no data currently set', __METHOD__ )); } - if (!is_array($this->data)) { + if (! is_array($this->data)) { $data = $this->extract(); $this->populateValues($data, true); - if (!is_array($data)) { + if (! is_array($data)) { throw new Exception\DomainException(sprintf( '%s is unable to validate as there is no data currently set', __METHOD__ @@ -494,7 +494,7 @@ public function isValid() } $filter = $this->getInputFilter(); - if (!$filter instanceof InputFilterInterface) { + if (! $filter instanceof InputFilterInterface) { throw new Exception\DomainException(sprintf( '%s is unable to validate as there is no input filter present', __METHOD__ @@ -517,7 +517,7 @@ public function isValid() $this->bindValues(); } - if (!$result) { + if (! $result) { $this->setMessages($filter->getMessages()); } @@ -536,7 +536,7 @@ public function isValid() */ public function getData($flag = FormInterface::VALUES_NORMALIZED) { - if (!$this->hasValidated) { + if (! $this->hasValidated) { throw new Exception\DomainException(sprintf( '%s cannot return data as validation has not yet occurred', __METHOD__ @@ -588,7 +588,7 @@ public function setValidationGroup() return $this; } - if (!is_array($arg)) { + if (! is_array($arg)) { $arg = (array) $arg; } @@ -607,8 +607,8 @@ public function getValidationGroup() } /** - * Prepare the validation group in case Collection elements were used (this function also handle the case where elements - * could have been dynamically added or removed from a collection using JavaScript) + * Prepare the validation group in case Collection elements were used (this function also handle + * the case where elements could have been dynamically added or removed from a collection using JavaScript) * * @param FieldsetInterface $formOrFieldset * @param array $data @@ -617,14 +617,14 @@ public function getValidationGroup() protected function prepareValidationGroup(FieldsetInterface $formOrFieldset, array $data, array &$validationGroup) { foreach ($validationGroup as $key => &$value) { - if (!$formOrFieldset->has($key)) { + if (! $formOrFieldset->has($key)) { continue; } $fieldset = $formOrFieldset->iterator->get($key); if ($fieldset instanceof Collection) { - if (!isset($data[$key]) && $fieldset->getCount() == 0) { + if (! isset($data[$key]) && $fieldset->getCount() == 0) { unset($validationGroup[$key]); continue; } @@ -640,7 +640,7 @@ protected function prepareValidationGroup(FieldsetInterface $formOrFieldset, arr $value = $values; } - if (!isset($data[$key])) { + if (! isset($data[$key])) { $data[$key] = []; } $this->prepareValidationGroup($fieldset, $data[$key], $validationGroup[$key]); @@ -678,7 +678,7 @@ public function getInputFilter() $this->filter = $this->object->getInputFilter(); } else { $name = $this->baseFieldset->getName(); - if (!$this->filter instanceof InputFilterInterface || !$this->filter->has($name)) { + if (! $this->filter instanceof InputFilterInterface || ! $this->filter->has($name)) { $filter = new InputFilter(); $filter->setFactory($this->getFormFactory()->getInputFilterFactory()); $filter->add($this->object->getInputFilter(), $name); @@ -687,12 +687,12 @@ public function getInputFilter() } } - if (!isset($this->filter)) { + if (! isset($this->filter)) { $this->filter = new InputFilter(); $this->filter->setFactory($this->getFormFactory()->getInputFilterFactory()); } - if (!$this->hasAddedInputFilterDefaults + if (! $this->hasAddedInputFilterDefaults && $this->filter instanceof InputFilterInterface && $this->useInputFilterDefaults() ) { @@ -766,13 +766,16 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie $elements = $fieldset->getElements(); } - if (!$fieldset instanceof Collection || !$fieldset->getTargetElement() instanceof FieldsetInterface || $inputFilter instanceof CollectionInputFilter) { + if (! $fieldset instanceof Collection + || ! $fieldset->getTargetElement() instanceof FieldsetInterface + || $inputFilter instanceof CollectionInputFilter + ) { foreach ($elements as $name => $element) { if ($this->preferFormInputFilter && $inputFilter->has($name)) { continue; } - if (!$element instanceof InputProviderInterface) { + if (! $element instanceof InputProviderInterface) { if ($inputFilter->has($name)) { continue; } @@ -792,7 +795,7 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie } // Add element input filter to CollectionInputFilter - if ($inputFilter instanceof CollectionInputFilter && !$inputFilter->getInputFilter()->has($name)) { + if ($inputFilter instanceof CollectionInputFilter && ! $inputFilter->getInputFilter()->has($name)) { $inputFilter->getInputFilter()->add($input, $name); } else { $inputFilter->add($input, $name); @@ -808,8 +811,8 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie } foreach ($fieldset->getFieldsets() as $name => $childFieldset) { - if (!$childFieldset instanceof InputFilterProviderInterface) { - if (!$inputFilter->has($name)) { + if (! $childFieldset instanceof InputFilterProviderInterface) { + if (! $inputFilter->has($name)) { // Add a new empty input filter if it does not exist (or the fieldset's object input filter), // so that elements of nested fieldsets can be recursively added if ($childFieldset->getObject() instanceof InputFilterAwareInterface) { @@ -844,7 +847,7 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie $fieldsetFilter = $inputFilter->get($name); - if (!$fieldsetFilter instanceof InputFilterInterface) { + if (! $fieldsetFilter instanceof InputFilterInterface) { // Input attached for fieldset, not input filter; nothing more to do. continue; } @@ -884,7 +887,7 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie private function addInputsToCollectionInputFilter(CollectionInputFilter $inputFilter) { foreach ($inputFilter->getInputs() as $name => $input) { - if (!$inputFilter->getInputFilter()->has($name)) { + if (! $inputFilter->getInputFilter()->has($name)) { $inputFilter->getInputFilter()->add($input, $name); } } diff --git a/src/FormAbstractServiceFactory.php b/src/FormAbstractServiceFactory.php index 47e3aaa7..920862ba 100644 --- a/src/FormAbstractServiceFactory.php +++ b/src/FormAbstractServiceFactory.php @@ -68,7 +68,9 @@ public function canCreate(ContainerInterface $container, $requestedName) return false; } - return (isset($config[$requestedName]) && is_array($config[$requestedName]) && !empty($config[$requestedName])); + return (isset($config[$requestedName]) + && is_array($config[$requestedName]) + && ! empty($config[$requestedName])); } /** @@ -109,14 +111,14 @@ protected function getConfig(ContainerInterface $container) return $this->config; } - if (!$container->has('config')) { + if (! $container->has('config')) { $this->config = []; return $this->config; } $config = $container->get('config'); - if (!isset($config[$this->configKey]) - || !is_array($config[$this->configKey]) + if (! isset($config[$this->configKey]) + || ! is_array($config[$this->configKey]) ) { $this->config = []; return $this->config; @@ -162,7 +164,7 @@ protected function getFormFactory(ContainerInterface $container) */ protected function marshalInputFilter(array &$config, ContainerInterface $container, Factory $formFactory) { - if (!isset($config['input_filter'])) { + if (! isset($config['input_filter'])) { return; } diff --git a/src/LabelAwareTrait.php b/src/LabelAwareTrait.php index 198620db..a52aa059 100644 --- a/src/LabelAwareTrait.php +++ b/src/LabelAwareTrait.php @@ -60,7 +60,7 @@ public function getLabelAttributes() */ public function setLabelOptions($arrayOrTraversable) { - if (!is_array($arrayOrTraversable) && !$arrayOrTraversable instanceof Traversable) { + if (! is_array($arrayOrTraversable) && ! $arrayOrTraversable instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '%s expects an array or Traversable argument; received "%s"', __METHOD__, @@ -130,7 +130,7 @@ public function setLabelOption($key, $value) */ public function getLabelOption($key) { - if (!array_key_exists($key, $this->labelOptions)) { + if (! array_key_exists($key, $this->labelOptions)) { return; } return $this->labelOptions[$key]; diff --git a/src/View/Helper/AbstractHelper.php b/src/View/Helper/AbstractHelper.php index 17e9a388..d6ec9540 100644 --- a/src/View/Helper/AbstractHelper.php +++ b/src/View/Helper/AbstractHelper.php @@ -212,7 +212,7 @@ public function createAttributesString(array $attributes) foreach ($attributes as $key => $value) { $key = strtolower($key); - if (!$value && isset($this->booleanAttributes[$key])) { + if (! $value && isset($this->booleanAttributes[$key])) { // Skip boolean attributes that expect empty string as false value if ('' === $this->booleanAttributes[$key]['off']) { continue; @@ -220,7 +220,7 @@ public function createAttributesString(array $attributes) } //check if attribute is translatable - if (isset($this->translatableAttributes[$key]) && !empty($value)) { + if (isset($this->translatableAttributes[$key]) && ! empty($value)) { if (($translator = $this->getTranslator()) !== null) { $value = $translator->translate($value, $this->getTranslatorTextDomain()); } @@ -283,7 +283,7 @@ protected function getDoctypeHelper() $this->doctypeHelper = $this->view->plugin('doctype'); } - if (!$this->doctypeHelper instanceof Doctype) { + if (! $this->doctypeHelper instanceof Doctype) { $this->doctypeHelper = new Doctype(); } @@ -305,7 +305,7 @@ protected function getEscapeHtmlHelper() $this->escapeHtmlHelper = $this->view->plugin('escapehtml'); } - if (!$this->escapeHtmlHelper instanceof EscapeHtml) { + if (! $this->escapeHtmlHelper instanceof EscapeHtml) { $this->escapeHtmlHelper = new EscapeHtml(); } @@ -327,7 +327,7 @@ protected function getEscapeHtmlAttrHelper() $this->escapeHtmlAttrHelper = $this->view->plugin('escapehtmlattr'); } - if (!$this->escapeHtmlAttrHelper instanceof EscapeHtmlAttr) { + if (! $this->escapeHtmlAttrHelper instanceof EscapeHtmlAttr) { $this->escapeHtmlAttrHelper = new EscapeHtmlAttr(); } @@ -350,8 +350,8 @@ protected function prepareAttributes(array $attributes) foreach ($attributes as $key => $value) { $attribute = strtolower($key); - if (!isset($this->validGlobalAttributes[$attribute]) - && !isset($this->validTagAttributes[$attribute]) + if (! isset($this->validGlobalAttributes[$attribute]) + && ! isset($this->validTagAttributes[$attribute]) && 'data-' != substr($attribute, 0, 5) && 'aria-' != substr($attribute, 0, 5) && 'x-' != substr($attribute, 0, 2) @@ -387,7 +387,7 @@ protected function prepareAttributes(array $attributes) */ protected function prepareBooleanAttributeValue($attribute, $value) { - if (!is_bool($value) && in_array($value, $this->booleanAttributes[$attribute])) { + if (! is_bool($value) && in_array($value, $this->booleanAttributes[$attribute])) { return $value; } diff --git a/src/View/Helper/Captcha/AbstractWord.php b/src/View/Helper/Captcha/AbstractWord.php index aa7796e3..05f41186 100644 --- a/src/View/Helper/Captcha/AbstractWord.php +++ b/src/View/Helper/Captcha/AbstractWord.php @@ -46,7 +46,7 @@ abstract class AbstractWord extends FormInput */ public function __invoke(ElementInterface $element = null) { - if (!$element) { + if (! $element) { return $this; } @@ -79,9 +79,10 @@ protected function renderCaptchaInputs(ElementInterface $element) $attributes = $element->getAttributes(); $captcha = $element->getCaptcha(); - if ($captcha === null || !$captcha instanceof CaptchaAdapter) { + if ($captcha === null || ! $captcha instanceof CaptchaAdapter) { throw new Exception\DomainException(sprintf( - '%s requires that the element has a "captcha" attribute implementing Zend\Captcha\AdapterInterface; none found', + '%s requires that the element has a "captcha" attribute implementing Zend\Captcha\AdapterInterface; ' + . 'none found', __METHOD__ )); } @@ -159,7 +160,7 @@ protected function renderCaptchaInput(CaptchaAdapter $captcha, array $attributes public function setCaptchaPosition($captchaPosition) { $captchaPosition = strtolower($captchaPosition); - if (!in_array($captchaPosition, [self::CAPTCHA_APPEND, self::CAPTCHA_PREPEND])) { + if (! in_array($captchaPosition, [self::CAPTCHA_APPEND, self::CAPTCHA_PREPEND])) { throw new Exception\InvalidArgumentException(sprintf( '%s expects either %s::CAPTCHA_APPEND or %s::CAPTCHA_PREPEND; received "%s"', __METHOD__, diff --git a/src/View/Helper/Captcha/Dumb.php b/src/View/Helper/Captcha/Dumb.php index d6acd1b3..37a1efda 100644 --- a/src/View/Helper/Captcha/Dumb.php +++ b/src/View/Helper/Captcha/Dumb.php @@ -26,7 +26,7 @@ public function render(ElementInterface $element) { $captcha = $element->getCaptcha(); - if ($captcha === null || !$captcha instanceof CaptchaAdapter) { + if ($captcha === null || ! $captcha instanceof CaptchaAdapter) { throw new Exception\DomainException(sprintf( '%s requires that the element has a "captcha" attribute of type Zend\Captcha\Dumb; none found', __METHOD__ diff --git a/src/View/Helper/Captcha/Figlet.php b/src/View/Helper/Captcha/Figlet.php index a0497575..723d740d 100644 --- a/src/View/Helper/Captcha/Figlet.php +++ b/src/View/Helper/Captcha/Figlet.php @@ -26,7 +26,7 @@ public function render(ElementInterface $element) { $captcha = $element->getCaptcha(); - if ($captcha === null || !$captcha instanceof CaptchaAdapter) { + if ($captcha === null || ! $captcha instanceof CaptchaAdapter) { throw new Exception\DomainException(sprintf( '%s requires that the element has a "captcha" attribute of type Zend\Captcha\Figlet; none found', __METHOD__ diff --git a/src/View/Helper/Captcha/Image.php b/src/View/Helper/Captcha/Image.php index 1bde5176..cfa1e096 100644 --- a/src/View/Helper/Captcha/Image.php +++ b/src/View/Helper/Captcha/Image.php @@ -26,7 +26,7 @@ public function render(ElementInterface $element) { $captcha = $element->getCaptcha(); - if ($captcha === null || !$captcha instanceof CaptchaAdapter) { + if ($captcha === null || ! $captcha instanceof CaptchaAdapter) { throw new Exception\DomainException(sprintf( '%s requires that the element has a "captcha" attribute of type Zend\Captcha\Image; none found', __METHOD__ diff --git a/src/View/Helper/Captcha/ReCaptcha.php b/src/View/Helper/Captcha/ReCaptcha.php index 1b36ddee..e5f1b293 100644 --- a/src/View/Helper/Captcha/ReCaptcha.php +++ b/src/View/Helper/Captcha/ReCaptcha.php @@ -26,7 +26,7 @@ class ReCaptcha extends FormInput */ public function __invoke(ElementInterface $element = null) { - if (!$element) { + if (! $element) { return $this; } @@ -45,9 +45,10 @@ public function render(ElementInterface $element) $attributes = $element->getAttributes(); $captcha = $element->getCaptcha(); - if ($captcha === null || !$captcha instanceof CaptchaAdapter) { + if ($captcha === null || ! $captcha instanceof CaptchaAdapter) { throw new Exception\DomainException(sprintf( - '%s requires that the element has a "captcha" attribute implementing Zend\Captcha\AdapterInterface; none found', + '%s requires that the element has a "captcha" attribute implementing Zend\Captcha\AdapterInterface; ' + . 'none found', __METHOD__ )); } @@ -55,7 +56,7 @@ public function render(ElementInterface $element) $name = $element->getName(); $id = isset($attributes['id']) ? $attributes['id'] : $name; $challengeName = empty($name) ? 'recaptcha_challenge_field' : $name . '[recaptcha_challenge_field]'; - $responseName = empty($name) ? 'recaptcha_response_field' : $name . '[recaptcha_response_field]'; + $responseName = empty($name) ? 'recaptcha_response_field' : $name . '[recaptcha_response_field]'; $challengeId = $id . '-challenge'; $responseId = $id . '-response'; @@ -105,7 +106,7 @@ protected function renderHiddenInput($challengeName, $challengeId, $responseName protected function renderJsEvents($challengeId, $responseId) { $elseif = 'else if'; // php-cs-fixer bug - $js =<< function windowOnLoad(fn) { diff --git a/src/View/Helper/Form.php b/src/View/Helper/Form.php index 7810b47c..3b2a9e00 100644 --- a/src/View/Helper/Form.php +++ b/src/View/Helper/Form.php @@ -42,7 +42,7 @@ class Form extends AbstractHelper */ public function __invoke(FormInterface $form = null) { - if (!$form) { + if (! $form) { return $this; } @@ -65,9 +65,9 @@ public function render(FormInterface $form) foreach ($form as $element) { if ($element instanceof FieldsetInterface) { - $formContent.= $this->getView()->formCollection($element); + $formContent .= $this->getView()->formCollection($element); } else { - $formContent.= $this->getView()->formRow($element); + $formContent .= $this->getView()->formRow($element); } } @@ -94,7 +94,7 @@ public function openTag(FormInterface $form = null) if ($form instanceof FormInterface) { $formAttributes = $form->getAttributes(); - if (!array_key_exists('id', $formAttributes) && array_key_exists('name', $formAttributes)) { + if (! array_key_exists('id', $formAttributes) && array_key_exists('name', $formAttributes)) { $formAttributes['id'] = $formAttributes['name']; } $attributes = array_merge($attributes, $formAttributes); diff --git a/src/View/Helper/FormButton.php b/src/View/Helper/FormButton.php index 83520142..05f8a0e9 100644 --- a/src/View/Helper/FormButton.php +++ b/src/View/Helper/FormButton.php @@ -56,7 +56,7 @@ class FormButton extends FormInput */ public function __invoke(ElementInterface $element = null, $buttonContent = null) { - if (!$element) { + if (! $element) { return $this; } @@ -91,7 +91,8 @@ public function render(ElementInterface $element, $buttonContent = null) if (null !== ($translator = $this->getTranslator())) { $buttonContent = $translator->translate( - $buttonContent, $this->getTranslatorTextDomain() + $buttonContent, + $this->getTranslatorTextDomain() ); } @@ -123,7 +124,7 @@ public function openTag($attributesOrElement = null) return sprintf('$#', $markup); + $this->assertRegexp( + '#^$#', + $markup + ); } public function testAssertLabelHtmlEscapeIsOnByDefault() @@ -486,10 +500,16 @@ public function testCanSetLabelPositionViaRender() $element->setLabel('Baz'); $markup = $this->helper->render($element, 'append'); - $this->assertRegexp('#^$#', $markup); + $this->assertRegexp( + '#^$#', + $markup + ); $markup = $this->helper->render($element, 'prepend'); - $this->assertRegexp('#^$#', $markup); + $this->assertRegexp( + '#^$#', + $markup + ); } public function testSetLabelPositionViaRenderIsNotCached() @@ -514,10 +534,16 @@ public function testCanSetLabelPositionViaInvoke() $element->setLabel('Baz'); $markup = $this->helper->__invoke($element, 'append'); - $this->assertRegexp('#^$#', $markup); + $this->assertRegexp( + '#^$#', + $markup + ); $markup = $this->helper->__invoke($element, 'prepend'); - $this->assertRegexp('#^$#', $markup); + $this->assertRegexp( + '#^$#', + $markup + ); } /** @@ -552,7 +578,10 @@ public function testCanSetOptionToWrapElementInLabel() $element->setLabel('baz'); $markup = $this->helper->render($element); - $this->assertRegexp('#^$#', $markup); + $this->assertRegexp( + '#^$#', + $markup + ); } /** diff --git a/test/View/Helper/FormSelectTest.php b/test/View/Helper/FormSelectTest.php index 24888791..6670fac1 100644 --- a/test/View/Helper/FormSelectTest.php +++ b/test/View/Helper/FormSelectTest.php @@ -133,7 +133,9 @@ public function testOptgroupsAreCreatedWhenAnOptionHasAnOptionsKey() $element->setValueOptions($options); $markup = $this->helper->render($element); + // @codingStandardsIgnoreStart $this->assertRegexp('#optgroup[^>]*?label="This\&\#x20\;is\&\#x20\;the\&\#x20\;second\&\#x20\;label"[^>]*>\s*]*?value="bar"[^>]*?>foo.*?#s', $markup); + // @codingStandardsIgnoreEnd } public function testCanDisableAnOptgroup() @@ -150,7 +152,9 @@ public function testCanDisableAnOptgroup() $element->setValueOptions($options); $markup = $this->helper->render($element); + // @codingStandardsIgnoreStart $this->assertRegexp('#optgroup .*?label="This\&\#x20\;is\&\#x20\;the\&\#x20\;second\&\#x20\;label"[^>]*?disabled="disabled"[^>]*?>\s*]*?value="bar"[^>]*?>foo.*?#', $markup); + // @codingStandardsIgnoreEnd } /** diff --git a/test/View/Helper/FormTextareaTest.php b/test/View/Helper/FormTextareaTest.php index 811b3aec..9224d1ce 100644 --- a/test/View/Helper/FormTextareaTest.php +++ b/test/View/Helper/FormTextareaTest.php @@ -256,15 +256,27 @@ public function testBooleanAttributeTypesAreRenderedCorrectly($attribute, $on, $ $element->setAttribute($attribute, true); $markup = $this->helper->render($element); $expect = sprintf('%s="%s"', $attribute, $on); - $this->assertContains($expect, $markup, sprintf("Enabled value for %s should be '%s'; received %s", $attribute, $on, $markup)); + $this->assertContains( + $expect, + $markup, + sprintf("Enabled value for %s should be '%s'; received %s", $attribute, $on, $markup) + ); $element->setAttribute($attribute, false); $markup = $this->helper->render($element); $expect = sprintf('%s="%s"', $attribute, $off); if ($off !== '') { - $this->assertContains($expect, $markup, sprintf("Disabled value for %s should be '%s'; received %s", $attribute, $off, $markup)); + $this->assertContains( + $expect, + $markup, + sprintf("Disabled value for %s should be '%s'; received %s", $attribute, $off, $markup) + ); } else { - $this->assertNotContains($expect, $markup, sprintf("Disabled value for %s should not be rendered; received %s", $attribute, $markup)); + $this->assertNotContains( + $expect, + $markup, + sprintf("Disabled value for %s should not be rendered; received %s", $attribute, $markup) + ); } }