diff --git a/.php_cs b/.php_cs index 6b3d68bc..8f4dd5aa 100644 --- a/.php_cs +++ b/.php_cs @@ -32,6 +32,7 @@ $config->fixers( 'object_operator', 'php_closing_tag', 'remove_lines_between_uses', + 'short_array_syntax', 'short_tag', 'standardize_not_equal', 'trailing_spaces', diff --git a/src/Annotation/AnnotationBuilder.php b/src/Annotation/AnnotationBuilder.php index 01406074..553774fa 100644 --- a/src/Annotation/AnnotationBuilder.php +++ b/src/Annotation/AnnotationBuilder.php @@ -57,7 +57,7 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI /** * @var array Default annotations to register */ - protected $defaultAnnotations = array( + protected $defaultAnnotations = [ 'AllowEmpty', 'Attributes', 'ComposedObject', @@ -77,7 +77,7 @@ class AnnotationBuilder implements EventManagerAwareInterface, FormFactoryAwareI 'Type', 'ValidationGroup', 'Validator' - ); + ]; /** * @var bool @@ -122,10 +122,10 @@ public function setAnnotationManager(AnnotationManager $annotationManager) */ public function setEventManager(EventManagerInterface $events) { - $events->setIdentifiers(array( + $events->setIdentifiers([ __CLASS__, get_class($this), - )); + ]); $events->attach(new ElementAnnotationsListener()); $events->attach(new FormAnnotationsListener()); $this->events = $events; @@ -271,18 +271,18 @@ protected function configureForm($annotations, $reflection, $formSpec, $filterSp { $name = $this->discoverName($annotations, $reflection); $formSpec['name'] = $name; - $formSpec['attributes'] = array(); - $formSpec['elements'] = array(); - $formSpec['fieldsets'] = array(); + $formSpec['attributes'] = []; + $formSpec['elements'] = []; + $formSpec['fieldsets'] = []; $events = $this->getEventManager(); foreach ($annotations as $annotation) { - $events->trigger(__FUNCTION__, $this, array( + $events->trigger(__FUNCTION__, $this, [ 'annotation' => $annotation, 'name' => $name, 'formSpec' => $formSpec, 'filterSpec' => $filterSpec, - )); + ]); } } @@ -308,24 +308,24 @@ protected function configureElement($annotations, $reflection, $formSpec, $filte $events = $this->getEventManager(); $name = $this->discoverName($annotations, $reflection); - $elementSpec = new ArrayObject(array( - 'flags' => array(), - 'spec' => array( + $elementSpec = new ArrayObject([ + 'flags' => [], + 'spec' => [ 'name' => $name - ), - )); - $inputSpec = new ArrayObject(array( + ], + ]); + $inputSpec = new ArrayObject([ 'name' => $name, - )); + ]); $event = new Event(); - $event->setParams(array( + $event->setParams([ 'name' => $name, 'elementSpec' => $elementSpec, 'inputSpec' => $inputSpec, 'formSpec' => $formSpec, 'filterSpec' => $filterSpec, - )); + ]); foreach ($annotations as $annotation) { $event->setParam('annotation', $annotation); $events->trigger(__FUNCTION__, $this, $event); @@ -351,12 +351,12 @@ protected function configureElement($annotations, $reflection, $formSpec, $filte // 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'])) { - $formSpec['fieldsets'] = array(); + $formSpec['fieldsets'] = []; } $formSpec['fieldsets'][] = $elementSpec; } else { if (!isset($formSpec['elements'])) { - $formSpec['elements'] = array(); + $formSpec['elements'] = []; } $formSpec['elements'][] = $elementSpec; } @@ -389,10 +389,10 @@ public function preserveDefinedOrder() */ protected function discoverName($annotations, $reflection) { - $results = $this->getEventManager()->trigger('discoverName', $this, array( + $results = $this->getEventManager()->trigger('discoverName', $this, [ 'annotations' => $annotations, 'reflection' => $reflection, - ), function ($r) { + ], function ($r) { return (is_string($r) && !empty($r)); }); return $results->last(); @@ -406,9 +406,9 @@ protected function discoverName($annotations, $reflection) */ protected function checkForExclude($annotations) { - $results = $this->getEventManager()->trigger('checkForExclude', $this, array( + $results = $this->getEventManager()->trigger('checkForExclude', $this, [ 'annotations' => $annotations, - ), function ($r) { + ], function ($r) { return (true === $r); }); return (bool) $results->last(); diff --git a/src/Annotation/ComposedObject.php b/src/Annotation/ComposedObject.php index b8649f99..ceec8149 100644 --- a/src/Annotation/ComposedObject.php +++ b/src/Annotation/ComposedObject.php @@ -51,6 +51,6 @@ public function isCollection() */ public function getOptions() { - return is_array($this->value) && isset($this->value['options']) ? $this->value['options'] : array(); + return is_array($this->value) && isset($this->value['options']) ? $this->value['options'] : []; } } diff --git a/src/Annotation/ElementAnnotationsListener.php b/src/Annotation/ElementAnnotationsListener.php index 93e1f2fe..9ea5de9e 100644 --- a/src/Annotation/ElementAnnotationsListener.php +++ b/src/Annotation/ElementAnnotationsListener.php @@ -41,25 +41,25 @@ class ElementAnnotationsListener extends AbstractAnnotationsListener */ public function attach(EventManagerInterface $events) { - $this->listeners[] = $events->attach('configureElement', array($this, 'handleAllowEmptyAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleAttributesAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleComposedObjectAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleContinueIfEmptyAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleErrorMessageAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleFilterAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleFlagsAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleHydratorAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleInputAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleObjectAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleOptionsAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleRequiredAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleTypeAnnotation')); - $this->listeners[] = $events->attach('configureElement', array($this, 'handleValidatorAnnotation')); - - $this->listeners[] = $events->attach('discoverName', array($this, 'handleNameAnnotation')); - $this->listeners[] = $events->attach('discoverName', array($this, 'discoverFallbackName')); - - $this->listeners[] = $events->attach('checkForExclude', array($this, 'handleExcludeAnnotation')); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleAllowEmptyAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleAttributesAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleComposedObjectAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleContinueIfEmptyAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleErrorMessageAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleFilterAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleFlagsAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleHydratorAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleInputAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleObjectAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleOptionsAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleRequiredAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleTypeAnnotation']); + $this->listeners[] = $events->attach('configureElement', [$this, 'handleValidatorAnnotation']); + + $this->listeners[] = $events->attach('discoverName', [$this, 'handleNameAnnotation']); + $this->listeners[] = $events->attach('discoverName', [$this, 'discoverFallbackName']); + + $this->listeners[] = $events->attach('checkForExclude', [$this, 'handleExcludeAnnotation']); } /** @@ -167,7 +167,7 @@ public function handleComposedObjectAnnotation($e) } if (isset($elementSpec['spec']['options'])) { - $specification['options'] = isset($specification['options']) ? $specification['options'] : array(); + $specification['options'] = isset($specification['options']) ? $specification['options'] : []; $specification['options'] = array_merge($elementSpec['spec']['options'], $specification['options']); } @@ -248,7 +248,7 @@ public function handleFilterAnnotation($e) $inputSpec = $e->getParam('inputSpec'); if (!isset($inputSpec['filters'])) { - $inputSpec['filters'] = array(); + $inputSpec['filters'] = []; } $inputSpec['filters'][] = $annotation->getFilter(); } @@ -374,7 +374,7 @@ public function handleRequiredAnnotation($e) if ($required) { $elementSpec = $e->getParam('elementSpec'); if (!isset($elementSpec['spec']['attributes'])) { - $elementSpec['spec']['attributes'] = array(); + $elementSpec['spec']['attributes'] = []; } $elementSpec['spec']['attributes']['required'] = 'required'; @@ -417,7 +417,7 @@ public function handleValidatorAnnotation($e) $inputSpec = $e->getParam('inputSpec'); if (!isset($inputSpec['validators'])) { - $inputSpec['validators'] = array(); + $inputSpec['validators'] = []; } $inputSpec['validators'][] = $annotation->getValidator(); } diff --git a/src/Annotation/FormAnnotationsListener.php b/src/Annotation/FormAnnotationsListener.php index 1701391a..56ade307 100644 --- a/src/Annotation/FormAnnotationsListener.php +++ b/src/Annotation/FormAnnotationsListener.php @@ -39,17 +39,17 @@ class FormAnnotationsListener extends AbstractAnnotationsListener */ public function attach(EventManagerInterface $events) { - $this->listeners[] = $events->attach('configureForm', array($this, 'handleAttributesAnnotation')); - $this->listeners[] = $events->attach('configureForm', array($this, 'handleFlagsAnnotation')); - $this->listeners[] = $events->attach('configureForm', array($this, 'handleHydratorAnnotation')); - $this->listeners[] = $events->attach('configureForm', array($this, 'handleInputFilterAnnotation')); - $this->listeners[] = $events->attach('configureForm', array($this, 'handleObjectAnnotation')); - $this->listeners[] = $events->attach('configureForm', array($this, 'handleOptionsAnnotation')); - $this->listeners[] = $events->attach('configureForm', array($this, 'handleTypeAnnotation')); - $this->listeners[] = $events->attach('configureForm', array($this, 'handleValidationGroupAnnotation')); - - $this->listeners[] = $events->attach('discoverName', array($this, 'handleNameAnnotation')); - $this->listeners[] = $events->attach('discoverName', array($this, 'discoverFallbackName')); + $this->listeners[] = $events->attach('configureForm', [$this, 'handleAttributesAnnotation']); + $this->listeners[] = $events->attach('configureForm', [$this, 'handleFlagsAnnotation']); + $this->listeners[] = $events->attach('configureForm', [$this, 'handleHydratorAnnotation']); + $this->listeners[] = $events->attach('configureForm', [$this, 'handleInputFilterAnnotation']); + $this->listeners[] = $events->attach('configureForm', [$this, 'handleObjectAnnotation']); + $this->listeners[] = $events->attach('configureForm', [$this, 'handleOptionsAnnotation']); + $this->listeners[] = $events->attach('configureForm', [$this, 'handleTypeAnnotation']); + $this->listeners[] = $events->attach('configureForm', [$this, 'handleValidationGroupAnnotation']); + + $this->listeners[] = $events->attach('discoverName', [$this, 'handleNameAnnotation']); + $this->listeners[] = $events->attach('discoverName', [$this, 'discoverFallbackName']); } /** diff --git a/src/Element.php b/src/Element.php index decdadeb..1aa95ffd 100644 --- a/src/Element.php +++ b/src/Element.php @@ -22,7 +22,7 @@ class Element implements /** * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * @var null|string @@ -32,24 +32,24 @@ class Element implements /** * @var array */ - protected $labelAttributes = array(); + protected $labelAttributes = []; /** * Label specific options * * @var array */ - protected $labelOptions = array(); + protected $labelOptions = []; /** * @var array Validation error messages */ - protected $messages = array(); + protected $messages = []; /** * @var array custom options */ - protected $options = array(); + protected $options = []; /** * @var mixed @@ -61,7 +61,7 @@ class Element implements * @param array $options Optional options for the element * @throws Exception\InvalidArgumentException */ - public function __construct($name = null, $options = array()) + public function __construct($name = null, $options = []) { if (null !== $name) { $this->setName($name); @@ -291,7 +291,7 @@ public function removeAttributes(array $keys) */ public function clearAttributes() { - $this->attributes = array(); + $this->attributes = []; return $this; } @@ -405,7 +405,7 @@ public function getLabelOptions() */ public function clearLabelOptions() { - $this->labelOptions = array(); + $this->labelOptions = []; return $this; } diff --git a/src/Element/Button.php b/src/Element/Button.php index 22e6f62f..64755dc1 100644 --- a/src/Element/Button.php +++ b/src/Element/Button.php @@ -18,7 +18,7 @@ class Button extends Element * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'button', - ); + ]; } diff --git a/src/Element/Captcha.php b/src/Element/Captcha.php index 2d0d45b3..c458d5f8 100644 --- a/src/Element/Captcha.php +++ b/src/Element/Captcha.php @@ -82,18 +82,18 @@ public function getCaptcha() */ public function getInputSpecification() { - $spec = array( + $spec = [ 'name' => $this->getName(), 'required' => true, - 'filters' => array( - array('name' => 'Zend\Filter\StringTrim'), - ), - ); + 'filters' => [ + ['name' => 'Zend\Filter\StringTrim'], + ], + ]; // Test that we have a captcha before adding it to the spec $captcha = $this->getCaptcha(); if ($captcha instanceof ZendCaptcha\AdapterInterface) { - $spec['validators'] = array($captcha); + $spec['validators'] = [$captcha]; } return $spec; diff --git a/src/Element/Checkbox.php b/src/Element/Checkbox.php index 9d60cdd9..32683155 100644 --- a/src/Element/Checkbox.php +++ b/src/Element/Checkbox.php @@ -21,9 +21,9 @@ class Checkbox extends Element implements InputProviderInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'checkbox' - ); + ]; /** * @var \Zend\Validator\ValidatorInterface @@ -147,10 +147,10 @@ public function getCheckedValue() protected function getValidator() { if (null === $this->validator) { - $this->validator = new InArrayValidator(array( - 'haystack' => array($this->checkedValue, $this->uncheckedValue), + $this->validator = new InArrayValidator([ + 'haystack' => [$this->checkedValue, $this->uncheckedValue], 'strict' => false - )); + ]); } return $this->validator; } @@ -164,15 +164,15 @@ protected function getValidator() */ public function getInputSpecification() { - $spec = array( + $spec = [ 'name' => $this->getName(), 'required' => true, - ); + ]; if ($validator = $this->getValidator()) { - $spec['validators'] = array( + $spec['validators'] = [ $validator, - ); + ]; } return $spec; diff --git a/src/Element/Collection.php b/src/Element/Collection.php index 88cbd8c8..7c4b9ceb 100644 --- a/src/Element/Collection.php +++ b/src/Element/Collection.php @@ -209,7 +209,7 @@ public function populateValues($data) } // Check to see if elements have been replaced or removed - $toRemove = array(); + $toRemove = []; foreach ($this as $name => $elementOrFieldset) { if (isset($data[$name])) { continue; @@ -268,9 +268,9 @@ public function allowValueBinding() * @param array $values * @return array|mixed|void */ - public function bindValues(array $values = array()) + public function bindValues(array $values = []) { - $collection = array(); + $collection = []; foreach ($values as $name => $value) { $element = $this->get($name); @@ -512,10 +512,10 @@ public function extract() } if (!is_array($this->object)) { - return array(); + return []; } - $values = array(); + $values = []; foreach ($this->object as $key => $value) { // If a hydrator is provided, our work here is done diff --git a/src/Element/Color.php b/src/Element/Color.php index 7de8ee97..24664d5f 100644 --- a/src/Element/Color.php +++ b/src/Element/Color.php @@ -20,9 +20,9 @@ class Color extends Element implements InputProviderInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'color', - ); + ]; /** * @var \Zend\Validator\ValidatorInterface @@ -51,16 +51,16 @@ protected function getValidator() */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => true, - 'filters' => array( - array('name' => 'Zend\Filter\StringTrim'), - array('name' => 'Zend\Filter\StringToLower'), - ), - 'validators' => array( + 'filters' => [ + ['name' => 'Zend\Filter\StringTrim'], + ['name' => 'Zend\Filter\StringToLower'], + ], + 'validators' => [ $this->getValidator(), - ), - ); + ], + ]; } } diff --git a/src/Element/Csrf.php b/src/Element/Csrf.php index 8c8bfa03..7894c288 100644 --- a/src/Element/Csrf.php +++ b/src/Element/Csrf.php @@ -22,14 +22,14 @@ class Csrf extends Element implements InputProviderInterface, ElementPrepareAwar * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'hidden', - ); + ]; /** * @var array */ - protected $csrfValidatorOptions = array(); + protected $csrfValidatorOptions = []; /** * @var CsrfValidator @@ -81,7 +81,7 @@ public function getCsrfValidator() { if (null === $this->csrfValidator) { $csrfOptions = $this->getCsrfValidatorOptions(); - $csrfOptions = array_merge($csrfOptions, array('name' => $this->getName())); + $csrfOptions = array_merge($csrfOptions, ['name' => $this->getName()]); $this->setCsrfValidator(new CsrfValidator($csrfOptions)); } return $this->csrfValidator; @@ -134,16 +134,16 @@ public function getAttributes() */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => true, - 'filters' => array( - array('name' => 'Zend\Filter\StringTrim'), - ), - 'validators' => array( + 'filters' => [ + ['name' => 'Zend\Filter\StringTrim'], + ], + 'validators' => [ $this->getCsrfValidator(), - ), - ); + ], + ]; } /** diff --git a/src/Element/Date.php b/src/Element/Date.php index 209060f3..0ecfc5a9 100644 --- a/src/Element/Date.php +++ b/src/Element/Date.php @@ -21,9 +21,9 @@ class Date extends DateTimeElement * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'date', - ); + ]; /** * Date format to use for DateTime values. By default, this is RFC-3339, @@ -47,11 +47,11 @@ protected function getStepValidator() $baseValue = (isset($this->attributes['min'])) ? $this->attributes['min'] : date($format, 0); - return new DateStepValidator(array( + return new DateStepValidator([ 'format' => $format, 'baseValue' => $baseValue, 'timezone' => new DateTimezone('UTC'), 'step' => new DateInterval("P{$stepValue}D"), - )); + ]); } } diff --git a/src/Element/DateSelect.php b/src/Element/DateSelect.php index 5376cc81..05e26ff0 100644 --- a/src/Element/DateSelect.php +++ b/src/Element/DateSelect.php @@ -31,7 +31,7 @@ class DateSelect extends MonthSelect * @param null|int|string $name Optional name for the element * @param array $options Optional options for the element */ - public function __construct($name = null, $options = array()) + public function __construct($name = null, $options = []) { $this->dayElement = new Select('day'); @@ -71,7 +71,7 @@ public function getDayElement() */ public function getElements() { - return array_merge(array($this->dayElement), parent::getElements()); + return array_merge([$this->dayElement], parent::getElements()); } /** @@ -112,11 +112,11 @@ public function setValue($value) } if ($value instanceof PhpDateTime) { - $value = array( + $value = [ 'year' => $value->format('Y'), 'month' => $value->format('m'), 'day' => $value->format('d'), - ); + ]; } $this->yearElement->setValue($value['year']); @@ -161,7 +161,7 @@ public function prepareElement(FormInterface $form) protected function getValidator() { if (null === $this->validator) { - $this->validator = new DateValidator(array('format' => 'Y-m-d')); + $this->validator = new DateValidator(['format' => 'Y-m-d']); } return $this->validator; @@ -175,16 +175,16 @@ protected function getValidator() */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => false, - 'filters' => array( - array('name' => 'DateSelect') - ), - 'validators' => array( + 'filters' => [ + ['name' => 'DateSelect'] + ], + 'validators' => [ $this->getValidator(), - ) - ); + ] + ]; } /** diff --git a/src/Element/DateTime.php b/src/Element/DateTime.php index 3ec892ed..8be075a8 100644 --- a/src/Element/DateTime.php +++ b/src/Element/DateTime.php @@ -27,9 +27,9 @@ class DateTime extends Element implements InputProviderInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'datetime', - ); + ]; /** * A valid format string accepted by date() @@ -117,20 +117,20 @@ protected function getValidators() return $this->validators; } - $validators = array(); + $validators = []; $validators[] = $this->getDateValidator(); if (isset($this->attributes['min'])) { - $validators[] = new GreaterThanValidator(array( + $validators[] = new GreaterThanValidator([ 'min' => $this->attributes['min'], 'inclusive' => true, - )); + ]); } if (isset($this->attributes['max'])) { - $validators[] = new LessThanValidator(array( + $validators[] = new LessThanValidator([ 'max' => $this->attributes['max'], 'inclusive' => true, - )); + ]); } if (!isset($this->attributes['step']) || 'any' !== $this->attributes['step'] @@ -149,7 +149,7 @@ protected function getValidators() */ protected function getDateValidator() { - return new DateValidator(array('format' => $this->format)); + return new DateValidator(['format' => $this->format]); } /** @@ -166,11 +166,11 @@ protected function getStepValidator() $baseValue = (isset($this->attributes['min'])) ? $this->attributes['min'] : date($format, 0); - return new DateStepValidator(array( + return new DateStepValidator([ 'format' => $format, 'baseValue' => $baseValue, 'step' => new DateInterval("PT{$stepValue}M"), - )); + ]); } /** @@ -182,13 +182,13 @@ protected function getStepValidator() */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => true, - 'filters' => array( - array('name' => 'Zend\Filter\StringTrim'), - ), + 'filters' => [ + ['name' => 'Zend\Filter\StringTrim'], + ], 'validators' => $this->getValidators(), - ); + ]; } } diff --git a/src/Element/DateTimeLocal.php b/src/Element/DateTimeLocal.php index 5e602a49..0cc3f58d 100644 --- a/src/Element/DateTimeLocal.php +++ b/src/Element/DateTimeLocal.php @@ -20,9 +20,9 @@ class DateTimeLocal extends DateTime * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'datetime-local', - ); + ]; /** * {@inheritDoc} @@ -42,10 +42,10 @@ protected function getStepValidator() $baseValue = (isset($this->attributes['min'])) ? $this->attributes['min'] : '1970-01-01T00:00'; - return new DateStepValidator(array( + return new DateStepValidator([ 'format' => $this->format, 'baseValue' => $baseValue, 'step' => new \DateInterval("PT{$stepValue}M"), - )); + ]); } } diff --git a/src/Element/DateTimeSelect.php b/src/Element/DateTimeSelect.php index c82c7d94..f2acce5c 100644 --- a/src/Element/DateTimeSelect.php +++ b/src/Element/DateTimeSelect.php @@ -54,7 +54,7 @@ class DateTimeSelect extends DateSelect * @param null|int|string $name Optional name for the element * @param array $options Optional options for the element */ - public function __construct($name = null, $options = array()) + public function __construct($name = null, $options = []) { parent::__construct($name, $options); @@ -234,14 +234,14 @@ public function setValue($value) } if ($value instanceof PhpDateTime) { - $value = array( + $value = [ 'year' => $value->format('Y'), 'month' => $value->format('m'), 'day' => $value->format('d'), 'hour' => $value->format('H'), 'minute' => $value->format('i'), 'second' => $value->format('s') - ); + ]; } if (! isset($value['second'])) { @@ -298,7 +298,7 @@ public function prepareElement(FormInterface $form) protected function getValidator() { if (null === $this->validator) { - $this->validator = new DateValidator(array('format' => 'Y-m-d H:i:s')); + $this->validator = new DateValidator(['format' => 'Y-m-d H:i:s']); } return $this->validator; @@ -312,16 +312,16 @@ protected function getValidator() */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => false, - 'filters' => array( - array('name' => 'DateTimeSelect') - ), - 'validators' => array( + 'filters' => [ + ['name' => 'DateTimeSelect'] + ], + 'validators' => [ $this->getValidator(), - ), - ); + ], + ]; } /** diff --git a/src/Element/Email.php b/src/Element/Email.php index a16eb4a8..688f9040 100644 --- a/src/Element/Email.php +++ b/src/Element/Email.php @@ -22,9 +22,9 @@ class Email extends Element implements InputProviderInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'email', - ); + ]; /** * @var ValidatorInterface @@ -50,9 +50,9 @@ public function getValidator() ? $this->attributes['multiple'] : null; if (true === $multiple || 'multiple' === $multiple) { - $this->validator = new ExplodeValidator(array( + $this->validator = new ExplodeValidator([ 'validator' => $emailValidator, - )); + ]); } else { $this->validator = $emailValidator; } @@ -125,15 +125,15 @@ public function setEmailValidator(ValidatorInterface $validator) */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => true, - 'filters' => array( - array('name' => 'Zend\Filter\StringTrim'), - ), - 'validators' => array( + 'filters' => [ + ['name' => 'Zend\Filter\StringTrim'], + ], + 'validators' => [ $this->getValidator(), - ), - ); + ], + ]; } } diff --git a/src/Element/File.php b/src/Element/File.php index 68577826..15a5f1e6 100644 --- a/src/Element/File.php +++ b/src/Element/File.php @@ -21,9 +21,9 @@ class File extends Element implements InputProviderInterface, ElementPrepareAwar * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'file', - ); + ]; /** * Prepare the form element (mostly used for rendering purposes) @@ -45,10 +45,10 @@ public function prepareElement(FormInterface $form) */ public function getInputSpecification() { - return array( + return [ 'type' => 'Zend\InputFilter\FileInput', 'name' => $this->getName(), 'required' => false, - ); + ]; } } diff --git a/src/Element/Hidden.php b/src/Element/Hidden.php index 9216c0ba..8952e05d 100644 --- a/src/Element/Hidden.php +++ b/src/Element/Hidden.php @@ -18,7 +18,7 @@ class Hidden extends Element * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'hidden', - ); + ]; } diff --git a/src/Element/Image.php b/src/Element/Image.php index 11f57042..f5ef4c88 100644 --- a/src/Element/Image.php +++ b/src/Element/Image.php @@ -18,7 +18,7 @@ class Image extends Element * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'image', - ); + ]; } diff --git a/src/Element/Month.php b/src/Element/Month.php index e831df08..fbfcf01d 100644 --- a/src/Element/Month.php +++ b/src/Element/Month.php @@ -20,9 +20,9 @@ class Month extends DateTime * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'month', - ); + ]; /** * Retrieves a Date Validator configured for a Month Input type @@ -47,10 +47,10 @@ protected function getStepValidator() $baseValue = (isset($this->attributes['min'])) ? $this->attributes['min'] : '1970-01'; - return new DateStepValidator(array( + return new DateStepValidator([ 'format' => "Y-m", 'baseValue' => $baseValue, 'step' => new \DateInterval("P{$stepValue}M"), - )); + ]); } } diff --git a/src/Element/MonthSelect.php b/src/Element/MonthSelect.php index 69eaf615..70b8de2b 100644 --- a/src/Element/MonthSelect.php +++ b/src/Element/MonthSelect.php @@ -76,7 +76,7 @@ class MonthSelect extends Element implements InputProviderInterface, ElementPrep * @param null|int|string $name Optional name for the element * @param array $options Optional options for the element */ - public function __construct($name = null, $options = array()) + public function __construct($name = null, $options = []) { $this->minYear = date('Y') - 100; $this->maxYear = date('Y'); @@ -158,7 +158,7 @@ public function getYearElement() */ public function getElements() { - return array($this->monthElement, $this->yearElement); + return [$this->monthElement, $this->yearElement]; } /** @@ -284,10 +284,10 @@ public function shouldRenderDelimiters() public function setValue($value) { if ($value instanceof PhpDateTime) { - $value = array( + $value = [ 'year' => $value->format('Y'), 'month' => $value->format('m') - ); + ]; } $this->yearElement->setValue($value['year']); @@ -338,16 +338,16 @@ protected function getValidator() */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => false, - 'filters' => array( - array('name' => 'MonthSelect'), - ), - 'validators' => array( + 'filters' => [ + ['name' => 'MonthSelect'], + ], + 'validators' => [ $this->getValidator(), - ), - ); + ], + ]; } /** diff --git a/src/Element/MultiCheckbox.php b/src/Element/MultiCheckbox.php index c98ac3a8..d8b7c05b 100644 --- a/src/Element/MultiCheckbox.php +++ b/src/Element/MultiCheckbox.php @@ -22,9 +22,9 @@ class MultiCheckbox extends Checkbox * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'multi_checkbox', - ); + ]; /** * @var bool @@ -44,7 +44,7 @@ class MultiCheckbox extends Checkbox /** * @var array */ - protected $valueOptions = array(); + protected $valueOptions = []; /** * @return array @@ -160,14 +160,14 @@ public function disableInArrayValidator() protected function getValidator() { if (null === $this->validator && !$this->disableInArrayValidator()) { - $inArrayValidator = new InArrayValidator(array( + $inArrayValidator = new InArrayValidator([ 'haystack' => $this->getValueOptionsValues(), 'strict' => false, - )); - $this->validator = new ExplodeValidator(array( + ]); + $this->validator = new ExplodeValidator([ 'validator' => $inArrayValidator, 'valueDelimiter' => null, // skip explode if only one value - )); + ]); } return $this->validator; } @@ -179,7 +179,7 @@ protected function getValidator() */ protected function getValueOptionsValues() { - $values = array(); + $values = []; $options = $this->getValueOptions(); foreach ($options as $key => $optionSpec) { $value = (is_array($optionSpec)) ? $optionSpec['value'] : $key; diff --git a/src/Element/Number.php b/src/Element/Number.php index a56255a8..5db3980e 100644 --- a/src/Element/Number.php +++ b/src/Element/Number.php @@ -23,9 +23,9 @@ class Number extends Element implements InputProviderInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'number', - ); + ]; /** * @var array @@ -43,7 +43,7 @@ protected function getValidators() return $this->validators; } - $validators = array(); + $validators = []; // HTML5 always transmits values in the format "1000.01", without a // thousand separator. The prior use of the i18n Float validator // allowed the thousand separator, which resulted in wrong numbers @@ -56,25 +56,25 @@ protected function getValidators() } if (isset($this->attributes['min'])) { - $validators[] = new GreaterThanValidator(array( + $validators[] = new GreaterThanValidator([ 'min' => $this->attributes['min'], 'inclusive' => $inclusive - )); + ]); } if (isset($this->attributes['max'])) { - $validators[] = new LessThanValidator(array( + $validators[] = new LessThanValidator([ 'max' => $this->attributes['max'], 'inclusive' => $inclusive - )); + ]); } if (!isset($this->attributes['step']) || 'any' !== $this->attributes['step'] ) { - $validators[] = new StepValidator(array( + $validators[] = new StepValidator([ 'baseValue' => (isset($this->attributes['min'])) ? $this->attributes['min'] : 0, 'step' => (isset($this->attributes['step'])) ? $this->attributes['step'] : 1, - )); + ]); } $this->validators = $validators; @@ -90,13 +90,13 @@ protected function getValidators() */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => true, - 'filters' => array( - array('name' => 'Zend\Filter\StringTrim') - ), + 'filters' => [ + ['name' => 'Zend\Filter\StringTrim'] + ], 'validators' => $this->getValidators(), - ); + ]; } } diff --git a/src/Element/Password.php b/src/Element/Password.php index 47b44947..03a58403 100644 --- a/src/Element/Password.php +++ b/src/Element/Password.php @@ -20,9 +20,9 @@ class Password extends Element implements ElementPrepareAwareInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'password', - ); + ]; /** * Remove the password before rendering if the form fails in order to avoid any security issue diff --git a/src/Element/Radio.php b/src/Element/Radio.php index e0b1de55..aba940c7 100644 --- a/src/Element/Radio.php +++ b/src/Element/Radio.php @@ -18,9 +18,9 @@ class Radio extends MultiCheckbox * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'radio' - ); + ]; /** * Get validator @@ -30,10 +30,10 @@ class Radio extends MultiCheckbox protected function getValidator() { if (null === $this->validator && !$this->disableInArrayValidator()) { - $this->validator = new InArrayValidator(array( + $this->validator = new InArrayValidator([ 'haystack' => $this->getValueOptionsValues(), 'strict' => false, - )); + ]); } return $this->validator; } diff --git a/src/Element/Range.php b/src/Element/Range.php index a4611cf5..0c3c4653 100644 --- a/src/Element/Range.php +++ b/src/Element/Range.php @@ -22,9 +22,9 @@ class Range extends NumberElement * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'range', - ); + ]; /** * Get validator @@ -37,7 +37,7 @@ protected function getValidators() return $this->validators; } - $validators = array(); + $validators = []; $validators[] = new NumberValidator(); $inclusive = true; @@ -45,23 +45,23 @@ protected function getValidators() $inclusive = $this->attributes['inclusive']; } - $validators[] = new GreaterThanValidator(array( + $validators[] = new GreaterThanValidator([ 'min' => (isset($this->attributes['min'])) ? $this->attributes['min'] : 0, 'inclusive' => $inclusive - )); + ]); - $validators[] = new LessThanValidator(array( + $validators[] = new LessThanValidator([ 'max' => (isset($this->attributes['max'])) ? $this->attributes['max'] : 100, 'inclusive' => $inclusive - )); + ]); if (!isset($this->attributes['step']) || 'any' !== $this->attributes['step'] ) { - $validators[] = new StepValidator(array( + $validators[] = new StepValidator([ 'baseValue' => (isset($this->attributes['min'])) ? $this->attributes['min'] : 0, 'step' => (isset($this->attributes['step'])) ? $this->attributes['step'] : 1, - )); + ]); } $this->validators = $validators; diff --git a/src/Element/Select.php b/src/Element/Select.php index 7417f645..25dcd5f6 100644 --- a/src/Element/Select.php +++ b/src/Element/Select.php @@ -24,9 +24,9 @@ class Select extends Element implements InputProviderInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'select', - ); + ]; /** * @var \Zend\Validator\ValidatorInterface @@ -48,7 +48,7 @@ class Select extends Element implements InputProviderInterface /** * @var array */ - protected $valueOptions = array(); + protected $valueOptions = []; /** * @var bool @@ -219,16 +219,16 @@ public function getEmptyOption() protected function getValidator() { if (null === $this->validator && !$this->disableInArrayValidator()) { - $validator = new InArrayValidator(array( + $validator = new InArrayValidator([ 'haystack' => $this->getValueOptionsValues(), 'strict' => false - )); + ]); if ($this->isMultiple()) { - $validator = new ExplodeValidator(array( + $validator = new ExplodeValidator([ 'validator' => $validator, 'valueDelimiter' => null, // skip explode if only one value - )); + ]); } $this->validator = $validator; @@ -287,33 +287,33 @@ public function getUnselectedValue() */ public function getInputSpecification() { - $spec = array( + $spec = [ 'name' => $this->getName(), 'required' => true, - ); + ]; if ($this->useHiddenElement() && $this->isMultiple()) { $unselectedValue = $this->getUnselectedValue(); $spec['allow_empty'] = true; $spec['continue_if_empty'] = true; - $spec['filters'] = array(array( + $spec['filters'] = [[ 'name' => 'Callback', - 'options' => array( + 'options' => [ 'callback' => function ($value) use ($unselectedValue) { if ($value === $unselectedValue) { - $value = array(); + $value = []; } return $value; } - ) - )); + ] + ]]; } if ($validator = $this->getValidator()) { - $spec['validators'] = array( + $spec['validators'] = [ $validator, - ); + ]; } return $spec; @@ -326,7 +326,7 @@ public function getInputSpecification() */ protected function getValueOptionsValues() { - $values = array(); + $values = []; $options = $this->getValueOptions(); foreach ($options as $key => $optionSpec) { if (is_array($optionSpec) && array_key_exists('options', $optionSpec)) { diff --git a/src/Element/Submit.php b/src/Element/Submit.php index b4360721..3114f1ea 100644 --- a/src/Element/Submit.php +++ b/src/Element/Submit.php @@ -18,7 +18,7 @@ class Submit extends Element * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'submit', - ); + ]; } diff --git a/src/Element/Text.php b/src/Element/Text.php index a1aeb2f9..7c10f8c4 100644 --- a/src/Element/Text.php +++ b/src/Element/Text.php @@ -18,7 +18,7 @@ class Text extends Element * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'text', - ); + ]; } diff --git a/src/Element/Textarea.php b/src/Element/Textarea.php index 82b63702..999c0147 100644 --- a/src/Element/Textarea.php +++ b/src/Element/Textarea.php @@ -18,7 +18,7 @@ class Textarea extends Element * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'textarea', - ); + ]; } diff --git a/src/Element/Time.php b/src/Element/Time.php index 26b1d5ed..ff1e7467 100644 --- a/src/Element/Time.php +++ b/src/Element/Time.php @@ -19,9 +19,9 @@ class Time extends DateTime * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'time', - ); + ]; /** * Default date format @@ -43,10 +43,10 @@ protected function getStepValidator() $baseValue = (isset($this->attributes['min'])) ? $this->attributes['min'] : date($format, 0); - return new DateStepValidator(array( + return new DateStepValidator([ 'format' => $format, 'baseValue' => $baseValue, 'step' => new DateInterval("PT{$stepValue}S"), - )); + ]); } } diff --git a/src/Element/Url.php b/src/Element/Url.php index f03b1713..d913349e 100644 --- a/src/Element/Url.php +++ b/src/Element/Url.php @@ -20,9 +20,9 @@ class Url extends Element implements InputProviderInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'url', - ); + ]; /** * @var \Zend\Validator\ValidatorInterface @@ -37,10 +37,10 @@ class Url extends Element implements InputProviderInterface public function getValidator() { if (null === $this->validator) { - $this->validator = new UriValidator(array( + $this->validator = new UriValidator([ 'allowAbsolute' => true, 'allowRelative' => false, - )); + ]); } return $this->validator; } @@ -54,15 +54,15 @@ public function getValidator() */ public function getInputSpecification() { - return array( + return [ 'name' => $this->getName(), 'required' => true, - 'filters' => array( - array('name' => 'Zend\Filter\StringTrim'), - ), - 'validators' => array( + 'filters' => [ + ['name' => 'Zend\Filter\StringTrim'], + ], + 'validators' => [ $this->getValidator(), - ), - ); + ], + ]; } } diff --git a/src/Element/Week.php b/src/Element/Week.php index 0fec5593..d0a5e59a 100644 --- a/src/Element/Week.php +++ b/src/Element/Week.php @@ -19,9 +19,9 @@ class Week extends DateTime * * @var array */ - protected $attributes = array( + protected $attributes = [ 'type' => 'week', - ); + ]; /** * Retrieves a Date Validator configured for a Week Input type @@ -46,10 +46,10 @@ protected function getStepValidator() $baseValue = (isset($this->attributes['min'])) ? $this->attributes['min'] : '1970-W01'; - return new DateStepValidator(array( + return new DateStepValidator([ 'format' => 'Y-\WW', 'baseValue' => $baseValue, 'step' => new \DateInterval("P{$stepValue}W"), - )); + ]); } } diff --git a/src/Factory.php b/src/Factory.php index 56834f9d..6f8deed2 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -339,8 +339,8 @@ protected function prepareAndInjectElements($elements, FieldsetInterface $fields continue; } - $flags = isset($elementSpecification['flags']) ? $elementSpecification['flags'] : array(); - $spec = isset($elementSpecification['spec']) ? $elementSpecification['spec'] : array(); + $flags = isset($elementSpecification['flags']) ? $elementSpecification['flags'] : []; + $spec = isset($elementSpecification['spec']) ? $elementSpecification['spec'] : []; if (!isset($spec['type'])) { $spec['type'] = 'Zend\Form\Element'; @@ -364,8 +364,8 @@ public function prepareAndInjectFieldsets($fieldsets, FieldsetInterface $masterF $fieldsets = $this->validateSpecification($fieldsets, $method); foreach ($fieldsets as $fieldsetSpecification) { - $flags = isset($fieldsetSpecification['flags']) ? $fieldsetSpecification['flags'] : array(); - $spec = isset($fieldsetSpecification['spec']) ? $fieldsetSpecification['spec'] : array(); + $flags = isset($fieldsetSpecification['flags']) ? $fieldsetSpecification['flags'] : []; + $spec = isset($fieldsetSpecification['spec']) ? $fieldsetSpecification['spec'] : []; $fieldset = $this->createFieldset($spec); $masterFieldset->add($fieldset, $flags); @@ -432,10 +432,10 @@ protected function prepareAndInjectHydrator($hydratorOrName, FieldsetInterface $ $method )); } - $hydratorOptions = (isset($hydratorOrName['options'])) ? $hydratorOrName['options'] : array(); + $hydratorOptions = (isset($hydratorOrName['options'])) ? $hydratorOrName['options'] : []; $hydratorOrName = $hydratorOrName['type']; } else { - $hydratorOptions = array(); + $hydratorOptions = []; } if (is_string($hydratorOrName)) { diff --git a/src/Fieldset.php b/src/Fieldset.php index 5074b59a..c2d23b98 100644 --- a/src/Fieldset.php +++ b/src/Fieldset.php @@ -26,17 +26,17 @@ class Fieldset extends Element implements FieldsetInterface /** * @var array */ - protected $elements = array(); + protected $elements = []; /** * @var array */ - protected $fieldsets = array(); + protected $fieldsets = []; /** * @var array */ - protected $messages = array(); + protected $messages = []; /** * @var PriorityList @@ -75,7 +75,7 @@ class Fieldset extends Element implements FieldsetInterface * @param null|int|string $name Optional name for the element * @param array $options Optional options for the element */ - public function __construct($name = null, $options = array()) + public function __construct($name = null, $options = []) { $this->iterator = new PriorityList(); $this->iterator->isLIFO(false); @@ -145,7 +145,7 @@ public function getFormFactory() * @return Fieldset|FieldsetInterface * @throws Exception\InvalidArgumentException */ - public function add($elementOrFieldset, array $flags = array()) + public function add($elementOrFieldset, array $flags = []) { if (is_array($elementOrFieldset) || ($elementOrFieldset instanceof Traversable && !$elementOrFieldset instanceof ElementInterface) @@ -325,7 +325,7 @@ public function setMessages($messages) public function getMessages($elementName = null) { if (null === $elementName) { - $messages = array(); + $messages = []; foreach ($this->iterator as $name => $element) { $messageSet = $element->getMessages(); if (!is_array($messageSet) @@ -405,7 +405,7 @@ public function populateValues($data) /* This ensures that collections with allow_remove don't re-create child * elements if they all were removed */ - $elementOrFieldset->populateValues(array()); + $elementOrFieldset->populateValues([]); continue; } } @@ -558,11 +558,11 @@ public function allowValueBinding() * @param array $values * @return mixed|void */ - public function bindValues(array $values = array()) + public function bindValues(array $values = []) { $objectData = $this->extract(); $hydrator = $this->getHydrator(); - $hydratableData = array(); + $hydratableData = []; foreach ($values as $name => $value) { if (!$this->has($name)) { @@ -620,19 +620,19 @@ public function useAsBaseFieldset() protected function extract() { if (!is_object($this->object)) { - return array(); + return []; } $hydrator = $this->getHydrator(); if (!$hydrator instanceof Hydrator\HydratorInterface) { - return array(); + return []; } $values = $hydrator->extract($this->object); if (!is_array($values)) { // Do nothing if the hydrator returned a non-array - return array(); + return []; } // Recursively extract and populate values for nested fieldsets @@ -661,8 +661,8 @@ public function __clone() { $items = $this->iterator->toArray(PriorityList::EXTR_BOTH); - $this->elements = array(); - $this->fieldsets = array(); + $this->elements = []; + $this->fieldsets = []; $this->iterator = new PriorityList(); $this->iterator->isLIFO(false); diff --git a/src/FieldsetInterface.php b/src/FieldsetInterface.php index f4adab4f..ca112524 100644 --- a/src/FieldsetInterface.php +++ b/src/FieldsetInterface.php @@ -32,7 +32,7 @@ interface FieldsetInterface extends * @param array $flags * @return FieldsetInterface */ - public function add($elementOrFieldset, array $flags = array()); + public function add($elementOrFieldset, array $flags = []); /** * Does the fieldset have an element/fieldset by the given name? @@ -137,7 +137,7 @@ public function getHydrator(); * @param array $values * @return mixed */ - public function bindValues(array $values = array()); + public function bindValues(array $values = []); /** * Checks if this fieldset can bind data diff --git a/src/Form.php b/src/Form.php index 886f94ed..dfea9d63 100644 --- a/src/Form.php +++ b/src/Form.php @@ -28,9 +28,9 @@ class Form extends Fieldset implements FormInterface * * @var array */ - protected $attributes = array( + protected $attributes = [ 'method' => 'POST', - ); + ]; /** * How to bind values to the attached object @@ -165,7 +165,7 @@ public function setOptions($options) * @param array $flags * @return self */ - public function add($elementOrFieldset, array $flags = array()) + 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 @@ -283,7 +283,7 @@ public function setData($data) */ public function bind($object, $flags = FormInterface::VALUES_NORMALIZED) { - if (!in_array($flags, array(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__, @@ -328,7 +328,7 @@ public function setHydrator(HydratorInterface $hydrator) * @param array $values * @return mixed */ - public function bindValues(array $values = array()) + public function bindValues(array $values = []) { if (!is_object($this->object)) { if ($this->baseFieldset === null || $this->baseFieldset->allowValueBinding() == false) { @@ -376,7 +376,7 @@ public function bindValues(array $values = array()) */ protected function prepareBindData(array $values, array $match) { - $data = array(); + $data = []; foreach ($values as $name => $value) { if (!array_key_exists($name, $match)) { continue; @@ -400,7 +400,7 @@ protected function prepareBindData(array $values, array $match) */ public function setBindOnValidate($bindOnValidateFlag) { - if (!in_array($bindOnValidateFlag, array(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__, @@ -628,7 +628,7 @@ protected function prepareValidationGroup(FieldsetInterface $formOrFieldset, arr continue; } - $values = array(); + $values = []; if (isset($data[$key])) { foreach (array_keys($data[$key]) as $cKey) { @@ -640,7 +640,7 @@ protected function prepareValidationGroup(FieldsetInterface $formOrFieldset, arr } if (!isset($data[$key])) { - $data[$key] = array(); + $data[$key] = []; } $this->prepareValidationGroup($fieldset, $data[$key], $validationGroup[$key]); } @@ -774,7 +774,7 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie continue; } // Create a new empty default input for this element - $spec = array('name' => $name, 'required' => false); + $spec = ['name' => $name, 'required' => false]; $input = $inputFactory->createInput($spec); } else { // Create an input based on the specification returned from the element diff --git a/src/FormAbstractServiceFactory.php b/src/FormAbstractServiceFactory.php index cc66abf8..f99a8b8a 100644 --- a/src/FormAbstractServiceFactory.php +++ b/src/FormAbstractServiceFactory.php @@ -79,7 +79,7 @@ protected function getConfig(ServiceLocatorInterface $services) } if (!$services->has('Config')) { - $this->config = array(); + $this->config = []; return $this->config; } @@ -87,7 +87,7 @@ protected function getConfig(ServiceLocatorInterface $services) if (!isset($config[$this->configKey]) || !is_array($config[$this->configKey]) ) { - $this->config = array(); + $this->config = []; return $this->config; } diff --git a/src/FormElementManager.php b/src/FormElementManager.php index 34244da4..d950fd1d 100644 --- a/src/FormElementManager.php +++ b/src/FormElementManager.php @@ -27,7 +27,7 @@ class FormElementManager extends AbstractPluginManager * * @var array */ - protected $invokableClasses = array( + protected $invokableClasses = [ 'button' => 'Zend\Form\Element\Button', 'captcha' => 'Zend\Form\Element\Captcha', 'checkbox' => 'Zend\Form\Element\Checkbox', @@ -60,7 +60,7 @@ class FormElementManager extends AbstractPluginManager 'time' => 'Zend\Form\Element\Time', 'url' => 'Zend\Form\Element\Url', 'week' => 'Zend\Form\Element\Week', - ); + ]; /** * Don't share form elements by default @@ -76,8 +76,8 @@ public function __construct(ConfigInterface $configuration = null) { parent::__construct($configuration); - $this->addInitializer(array($this, 'injectFactory')); - $this->addInitializer(array($this, 'callElementInit'), false); + $this->addInitializer([$this, 'injectFactory']); + $this->addInitializer([$this, 'callElementInit'], false); } /** @@ -145,10 +145,10 @@ public function validatePlugin($plugin) * @param bool $usePeeringServiceManagers * @return object */ - public function get($name, $options = array(), $usePeeringServiceManagers = true) + public function get($name, $options = [], $usePeeringServiceManagers = true) { if (is_string($options)) { - $options = array('name' => $options); + $options = ['name' => $options]; } return parent::get($name, $options, $usePeeringServiceManagers); } diff --git a/src/InputFilterProviderFieldset.php b/src/InputFilterProviderFieldset.php index 74b291b1..6afcac49 100644 --- a/src/InputFilterProviderFieldset.php +++ b/src/InputFilterProviderFieldset.php @@ -19,7 +19,7 @@ class InputFilterProviderFieldset extends Fieldset implements InputFilterProvide * * @var array|Traversable */ - protected $filterSpec = array(); + protected $filterSpec = []; /** * @return array|Traversable diff --git a/src/LabelAwareTrait.php b/src/LabelAwareTrait.php index 545065d6..198620db 100644 --- a/src/LabelAwareTrait.php +++ b/src/LabelAwareTrait.php @@ -25,7 +25,7 @@ trait LabelAwareTrait * * @var array */ - protected $labelOptions = array(); + protected $labelOptions = []; /** * Set the attributes to use with the label @@ -90,7 +90,7 @@ public function getLabelOptions() */ public function clearLabelOptions() { - $this->labelOptions = array(); + $this->labelOptions = []; return $this; } diff --git a/src/View/Helper/AbstractHelper.php b/src/View/Helper/AbstractHelper.php index 5d952b68..312a2f8a 100644 --- a/src/View/Helper/AbstractHelper.php +++ b/src/View/Helper/AbstractHelper.php @@ -25,25 +25,25 @@ abstract class AbstractHelper extends BaseAbstractHelper * * @var array */ - protected $booleanAttributes = array( - 'autofocus' => array('on' => 'autofocus', 'off' => ''), - 'checked' => array('on' => 'checked', 'off' => ''), - 'disabled' => array('on' => 'disabled', 'off' => ''), - 'multiple' => array('on' => 'multiple', 'off' => ''), - 'readonly' => array('on' => 'readonly', 'off' => ''), - 'required' => array('on' => 'required', 'off' => ''), - 'selected' => array('on' => 'selected', 'off' => ''), - ); + protected $booleanAttributes = [ + 'autofocus' => ['on' => 'autofocus', 'off' => ''], + 'checked' => ['on' => 'checked', 'off' => ''], + 'disabled' => ['on' => 'disabled', 'off' => ''], + 'multiple' => ['on' => 'multiple', 'off' => ''], + 'readonly' => ['on' => 'readonly', 'off' => ''], + 'required' => ['on' => 'required', 'off' => ''], + 'selected' => ['on' => 'selected', 'off' => ''], + ]; /** * Translatable attributes * * @var array */ - protected $translatableAttributes = array( + protected $translatableAttributes = [ 'placeholder' => true, 'title' => true, - ); + ]; /** * @var Doctype @@ -65,7 +65,7 @@ abstract class AbstractHelper extends BaseAbstractHelper * * @var array */ - protected $validGlobalAttributes = array( + protected $validGlobalAttributes = [ 'accesskey' => true, 'class' => true, 'contenteditable' => true, @@ -139,7 +139,7 @@ abstract class AbstractHelper extends BaseAbstractHelper 'xml:base' => true, 'xml:lang' => true, 'xml:space' => true, - ); + ]; /** * Attributes valid for the tag represented by this helper @@ -148,8 +148,8 @@ abstract class AbstractHelper extends BaseAbstractHelper * * @var array */ - protected $validTagAttributes = array( - ); + protected $validTagAttributes = [ + ]; /** * Set value for doctype @@ -209,7 +209,7 @@ public function createAttributesString(array $attributes) $attributes = $this->prepareAttributes($attributes); $escape = $this->getEscapeHtmlHelper(); $escapeAttr = $this->getEscapeHtmlAttrHelper(); - $strings = array(); + $strings = []; foreach ($attributes as $key => $value) { $key = strtolower($key); diff --git a/src/View/Helper/Captcha/AbstractWord.php b/src/View/Helper/Captcha/AbstractWord.php index 10d9032f..aa7796e3 100644 --- a/src/View/Helper/Captcha/AbstractWord.php +++ b/src/View/Helper/Captcha/AbstractWord.php @@ -159,7 +159,7 @@ protected function renderCaptchaInput(CaptchaAdapter $captcha, array $attributes public function setCaptchaPosition($captchaPosition) { $captchaPosition = strtolower($captchaPosition); - if (!in_array($captchaPosition, array(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/Image.php b/src/View/Helper/Captcha/Image.php index f2e6fd05..1bde5176 100644 --- a/src/View/Helper/Captcha/Image.php +++ b/src/View/Helper/Captcha/Image.php @@ -35,12 +35,12 @@ public function render(ElementInterface $element) $captcha->generate(); - $imgAttributes = array( + $imgAttributes = [ 'width' => $captcha->getWidth(), 'height' => $captcha->getHeight(), 'alt' => $captcha->getImgAlt(), 'src' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(), - ); + ]; if ($element->hasAttribute('id')) { $imgAttributes['id'] = $element->getAttribute('id') . '-image'; diff --git a/src/View/Helper/Captcha/ReCaptcha.php b/src/View/Helper/Captcha/ReCaptcha.php index eb7aaa5f..1b36ddee 100644 --- a/src/View/Helper/Captcha/ReCaptcha.php +++ b/src/View/Helper/Captcha/ReCaptcha.php @@ -80,16 +80,16 @@ protected function renderHiddenInput($challengeName, $challengeId, $responseName $pattern = 'getInlineClosingBracket(); - $attributes = $this->createAttributesString(array( + $attributes = $this->createAttributesString([ 'name' => $challengeName, 'id' => $challengeId, - )); + ]); $challenge = sprintf($pattern, $attributes, $closingBracket); - $attributes = $this->createAttributesString(array( + $attributes = $this->createAttributesString([ 'name' => $responseName, 'id' => $responseId, - )); + ]); $response = sprintf($pattern, $attributes, $closingBracket); return $challenge . $response; diff --git a/src/View/Helper/File/FormFileUploadProgress.php b/src/View/Helper/File/FormFileUploadProgress.php index 515d9721..919f81cc 100644 --- a/src/View/Helper/File/FormFileUploadProgress.php +++ b/src/View/Helper/File/FormFileUploadProgress.php @@ -38,12 +38,12 @@ public function __invoke(ElementInterface $element = null) */ public function renderHiddenId() { - $attributes = array( + $attributes = [ 'id' => 'progress_key', 'name' => $this->getName(), 'type' => 'hidden', 'value' => $this->getValue() - ); + ]; return sprintf( ' true, 'action' => true, 'autocomplete' => true, @@ -32,7 +32,7 @@ class Form extends AbstractHelper 'name' => true, 'novalidate' => true, 'target' => true, - ); + ]; /** * Invoke as function @@ -83,13 +83,13 @@ public function render(FormInterface $form) public function openTag(FormInterface $form = null) { $doctype = $this->getDoctype(); - $attributes = array(); + $attributes = []; if (! (Doctype::HTML5 === $doctype || Doctype::XHTML5 === $doctype)) { - $attributes = array( + $attributes = [ 'action' => '', 'method' => 'get', - ); + ]; } if ($form instanceof FormInterface) { diff --git a/src/View/Helper/FormButton.php b/src/View/Helper/FormButton.php index 74de9f93..83520142 100644 --- a/src/View/Helper/FormButton.php +++ b/src/View/Helper/FormButton.php @@ -20,7 +20,7 @@ class FormButton extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autofocus' => true, 'disabled' => true, @@ -32,18 +32,18 @@ class FormButton extends FormInput 'formtarget' => true, 'type' => true, 'value' => true, - ); + ]; /** * Valid values for the button type * * @var array */ - protected $validTypes = array( + protected $validTypes = [ 'button' => true, 'reset' => true, 'submit' => true, - ); + ]; /** * Invoke helper as functor diff --git a/src/View/Helper/FormCheckbox.php b/src/View/Helper/FormCheckbox.php index aee31bff..62c0f468 100644 --- a/src/View/Helper/FormCheckbox.php +++ b/src/View/Helper/FormCheckbox.php @@ -57,11 +57,11 @@ public function render(ElementInterface $element) ); if ($element->useHiddenElement()) { - $hiddenAttributes = array( + $hiddenAttributes = [ 'disabled' => isset($attributes['disabled']) ? $attributes['disabled'] : false, 'name' => $attributes['name'], 'value' => $element->getUncheckedValue(), - ); + ]; $rendered = sprintf( ' true, 'autocomplete' => true, 'autofocus' => true, @@ -27,7 +27,7 @@ class FormColor extends FormInput 'list' => true, 'type' => true, 'value' => true, - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormDateSelect.php b/src/View/Helper/FormDateSelect.php index be21bbc0..5625e192 100644 --- a/src/View/Helper/FormDateSelect.php +++ b/src/View/Helper/FormDateSelect.php @@ -60,7 +60,7 @@ public function render(ElementInterface $element) $monthElement->setEmptyOption(''); } - $data = array(); + $data = []; $data[$pattern['day']] = $selectHelper->render($dayElement); $data[$pattern['month']] = $selectHelper->render($monthElement); $data[$pattern['year']] = $selectHelper->render($yearElement); @@ -90,7 +90,7 @@ protected function getDaysOptions($pattern) $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern); $date = new DateTime('1970-01-01'); - $result = array(); + $result = []; for ($day = 1; $day <= 31; $day++) { $key = $keyFormatter->format($date->getTimestamp()); $value = $valueFormatter->format($date->getTimestamp()); diff --git a/src/View/Helper/FormDateTime.php b/src/View/Helper/FormDateTime.php index 3bc62e4e..47930dc8 100644 --- a/src/View/Helper/FormDateTime.php +++ b/src/View/Helper/FormDateTime.php @@ -18,7 +18,7 @@ class FormDateTime extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autocomplete' => true, 'autofocus' => true, @@ -32,7 +32,7 @@ class FormDateTime extends FormInput 'step' => true, 'type' => true, 'value' => true, - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormDateTimeSelect.php b/src/View/Helper/FormDateTimeSelect.php index 31048b92..3b23900a 100644 --- a/src/View/Helper/FormDateTimeSelect.php +++ b/src/View/Helper/FormDateTimeSelect.php @@ -119,7 +119,7 @@ public function render(ElementInterface $element) $secondElement->setEmptyOption(''); } - $data = array(); + $data = []; $data[$pattern['day']] = $selectHelper->render($dayElement); $data[$pattern['month']] = $selectHelper->render($monthElement); $data[$pattern['year']] = $selectHelper->render($yearElement); @@ -200,7 +200,7 @@ protected function parsePattern($renderDelimiters = true) $pattern = $this->getPattern(); $pregResult = preg_split("/([ -,.:\/]*'.*?'[ -,.:\/]*)|([ -,.:\/]+)/", $pattern, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - $result = array(); + $result = []; foreach ($pregResult as $value) { if (stripos($value, "'") === false && stripos($value, 'd') !== false) { $result['day'] = $value; @@ -237,7 +237,7 @@ protected function getHoursOptions($pattern) $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern); $date = new DateTime('1970-01-01 00:00:00'); - $result = array(); + $result = []; for ($hour = 1; $hour <= 24; $hour++) { $key = $keyFormatter->format($date); $value = $valueFormatter->format($date); @@ -261,7 +261,7 @@ protected function getMinutesOptions($pattern) $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern); $date = new DateTime('1970-01-01 00:00:00'); - $result = array(); + $result = []; for ($min = 1; $min <= 60; $min++) { $key = $keyFormatter->format($date); $value = $valueFormatter->format($date); @@ -285,7 +285,7 @@ protected function getSecondsOptions($pattern) $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern); $date = new DateTime('1970-01-01 00:00:00'); - $result = array(); + $result = []; for ($sec = 1; $sec <= 60; $sec++) { $key = $keyFormatter->format($date); $value = $valueFormatter->format($date); diff --git a/src/View/Helper/FormElement.php b/src/View/Helper/FormElement.php index 8327d18f..84e17068 100644 --- a/src/View/Helper/FormElement.php +++ b/src/View/Helper/FormElement.php @@ -21,7 +21,7 @@ class FormElement extends BaseAbstractHelper * * @var array */ - protected $classMap = array( + protected $classMap = [ 'Zend\Form\Element\Button' => 'formbutton', 'Zend\Form\Element\Captcha' => 'formcaptcha', 'Zend\Form\Element\Csrf' => 'formhidden', @@ -29,14 +29,14 @@ class FormElement extends BaseAbstractHelper 'Zend\Form\Element\DateTimeSelect' => 'formdatetimeselect', 'Zend\Form\Element\DateSelect' => 'formdateselect', 'Zend\Form\Element\MonthSelect' => 'formmonthselect', - ); + ]; /** * Type map to view helper * * @var array */ - protected $typeMap = array( + protected $typeMap = [ 'checkbox' => 'formcheckbox', 'color' => 'formcolor', 'date' => 'formdate', @@ -62,7 +62,7 @@ class FormElement extends BaseAbstractHelper 'time' => 'formtime', 'url' => 'formurl', 'week' => 'formweek', - ); + ]; /** * Default helper name diff --git a/src/View/Helper/FormElementErrors.php b/src/View/Helper/FormElementErrors.php index 15fe08ff..fa6f0a8d 100644 --- a/src/View/Helper/FormElementErrors.php +++ b/src/View/Helper/FormElementErrors.php @@ -26,7 +26,7 @@ class FormElementErrors extends AbstractHelper /** * @var array Default attributes for the open format tag */ - protected $attributes = array(); + protected $attributes = []; /** * Invoke helper as functor @@ -37,7 +37,7 @@ class FormElementErrors extends AbstractHelper * @param array $attributes * @return string|FormElementErrors */ - public function __invoke(ElementInterface $element = null, array $attributes = array()) + public function __invoke(ElementInterface $element = null, array $attributes = []) { if (!$element) { return $this; @@ -54,7 +54,7 @@ public function __invoke(ElementInterface $element = null, array $attributes = a * @throws Exception\DomainException * @return string */ - public function render(ElementInterface $element, array $attributes = array()) + public function render(ElementInterface $element, array $attributes = []) { $messages = $element->getMessages(); if (empty($messages)) { @@ -77,7 +77,7 @@ public function render(ElementInterface $element, array $attributes = array()) // Flatten message array $escapeHtml = $this->getEscapeHtmlHelper(); - $messagesToPrint = array(); + $messagesToPrint = []; array_walk_recursive($messages, function ($item) use (&$messagesToPrint, $escapeHtml) { $messagesToPrint[] = $escapeHtml($item); }); diff --git a/src/View/Helper/FormEmail.php b/src/View/Helper/FormEmail.php index 2ffb3142..1d06166e 100644 --- a/src/View/Helper/FormEmail.php +++ b/src/View/Helper/FormEmail.php @@ -18,7 +18,7 @@ class FormEmail extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autocomplete' => true, 'autofocus' => true, @@ -34,7 +34,7 @@ class FormEmail extends FormInput 'size' => true, 'type' => true, 'value' => true, - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormFile.php b/src/View/Helper/FormFile.php index 6fbdfab6..dff32616 100644 --- a/src/View/Helper/FormFile.php +++ b/src/View/Helper/FormFile.php @@ -19,7 +19,7 @@ class FormFile extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'accept' => true, 'autofocus' => true, @@ -28,7 +28,7 @@ class FormFile extends FormInput 'multiple' => true, 'required' => true, 'type' => true, - ); + ]; /** * Render a form element from the provided $element diff --git a/src/View/Helper/FormHidden.php b/src/View/Helper/FormHidden.php index c041ad97..48371dea 100644 --- a/src/View/Helper/FormHidden.php +++ b/src/View/Helper/FormHidden.php @@ -18,13 +18,13 @@ class FormHidden extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'disabled' => true, 'form' => true, 'type' => true, 'value' => true, - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormImage.php b/src/View/Helper/FormImage.php index 7a0577b5..2835103c 100644 --- a/src/View/Helper/FormImage.php +++ b/src/View/Helper/FormImage.php @@ -19,7 +19,7 @@ class FormImage extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'alt' => true, 'autofocus' => true, @@ -34,7 +34,7 @@ class FormImage extends FormInput 'src' => true, 'type' => true, 'width' => true, - ); + ]; /** * Render a form element from the provided $element diff --git a/src/View/Helper/FormInput.php b/src/View/Helper/FormInput.php index e7346159..9aaf4866 100644 --- a/src/View/Helper/FormInput.php +++ b/src/View/Helper/FormInput.php @@ -19,7 +19,7 @@ class FormInput extends AbstractHelper * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'accept' => true, 'alt' => true, @@ -50,14 +50,14 @@ class FormInput extends AbstractHelper 'type' => true, 'value' => true, 'width' => true, - ); + ]; /** * Valid values for the input type * * @var array */ - protected $validTypes = array( + protected $validTypes = [ 'text' => true, 'button' => true, 'checkbox' => true, @@ -82,7 +82,7 @@ class FormInput extends AbstractHelper 'time' => true, 'url' => true, 'week' => true, - ); + ]; /** * Invoke helper as functor diff --git a/src/View/Helper/FormLabel.php b/src/View/Helper/FormLabel.php index b512c5d2..955e01e5 100644 --- a/src/View/Helper/FormLabel.php +++ b/src/View/Helper/FormLabel.php @@ -23,10 +23,10 @@ class FormLabel extends AbstractHelper * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'for' => true, 'form' => true, - ); + ]; /** * Generate a form label, optionally with content @@ -124,12 +124,12 @@ public function openTag($attributesOrElement = null) )); } - $labelAttributes = array(); + $labelAttributes = []; if ($attributesOrElement instanceof LabelAwareInterface) { $labelAttributes = $attributesOrElement->getLabelAttributes(); } - $attributes = array('for' => $id); + $attributes = ['for' => $id]; if (!empty($labelAttributes)) { $attributes = array_merge($labelAttributes, $attributes); diff --git a/src/View/Helper/FormMonthSelect.php b/src/View/Helper/FormMonthSelect.php index dc0fe3dd..a0f3a4b3 100644 --- a/src/View/Helper/FormMonthSelect.php +++ b/src/View/Helper/FormMonthSelect.php @@ -130,7 +130,7 @@ public function render(ElementInterface $element) $yearElement->setEmptyOption(''); } - $data = array(); + $data = []; $data[$pattern['month']] = $selectHelper->render($monthElement); $data[$pattern['year']] = $selectHelper->render($yearElement); @@ -158,7 +158,7 @@ protected function parsePattern($renderDelimiters = true) $pattern = $this->getPattern(); $pregResult = preg_split("/([ -,.\/]*(?:'[a-zA-Z]+')*[ -,.\/]+)/", $pattern, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - $result = array(); + $result = []; foreach ($pregResult as $value) { if (stripos($value, "'") === false && stripos($value, 'd') !== false) { $result['day'] = $value; @@ -255,7 +255,7 @@ protected function getMonthsOptions($pattern) $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern); $date = new DateTime('1970-01-01'); - $result = array(); + $result = []; for ($month = 1; $month <= 12; $month++) { $key = $keyFormatter->format($date->getTimestamp()); $value = $valueFormatter->format($date->getTimestamp()); @@ -278,7 +278,7 @@ protected function getMonthsOptions($pattern) */ protected function getYearsOptions($minYear, $maxYear) { - $result = array(); + $result = []; for ($i = $maxYear; $i >= $minYear; --$i) { $result[$i] = $i; } diff --git a/src/View/Helper/FormMultiCheckbox.php b/src/View/Helper/FormMultiCheckbox.php index 2fd1d80b..3d5e49d9 100644 --- a/src/View/Helper/FormMultiCheckbox.php +++ b/src/View/Helper/FormMultiCheckbox.php @@ -144,7 +144,7 @@ protected function renderOptions(MultiCheckboxElement $element, array $options, $labelHelper = $this->getLabelHelper(); $labelClose = $labelHelper->closeTag(); $labelPosition = $this->getLabelPosition(); - $globalLabelAttributes = array(); + $globalLabelAttributes = []; $closingBracket = $this->getInlineClosingBracket(); if ($element instanceof LabelAwareInterface) { @@ -155,7 +155,7 @@ protected function renderOptions(MultiCheckboxElement $element, array $options, $globalLabelAttributes = $this->labelAttributes; } - $combinedMarkup = array(); + $combinedMarkup = []; $count = 0; foreach ($options as $key => $optionSpec) { @@ -172,10 +172,10 @@ protected function renderOptions(MultiCheckboxElement $element, array $options, $disabled = (isset($inputAttributes['disabled']) && $inputAttributes['disabled']); if (is_scalar($optionSpec)) { - $optionSpec = array( + $optionSpec = [ 'label' => $optionSpec, 'value' => $key - ); + ]; } if (isset($optionSpec['value'])) { @@ -257,10 +257,10 @@ protected function renderHiddenElement(MultiCheckboxElement $element, array $att ? $element->getUncheckedValue() : $this->uncheckedValue; - $hiddenAttributes = array( + $hiddenAttributes = [ 'name' => $element->getName(), 'value' => $uncheckedValue, - ); + ]; return sprintf( ' true, 'autocomplete' => true, 'autofocus' => true, @@ -33,7 +33,7 @@ class FormNumber extends FormInput 'required' => true, 'type' => true, 'value' => true - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormPassword.php b/src/View/Helper/FormPassword.php index cbd78228..287f7d29 100644 --- a/src/View/Helper/FormPassword.php +++ b/src/View/Helper/FormPassword.php @@ -18,7 +18,7 @@ class FormPassword extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autocomplete' => true, 'autofocus' => true, @@ -32,7 +32,7 @@ class FormPassword extends FormInput 'size' => true, 'type' => true, 'value' => true, - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormRange.php b/src/View/Helper/FormRange.php index b1cbd9dd..f84b9449 100644 --- a/src/View/Helper/FormRange.php +++ b/src/View/Helper/FormRange.php @@ -18,7 +18,7 @@ class FormRange extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autocomplete' => true, 'autofocus' => true, @@ -31,7 +31,7 @@ class FormRange extends FormInput 'required' => true, 'type' => true, 'value' => true - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormReset.php b/src/View/Helper/FormReset.php index 22aed0b6..f8d5ab41 100644 --- a/src/View/Helper/FormReset.php +++ b/src/View/Helper/FormReset.php @@ -19,23 +19,23 @@ class FormReset extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autofocus' => true, 'disabled' => true, 'form' => true, 'type' => true, 'value' => true, - ); + ]; /** * Translatable attributes * * @var array */ - protected $translatableAttributes = array( + protected $translatableAttributes = [ 'value' => true - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormRow.php b/src/View/Helper/FormRow.php index 715b8b00..5925a39e 100644 --- a/src/View/Helper/FormRow.php +++ b/src/View/Helper/FormRow.php @@ -145,13 +145,13 @@ public function render(ElementInterface $element, $labelPosition = null) } if ($this->partial) { - $vars = array( + $vars = [ 'element' => $element, 'label' => $label, 'labelAttributes' => $this->labelAttributes, 'labelPosition' => $labelPosition, 'renderErrors' => $this->renderErrors, - ); + ]; return $this->view->render($this->partial, $vars); } @@ -165,7 +165,7 @@ public function render(ElementInterface $element, $labelPosition = null) // hidden elements do not need a -https://github.com/zendframework/zf2/issues/5607 $type = $element->getAttribute('type'); if (isset($label) && '' !== $label && $type !== 'hidden') { - $labelAttributes = array(); + $labelAttributes = []; if ($element instanceof LabelAwareInterface) { $labelAttributes = $element->getLabelAttributes(); @@ -299,7 +299,7 @@ public function getLabelAttributes() public function setLabelPosition($labelPosition) { $labelPosition = strtolower($labelPosition); - if (!in_array($labelPosition, array(self::LABEL_APPEND, self::LABEL_PREPEND))) { + if (!in_array($labelPosition, [self::LABEL_APPEND, self::LABEL_PREPEND])) { throw new Exception\InvalidArgumentException(sprintf( '%s expects either %s::LABEL_APPEND or %s::LABEL_PREPEND; received "%s"', __METHOD__, diff --git a/src/View/Helper/FormSelect.php b/src/View/Helper/FormSelect.php index e2d99762..ff00d2de 100644 --- a/src/View/Helper/FormSelect.php +++ b/src/View/Helper/FormSelect.php @@ -31,7 +31,7 @@ class FormSelect extends AbstractHelper * * @var array */ - protected $validSelectAttributes = array( + protected $validSelectAttributes = [ 'name' => true, 'autocomplete' => true, 'autofocus' => true, @@ -40,33 +40,33 @@ class FormSelect extends AbstractHelper 'multiple' => true, 'required' => true, 'size' => true - ); + ]; /** * Attributes valid for options * * @var array */ - protected $validOptionAttributes = array( + protected $validOptionAttributes = [ 'disabled' => true, 'selected' => true, 'label' => true, 'value' => true, - ); + ]; /** * Attributes valid for option groups * * @var array */ - protected $validOptgroupAttributes = array( + protected $validOptgroupAttributes = [ 'disabled' => true, 'label' => true, - ); + ]; - protected $translatableAttributes = array( + protected $translatableAttributes = [ 'label' => true, - ); + ]; /** * @var FormHidden|null @@ -118,7 +118,7 @@ public function render(ElementInterface $element) $options = $element->getValueOptions(); if (($emptyOption = $element->getEmptyOption()) !== null) { - $options = array('' => $emptyOption) + $options; + $options = ['' => $emptyOption] + $options; } $attributes = $element->getAttributes(); @@ -166,10 +166,10 @@ public function render(ElementInterface $element) * @param array $selectedOptions Option values that should be marked as selected * @return string */ - public function renderOptions(array $options, array $selectedOptions = array()) + public function renderOptions(array $options, array $selectedOptions = []) { $template = '%s'; - $optionStrings = array(); + $optionStrings = []; $escapeHtml = $this->getEscapeHtmlHelper(); foreach ($options as $key => $optionSpec) { @@ -179,10 +179,10 @@ public function renderOptions(array $options, array $selectedOptions = array()) $disabled = false; if (is_scalar($optionSpec)) { - $optionSpec = array( + $optionSpec = [ 'label' => $optionSpec, 'value' => $key - ); + ]; } if (isset($optionSpec['options']) && is_array($optionSpec['options'])) { @@ -242,11 +242,11 @@ public function renderOptions(array $options, array $selectedOptions = array()) * @param array $selectedOptions * @return string */ - public function renderOptgroup(array $optgroup, array $selectedOptions = array()) + public function renderOptgroup(array $optgroup, array $selectedOptions = []) { $template = '%s'; - $options = array(); + $options = []; if (isset($optgroup['options']) && is_array($optgroup['options'])) { $options = $optgroup['options']; unset($optgroup['options']); @@ -281,7 +281,7 @@ public function renderOptgroup(array $optgroup, array $selectedOptions = array() protected function validateMultiValue($value, array $attributes) { if (null === $value) { - return array(); + return []; } if (!is_array($value)) { diff --git a/src/View/Helper/FormSubmit.php b/src/View/Helper/FormSubmit.php index 2dbd4347..02a91eb7 100644 --- a/src/View/Helper/FormSubmit.php +++ b/src/View/Helper/FormSubmit.php @@ -19,7 +19,7 @@ class FormSubmit extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autofocus' => true, 'disabled' => true, @@ -31,16 +31,16 @@ class FormSubmit extends FormInput 'formtarget' => true, 'type' => true, 'value' => true, - ); + ]; /** * Translatable attributes * * @var array */ - protected $translatableAttributes = array( + protected $translatableAttributes = [ 'value' => true - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormTel.php b/src/View/Helper/FormTel.php index de1fc356..67bf308d 100644 --- a/src/View/Helper/FormTel.php +++ b/src/View/Helper/FormTel.php @@ -18,7 +18,7 @@ class FormTel extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autocomplete' => true, 'autofocus' => true, @@ -33,7 +33,7 @@ class FormTel extends FormInput 'size' => true, 'type' => true, 'value' => true, - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormText.php b/src/View/Helper/FormText.php index 2f39a471..d1600471 100644 --- a/src/View/Helper/FormText.php +++ b/src/View/Helper/FormText.php @@ -18,7 +18,7 @@ class FormText extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autocomplete' => true, 'autofocus' => true, @@ -34,7 +34,7 @@ class FormText extends FormInput 'size' => true, 'type' => true, 'value' => true, - ); + ]; /** * Determine input type to use diff --git a/src/View/Helper/FormTextarea.php b/src/View/Helper/FormTextarea.php index 114a408c..c03d93a7 100644 --- a/src/View/Helper/FormTextarea.php +++ b/src/View/Helper/FormTextarea.php @@ -19,7 +19,7 @@ class FormTextarea extends AbstractHelper * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'autocomplete' => true, 'autofocus' => true, 'cols' => true, @@ -33,7 +33,7 @@ class FormTextarea extends AbstractHelper 'required' => true, 'rows' => true, 'wrap' => true, - ); + ]; /** * Invoke helper as functor diff --git a/src/View/Helper/FormUrl.php b/src/View/Helper/FormUrl.php index a386debb..80e29440 100644 --- a/src/View/Helper/FormUrl.php +++ b/src/View/Helper/FormUrl.php @@ -18,7 +18,7 @@ class FormUrl extends FormInput * * @var array */ - protected $validTagAttributes = array( + protected $validTagAttributes = [ 'name' => true, 'autocomplete' => true, 'autofocus' => true, @@ -33,7 +33,7 @@ class FormUrl extends FormInput 'size' => true, 'type' => true, 'value' => true, - ); + ]; /** * Determine input type to use diff --git a/src/View/HelperConfig.php b/src/View/HelperConfig.php index 4a425e2f..46a97093 100644 --- a/src/View/HelperConfig.php +++ b/src/View/HelperConfig.php @@ -22,7 +22,7 @@ class HelperConfig implements ConfigInterface * * @var array */ - protected $invokables = array( + protected $invokables = [ 'form' => 'Zend\Form\View\Helper\Form', 'formbutton' => 'Zend\Form\View\Helper\FormButton', 'formcaptcha' => 'Zend\Form\View\Helper\FormCaptcha', @@ -71,7 +71,7 @@ class HelperConfig implements ConfigInterface 'formtime' => 'Zend\Form\View\Helper\FormTime', 'formurl' => 'Zend\Form\View\Helper\FormUrl', 'formweek' => 'Zend\Form\View\Helper\FormWeek', - ); + ]; /** * Configure the provided service manager instance with the configuration diff --git a/test/Annotation/AnnotationBuilderTest.php b/test/Annotation/AnnotationBuilderTest.php index bb85e5a7..b0d8f934 100644 --- a/test/Annotation/AnnotationBuilderTest.php +++ b/test/Annotation/AnnotationBuilderTest.php @@ -39,7 +39,7 @@ public function testCanCreateFormFromStandardEntity() $this->assertInstanceOf('Zend\Form\Element', $password); $attributes = $password->getAttributes(); $this->assertEquals( - array('type' => 'password', 'label' => 'Enter your password', 'name' => 'password'), + ['type' => 'password', 'label' => 'Enter your password', 'name' => 'password'], $attributes ); $this->assertNull($password->getAttribute('required')); @@ -83,7 +83,7 @@ public function testCanCreateFormWithClassAnnotations() $this->assertEquals('text', $attributes['type']); $this->assertObjectHasAttribute('validationGroup', $form); - $this->assertAttributeEquals(array('omit', 'keep'), 'validationGroup', $form); + $this->assertAttributeEquals(['omit', 'keep'], 'validationGroup', $form); } public function testComplexEntityCreationWithPriorities() @@ -156,8 +156,8 @@ public function testAllowsExtensionOfEntities() $this->assertTrue($form->has('email')); $this->assertEquals('extended', $form->getName()); - $expected = array('username', 'password', 'email'); - $test = array(); + $expected = ['username', 'password', 'email']; + $test = []; foreach ($form as $element) { $test[] = $element->getName(); } @@ -237,7 +237,7 @@ public function testOptionsAnnotationAndComposedObjectAnnotation($childName) */ public function provideOptionsAnnotationAndComposedObjectAnnotation() { - return array(array('child'), array('childTheSecond')); + return [['child'], ['childTheSecond']]; } /** @@ -265,7 +265,7 @@ public function testOptionsAnnotationAndComposedObjectAnnotationNoneCollection($ */ public function provideOptionsAnnotationAndComposedObjectAnnotationNoneCollection() { - return array(array('childTheThird'), array('childTheFourth')); + return [['childTheThird'], ['childTheFourth']]; } public function testCanHandleOptionsAnnotation() @@ -282,7 +282,7 @@ public function testCanHandleOptionsAnnotation() $this->assertInstanceOf('Zend\Form\Element', $username); $this->assertEquals('Username:', $username->getLabel()); - $this->assertEquals(array('class' => 'label'), $username->getLabelAttributes()); + $this->assertEquals(['class' => 'label'], $username->getLabelAttributes()); } public function testCanHandleHydratorArrayAnnotation() @@ -387,10 +387,10 @@ public function testInputFilterInputAnnotation() $inputFilter = $form->getInputFilter(); $this->assertTrue($inputFilter->has('input')); - $expected = array( + $expected = [ 'Zend\InputFilter\InputInterface', 'ZendTest\Form\TestAsset\Annotation\InputFilterInput', - ); + ]; foreach ($expected as $expectedInstance) { $this->assertInstanceOf($expectedInstance, $inputFilter->get('input')); } diff --git a/test/Element/CaptchaTest.php b/test/Element/CaptchaTest.php index 42dc92a3..5db57bb5 100644 --- a/test/Element/CaptchaTest.php +++ b/test/Element/CaptchaTest.php @@ -35,16 +35,16 @@ public function testCaptchaIsMutable() $this->assertSame($captcha, $element->getCaptcha()); // by array - $captcha = array( + $captcha = [ 'class' => 'dumb', - ); + ]; $element->setCaptcha($captcha); $this->assertInstanceOf('Zend\Captcha\Dumb', $element->getCaptcha()); // by traversable - $captcha = new ArrayObject(array( + $captcha = new ArrayObject([ 'class' => 'dumb', - )); + ]); $element->setCaptcha($captcha); $this->assertInstanceOf('Zend\Captcha\Dumb', $element->getCaptcha()); } @@ -67,15 +67,15 @@ public function testSettingCaptchaSetsCaptchaAttribute() public function testCreatingCaptchaElementViaFormFactoryWillCreateCaptcha() { $factory = new Factory(); - $element = $factory->createElement(array( + $element = $factory->createElement([ 'type' => 'Zend\Form\Element\Captcha', 'name' => 'foo', - 'options' => array( - 'captcha' => array( + 'options' => [ + 'captcha' => [ 'class' => 'dumb' - ) - ) - )); + ] + ] + ]); $this->assertInstanceOf('Zend\Form\Element\Captcha', $element); $captcha = $element->getCaptcha(); $this->assertInstanceOf('Zend\Captcha\Dumb', $captcha); @@ -99,11 +99,11 @@ public function testProvidesInputSpecificationThatIncludesCaptchaAsValidator() */ public function testAllowsPassingTraversableOptionsToConstructor() { - $options = new TestAsset\IteratorAggregate(new ArrayIterator(array( - 'captcha' => array( + $options = new TestAsset\IteratorAggregate(new ArrayIterator([ + 'captcha' => [ 'class' => 'dumb', - ), - ))); + ], + ])); $element = new CaptchaElement('captcha', $options); $captcha = $element->getCaptcha(); $this->assertInstanceOf('Zend\Captcha\Dumb', $captcha); diff --git a/test/Element/CheckboxTest.php b/test/Element/CheckboxTest.php index 09b828f1..41c6e80a 100644 --- a/test/Element/CheckboxTest.php +++ b/test/Element/CheckboxTest.php @@ -29,15 +29,15 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\InArray' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); switch ($class) { case 'Zend\Validator\InArray': - $this->assertEquals(array($element->getCheckedValue(), $element->getUncheckedValue()), $validator->getHaystack()); + $this->assertEquals([$element->getCheckedValue(), $element->getUncheckedValue()], $validator->getHaystack()); break; default: break; @@ -111,11 +111,11 @@ public function testCheckWithCheckedValue() public function testSetOptions() { $element = new CheckboxElement(); - $element->setOptions(array( + $element->setOptions([ 'use_hidden_element' => true, 'unchecked_value' => 'foo', 'checked_value' => 'bar', - )); + ]); $this->assertEquals(true, $element->getOption('use_hidden_element')); $this->assertEquals('foo', $element->getOption('unchecked_value')); $this->assertEquals('bar', $element->getOption('checked_value')); diff --git a/test/Element/CollectionTest.php b/test/Element/CollectionTest.php index 90b54759..398c9050 100644 --- a/test/Element/CollectionTest.php +++ b/test/Element/CollectionTest.php @@ -53,7 +53,7 @@ public function testCannotAllowNewElementsIfAllowAddIsFalse() $this->assertFalse($collection->allowAdd()); // By default, $collection contains 2 elements - $data = array(); + $data = []; $data[] = 'blue'; $data[] = 'green'; @@ -72,7 +72,7 @@ public function testCanAddNewElementsIfAllowAddIsTrue() $this->assertTrue($collection->allowAdd()); // By default, $collection contains 2 elements - $data = array(); + $data = []; $data[] = 'blue'; $data[] = 'green'; @@ -90,7 +90,7 @@ public function testCanRemoveElementsIfAllowRemoveIsTrue() $collection->setAllowRemove(true); $this->assertTrue($collection->allowRemove()); - $data = array(); + $data = []; $data[] = 'blue'; $data[] = 'green'; @@ -109,7 +109,7 @@ public function testCanReplaceElementsIfAllowAddAndAllowRemoveIsTrue() $collection->setAllowAdd(true); $collection->setAllowRemove(true); - $data = array(); + $data = []; $data[] = 'blue'; $data[] = 'green'; @@ -125,52 +125,52 @@ public function testCanReplaceElementsIfAllowAddAndAllowRemoveIsTrue() public function testCanValidateFormWithCollectionWithoutTemplate() { - $this->form->setData(array( - 'colors' => array( + $this->form->setData([ + 'colors' => [ '#ffffff', '#ffffff' - ), - 'fieldsets' => array( - array( + ], + 'fieldsets' => [ + [ 'field' => 'oneValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ), - array( + ] + ], + [ 'field' => 'twoValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ) - ) - )); + ] + ] + ] + ]); $this->assertEquals(true, $this->form->isValid()); } public function testCannotValidateFormWithCollectionWithBadColor() { - $this->form->setData(array( - 'colors' => array( + $this->form->setData([ + 'colors' => [ '#ffffff', '123465' - ), - 'fieldsets' => array( - array( + ], + 'fieldsets' => [ + [ 'field' => 'oneValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ), - array( + ] + ], + [ 'field' => 'twoValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ) - ) - )); + ] + ] + ] + ]); $this->assertEquals(false, $this->form->isValid()); $messages = $this->form->getMessages(); @@ -179,26 +179,26 @@ public function testCannotValidateFormWithCollectionWithBadColor() public function testCannotValidateFormWithCollectionWithBadFieldsetField() { - $this->form->setData(array( - 'colors' => array( + $this->form->setData([ + 'colors' => [ '#ffffff', '#ffffff' - ), - 'fieldsets' => array( - array( + ], + 'fieldsets' => [ + [ 'field' => 'oneValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ), - array( + ] + ], + [ 'field' => 'twoValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => null, - ) - ) - ) - )); + ] + ] + ] + ]); $this->assertEquals(false, $this->form->isValid()); $messages = $this->form->getMessages(); @@ -216,26 +216,26 @@ public function testCanValidateFormWithCollectionWithTemplate() $collection->setTemplatePlaceholder('__template__'); - $this->form->setData(array( - 'colors' => array( + $this->form->setData([ + 'colors' => [ '#ffffff', '#ffffff' - ), - 'fieldsets' => array( - array( + ], + 'fieldsets' => [ + [ 'field' => 'oneValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ), - array( + ] + ], + [ 'field' => 'twoValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ) - ) - )); + ] + ] + ] + ]); $this->assertEquals(true, $this->form->isValid()); } @@ -247,25 +247,25 @@ public function testThrowExceptionIfThereAreLessElementsAndAllowRemoveNotAllowed $collection = $this->form->get('colors'); $collection->setAllowRemove(false); - $this->form->setData(array( - 'colors' => array( + $this->form->setData([ + 'colors' => [ '#ffffff' - ), - 'fieldsets' => array( - array( + ], + 'fieldsets' => [ + [ 'field' => 'oneValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ), - array( + ] + ], + [ 'field' => 'twoValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ) - ) - )); + ] + ] + ] + ]); $this->form->isValid(); } @@ -275,25 +275,25 @@ public function testCanValidateLessThanSpecifiedCount() $collection = $this->form->get('colors'); $collection->setAllowRemove(true); - $this->form->setData(array( - 'colors' => array( + $this->form->setData([ + 'colors' => [ '#ffffff' - ), - 'fieldsets' => array( - array( + ], + 'fieldsets' => [ + [ 'field' => 'oneValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ), - array( + ] + ], + [ 'field' => 'twoValue', - 'nested_fieldset' => array( + 'nested_fieldset' => [ 'anotherField' => 'anotherValue' - ) - ) - ) - )); + ] + ] + ] + ]); $this->assertEquals(true, $this->form->isValid()); } @@ -302,14 +302,14 @@ public function testSetOptions() { $collection = $this->form->get('colors'); $element = new Element('foo'); - $collection->setOptions(array( + $collection->setOptions([ 'target_element' => $element, 'count' => 2, 'allow_add' => true, 'allow_remove' => false, 'should_create_template' => true, 'template_placeholder' => 'foo', - )); + ]); $this->assertInstanceOf('Zend\Form\Element', $collection->getOption('target_element')); $this->assertEquals(2, $collection->getOption('count')); $this->assertEquals(true, $collection->getOption('allow_add')); @@ -367,21 +367,21 @@ public function testExtractFromObjectDoesntTouchOriginalObject() $cat2 = new \ZendTest\Form\TestAsset\Entity\Category(); $cat2->setName("bar2"); - $product->setCategories(array($cat1, $cat2)); + $product->setCategories([$cat1, $cat2]); $form->bind($product); $form->setData( - array("product" => - array( + ["product" => + [ "name" => "franz", "price" => 13, - "categories" => array( - array("name" => "sepp"), - array("name" => "herbert") - ) - ) - ) + "categories" => [ + ["name" => "sepp"], + ["name" => "herbert"] + ] + ] + ] ); $objectAfterExtractHash = spl_object_hash( @@ -411,21 +411,21 @@ public function testDoesNotCreateNewObjects() $cat2 = new \ZendTest\Form\TestAsset\Entity\Category(); $cat2->setName("bar2"); - $product->setCategories(array($cat1, $cat2)); + $product->setCategories([$cat1, $cat2]); $form->bind($product); $form->setData( - array("product" => - array( + ["product" => + [ "name" => "franz", "price" => 13, - "categories" => array( - array("name" => "sepp"), - array("name" => "herbert") - ) - ) - ) + "categories" => [ + ["name" => "sepp"], + ["name" => "herbert"] + ] + ] + ] ); $form->isValid(); @@ -443,9 +443,9 @@ public function testCreatesNewObjectsIfSpecified() $this->productFieldset->setUseAsBaseFieldset(true); $categories = $this->productFieldset->get('categories'); - $categories->setOptions(array( + $categories->setOptions([ 'create_new_objects' => true, - )); + ]); $form = new \Zend\Form\Form(); $form->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods()); @@ -459,21 +459,21 @@ public function testCreatesNewObjectsIfSpecified() $cat2 = new \ZendTest\Form\TestAsset\Entity\Category(); $cat2->setName("bar2"); - $product->setCategories(array($cat1, $cat2)); + $product->setCategories([$cat1, $cat2]); $form->bind($product); $form->setData( - array("product" => - array( + ["product" => + [ "name" => "franz", "price" => 13, - "categories" => array( - array("name" => "sepp"), - array("name" => "herbert") - ) - ) - ) + "categories" => [ + ["name" => "sepp"], + ["name" => "herbert"] + ] + ] + ] ); $form->isValid(); @@ -493,28 +493,28 @@ public function testAddingCollectionElementAfterBind() $phone = new \ZendTest\Form\TestAsset\PhoneFieldset(); - $form->add(array( + $form->add([ 'name' => 'phones', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => $phone, 'count' => 1, 'allow_add' => true - ), - )); - - $data = array( - 'phones' => array( - array('number' => '1234567'), - array('number' => '1234568'), - ) - ); + ], + ]); + + $data = [ + 'phones' => [ + ['number' => '1234567'], + ['number' => '1234568'], + ] + ]; $phone = new Phone(); $phone->setNumber($data['phones'][0]['number']); $customer = new stdClass(); - $customer->phones = array($phone); + $customer->phones = [$phone]; $form->bind($customer); $form->setData($data); @@ -533,33 +533,33 @@ public function testDoesNotCreateNewObjectsWhenUsingNestedCollections() $form = new Form(); $form->setHydrator(new ObjectPropertyHydrator()); - $form->add(array( + $form->add([ 'name' => 'addresses', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => $addressesFieldeset, 'count' => 1 - ), - )); + ], + ]); - $data = array( + $data = [ 'addresses' => - array(array( + [[ 'street' => 'street1', 'phones' => - array(array('number' => '1234567')), - )) - ); + [['number' => '1234567']], + ]] + ]; $phone = new Phone(); $phone->setNumber($data['addresses'][0]['phones'][0]['number']); $address = new Address(); $address->setStreet($data['addresses'][0]['street']); - $address->setPhones(array($phone)); + $address->setPhones([$phone]); $customer = new stdClass(); - $customer->addresses = array($address); + $customer->addresses = [$address]; $form->bind($customer); $form->setData($data); @@ -577,10 +577,10 @@ public function testDoNotCreateExtraFieldsetOnMultipleBind() $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty()); $product = new Product(); - $categories = array( + $categories = [ new \ZendTest\Form\TestAsset\Entity\Category(), new \ZendTest\Form\TestAsset\Entity\Category(), - ); + ]; $product->setCategories($categories); $market = new \StdClass(); @@ -598,7 +598,7 @@ public function testDoNotCreateExtraFieldsetOnMultipleBind() public function testExtractDefaultIsEmptyArray() { $collection = $this->form->get('fieldsets'); - $this->assertEquals(array(), $collection->extract()); + $this->assertEquals([], $collection->extract()); } public function testExtractThroughTargetElementHydrator() @@ -606,10 +606,10 @@ public function testExtractThroughTargetElementHydrator() $collection = $this->form->get('fieldsets'); $this->prepareForExtract($collection); - $expected = array( - 'obj2' => array('field' => 'fieldOne'), - 'obj3' => array('field' => 'fieldTwo'), - ); + $expected = [ + 'obj2' => ['field' => 'fieldOne'], + 'obj3' => ['field' => 'fieldTwo'], + ]; $this->assertEquals($expected, $collection->extract()); } @@ -642,10 +642,10 @@ public function testExtractThroughCustomHydrator() $collection->setHydrator($mockHydrator); - $expected = array( + $expected = [ 'obj2' => 'fieldOne_foo', 'obj3' => 'fieldTwo_foo', - ); + ]; $this->assertEquals($expected, $collection->extract()); } @@ -658,10 +658,10 @@ public function testExtractFromTraversable() $traversable = new ArrayObject($collection->getObject()); $collection->setObject($traversable); - $expected = array( - 'obj2' => array('field' => 'fieldOne'), - 'obj3' => array('field' => 'fieldTwo'), - ); + $expected = [ + 'obj2' => ['field' => 'fieldOne'], + 'obj3' => ['field' => 'fieldTwo'], + ]; $this->assertEquals($expected, $collection->extract()); } @@ -669,27 +669,27 @@ public function testExtractFromTraversable() public function testValidateData() { $myFieldset = new Fieldset(); - $myFieldset->add(array( + $myFieldset->add([ 'name' => 'email', 'type' => 'Email', - )); + ]); $myForm = new Form(); - $myForm->add(array( + $myForm->add([ 'name' => 'collection', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => $myFieldset, - ), - )); - - $data = array( - 'collection' => array( - array('email' => 'test1@test1.com'), - array('email' => 'test2@test2.com'), - array('email' => 'test3@test3.com'), - ) - ); + ], + ]); + + $data = [ + 'collection' => [ + ['email' => 'test1@test1.com'], + ['email' => 'test2@test2.com'], + ['email' => 'test3@test3.com'], + ] + ]; $myForm->setData($data); @@ -712,10 +712,10 @@ protected function prepareForExtract($collection) $obj3 = new stdClass(); $obj3->field = 'fieldTwo'; - $collection->setObject(array( + $collection->setObject([ 'obj2' => $obj2, 'obj3' => $obj3, - )); + ]); } public function testCollectionCanBindObjectAndPopulateAndExtractNestedFieldsets() @@ -730,20 +730,20 @@ public function testCollectionCanBindObjectAndPopulateAndExtractNestedFieldsets( $form = new Form(); $form->setHydrator(new ObjectPropertyHydrator()); - $form->add(array( + $form->add([ 'name' => 'collection', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => $mainFieldset, 'count' => 2 - ), - )); + ], + ]); $market = new stdClass(); - $prices = array(100, 200); - $categoryNames = array('electronics', 'furniture'); - $productCountries = array('Russia', 'Jamaica'); + $prices = [100, 200]; + $categoryNames = ['electronics', 'furniture']; + $productCountries = ['Russia', 'Jamaica']; $shop1 = new stdClass(); $shop1->product = new Product(); @@ -751,7 +751,7 @@ public function testCollectionCanBindObjectAndPopulateAndExtractNestedFieldsets( $category = new \ZendTest\Form\TestAsset\Entity\Category(); $category->setName($categoryNames[0]); - $shop1->product->setCategories(array($category)); + $shop1->product->setCategories([$category]); $country = new \ZendTest\Form\TestAsset\Entity\Country(); $country->setName($productCountries[0]); @@ -765,7 +765,7 @@ public function testCollectionCanBindObjectAndPopulateAndExtractNestedFieldsets( $category = new \ZendTest\Form\TestAsset\Entity\Category(); $category->setName($categoryNames[1]); - $shop2->product->setCategories(array($category)); + $shop2->product->setCategories([$category]); $country = new \ZendTest\Form\TestAsset\Entity\Country(); $country->setName($productCountries[1]); @@ -773,7 +773,7 @@ public function testCollectionCanBindObjectAndPopulateAndExtractNestedFieldsets( - $market->collection = array($shop1, $shop2); + $market->collection = [$shop1, $shop2]; $form->bind($market); //test for object binding @@ -855,10 +855,10 @@ public function testExtractFromTraversableImplementingToArrayThroughCollectionHy $this->prepareForExtractWithCustomTraversable($collection); - $expected = array( - array('foo' => 'foo_value_1', 'bar' => 'bar_value_1', 'foobar' => 'foobar_value_1'), - array('foo' => 'foo_value_2', 'bar' => 'bar_value_2', 'foobar' => 'foobar_value_2'), - ); + $expected = [ + ['foo' => 'foo_value_1', 'bar' => 'bar_value_1', 'foobar' => 'foobar_value_1'], + ['foo' => 'foo_value_2', 'bar' => 'bar_value_2', 'foobar' => 'foobar_value_2'], + ]; $this->assertEquals($expected, $collection->extract()); } @@ -875,10 +875,10 @@ public function testExtractFromTraversableImplementingToArrayThroughTargetElemen $this->prepareForExtractWithCustomTraversable($collection); - $expected = array( - array('foo' => 'foo_value_1', 'bar' => 'bar_value_1', 'foobar' => 'foobar_value_1'), - array('foo' => 'foo_value_2', 'bar' => 'bar_value_2', 'foobar' => 'foobar_value_2'), - ); + $expected = [ + ['foo' => 'foo_value_1', 'bar' => 'bar_value_1', 'foobar' => 'foobar_value_1'], + ['foo' => 'foo_value_2', 'bar' => 'bar_value_2', 'foobar' => 'foobar_value_2'], + ]; $this->assertEquals($expected, $collection->extract()); } @@ -886,9 +886,9 @@ public function testExtractFromTraversableImplementingToArrayThroughTargetElemen protected function prepareForExtractWithCustomTraversable($collection) { $obj2 = new ArrayModel(); - $obj2->exchangeArray(array('foo' => 'foo_value_1', 'bar' => 'bar_value_1', 'foobar' => 'foobar_value_1')); + $obj2->exchangeArray(['foo' => 'foo_value_1', 'bar' => 'bar_value_1', 'foobar' => 'foobar_value_1']); $obj3 = new ArrayModel(); - $obj3->exchangeArray(array('foo' => 'foo_value_2', 'bar' => 'bar_value_2', 'foobar' => 'foobar_value_2')); + $obj3->exchangeArray(['foo' => 'foo_value_2', 'bar' => 'bar_value_2', 'foobar' => 'foobar_value_2']); $traversable = new CustomCollection(); $traversable->append($obj2); @@ -898,26 +898,26 @@ protected function prepareForExtractWithCustomTraversable($collection) public function testPopulateValuesWithFirstKeyGreaterThanZero() { - $inputData = array( - 1 => array('name' => 'black'), - 5 => array('name' => 'white'), - ); + $inputData = [ + 1 => ['name' => 'black'], + 5 => ['name' => 'white'], + ]; // Standalone Collection element - $collection = new Collection('fieldsets', array( + $collection = new Collection('fieldsets', [ 'count' => 1, 'target_element' => new \ZendTest\Form\TestAsset\CategoryFieldset(), - )); + ]); $form = new Form(); - $form->add(array( + $form->add([ 'type' => 'Zend\Form\Element\Collection', 'name' => 'collection', - 'options' => array( + 'options' => [ 'count' => 1, 'target_element' => new \ZendTest\Form\TestAsset\CategoryFieldset(), - ) - )); + ] + ]); // Collection element attached to a form $formCollection = $form->get('collection'); @@ -940,7 +940,7 @@ public function testCanRemoveAllElementsIfAllowRemoveIsTrue() // By default, $collection contains 2 elements - $data = array(); + $data = []; $collection->populateValues($data); $this->assertEquals(0, count($collection->getElements())); @@ -955,27 +955,27 @@ public function testCanBindObjectMultipleNestedFieldsets() $nestedFieldset = new Fieldset('nested'); $nestedFieldset->setHydrator(new ObjectPropertyHydrator()); $nestedFieldset->setObject(new stdClass()); - $nestedFieldset->add(array( + $nestedFieldset->add([ 'name' => 'products', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => $productFieldset, 'count' => 2, - ), - )); + ], + ]); $mainFieldset = new Fieldset('main'); $mainFieldset->setUseAsBaseFieldset(true); $mainFieldset->setHydrator(new ObjectPropertyHydrator()); $mainFieldset->setObject(new stdClass()); - $mainFieldset->add(array( + $mainFieldset->add([ 'name' => 'nested', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => $nestedFieldset, 'count' => 2, - ), - )); + ], + ]); $form = new Form(); $form->setHydrator(new ObjectPropertyHydrator()); @@ -983,7 +983,7 @@ public function testCanBindObjectMultipleNestedFieldsets() $market = new stdClass(); - $prices = array(100, 200); + $prices = [100, 200]; $products[0] = new Product(); $products[0]->setPrice($prices[0]); @@ -1028,19 +1028,19 @@ public function testNestedCollections() $form = new Form(); $form->setHydrator(new ObjectPropertyHydrator()); - $form->add(array( + $form->add([ 'name' => 'addresses', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => $addressesFieldeset, 'count' => 2 - ), - )); + ], + ]); - $data = array( - array('number' => '0000000001', 'street' => 'street1'), - array('number' => '0000000002', 'street' => 'street2'), - ); + $data = [ + ['number' => '0000000001', 'street' => 'street1'], + ['number' => '0000000002', 'street' => 'street2'], + ]; $phone1 = new Phone(); $phone1->setNumber($data[0]['number']); @@ -1050,14 +1050,14 @@ public function testNestedCollections() $address1 = new Address(); $address1->setStreet($data[0]['street']); - $address1->setPhones(array($phone1)); + $address1->setPhones([$phone1]); $address2 = new Address(); $address2->setStreet($data[1]['street']); - $address2->setPhones(array($phone2)); + $address2->setPhones([$phone2]); $customer = new stdClass(); - $customer->addresses = array($address1, $address2); + $customer->addresses = [$address1, $address2]; $form->bind($customer); @@ -1096,19 +1096,19 @@ public function testNestedCollections() public function testSetDataOnFormPopulatesCollection() { $form = new Form(); - $form->add(array( + $form->add([ 'name' => 'names', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => new Element\Text(), - ), - )); + ], + ]); - $names = array('foo', 'bar', 'baz', 'bat'); + $names = ['foo', 'bar', 'baz', 'bat']; - $form->setData(array( + $form->setData([ 'names' => $names - )); + ]); $this->assertCount(count($names), $form->get('names')); @@ -1123,18 +1123,18 @@ public function testSettingSomeDataButNoneForCollectionReturnsSpecifiedNumberOfE { $form = new Form(); $form->add(new Element\Text('input')); - $form->add(array( + $form->add([ 'name' => 'names', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => new Element\Text(), 'count' => 2 - ), - )); + ], + ]); - $form->setData(array( + $form->setData([ 'input' => 'foo', - )); + ]); $this->assertCount(0, $form->get('names')); @@ -1145,10 +1145,10 @@ public function testSettingSomeDataButNoneForCollectionReturnsSpecifiedNumberOfE public function testMininumLenghtIsMaintanedWhenSettingASmallerCollection() { - $arrayCollection = array( + $arrayCollection = [ new Element\Color(), new Element\Color(), - ); + ]; $collection = $this->form->get('colors'); $collection->setCount(3); @@ -1164,14 +1164,14 @@ public function testCollectionProperlyHandlesAddingObjectsOfTypeElementInterface { $form = new Form('test'); $text = new Element\Text('text'); - $form->add(array( + $form->add([ 'name' => 'text', 'type' => 'Zend\Form\Element\Collection', - 'options' => array( + 'options' => [ 'target_element' => $text, 'count' => 2, - ), - )); - $object = new \ArrayObject(array('text' => array('Foo', 'Bar'))); + ], + ]); + $object = new \ArrayObject(['text' => ['Foo', 'Bar']]); $form->bind($object); $this->assertTrue($form->isValid()); @@ -1201,17 +1201,17 @@ public function testCollectionShouldSilentlyIgnorePopulatingFieldsetWithDisallow $form = new Form(); $form->setObject(new \stdClass()); $form->setHydrator(new ObjectPropertyHydrator()); - $form->add(array( + $form->add([ 'name' => 'collection', 'type' => 'Collection', - 'options' => array( + 'options' => [ 'target_element' => $mainFieldset, 'count' => 2 - ), - )); + ], + ]); $model = new \stdClass(); - $model->collection = array(new \ArrayObject(array('test' => 'bar')), new \stdClass()); + $model->collection = [new \ArrayObject(['test' => 'bar']), new \stdClass()]; $form->bind($model); $this->assertTrue($form->isValid()); @@ -1233,11 +1233,11 @@ public function testCollectionShouldSilentlyIgnorePopulatingFieldsetWithDisallow public function testCanHydrateObject() { $form = $this->form; - $data = array( - 'colors' => array( + $data = [ + 'colors' => [ '#ffffff', - ), - ); + ], + ]; $form->setData($data); $object = new \ArrayObject(); $form->bind($object); @@ -1255,14 +1255,14 @@ public function testCanRemoveMultipleElements() $collection->setAllowRemove(true); $collection->setCount(0); - $data = array(); + $data = []; $data[] = 'blue'; $data[] = 'green'; $data[] = 'red'; $collection->populateValues($data); - $collection->populateValues(array('colors' => array('0' => 'blue'))); + $collection->populateValues(['colors' => ['0' => 'blue']]); $this->assertEquals(1, count($collection->getElements())); } } diff --git a/test/Element/ColorTest.php b/test/Element/ColorTest.php index d0bad522..b14a5caf 100644 --- a/test/Element/ColorTest.php +++ b/test/Element/ColorTest.php @@ -16,20 +16,20 @@ class ColorTest extends TestCase { public function colorData() { - return array( - array('#012345', true), - array('#abcdef', true), - array('#012abc', true), - array('#012abcd', false), - array('#012abcde', false), - array('#ABCDEF', true), - array('#012ABC', true), - array('#bcdefg', false), - array('#01a', false), - array('01abcd', false), - array('blue', false), - array('transparent', false), - ); + return [ + ['#012345', true], + ['#abcdef', true], + ['#012abc', true], + ['#012abcd', false], + ['#012abcde', false], + ['#ABCDEF', true], + ['#012ABC', true], + ['#bcdefg', false], + ['#01a', false], + ['01abcd', false], + ['blue', false], + ['transparent', false], + ]; } public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() @@ -40,9 +40,9 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Regex' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); diff --git a/test/Element/CsrfTest.php b/test/Element/CsrfTest.php index 43d1e2bb..7c0fce57 100644 --- a/test/Element/CsrfTest.php +++ b/test/Element/CsrfTest.php @@ -22,9 +22,9 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Csrf' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -50,7 +50,7 @@ public function testAllowSettingCustomCsrfValidator() public function testAllowSettingCsrfValidatorOptions() { $element = new CsrfElement('foo'); - $element->setCsrfValidatorOptions(array('timeout' => 777)); + $element->setCsrfValidatorOptions(['timeout' => 777]); $validator = $element->getCsrfValidator(); $this->assertEquals('foo', $validator->getName()); $this->assertEquals(777, $validator->getTimeout()); @@ -59,11 +59,11 @@ public function testAllowSettingCsrfValidatorOptions() public function testAllowSettingCsrfOptions() { $element = new CsrfElement('foo'); - $element->setOptions(array( - 'csrf_options' => array( + $element->setOptions([ + 'csrf_options' => [ 'timeout' => 777, - 'salt' => 'MySalt') - )); + 'salt' => 'MySalt'] + ]); $validator = $element->getCsrfValidator(); $this->assertEquals('foo', $validator->getName()); $this->assertEquals(777, $validator->getTimeOut()); diff --git a/test/Element/DateSelectTest.php b/test/Element/DateSelectTest.php index 8aebbc4a..81d8ac66 100644 --- a/test/Element/DateSelectTest.php +++ b/test/Element/DateSelectTest.php @@ -23,9 +23,9 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Date' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -78,7 +78,7 @@ public function testThrowsOnInvalidValue() public function testConstructAcceptsDayAttributes() { - $sut = new DateSelectElement('dateSelect', array('day_attributes' => array('class' => 'test'))); + $sut = new DateSelectElement('dateSelect', ['day_attributes' => ['class' => 'test']]); $dayAttributes = $sut->getDayAttributes(); $this->assertEquals('test', $dayAttributes['class']); } diff --git a/test/Element/DateTest.php b/test/Element/DateTest.php index 0f0c0f6b..7e292d5e 100644 --- a/test/Element/DateTest.php +++ b/test/Element/DateTest.php @@ -49,10 +49,10 @@ public function testProvidesDefaultInputSpecification() $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Date', 'Zend\Validator\DateStep', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -71,23 +71,23 @@ public function testProvidesDefaultInputSpecification() public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new DateElement('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => true, 'min' => '2000-01-01', 'max' => '2001-01-01', 'step' => '1', - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Date', 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\DateStep', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -123,10 +123,10 @@ public function testValueReturnedFromComposedDateTimeIsRfc3339FullDateFormat() public function testCorrectFormatPassedToDateValidator() { $element = new DateElement('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'min' => '2012-01-01', 'max' => '2012-12-31', - )); + ]); $element->setFormat('d-m-Y'); $inputSpec = $element->getInputSpecification(); diff --git a/test/Element/DateTimeLocalTest.php b/test/Element/DateTimeLocalTest.php index 6b062870..e96a6067 100644 --- a/test/Element/DateTimeLocalTest.php +++ b/test/Element/DateTimeLocalTest.php @@ -17,23 +17,23 @@ class DateTimeLocalTest extends TestCase public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new DateTimeLocalElement('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => true, 'min' => '2000-01-01T00:00Z', 'max' => '2001-01-01T00:00Z', 'step' => '1', - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Date', 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\DateStep', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); diff --git a/test/Element/DateTimeSelectTest.php b/test/Element/DateTimeSelectTest.php index 55075e74..eaac7c10 100644 --- a/test/Element/DateTimeSelectTest.php +++ b/test/Element/DateTimeSelectTest.php @@ -24,9 +24,9 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Date' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -44,18 +44,18 @@ public function testInputSpecificationFilterIfSecondNotProvided() { $element = new DateTimeSelectElement('test'); $factory = new InputFilterFactory(); - $inputFilter = $factory->createInputFilter(array( + $inputFilter = $factory->createInputFilter([ 'test' => $element->getInputSpecification(), - )); - $inputFilter->setData(array( - 'test' => array( + ]); + $inputFilter->setData([ + 'test' => [ 'year' => '2013', 'month' => '02', 'day' => '07', 'hour' => '03', 'minute' => '14' - ), - )); + ], + ]); $this->assertTrue($inputFilter->isValid()); } @@ -105,13 +105,13 @@ public function testThrowsOnInvalidValue() public function testUseDefaultValueForSecondsIfNotProvided() { $element = new DateTimeSelectElement(); - $element->setValue(array( + $element->setValue([ 'year' => '2012', 'month' => '09', 'day' => '24', 'hour' => '03', 'minute' => '04' - )); + ]); $this->assertEquals('2012', $element->getYearElement()->getValue()); $this->assertEquals('09', $element->getMonthElement()->getValue()); diff --git a/test/Element/DateTimeTest.php b/test/Element/DateTimeTest.php index e83bd1eb..2434d41f 100644 --- a/test/Element/DateTimeTest.php +++ b/test/Element/DateTimeTest.php @@ -18,23 +18,23 @@ class DateTimeTest extends TestCase public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new DateTimeElement('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => true, 'min' => '2000-01-01T00:00Z', 'max' => '2001-01-01T00:00Z', 'step' => '1', - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Date', 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\DateStep', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -113,9 +113,9 @@ public function testSetFormatWithOptions() { $format = 'Y-m-d'; $element = new DateTimeElement('foo'); - $element->setOptions(array( + $element->setOptions([ 'format' => $format, - )); + ]); $this->assertSame($format, $element->getFormat()); } diff --git a/test/Element/EmailTest.php b/test/Element/EmailTest.php index d4ce84e9..3846b9a5 100644 --- a/test/Element/EmailTest.php +++ b/test/Element/EmailTest.php @@ -22,9 +22,9 @@ public function testProvidesInputSpecificationThatIncludesDefaultValidators() $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedValidators = array( + $expectedValidators = [ 'Zend\Validator\Regex' - ); + ]; foreach ($inputSpec['validators'] as $i => $validator) { $class = get_class($validator); $this->assertEquals($expectedValidators[$i], $class); @@ -33,11 +33,11 @@ public function testProvidesInputSpecificationThatIncludesDefaultValidators() public function emailAttributesDataProvider() { - return array( + return [ // attributes // expectedValidators - array(array('multiple' => true), array('Zend\Validator\Explode')), - array(array('multiple' => false), array('Zend\Validator\Regex')), - ); + [['multiple' => true], ['Zend\Validator\Explode']], + [['multiple' => false], ['Zend\Validator\Regex']], + ]; } /** diff --git a/test/Element/MonthSelectTest.php b/test/Element/MonthSelectTest.php index 56715765..0186e69f 100644 --- a/test/Element/MonthSelectTest.php +++ b/test/Element/MonthSelectTest.php @@ -23,9 +23,9 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Regex' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -47,16 +47,16 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri */ public function monthValuesDataProvider() { - return array( + return [ // value expected - array('2012-01', true), - array('2012-12', true), - array('2012-13', false), - array('2012-12-01', false), - array('12-2012', false), - array('2012-1', true), - array('12-01', false), - ); + ['2012-01', true], + ['2012-12', true], + ['2012-13', false], + ['2012-12-01', false], + ['12-2012', false], + ['2012-1', true], + ['12-01', false], + ]; } /** diff --git a/test/Element/MonthTest.php b/test/Element/MonthTest.php index 13d6c44a..4efa95f8 100644 --- a/test/Element/MonthTest.php +++ b/test/Element/MonthTest.php @@ -17,23 +17,23 @@ class MonthTest extends TestCase public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new MonthElement('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => true, 'min' => '2000-01', 'max' => '2001-01', 'step' => '1', - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Regex', 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\DateStep', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -58,16 +58,16 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri public function monthValuesDataProvider() { - return array( + return [ // value expected - array('2012-01', true), - array('2012-12', true), - array('2012-13', false), - array('2012-12-01', false), - array('12-2012', false), - array('2012-1', false), - array('12-01', false), - ); + ['2012-01', true], + ['2012-12', true], + ['2012-13', false], + ['2012-12-01', false], + ['12-2012', false], + ['2012-1', false], + ['12-01', false], + ]; } /** diff --git a/test/Element/MultiCheckboxTest.php b/test/Element/MultiCheckboxTest.php index bf7353d4..a366af65 100644 --- a/test/Element/MultiCheckboxTest.php +++ b/test/Element/MultiCheckboxTest.php @@ -16,7 +16,7 @@ class MultiCheckboxTest extends TestCase { public function useHiddenAttributeDataProvider() { - return array(array(true), array(false)); + return [[true], [false]]; } /** @@ -25,23 +25,23 @@ public function useHiddenAttributeDataProvider() public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes($useHiddenElement) { $element = new MultiCheckboxElement(); - $options = array( + $options = [ '1' => 'Option 1', '2' => 'Option 2', '3' => 'Option 3', - ); - $element->setAttributes(array( + ]; + $element->setAttributes([ 'options' => $options, - )); + ]); $element->setUseHiddenElement($useHiddenElement); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Explode' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -58,22 +58,22 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri public function multiCheckboxOptionsDataProvider() { - return array( - array( - array('foo', 'bar'), - array( + return [ + [ + ['foo', 'bar'], + [ 'foo' => 'My Foo Label', 'bar' => 'My Bar Label', - ) - ), - array( - array('foo', 'bar'), - array( - 0 => array('label' => 'My Foo Label', 'value' => 'foo'), - 1 => array('label' => 'My Bar Label', 'value' => 'bar'), - ) - ), - ); + ] + ], + [ + ['foo', 'bar'], + [ + 0 => ['label' => 'My Foo Label', 'value' => 'foo'], + 1 => ['label' => 'My Bar Label', 'value' => 'bar'], + ] + ], + ]; } /** @@ -82,9 +82,9 @@ public function multiCheckboxOptionsDataProvider() public function testInArrayValidationOfOptions($valueTests, $options) { $element = new MultiCheckboxElement('my-checkbox'); - $element->setAttributes(array( + $element->setAttributes([ 'options' => $options, - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $explodeValidator = $inputSpec['validators'][0]; @@ -104,9 +104,9 @@ public function testInArrayValidatorHaystakIsUpdated($valueTests, $options) $inputSpec = $element->getInputSpecification(); $inArrayValidator=$inputSpec['validators'][0]->getValidator(); - $element->setAttributes(array( + $element->setAttributes([ 'options' => $options, - )); + ]); $haystack=$inArrayValidator->getHaystack(); $this->assertCount(count($options), $haystack); } @@ -124,22 +124,22 @@ public function testAttributeType() public function testSetOptionsOptions() { $element = new MultiCheckboxElement(); - $element->setOptions(array( - 'value_options' => array('bar' => 'baz'), - 'options' => array('foo' => 'bar'), - )); - $this->assertEquals(array('bar' => 'baz'), $element->getOption('value_options')); - $this->assertEquals(array('foo' => 'bar'), $element->getOption('options')); + $element->setOptions([ + 'value_options' => ['bar' => 'baz'], + 'options' => ['foo' => 'bar'], + ]); + $this->assertEquals(['bar' => 'baz'], $element->getOption('value_options')); + $this->assertEquals(['foo' => 'bar'], $element->getOption('options')); } public function testDisableInputSpecification() { $element = new MultiCheckboxElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $element->setDisableInArrayValidator(true); $inputSpec = $element->getInputSpecification(); @@ -149,11 +149,11 @@ public function testDisableInputSpecification() public function testUnsetValueOption() { $element = new MultiCheckboxElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $element->unsetValueOption('Option 2'); $valueOptions = $element->getValueOptions(); @@ -163,11 +163,11 @@ public function testUnsetValueOption() public function testUnsetUndefinedValueOption() { $element = new MultiCheckboxElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $element->unsetValueOption('Option Undefined'); $valueOptions = $element->getValueOptions(); @@ -177,14 +177,14 @@ public function testUnsetUndefinedValueOption() public function testOptionValueinSelectedOptions() { $element = new MultiCheckboxElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $optionValue = 'option3'; - $selectedOptions = array('option1', 'option3'); + $selectedOptions = ['option1', 'option3']; $element->setValue($selectedOptions); $this->assertContains($optionValue, $element->getValue()); } diff --git a/test/Element/NumberTest.php b/test/Element/NumberTest.php index 65dfe4e7..334f7fa5 100644 --- a/test/Element/NumberTest.php +++ b/test/Element/NumberTest.php @@ -22,10 +22,10 @@ public function testProvidesInputSpecificationWithDefaultAttributes() $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Regex', 'Zend\Validator\Step', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -42,23 +42,23 @@ public function testProvidesInputSpecificationWithDefaultAttributes() public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new NumberElement(); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => true, 'min' => 5, 'max' => 10, 'step' => 1, - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\Regex', 'Zend\Validator\Step', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -83,10 +83,10 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri public function testFalseInclusiveValidatorBasedOnAttributes() { $element = new NumberElement(); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => false, 'min' => 5, - )); + ]); $inputSpec = $element->getInputSpecification(); foreach ($inputSpec['validators'] as $validator) { @@ -100,9 +100,9 @@ public function testFalseInclusiveValidatorBasedOnAttributes() public function testDefaultInclusiveTrueatValidatorWhenInclusiveIsNotSetOnAttributes() { $element = new NumberElement(); - $element->setAttributes(array( + $element->setAttributes([ 'min' => 5, - )); + ]); $inputSpec = $element->getInputSpecification(); foreach ($inputSpec['validators'] as $validator) { diff --git a/test/Element/RadioTest.php b/test/Element/RadioTest.php index 98a3f495..8d75e989 100644 --- a/test/Element/RadioTest.php +++ b/test/Element/RadioTest.php @@ -16,7 +16,7 @@ class RadioTest extends TestCase { public function useHiddenAttributeDataProvider() { - return array(array(true), array(false)); + return [[true], [false]]; } /** @@ -25,23 +25,23 @@ public function useHiddenAttributeDataProvider() public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes($useHiddenElement) { $element = new RadioElement(); - $options = array( + $options = [ '1' => 'Option 1', '2' => 'Option 2', '3' => 'Option 3', - ); - $element->setAttributes(array( + ]; + $element->setAttributes([ 'options' => $options, - )); + ]); $element->setUseHiddenElement($useHiddenElement); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\InArray' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -50,22 +50,22 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri public function radioOptionsDataProvider() { - return array( - array( - array('foo', 'bar'), - array( + return [ + [ + ['foo', 'bar'], + [ 'foo' => 'My Foo Label', 'bar' => 'My Bar Label', - ) - ), - array( - array('foo', 'bar'), - array( - 0 => array('label' => 'My Foo Label', 'value' => 'foo'), - 1 => array('label' => 'My Bar Label', 'value' => 'bar'), - ) - ), - ); + ] + ], + [ + ['foo', 'bar'], + [ + 0 => ['label' => 'My Foo Label', 'value' => 'foo'], + 1 => ['label' => 'My Bar Label', 'value' => 'bar'], + ] + ], + ]; } /** @@ -74,9 +74,9 @@ public function radioOptionsDataProvider() public function testInArrayValidationOfOptions($valueTests, $options) { $element = new RadioElement('my-radio'); - $element->setAttributes(array( + $element->setAttributes([ 'options' => $options, - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $inArrayValidator = $inputSpec['validators'][0]; @@ -89,11 +89,11 @@ public function testInArrayValidationOfOptions($valueTests, $options) public function testDisableInputSpecification() { $element = new RadioElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $element->setDisableInArrayValidator(true); $inputSpec = $element->getInputSpecification(); diff --git a/test/Element/RangeTest.php b/test/Element/RangeTest.php index 4391de03..53a178b6 100644 --- a/test/Element/RangeTest.php +++ b/test/Element/RangeTest.php @@ -27,12 +27,12 @@ public function testProvidesInputSpecificationWithDefaultAttributes() $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\I18n\Validator\IsFloat', 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\Step', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -62,23 +62,23 @@ public function testProvidesInputSpecificationThatIncludesValidator() } $element = new RangeElement(); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => true, 'min' => 2, 'max' => 102, 'step' => 2, - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\I18n\Validator\IsFloat', 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\Step', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); diff --git a/test/Element/SelectTest.php b/test/Element/SelectTest.php index 76744721..d57912ea 100644 --- a/test/Element/SelectTest.php +++ b/test/Element/SelectTest.php @@ -17,19 +17,19 @@ class SelectTest extends TestCase public function testProvidesInputSpecificationForSingleSelect() { $element = new SelectElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\InArray' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -39,12 +39,12 @@ public function testProvidesInputSpecificationForSingleSelect() public function testValidateWorksForNestedSelectElementWithSimpleNaming() { $element = new SelectElement(); - $element->setValueOptions(array( - array('label' => 'group 1', 'options' => array( + $element->setValueOptions([ + ['label' => 'group 1', 'options' => [ 'Option 1' => 'Label 1', 'Option 2' => 'Label 2', 'Option 3' => 'Label 2', - )))); + ]]]); $inputSpec = $element->getInputSpecification(); $inArrayValidator = $inputSpec['validators'][0]; @@ -56,12 +56,12 @@ public function testValidateWorksForNestedSelectElementWithSimpleNaming() public function testValidateWorksForNestedSelectElementWithExplicitNaming() { $element = new SelectElement(); - $element->setValueOptions(array( - array('label' => 'group 1', 'options' => array( - array('value' => 'Option 1', 'label'=> 'Label 1'), - array('value' => 'Option 2', 'label'=> 'Label 2'), - array('value' => 'Option 3', 'label'=> 'Label 3'), - )))); + $element->setValueOptions([ + ['label' => 'group 1', 'options' => [ + ['value' => 'Option 1', 'label'=> 'Label 1'], + ['value' => 'Option 2', 'label'=> 'Label 2'], + ['value' => 'Option 3', 'label'=> 'Label 3'], + ]]]); $inputSpec = $element->getInputSpecification(); $inArrayValidator = $inputSpec['validators'][0]; @@ -74,22 +74,22 @@ public function testValidateWorksForNestedSelectElementWithExplicitNaming() public function testProvidesInputSpecificationForMultipleSelect() { $element = new SelectElement(); - $element->setAttributes(array( + $element->setAttributes([ 'multiple' => true, - )); - $element->setValueOptions(array( + ]); + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Explode' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -105,22 +105,22 @@ public function testProvidesInputSpecificationForMultipleSelect() public function selectOptionsDataProvider() { - return array( - array( - array('foo', 'bar'), - array( + return [ + [ + ['foo', 'bar'], + [ 'foo' => 'My Foo Label', 'bar' => 'My Bar Label', - ) - ), - array( - array('foo', 'bar'), - array( - 0 => array('label' => 'My Foo Label', 'value' => 'foo'), - 1 => array('label' => 'My Bar Label', 'value' => 'bar'), - ) - ), - ); + ] + ], + [ + ['foo', 'bar'], + [ + 0 => ['label' => 'My Foo Label', 'value' => 'foo'], + 1 => ['label' => 'My Bar Label', 'value' => 'bar'], + ] + ], + ]; } /** @@ -168,39 +168,39 @@ public function testOptionsHasArrayOnConstruct() public function testDeprecateOptionsInAttributes() { $element = new SelectElement(); - $valueOptions = array( + $valueOptions = [ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - ); - $element->setAttributes(array( + ]; + $element->setAttributes([ 'multiple' => true, 'options' => $valueOptions, - )); + ]); $this->assertEquals($valueOptions, $element->getValueOptions()); } public function testSetOptionsOptions() { $element = new SelectElement(); - $element->setOptions(array( - 'value_options' => array('bar' => 'baz'), - 'options' => array('foo' => 'bar'), - 'empty_option' => array('baz' => 'foo'), - )); - $this->assertEquals(array('bar' => 'baz'), $element->getOption('value_options')); - $this->assertEquals(array('foo' => 'bar'), $element->getOption('options')); - $this->assertEquals(array('baz' => 'foo'), $element->getOption('empty_option')); + $element->setOptions([ + 'value_options' => ['bar' => 'baz'], + 'options' => ['foo' => 'bar'], + 'empty_option' => ['baz' => 'foo'], + ]); + $this->assertEquals(['bar' => 'baz'], $element->getOption('value_options')); + $this->assertEquals(['foo' => 'bar'], $element->getOption('options')); + $this->assertEquals(['baz' => 'foo'], $element->getOption('empty_option')); } public function testDisableInputSpecification() { $element = new SelectElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $element->setDisableInArrayValidator(true); $inputSpec = $element->getInputSpecification(); @@ -210,11 +210,11 @@ public function testDisableInputSpecification() public function testUnsetValueOption() { $element = new SelectElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $element->unsetValueOption('Option 2'); $valueOptions = $element->getValueOptions(); @@ -224,11 +224,11 @@ public function testUnsetValueOption() public function testUnsetUndefinedValueOption() { $element = new SelectElement(); - $element->setValueOptions(array( + $element->setValueOptions([ 'Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3', - )); + ]); $element->unsetValueOption('Option Undefined'); $valueOptions = $element->getValueOptions(); @@ -237,16 +237,16 @@ public function testUnsetUndefinedValueOption() public function testSetOptionsToSelectMultiple() { - $element = new SelectElement(null, array( + $element = new SelectElement(null, [ 'label' => 'Importance', 'use_hidden_element' => true, 'unselected_value' => 'empty', - 'value_options' => array( + 'value_options' => [ 'foo' => 'Foo', 'bar' => 'Bar' - ), - )); - $element->setAttributes(array('multiple' => 'multiple')); + ], + ]); + $element->setAttributes(['multiple' => 'multiple']); $this->assertTrue($element->isMultiple()); $this->assertTrue($element->useHiddenElement()); @@ -258,9 +258,9 @@ public function testProvidesInputSpecificationForMultipleSelectWithUseHiddenElem $element = new SelectElement(); $element ->setUseHiddenElement(true) - ->setAttributes(array( + ->setAttributes([ 'multiple' => true, - )); + ]); $inputSpec = $element->getInputSpecification(); diff --git a/test/Element/TimeTest.php b/test/Element/TimeTest.php index 956f99d4..f8d4ed74 100644 --- a/test/Element/TimeTest.php +++ b/test/Element/TimeTest.php @@ -17,23 +17,23 @@ class TimeTest extends TestCase public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new TimeElement('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => true, 'min' => '00:00:00', 'max' => '00:01:00', 'step' => '60', - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Date', 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\DateStep', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); diff --git a/test/Element/UrlTest.php b/test/Element/UrlTest.php index 4f2cdd8d..d2634718 100644 --- a/test/Element/UrlTest.php +++ b/test/Element/UrlTest.php @@ -17,18 +17,18 @@ class UrlTest extends TestCase public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new UrlElement(); - $element->setAttributes(array( + $element->setAttributes([ 'allowAbsolute' => true, 'allowRelative' => false - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Uri' - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); diff --git a/test/Element/WeekTest.php b/test/Element/WeekTest.php index 08f9a94a..6916f7b6 100644 --- a/test/Element/WeekTest.php +++ b/test/Element/WeekTest.php @@ -17,23 +17,23 @@ class WeekTest extends TestCase public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes() { $element = new WeekElement('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'inclusive' => true, 'min' => '1970-W01', 'max' => '1970-W03', 'step' => '1', - )); + ]); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); - $expectedClasses = array( + $expectedClasses = [ 'Zend\Validator\Regex', 'Zend\Validator\GreaterThan', 'Zend\Validator\LessThan', 'Zend\Validator\DateStep', - ); + ]; foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertContains($class, $expectedClasses, $class); @@ -58,15 +58,15 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri public function weekValuesDataProvider() { - return array( + return [ // value expected - array('2012-W01', true), - array('2012-W52', true), - array('2012-01', false), - array('W12-2012', false), - array('2012-W1', false), - array('12-W01', false), - ); + ['2012-W01', true], + ['2012-W52', true], + ['2012-01', false], + ['W12-2012', false], + ['2012-W1', false], + ['12-W01', false], + ]; } /** diff --git a/test/ElementTest.php b/test/ElementTest.php index 648ade5c..8c0a066a 100644 --- a/test/ElementTest.php +++ b/test/ElementTest.php @@ -17,13 +17,13 @@ class ElementTest extends TestCase public function testAttributesAreEmptyByDefault() { $element = new Element(); - $this->assertEquals(array(), $element->getAttributes()); + $this->assertEquals([], $element->getAttributes()); } public function testLabelAttributesAreEmptyByDefault() { $element = new Element(); - $this->assertEquals(array(), $element->getLabelAttributes()); + $this->assertEquals([], $element->getLabelAttributes()); } public function testCanAddAttributesSingly() @@ -36,12 +36,12 @@ public function testCanAddAttributesSingly() public function testCanAddManyAttributesAtOnce() { $element = new Element(); - $attributes = array( + $attributes = [ 'type' => 'text', 'class' => 'text-element', 'data-foo' => 'bar', 'x-autocompletetype' => 'email' - ); + ]; $element->setAttributes($attributes); $this->assertEquals($attributes, $element->getAttributes()); } @@ -49,15 +49,15 @@ public function testCanAddManyAttributesAtOnce() public function testAddingAttributesMerges() { $element = new Element(); - $attributes = array( + $attributes = [ 'type' => 'text', 'class' => 'text-element', 'data-foo' => 'bar', - ); - $attributesExtra = array( + ]; + $attributesExtra = [ 'data-foo' => 'baz', 'width' => 20, - ); + ]; $element->setAttributes($attributes); $element->setAttributes($attributesExtra); $expected = array_merge($attributes, $attributesExtra); @@ -67,24 +67,24 @@ public function testAddingAttributesMerges() public function testCanClearAllAttributes() { $element = new Element(); - $attributes = array( + $attributes = [ 'type' => 'text', 'class' => 'text-element', 'data-foo' => 'bar', - ); + ]; $element->setAttributes($attributes); $element->clearAttributes(); - $this->assertEquals(array(), $element->getAttributes()); + $this->assertEquals([], $element->getAttributes()); } public function testCanRemoveSingleAttribute() { $element = new Element(); - $attributes = array( + $attributes = [ 'type' => 'text', 'class' => 'text-element', 'data-foo' => 'bar', - ); + ]; $element->setAttributes($attributes); $element->removeAttribute('type'); $this->assertFalse($element->hasAttribute('type')); @@ -93,13 +93,13 @@ public function testCanRemoveSingleAttribute() public function testCanRemoveMultipleAttributes() { $element = new Element(); - $attributes = array( + $attributes = [ 'type' => 'text', 'class' => 'text-element', 'data-foo' => 'bar', - ); + ]; $element->setAttributes($attributes); - $element->removeAttributes(array('type', 'class')); + $element->removeAttributes(['type', 'class']); $this->assertFalse($element->hasAttribute('type')); $this->assertFalse($element->hasAttribute('class')); } @@ -126,9 +126,9 @@ public function testCanPassNameToConstructor() public function testCanSetCustomOptionFromConstructor() { - $element = new Element('foo', array( + $element = new Element('foo', [ 'custom' => 'option' - )); + ]); $options = $element->getOptions(); $this->assertArrayHasKey('custom', $options); $this->assertEquals('option', $options['custom']); @@ -137,9 +137,9 @@ public function testCanSetCustomOptionFromConstructor() public function testCanSetCustomOptionFromMethod() { $element = new Element('foo'); - $element->setOptions(array( + $element->setOptions([ 'custom' => 'option' - )); + ]); $options = $element->getOptions(); $this->assertArrayHasKey('custom', $options); @@ -149,9 +149,9 @@ public function testCanSetCustomOptionFromMethod() public function testCanRetrieveSpecificOption() { $element = new Element('foo'); - $element->setOptions(array( + $element->setOptions([ 'custom' => 'option' - )); + ]); $option = $element->getOption('custom'); $this->assertEquals('option', $option); } @@ -159,23 +159,23 @@ public function testCanRetrieveSpecificOption() public function testSpecificOptionsSetLabelAttributes() { $element = new Element('foo'); - $element->setOptions(array( + $element->setOptions([ 'label' => 'foo', - 'label_attributes' => array('bar' => 'baz') - )); + 'label_attributes' => ['bar' => 'baz'] + ]); $option = $element->getOption('label_attributes'); - $this->assertEquals(array('bar' => 'baz'), $option); + $this->assertEquals(['bar' => 'baz'], $option); } public function testLabelOptionsAccessors() { $element = new Element('foo'); - $element->setOptions(array( - 'label_options' => array('moar' => 'foo') - )); + $element->setOptions([ + 'label_options' => ['moar' => 'foo'] + ]); $labelOptions = $element->getLabelOptions(); - $this->assertEquals(array('moar' => 'foo'), $labelOptions); + $this->assertEquals(['moar' => 'foo'], $labelOptions); } public function testCanSetSingleOptionForLabel() @@ -197,9 +197,9 @@ public function testSetOptionsWrongInputRaisesException() public function testSetOptionsIsTraversable() { $element = new Element('foo'); - $element->setOptions(new \ArrayObject(array('foo' => 'bar'))); + $element->setOptions(new \ArrayObject(['foo' => 'bar'])); $this->assertEquals('foo', $element->getName()); - $this->assertEquals(array('foo' => 'bar'), $element->getOptions()); + $this->assertEquals(['foo' => 'bar'], $element->getOptions()); } public function testGetOption() @@ -227,15 +227,15 @@ public function testSetMessagesWrongInputRaisesException() public function testLabelOptionsAreEmptyByDefault() { $element = new Element(); - $this->assertEquals(array(), $element->getLabelOptions()); + $this->assertEquals([], $element->getLabelOptions()); } public function testLabelOptionsCanBeSetViaOptionsArray() { $element = new Element('foo'); - $element->setOptions(array( - 'label_options' => array('moar' => 'foo') - )); + $element->setOptions([ + 'label_options' => ['moar' => 'foo'] + ]); $this->assertEquals('foo', $element->getLabelOption('moar')); } @@ -250,10 +250,10 @@ public function testCanAddLabelOptionSingly() public function testCanAddManyLabelOptionsAtOnce() { $element = new Element(); - $options = array( + $options = [ 'foo' => 'bar', 'foo2' => 'baz' - ); + ]; $element->setLabelOptions($options); // check each expected key individually @@ -274,14 +274,14 @@ public function testPassingWrongArgumentToSetLabelOptionsThrowsException() public function testSettingLabelOptionsMerges() { $element = new Element(); - $options = array( + $options = [ 'foo' => 'bar', 'foo2' => 'baz' - ); - $optionsExtra = array( + ]; + $optionsExtra = [ 'foo3' => 'bar2', 'foo2' => 'baz2' - ); + ]; $element->setLabelOptions($options); $element->setLabelOptions($optionsExtra); $expected = array_merge($options, $optionsExtra); @@ -295,22 +295,22 @@ public function testSettingLabelOptionsMerges() public function testCanClearAllLabelOptions() { $element = new Element(); - $options = array( + $options = [ 'foo' => 'bar', 'foo2' => 'baz' - ); + ]; $element->setLabelOptions($options); $element->clearLabelOptions(); - $this->assertEquals(array(), $element->getLabelOptions()); + $this->assertEquals([], $element->getLabelOptions()); } public function testCanRemoveSingleLabelOption() { $element = new Element(); - $options = array( + $options = [ 'foo' => 'bar', 'foo2' => 'baz' - ); + ]; $element->setLabelOptions($options); $element->removeLabelOption('foo2'); $this->assertFalse($element->hasLabelOption('foo2')); @@ -319,13 +319,13 @@ public function testCanRemoveSingleLabelOption() public function testCanRemoveMultipleLabelOptions() { $element = new Element(); - $options = array( + $options = [ 'foo' => 'bar', 'foo2' => 'baz', 'foo3' => 'bar2' - ); + ]; $element->setLabelOptions($options); - $element->removeLabelOptions(array('foo', 'foo2')); + $element->removeLabelOptions(['foo', 'foo2']); $this->assertFalse($element->hasLabelOption('foo')); $this->assertFalse($element->hasLabelOption('foo2')); $this->assertTrue($element->hasLabelOption('foo3')); diff --git a/test/FactoryTest.php b/test/FactoryTest.php index dc6c1689..dcaa57b6 100644 --- a/test/FactoryTest.php +++ b/test/FactoryTest.php @@ -33,14 +33,14 @@ public function setUp() public function testCanCreateElements() { - $element = $this->factory->createElement(array( + $element = $this->factory->createElement([ 'name' => 'foo', - 'attributes' => array( + 'attributes' => [ 'type' => 'text', 'class' => 'foo-class', 'data-js-type' => 'my.form.text', - ), - )); + ], + ]); $this->assertInstanceOf('Zend\Form\ElementInterface', $element); $this->assertEquals('foo', $element->getName()); $this->assertEquals('text', $element->getAttribute('type')); @@ -50,15 +50,15 @@ public function testCanCreateElements() public function testCanCreateFieldsets() { - $fieldset = $this->factory->createFieldset(array( + $fieldset = $this->factory->createFieldset([ 'name' => 'foo', 'object' => 'ZendTest\Form\TestAsset\Model', - 'attributes' => array( + 'attributes' => [ 'type' => 'fieldset', 'class' => 'foo-class', 'data-js-type' => 'my.form.fieldset', - ), - )); + ], + ]); $this->assertInstanceOf('Zend\Form\FieldsetInterface', $fieldset); $this->assertEquals('foo', $fieldset->getName()); $this->assertEquals('fieldset', $fieldset->getAttribute('type')); @@ -69,47 +69,47 @@ public function testCanCreateFieldsets() public function testCanCreateFieldsetsWithElements() { - $fieldset = $this->factory->createFieldset(array( + $fieldset = $this->factory->createFieldset([ 'name' => 'foo', - 'elements' => array( - array( - 'flags' => array( + 'elements' => [ + [ + 'flags' => [ 'name' => 'bar', - ), - 'spec' => array( - 'attributes' => array( + ], + 'spec' => [ + 'attributes' => [ 'type' => 'text', - ), - ), - ), - array( - 'flags' => array( + ], + ], + ], + [ + 'flags' => [ 'name' => 'baz', - ), - 'spec' => array( - 'attributes' => array( + ], + 'spec' => [ + 'attributes' => [ 'type' => 'radio', - 'options' => array( + 'options' => [ 'foo' => 'Foo Bar', 'bar' => 'Bar Baz', - ), - ), - ), - ), - array( - 'flags' => array( + ], + ], + ], + ], + [ + 'flags' => [ 'priority' => 10, - ), - 'spec' => array( + ], + 'spec' => [ 'name' => 'bat', - 'attributes' => array( + 'attributes' => [ 'type' => 'textarea', 'content' => 'Type here...', - ), - ), - ), - ), - )); + ], + ], + ], + ], + ]); $this->assertInstanceOf('Zend\Form\FieldsetInterface', $fieldset); $elements = $fieldset->getElements(); $this->assertEquals(3, count($elements)); @@ -122,10 +122,10 @@ public function testCanCreateFieldsetsWithElements() $element = $fieldset->get('baz'); $this->assertEquals('radio', $element->getAttribute('type')); - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'Foo Bar', 'bar' => 'Bar Baz', - ), $element->getAttribute('options')); + ], $element->getAttribute('options')); $element = $fieldset->get('bat'); $this->assertEquals('textarea', $element->getAttribute('type')); @@ -142,54 +142,54 @@ public function testCanCreateFieldsetsWithElements() public function testCanCreateNestedFieldsets() { - $masterFieldset = $this->factory->createFieldset(array( + $masterFieldset = $this->factory->createFieldset([ 'name' => 'foo', - 'fieldsets' => array( - array( - 'flags' => array('name' => 'bar'), - 'spec' => array( - 'elements' => array( - array( - 'flags' => array( + 'fieldsets' => [ + [ + 'flags' => ['name' => 'bar'], + 'spec' => [ + 'elements' => [ + [ + 'flags' => [ 'name' => 'bar', - ), - 'spec' => array( - 'attributes' => array( + ], + 'spec' => [ + 'attributes' => [ 'type' => 'text', - ), - ), - ), - array( - 'flags' => array( + ], + ], + ], + [ + 'flags' => [ 'name' => 'baz', - ), - 'spec' => array( - 'attributes' => array( + ], + 'spec' => [ + 'attributes' => [ 'type' => 'radio', - 'options' => array( + 'options' => [ 'foo' => 'Foo Bar', 'bar' => 'Bar Baz', - ), - ), - ), - ), - array( - 'flags' => array( + ], + ], + ], + ], + [ + 'flags' => [ 'priority' => 10, - ), - 'spec' => array( + ], + 'spec' => [ 'name' => 'bat', - 'attributes' => array( + 'attributes' => [ 'type' => 'textarea', 'content' => 'Type here...', - ), - ), - ), - ), - ) - ) - ) - )); + ], + ], + ], + ], + ] + ] + ] + ]); $this->assertInstanceOf('Zend\Form\FieldsetInterface', $masterFieldset); $fieldsets = $masterFieldset->getFieldsets(); $this->assertEquals(1, count($fieldsets)); @@ -203,10 +203,10 @@ public function testCanCreateNestedFieldsets() $element = $fieldset->get('baz'); $this->assertEquals('radio', $element->getAttribute('type')); - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'Foo Bar', 'bar' => 'Bar Baz', - ), $element->getAttribute('options')); + ], $element->getAttribute('options')); $element = $fieldset->get('bat'); $this->assertEquals('textarea', $element->getAttribute('type')); @@ -223,13 +223,13 @@ public function testCanCreateNestedFieldsets() public function testCanCreateForms() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', 'object' => 'ZendTest\Form\TestAsset\Model', - 'attributes' => array( + 'attributes' => [ 'method' => 'get', - ), - )); + ], + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $this->assertEquals('foo', $form->getName()); $this->assertEquals('get', $form->getAttribute('method')); @@ -238,10 +238,10 @@ public function testCanCreateForms() public function testCanCreateFormsWithNamedInputFilters() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', 'input_filter' => 'ZendTest\Form\TestAsset\InputFilter', - )); + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $filter = $form->getInputFilter(); $this->assertInstanceOf('ZendTest\Form\TestAsset\InputFilter', $filter); @@ -249,46 +249,46 @@ public function testCanCreateFormsWithNamedInputFilters() public function testCanCreateFormsWithInputFilterSpecifications() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', - 'input_filter' => array( - 'foo' => array( + 'input_filter' => [ + 'foo' => [ 'name' => 'foo', 'required' => false, - 'validators' => array( - array( + 'validators' => [ + [ 'name' => 'not_empty', - ), - array( + ], + [ 'name' => 'string_length', - 'options' => array( + 'options' => [ 'min' => 3, 'max' => 5, - ), - ), - ), - ), - 'bar' => array( + ], + ], + ], + ], + 'bar' => [ 'allow_empty' => true, - 'filters' => array( - array( + 'filters' => [ + [ 'name' => 'string_trim', - ), - array( + ], + [ 'name' => 'string_to_lower', - 'options' => array( + 'options' => [ 'encoding' => 'ISO-8859-1', - ), - ), - ), - ), - ), - )); + ], + ], + ], + ], + ], + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $filter = $form->getInputFilter(); $this->assertInstanceOf('Zend\InputFilter\InputFilterInterface', $filter); $this->assertEquals(2, count($filter)); - foreach (array('foo', 'bar') as $name) { + foreach (['foo', 'bar'] as $name) { $input = $filter->get($name); switch ($name) { @@ -311,10 +311,10 @@ public function testCanCreateFormsWithInputFilterSpecifications() public function testCanCreateFormsWithInputFilterInstances() { $filter = new TestAsset\InputFilter(); - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', 'input_filter' => $filter, - )); + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $test = $form->getInputFilter(); $this->assertSame($filter, $test); @@ -322,10 +322,10 @@ public function testCanCreateFormsWithInputFilterInstances() public function testCanCreateFormsAndSpecifyHydrator() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', 'hydrator' => 'Zend\Stdlib\Hydrator\ObjectProperty', - )); + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $hydrator = $form->getHydrator(); $this->assertInstanceOf('Zend\Stdlib\Hydrator\ObjectProperty', $hydrator); @@ -338,10 +338,10 @@ public function testCanCreateFormsAndSpecifyHydratorManagedByHydratorManager() $hydrators->setServiceLocator($services); $services->setService('HydratorManager', new HydratorPluginManager()); - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', 'hydrator' => 'ObjectProperty', - )); + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $hydrator = $form->getHydrator(); $this->assertInstanceOf('Zend\Stdlib\Hydrator\ObjectProperty', $hydrator); @@ -349,13 +349,13 @@ public function testCanCreateFormsAndSpecifyHydratorManagedByHydratorManager() public function testCanCreateHydratorFromArray() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', - 'hydrator' => array( + 'hydrator' => [ 'type' => 'Zend\Stdlib\Hydrator\ClassMethods', - 'options' => array('underscoreSeparatedKeys' => false), - ), - )); + 'options' => ['underscoreSeparatedKeys' => false], + ], + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $hydrator = $form->getHydrator(); @@ -365,10 +365,10 @@ public function testCanCreateHydratorFromArray() public function testCanCreateHydratorFromConcreteClass() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', 'hydrator' => new \Zend\Stdlib\Hydrator\ObjectProperty() - )); + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $hydrator = $form->getHydrator(); @@ -377,10 +377,10 @@ public function testCanCreateHydratorFromConcreteClass() public function testCanCreateFormsAndSpecifyFactory() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', 'factory' => 'Zend\Form\Factory', - )); + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $factory = $form->getFormFactory(); $this->assertInstanceOf('Zend\Form\Factory', $factory); @@ -388,12 +388,12 @@ public function testCanCreateFormsAndSpecifyFactory() public function testCanCreateFactoryFromArray() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', - 'factory' => array( + 'factory' => [ 'type' => 'Zend\Form\Factory', - ), - )); + ], + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $factory = $form->getFormFactory(); @@ -403,10 +403,10 @@ public function testCanCreateFactoryFromArray() public function testCanCreateFactoryFromConcreteClass() { $factory = new \Zend\Form\Factory(); - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', 'factory' => $factory, - )); + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $test = $form->getFormFactory(); @@ -427,21 +427,21 @@ public function testCanCreateFormFromConcreteClassAndSpecifyCustomValidatorByNam $factory = new FormFactory(); $factory->setInputFilterFactory($inputFilterFactory); - $form = $factory->createForm(array( + $form = $factory->createForm([ 'name' => 'foo', 'factory' => $factory, - 'input_filter' => array( - 'bar' => array( + 'input_filter' => [ + 'bar' => [ 'name' => 'bar', 'required' => true, - 'validators' => array( - array( + 'validators' => [ + [ 'name' => 'baz', - ), - ), - ), - ), - )); + ], + ], + ], + ], + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); @@ -470,94 +470,94 @@ public function testCanCreateFormFromConcreteClassAndSpecifyCustomValidatorByNam public function testCanCreateFormWithHydratorAndInputFilterAndElementsAndFieldsets() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', - 'elements' => array( - array( - 'flags' => array( + 'elements' => [ + [ + 'flags' => [ 'name' => 'bar', - ), - 'spec' => array( - 'attributes' => array( + ], + 'spec' => [ + 'attributes' => [ 'type' => 'text', - ), - ), - ), - array( - 'flags' => array( + ], + ], + ], + [ + 'flags' => [ 'name' => 'baz', - ), - 'spec' => array( - 'attributes' => array( + ], + 'spec' => [ + 'attributes' => [ 'type' => 'radio', - 'options' => array( + 'options' => [ 'foo' => 'Foo Bar', 'bar' => 'Bar Baz', - ), - ), - ), - ), - array( - 'flags' => array( + ], + ], + ], + ], + [ + 'flags' => [ 'priority' => 10, - ), - 'spec' => array( + ], + 'spec' => [ 'name' => 'bat', - 'attributes' => array( + 'attributes' => [ 'type' => 'textarea', 'content' => 'Type here...', - ), - ), - ), - ), - 'fieldsets' => array( - array( - 'flags' => array('name' => 'foobar'), - 'spec' => array( - 'elements' => array( - array( - 'flags' => array( + ], + ], + ], + ], + 'fieldsets' => [ + [ + 'flags' => ['name' => 'foobar'], + 'spec' => [ + 'elements' => [ + [ + 'flags' => [ 'name' => 'bar', - ), - 'spec' => array( - 'attributes' => array( + ], + 'spec' => [ + 'attributes' => [ 'type' => 'text', - ), - ), - ), - array( - 'flags' => array( + ], + ], + ], + [ + 'flags' => [ 'name' => 'baz', - ), - 'spec' => array( - 'attributes' => array( + ], + 'spec' => [ + 'attributes' => [ 'type' => 'radio', - 'options' => array( + 'options' => [ 'foo' => 'Foo Bar', 'bar' => 'Bar Baz', - ), - ), - ), - ), - array( - 'flags' => array( + ], + ], + ], + ], + [ + 'flags' => [ 'priority' => 10, - ), - 'spec' => array( + ], + 'spec' => [ 'name' => 'bat', - 'attributes' => array( + 'attributes' => [ 'type' => 'textarea', 'content' => 'Type here...', - ), - ), - ), - ), - ), - ), - ), + ], + ], + ], + ], + ], + ], + ], 'input_filter' => 'ZendTest\Form\TestAsset\InputFilter', 'hydrator' => 'Zend\Stdlib\Hydrator\ObjectProperty', - )); + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $elements = $form->getElements(); @@ -571,10 +571,10 @@ public function testCanCreateFormWithHydratorAndInputFilterAndElementsAndFieldse $element = $form->get('baz'); $this->assertEquals('radio', $element->getAttribute('type')); - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'Foo Bar', 'bar' => 'Bar Baz', - ), $element->getAttribute('options')); + ], $element->getAttribute('options')); $element = $form->get('bat'); $this->assertEquals('textarea', $element->getAttribute('type')); @@ -601,10 +601,10 @@ public function testCanCreateFormWithHydratorAndInputFilterAndElementsAndFieldse $element = $fieldset->get('baz'); $this->assertEquals('radio', $element->getAttribute('type')); - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'Foo Bar', 'bar' => 'Bar Baz', - ), $element->getAttribute('options')); + ], $element->getAttribute('options')); $element = $fieldset->get('bat'); $this->assertEquals('textarea', $element->getAttribute('type')); @@ -629,13 +629,13 @@ public function testCanCreateFormWithHydratorAndInputFilterAndElementsAndFieldse public function testCanCreateFormUsingCreate() { - $form = $this->factory->create(array( + $form = $this->factory->create([ 'type' => 'Zend\Form\Form', 'name' => 'foo', - 'attributes' => array( + 'attributes' => [ 'method' => 'get', - ), - )); + ], + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $this->assertEquals('foo', $form->getName()); $this->assertEquals('get', $form->getAttribute('method')); @@ -643,15 +643,15 @@ public function testCanCreateFormUsingCreate() public function testCanCreateFieldsetUsingCreate() { - $fieldset = $this->factory->create(array( + $fieldset = $this->factory->create([ 'type' => 'Zend\Form\Fieldset', 'name' => 'foo', - 'attributes' => array( + 'attributes' => [ 'type' => 'fieldset', 'class' => 'foo-class', 'data-js-type' => 'my.form.fieldset', - ), - )); + ], + ]); $this->assertInstanceOf('Zend\Form\FieldsetInterface', $fieldset); $this->assertEquals('foo', $fieldset->getName()); $this->assertEquals('fieldset', $fieldset->getAttribute('type')); @@ -661,14 +661,14 @@ public function testCanCreateFieldsetUsingCreate() public function testCanCreateElementUsingCreate() { - $element = $this->factory->create(array( + $element = $this->factory->create([ 'name' => 'foo', - 'attributes' => array( + 'attributes' => [ 'type' => 'text', 'class' => 'foo-class', 'data-js-type' => 'my.form.text', - ), - )); + ], + ]); $this->assertInstanceOf('Zend\Form\ElementInterface', $element); $this->assertEquals('foo', $element->getName()); $this->assertEquals('text', $element->getAttribute('type')); @@ -678,14 +678,14 @@ public function testCanCreateElementUsingCreate() public function testAutomaticallyAddFieldsetTypeWhenCreateFieldset() { - $fieldset = $this->factory->createFieldset(array('name' => 'myFieldset')); + $fieldset = $this->factory->createFieldset(['name' => 'myFieldset']); $this->assertInstanceOf('Zend\Form\Fieldset', $fieldset); $this->assertEquals('myFieldset', $fieldset->getName()); } public function testAutomaticallyAddFormTypeWhenCreateForm() { - $form = $this->factory->createForm(array('name' => 'myForm')); + $form = $this->factory->createForm(['name' => 'myForm']); $this->assertInstanceOf('Zend\Form\Form', $form); $this->assertEquals('myForm', $form->getName()); } @@ -695,24 +695,24 @@ public function testCanPullHydratorThroughServiceManager() $serviceLocator = $this->factory->getFormElementManager()->getServiceLocator(); $serviceLocator->setInvokableClass('MyHydrator', 'Zend\Stdlib\Hydrator\ObjectProperty'); - $fieldset = $this->factory->createFieldset(array( + $fieldset = $this->factory->createFieldset([ 'hydrator' => 'MyHydrator', 'name' => 'fieldset', - 'elements' => array( - array( - 'flags' => array( + 'elements' => [ + [ + 'flags' => [ 'name' => 'bar', - ), - ) - ) - )); + ], + ] + ] + ]); $this->assertInstanceOf('Zend\Stdlib\Hydrator\ObjectProperty', $fieldset->getHydrator()); } public function testCreatedFieldsetsHaveFactoryAndFormElementManagerInjected() { - $fieldset = $this->factory->createFieldset(array('name' => 'myFieldset')); + $fieldset = $this->factory->createFieldset(['name' => 'myFieldset']); $this->assertAttributeInstanceOf('Zend\Form\Factory', 'factory', $fieldset); $this->assertSame($fieldset->getFormFactory()->getFormElementManager(), $this->factory->getFormElementManager()); } @@ -722,30 +722,30 @@ public function testCreatedFieldsetsHaveFactoryAndFormElementManagerInjected() */ public function testPrepareAndInjectWillThrowAndException() { - $fieldset = $this->factory->createFieldset(array('name' => 'myFieldset')); + $fieldset = $this->factory->createFieldset(['name' => 'myFieldset']); $this->setExpectedException('Zend\Form\Exception\DomainException'); - $this->factory->configureFieldset($fieldset, array('hydrator' => 0)); + $this->factory->configureFieldset($fieldset, ['hydrator' => 0]); } public function testCanCreateFormWithNullElements() { - $form = $this->factory->createForm(array( + $form = $this->factory->createForm([ 'name' => 'foo', - 'elements' => array( - 'bar' => array( - 'spec' => array( + 'elements' => [ + 'bar' => [ + 'spec' => [ 'name' => 'bar', - ), - ), + ], + ], 'baz' => null, - 'bat' => array( - 'spec' => array( + 'bat' => [ + 'spec' => [ 'name' => 'bat', - ), - ), - ), - )); + ], + ], + ], + ]); $this->assertInstanceOf('Zend\Form\FormInterface', $form); $elements = $form->getElements(); diff --git a/test/FieldsetTest.php b/test/FieldsetTest.php index 8b0acd58..76c6bd7b 100644 --- a/test/FieldsetTest.php +++ b/test/FieldsetTest.php @@ -44,62 +44,62 @@ public function populateFieldset() public function getMessages() { - return array( - 'foo' => array( + return [ + 'foo' => [ 'Foo message 1', - ), - 'bar' => array( + ], + 'bar' => [ 'Bar message 1', 'Bar message 2', - ), - 'baz' => array( + ], + 'baz' => [ 'Baz message 1', - ), - 'foobar' => array( - 'foo' => array( + ], + 'foobar' => [ + 'foo' => [ 'Foo message 1', - ), - 'bar' => array( + ], + 'bar' => [ 'Bar message 1', 'Bar message 2', - ), - 'baz' => array( + ], + 'baz' => [ 'Baz message 1', - ), - ), - 'barbaz' => array( - 'foo' => array( + ], + ], + 'barbaz' => [ + 'foo' => [ 'Foo message 1', - ), - 'bar' => array( + ], + 'bar' => [ 'Bar message 1', 'Bar message 2', - ), - 'baz' => array( + ], + 'baz' => [ 'Baz message 1', - ), - ), - ); + ], + ], + ]; } public function testExtractOnAnEmptyRelationship() { $form = new TestAsset\FormCollection(); - $form->populateValues(array('fieldsets' => array())); + $form->populateValues(['fieldsets' => []]); } public function testExtractOnAnEmptyTraversable() { $form = new TestAsset\FormCollection(); - $form->populateValues(new \ArrayObject(array('fieldsets' => new \ArrayObject()))); + $form->populateValues(new \ArrayObject(['fieldsets' => new \ArrayObject()])); } public function testTraversableAcceptedValueForFieldset() { - $subValue = new \ArrayObject(array('field' => 'value')); + $subValue = new \ArrayObject(['field' => 'value']); $subFieldset = new TestAsset\ValueStoringFieldset('subFieldset'); $this->fieldset->add($subFieldset); - $this->fieldset->populateValues(array('subFieldset' => $subValue)); + $this->fieldset->populateValues(['subFieldset' => $subValue]); $this->assertEquals($subValue, $subFieldset->getStoredValue()); } @@ -122,9 +122,9 @@ public function testCanAddElementsToFieldset() public function testCanSetCustomOptionFromConstructor() { - $fieldset = new Fieldset('foo', array( + $fieldset = new Fieldset('foo', [ 'custom' => 'option' - )); + ]); $options = $fieldset->getOptions(); $this->assertArrayHasKey('custom', $options); $this->assertEquals('option', $options['custom']); @@ -146,21 +146,21 @@ public function testCanGrabElementByNameWhenNotProvidedWithAlias() public function testElementMayBeRetrievedByAliasProvidedWhenAdded() { $element = new Element('foo'); - $this->fieldset->add($element, array('name' => 'bar')); + $this->fieldset->add($element, ['name' => 'bar']); $this->assertSame($element, $this->fieldset->get('bar')); } public function testElementNameIsChangedToAliasWhenAdded() { $element = new Element('foo'); - $this->fieldset->add($element, array('name' => 'bar')); + $this->fieldset->add($element, ['name' => 'bar']); $this->assertEquals('bar', $element->getName()); } public function testCannotRetrieveElementByItsNameWhenProvidingAnAliasDuringAddition() { $element = new Element('foo'); - $this->fieldset->add($element, array('name' => 'bar')); + $this->fieldset->add($element, ['name' => 'bar']); $this->assertFalse($this->fieldset->has('foo')); } @@ -220,7 +220,7 @@ public function testCanRetrieveAllAttachedElementsSeparateFromFieldsetsAtOnce() $this->populateFieldset(); $elements = $this->fieldset->getElements(); $this->assertEquals(3, count($elements)); - foreach (array('foo', 'bar', 'baz') as $name) { + foreach (['foo', 'bar', 'baz'] as $name) { $this->assertTrue(isset($elements[$name])); $element = $this->fieldset->get($name); $this->assertSame($element, $elements[$name]); @@ -232,7 +232,7 @@ public function testCanRetrieveAllAttachedFieldsetsSeparateFromElementsAtOnce() $this->populateFieldset(); $fieldsets = $this->fieldset->getFieldsets(); $this->assertEquals(2, count($fieldsets)); - foreach (array('foobar', 'barbaz') as $name) { + foreach (['foobar', 'barbaz'] as $name) { $this->assertTrue(isset($fieldsets[$name])); $fieldset = $this->fieldset->get($name); $this->assertSame($fieldset, $fieldsets[$name]); @@ -263,7 +263,7 @@ public function testOnlyElementsWithErrorsInMessages() $form = new Form(); $form->add($fieldset); $form->setInputFilter(new InputFilter()); - $form->setData(array()); + $form->setData([]); $form->isValid(); $messages = $form->getMessages(); @@ -306,8 +306,8 @@ public function testCountGivesCountOfAttachedElementsAndFieldsets() public function testCanIterateOverElementsAndFieldsetsInOrderAttached() { $this->populateFieldset(); - $expected = array('foo', 'bar', 'baz', 'foobar', 'barbaz'); - $test = array(); + $expected = ['foo', 'bar', 'baz', 'foobar', 'barbaz']; + $test = []; foreach ($this->fieldset as $element) { $test[] = $element->getName(); } @@ -316,13 +316,13 @@ public function testCanIterateOverElementsAndFieldsetsInOrderAttached() public function testIteratingRespectsOrderPriorityProvidedWhenAttaching() { - $this->fieldset->add(new Element('foo'), array('priority' => 10)); - $this->fieldset->add(new Element('bar'), array('priority' => 20)); - $this->fieldset->add(new Element('baz'), array('priority' => -10)); - $this->fieldset->add(new Fieldset('barbaz'), array('priority' => 30)); + $this->fieldset->add(new Element('foo'), ['priority' => 10]); + $this->fieldset->add(new Element('bar'), ['priority' => 20]); + $this->fieldset->add(new Element('baz'), ['priority' => -10]); + $this->fieldset->add(new Fieldset('barbaz'), ['priority' => 30]); - $expected = array('barbaz', 'bar', 'foo', 'baz'); - $test = array(); + $expected = ['barbaz', 'bar', 'foo', 'baz']; + $test = []; foreach ($this->fieldset as $element) { $test[] = $element->getName(); } @@ -331,14 +331,14 @@ public function testIteratingRespectsOrderPriorityProvidedWhenAttaching() public function testIteratingRespectsOrderPriorityProvidedWhenSetLater() { - $this->fieldset->add(new Element('foo'), array('priority' => 10)); - $this->fieldset->add(new Element('bar'), array('priority' => 20)); - $this->fieldset->add(new Element('baz'), array('priority' => -10)); - $this->fieldset->add(new Fieldset('barbaz'), array('priority' => 30)); + $this->fieldset->add(new Element('foo'), ['priority' => 10]); + $this->fieldset->add(new Element('bar'), ['priority' => 20]); + $this->fieldset->add(new Element('baz'), ['priority' => -10]); + $this->fieldset->add(new Fieldset('barbaz'), ['priority' => 30]); $this->fieldset->setPriority('baz', 99); - $expected = array('baz', 'barbaz', 'bar', 'foo'); - $test = array(); + $expected = ['baz', 'barbaz', 'bar', 'foo']; + $test = []; foreach ($this->fieldset as $element) { $test[] = $element->getName(); } @@ -347,15 +347,15 @@ public function testIteratingRespectsOrderPriorityProvidedWhenSetLater() public function testIteratingRespectsOrderPriorityWhenCloned() { - $this->fieldset->add(new Element('foo'), array('priority' => 10)); - $this->fieldset->add(new Element('bar'), array('priority' => 20)); - $this->fieldset->add(new Element('baz'), array('priority' => -10)); - $this->fieldset->add(new Fieldset('barbaz'), array('priority' => 30)); + $this->fieldset->add(new Element('foo'), ['priority' => 10]); + $this->fieldset->add(new Element('bar'), ['priority' => 20]); + $this->fieldset->add(new Element('baz'), ['priority' => -10]); + $this->fieldset->add(new Fieldset('barbaz'), ['priority' => 30]); - $expected = array('barbaz', 'bar', 'foo', 'baz'); + $expected = ['barbaz', 'bar', 'foo', 'baz']; - $testOrig = array(); - $testClone = array(); + $testOrig = []; + $testClone = []; $fieldsetClone = clone $this->fieldset; @@ -389,36 +389,36 @@ public function testSubFieldsetsBindObject() $form = new Form(); $fieldset = new Fieldset('foobar'); $form->add($fieldset); - $value = new \ArrayObject(array( + $value = new \ArrayObject([ 'foobar' => 'abc', - )); - $value['foobar'] = new \ArrayObject(array( + ]); + $value['foobar'] = new \ArrayObject([ 'foo' => 'abc' - )); + ]); $form->bind($value); $this->assertSame($fieldset, $form->get('foobar')); } public function testBindEmptyValue() { - $value = new \ArrayObject(array( + $value = new \ArrayObject([ 'foo' => 'abc', 'bar' => 'def', - )); + ]); $inputFilter = new InputFilter(); - $inputFilter->add(array('name' => 'foo', 'required' => false)); - $inputFilter->add(array('name' => 'bar', 'required' => false)); + $inputFilter->add(['name' => 'foo', 'required' => false]); + $inputFilter->add(['name' => 'bar', 'required' => false]); $form = new Form(); $form->add(new Element('foo')); $form->add(new Element('bar')); $form->setInputFilter($inputFilter); $form->bind($value); - $form->setData(array( + $form->setData([ 'foo' => '', 'bar' => 'ghi', - )); + ]); $form->isValid(); $this->assertSame('', $value['foo']); @@ -435,9 +435,9 @@ public function testFieldsetExposesFluentInterface() public function testSetOptions() { - $this->fieldset->setOptions(array( + $this->fieldset->setOptions([ 'foo' => 'bar' - )); + ]); $option = $this->fieldset->getOption('foo'); $this->assertEquals('bar', $option); @@ -445,9 +445,9 @@ public function testSetOptions() public function testSetOptionsUseAsBaseFieldset() { - $this->fieldset->setOptions(array( + $this->fieldset->setOptions([ 'use_as_base_fieldset' => 'bar' - )); + ]); $option = $this->fieldset->getOption('use_as_base_fieldset'); $this->assertEquals('bar', $option); @@ -455,9 +455,9 @@ public function testSetOptionsUseAsBaseFieldset() public function testSetOptionAllowedObjectBindingClass() { - $this->fieldset->setOptions(array( + $this->fieldset->setOptions([ 'allowed_object_binding_class' => 'bar' - )); + ]); $option = $this->fieldset->getOption('allowed_object_binding_class'); $this->assertEquals('bar', $option); @@ -473,7 +473,7 @@ public function testShouldThrowExceptionWhenGetInvalidElement() public function testBindValuesHasNoName() { - $bindValues = $this->fieldset->bindValues(array('foo')); + $bindValues = $this->fieldset->bindValues(['foo']); $this->assertNull($bindValues); } @@ -493,7 +493,7 @@ public function testBindValuesSkipDisabled() $form->setObject($object); $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty()); - $form->bindValues(array('not_disabled' => 'modified', 'disabled' => 'modified')); + $form->bindValues(['not_disabled' => 'modified', 'disabled' => 'modified']); $this->assertEquals('modified', $object->not_disabled); $this->assertEquals('notModified', $object->disabled); @@ -518,7 +518,7 @@ public function testBindValuesDoesNotSkipElementsWithFalsyDisabledValues() $form->setObject($object); $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty()); - $form->bindValues(array('not_disabled' => 'modified', 'disabled' => 'modified')); + $form->bindValues(['not_disabled' => 'modified', 'disabled' => 'modified']); $this->assertEquals('modified', $object->not_disabled); $this->assertEquals('modified', $object->disabled); @@ -562,9 +562,9 @@ public function testBindValuesPreservesNewValueAfterValidation() $object->foo = 'Initial value'; $form->bind($object); - $form->setData(array( + $form->setData([ 'foo' => 'New value' - )); + ]); $this->assertSame('New value', $form->get('foo')->getValue()); diff --git a/test/FormAbstractServiceFactoryTest.php b/test/FormAbstractServiceFactoryTest.php index cb40e5f4..e2ce0edd 100644 --- a/test/FormAbstractServiceFactoryTest.php +++ b/test/FormAbstractServiceFactoryTest.php @@ -54,90 +54,90 @@ public function testMissingConfigServiceIndicatesCannotCreateForm() public function testMissingFormServicePrefixIndicatesCannotCreateForm() { - $this->services->setService('Config', array()); + $this->services->setService('Config', []); $this->assertFalse($this->forms->canCreateServiceWithName($this->services, 'foo', 'foo')); } public function testMissingFormManagerConfigIndicatesCannotCreateForm() { - $this->services->setService('Config', array()); + $this->services->setService('Config', []); $this->assertFalse($this->forms->canCreateServiceWithName($this->services, 'Form\Foo', 'Form\Foo')); } public function testInvalidFormManagerConfigIndicatesCannotCreateForm() { - $this->services->setService('Config', array('forms' => 'string')); + $this->services->setService('Config', ['forms' => 'string']); $this->assertFalse($this->forms->canCreateServiceWithName($this->services, 'Form\Foo', 'Form\Foo')); } public function testEmptyFormManagerConfigIndicatesCannotCreateForm() { - $this->services->setService('Config', array('forms' => array())); + $this->services->setService('Config', ['forms' => []]); $this->assertFalse($this->forms->canCreateServiceWithName($this->services, 'Form\Foo', 'Form\Foo')); } public function testMissingFormConfigIndicatesCannotCreateForm() { - $this->services->setService('Config', array( - 'forms' => array( - 'Bar' => array(), - ), - )); + $this->services->setService('Config', [ + 'forms' => [ + 'Bar' => [], + ], + ]); $this->assertFalse($this->forms->canCreateServiceWithName($this->services, 'Form\Foo', 'Form\Foo')); } public function testInvalidFormConfigIndicatesCannotCreateForm() { - $this->services->setService('Config', array( - 'forms' => array( + $this->services->setService('Config', [ + 'forms' => [ 'Foo' => 'string', - ), - )); + ], + ]); $this->assertFalse($this->forms->canCreateServiceWithName($this->services, 'Foo', 'Foo')); } public function testEmptyFormConfigIndicatesCannotCreateForm() { - $this->services->setService('Config', array( - 'forms' => array( - 'Foo' => array(), - ), - )); + $this->services->setService('Config', [ + 'forms' => [ + 'Foo' => [], + ], + ]); $this->assertFalse($this->forms->canCreateServiceWithName($this->services, 'Foo', 'Foo')); } public function testPopulatedFormConfigIndicatesFormCanBeCreated() { - $this->services->setService('Config', array( - 'forms' => array( - 'Foo' => array( + $this->services->setService('Config', [ + 'forms' => [ + 'Foo' => [ 'type' => 'Zend\Form\Form', - 'elements' => array(), - ), - ), - )); + 'elements' => [], + ], + ], + ]); $this->assertTrue($this->forms->canCreateServiceWithName($this->services, 'Foo', 'Foo')); } public function testFormCanBeCreatedViaInteractionOfAllManagers() { - $formConfig = array( + $formConfig = [ 'hydrator' => 'ObjectProperty', 'type' => 'Zend\Form\Form', - 'elements' => array( - array( - 'spec' => array( + 'elements' => [ + [ + 'spec' => [ 'type' => 'Zend\Form\Element\Email', 'name' => 'email', - 'options' => array( + 'options' => [ 'label' => 'Your email address', - ) - ), - ), - ), + ] + ], + ], + ], 'input_filter' => 'FooInputFilter', - ); - $config = array('forms' => array('Foo' => $formConfig)); + ]; + $config = ['forms' => ['Foo' => $formConfig]]; $this->services->setService('Config', $config); $form = $this->forms->createServiceWithName($this->services, 'Foo', 'Foo'); $this->assertInstanceOf('Zend\Form\Form', $form); @@ -158,37 +158,37 @@ public function testFormCanBeCreatedViaInteractionOfAllManagers() public function testFormCanBeCreatedViaInteractionOfAllManagersExceptInputFilterManager() { - $formConfig = array( + $formConfig = [ 'hydrator' => 'ObjectProperty', 'type' => 'Zend\Form\Form', - 'elements' => array( - array( - 'spec' => array( + 'elements' => [ + [ + 'spec' => [ 'type' => 'Zend\Form\Element\Email', 'name' => 'email', - 'options' => array( + 'options' => [ 'label' => 'Your email address', - ) - ), - ), - ), - 'input_filter' => array( - 'email' => array( + ] + ], + ], + ], + 'input_filter' => [ + 'email' => [ 'required' => true, - 'filters' => array( - array( + 'filters' => [ + [ 'name' => 'string_trim', - ), - ), - 'validators' => array( - array( + ], + ], + 'validators' => [ + [ 'name' => 'email_address', - ), - ), - ), - ), - ); - $config = array('forms' => array('Foo' => $formConfig)); + ], + ], + ], + ], + ]; + $config = ['forms' => ['Foo' => $formConfig]]; $this->services->setService('Config', $config); $form = $this->forms->createServiceWithName($this->services, 'Foo', 'Foo'); $this->assertInstanceOf('Zend\Form\Form', $form); diff --git a/test/FormElementManagerFactoryTest.php b/test/FormElementManagerFactoryTest.php index 06995b0d..d9537f16 100644 --- a/test/FormElementManagerFactoryTest.php +++ b/test/FormElementManagerFactoryTest.php @@ -36,7 +36,7 @@ class FormElementManagerFactoryTest extends TestCase public function setUp() { $formElementManagerFactory = new FormElementManagerFactory(); - $config = new ArrayObject(array('di' => array())); + $config = new ArrayObject(['di' => []]); $services = $this->services = new ServiceManager(); $services->setService('Zend\ServiceManager\ServiceLocatorInterface', $services); $services->setFactory('FormElementManager', $formElementManagerFactory); @@ -55,7 +55,7 @@ public function tearDown() $ref = new \ReflectionClass('Zend\Validator\Csrf'); $hashCache = $ref->getProperty('hashCache'); $hashCache->setAccessible(true); - $hashCache->setValue(new Csrf, array()); + $hashCache->setValue(new Csrf, []); SessionContainer::setDefaultManager(null); } @@ -86,7 +86,7 @@ public function testNoWrapFieldName() public function testCsrfCompatibility() { - $_SESSION = array(); + $_SESSION = []; $formClass = 'ZendTest\Form\TestAsset\CustomForm'; $ref = new \ReflectionClass('Zend\Validator\Csrf'); $hashPropRef = $ref->getProperty('hash'); @@ -103,7 +103,7 @@ public function testCsrfCompatibility() public function testCsrfWorkFlow() { - $_SESSION = array(); + $_SESSION = []; $formClass = 'ZendTest\Form\TestAsset\CustomForm'; $preForm = new $formClass; diff --git a/test/FormElementManagerTest.php b/test/FormElementManagerTest.php index c094d17f..a641797e 100644 --- a/test/FormElementManagerTest.php +++ b/test/FormElementManagerTest.php @@ -72,12 +72,12 @@ public function testStringCreationOptions() public function testArrayCreationOptions() { - $args = array( + $args = [ 'name' => 'foo', - 'options' => array( + 'options' => [ 'label' => 'bar' - ), - ); + ], + ]; $element = $this->manager->get('element', $args); $this->assertEquals('foo', $element->getName(), 'Specified name in array[name]'); $this->assertEquals('bar', $element->getLabel(), 'Specified options in array[options]'); @@ -85,9 +85,9 @@ public function testArrayCreationOptions() public function testOptionsCreationOptions() { - $args = array( + $args = [ 'label' => 'bar' - ); + ]; $element = $this->manager->get('element', $args); $this->assertEquals('element', $element->getName(), 'Invokable CNAME'); $this->assertEquals('bar', $element->getLabel(), 'Specified options in array'); @@ -95,11 +95,11 @@ public function testOptionsCreationOptions() public function testArrayOptionsCreationOptions() { - $args = array( - 'options' => array( + $args = [ + 'options' => [ 'label' => 'bar' - ), - ); + ], + ]; $element = $this->manager->get('element', $args); $this->assertEquals('element', $element->getName(), 'Invokable CNAME'); $this->assertEquals('bar', $element->getLabel(), 'Specified options in array[options]'); @@ -110,7 +110,7 @@ public function testArrayOptionsCreationOptions() */ public function testSharedFormElementsAreNotInitializedMultipleTimes() { - $element = $this->getMock('Zend\Form\Element', array('init')); + $element = $this->getMock('Zend\Form\Element', ['init']); $element->expects($this->once())->method('init'); diff --git a/test/FormTest.php b/test/FormTest.php index ff839ec7..2370c558 100644 --- a/test/FormTest.php +++ b/test/FormTest.php @@ -65,7 +65,7 @@ public function getOneToManyEntity() $secondCategory = new TestAsset\Entity\Category(); $secondCategory->setName('Armchair'); - $product->setCategories(array($firstCategory, $secondCategory)); + $product->setCategories([$firstCategory, $secondCategory]); return $product; } @@ -86,71 +86,71 @@ public function populateForm() $this->form->add($fieldset); $inputFilterFactory = new InputFilterFactory(); - $inputFilter = $inputFilterFactory->createInputFilter(array( - 'foo' => array( + $inputFilter = $inputFilterFactory->createInputFilter([ + 'foo' => [ 'name' => 'foo', 'required' => false, - 'validators' => array( - array( + 'validators' => [ + [ 'name' => 'not_empty', - ), - array( + ], + [ 'name' => 'string_length', - 'options' => array( + 'options' => [ 'min' => 3, 'max' => 5, - ), - ), - ), - ), - 'bar' => array( + ], + ], + ], + ], + 'bar' => [ 'allow_empty' => true, - 'filters' => array( - array( + 'filters' => [ + [ 'name' => 'string_trim', - ), - array( + ], + [ 'name' => 'string_to_lower', - 'options' => array( + 'options' => [ 'encoding' => 'ISO-8859-1', - ), - ), - ), - ), - 'foobar' => array( + ], + ], + ], + ], + 'foobar' => [ 'type' => 'Zend\InputFilter\InputFilter', - 'foo' => array( + 'foo' => [ 'name' => 'foo', 'required' => true, - 'validators' => array( - array( + 'validators' => [ + [ 'name' => 'not_empty', - ), - array( + ], + [ 'name' => 'string_length', - 'options' => array( + 'options' => [ 'min' => 3, 'max' => 5, - ), - ), - ), - ), - 'bar' => array( + ], + ], + ], + ], + 'bar' => [ 'allow_empty' => true, - 'filters' => array( - array( + 'filters' => [ + [ 'name' => 'string_trim', - ), - array( + ], + [ 'name' => 'string_to_lower', - 'options' => array( + 'options' => [ 'encoding' => 'ISO-8859-1', - ), - ), - ), - ), - ), - )); + ], + ], + ], + ], + ], + ]); $this->form->setInputFilter($inputFilter); } @@ -217,7 +217,7 @@ public function testHasValidatedFlag() $this->assertFalse($form->hasValidated()); - $form->setData(array()); + $form->setData([]); $form->isValid(); @@ -227,25 +227,25 @@ public function testHasValidatedFlag() public function testValidatesEntireDataSetByDefault() { $this->populateForm(); - $invalidSet = array( + $invalidSet = [ 'foo' => 'a', 'bar' => 'always valid', - 'foobar' => array( + 'foobar' => [ 'foo' => 'a', 'bar' => 'always valid', - ), - ); + ], + ]; $this->form->setData($invalidSet); $this->assertFalse($this->form->isValid()); - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => 'always valid', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => 'always valid', - ), - ); + ], + ]; $this->form->setData($validSet); $this->assertTrue($this->form->isValid()); } @@ -258,16 +258,16 @@ public function testSpecifyingValidationGroupForcesPartialValidation() } $this->populateForm(); - $invalidSet = array( + $invalidSet = [ 'foo' => 'a', - ); + ]; $this->form->setValidationGroup('foo'); $this->form->setData($invalidSet); $this->assertFalse($this->form->isValid()); - $validSet = array( + $validSet = [ 'foo' => 'abcde', - ); + ]; $this->form->setData($validSet); $this->assertTrue($this->form->isValid()); } @@ -280,19 +280,19 @@ public function testSpecifyingValidationGroupForNestedFieldsetsForcesPartialVali } $form = new TestAsset\NewProductForm(); - $form->setData(array( - 'product' => array( + $form->setData([ + 'product' => [ 'name' => 'Chair' - ) - )); + ] + ]); $this->assertFalse($form->isValid()); - $form->setValidationGroup(array( - 'product' => array( + $form->setValidationGroup([ + 'product' => [ 'name' - ) - )); + ] + ]); $this->assertTrue($form->isValid()); } @@ -302,9 +302,9 @@ public function testSettingValidateAllFlagAfterPartialValidationForcesFullValida $this->populateForm(); $this->form->setValidationGroup('foo'); - $validSet = array( + $validSet = [ 'foo' => 'abcde', - ); + ]; $this->form->setData($validSet); $this->form->setValidationGroup(Form::VALIDATE_ALL); $this->assertFalse($this->form->isValid()); @@ -333,14 +333,14 @@ public function testAttemptingToValidateWithNoInputFilterAttachedRaisesException public function testCanRetrieveDataWithoutErrorsFollowingValidation() { $this->populateForm(); - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid ', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid', - ), - ); + ], + ]; $this->form->setData($validSet); $this->form->isValid(); @@ -355,7 +355,7 @@ public function testCanAddFileEnctypeAttribute() { $file = new Element\File('file_resource'); $file - ->setOptions(array()) + ->setOptions([]) ->setLabel('File'); $this->form->add($file); @@ -372,16 +372,16 @@ public function testCanAddFileEnctypeFromCollectionAttribute() { $file = new Element\File('file_resource'); $file - ->setOptions(array()) + ->setOptions([]) ->setLabel('File'); $fileCollection = new Element\Collection('collection'); - $fileCollection->setOptions(array( + $fileCollection->setOptions([ 'count' => 2, 'allow_add' => false, 'allow_remove' => false, 'target_element' => $file, - )); + ]); $this->form->add($fileCollection); $this->form->prepare(); @@ -393,40 +393,40 @@ public function testCanAddFileEnctypeFromCollectionAttribute() public function testCallingGetDataReturnsNormalizedDataByDefault() { $this->populateForm(); - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid ', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid', - ), - ); + ], + ]; $this->form->setData($validSet); $this->form->isValid(); $data = $this->form->getData(); - $expected = array( + $expected = [ 'foo' => 'abcde', 'bar' => 'always valid', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => 'always valid', - ), - ); + ], + ]; $this->assertEquals($expected, $data); } public function testAllowsReturningRawValuesViaGetData() { $this->populateForm(); - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid ', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid', - ), - ); + ], + ]; $this->form->setData($validSet); $this->form->isValid(); $data = $this->form->getData(Form::VALUES_RAW); @@ -438,7 +438,7 @@ public function testGetDataReturnsBoundModel() $model = new stdClass; $this->form->setHydrator(new Hydrator\ObjectProperty()); $this->populateForm(); - $this->form->setData(array()); + $this->form->setData([]); $this->form->bind($model); $this->form->isValid(); $data = $this->form->getData(); @@ -448,14 +448,14 @@ public function testGetDataReturnsBoundModel() public function testGetDataCanReturnValuesAsArrayWhenModelIsBound() { $model = new stdClass; - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => 'always valid', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => 'always valid', - ), - ); + ], + ]; $this->populateForm(); $this->form->setHydrator(new Hydrator\ObjectProperty()); $this->form->bind($model); @@ -468,14 +468,14 @@ public function testGetDataCanReturnValuesAsArrayWhenModelIsBound() public function testValuesBoundToModelAreNormalizedByDefault() { $model = new stdClass; - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid ', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => ' always VALID', - ), - ); + ], + ]; $this->populateForm(); $this->form->setHydrator(new Hydrator\ObjectProperty()); $this->form->bind($model); @@ -487,23 +487,23 @@ public function testValuesBoundToModelAreNormalizedByDefault() $this->assertObjectHasAttribute('bar', $model); $this->assertEquals('always valid', $model->bar); $this->assertObjectHasAttribute('foobar', $model); - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'abcde', 'bar' => 'always valid', - ), $model->foobar); + ], $model->foobar); } public function testCanBindRawValuesToModel() { $model = new stdClass; - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid ', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => ' always VALID', - ), - ); + ], + ]; $this->populateForm(); $this->form->setHydrator(new Hydrator\ObjectProperty()); $this->form->bind($model, Form::VALUES_RAW); @@ -515,22 +515,22 @@ public function testCanBindRawValuesToModel() $this->assertObjectHasAttribute('bar', $model); $this->assertEquals(' ALWAYS valid ', $model->bar); $this->assertObjectHasAttribute('foobar', $model); - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'abcde', 'bar' => ' always VALID', - ), $model->foobar); + ], $model->foobar); } public function testGetDataReturnsSubsetOfDataWhenValidationGroupSet() { - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid ', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => ' always VALID', - ), - ); + ], + ]; $this->populateForm(); $this->form->setValidationGroup('foo'); $this->form->setData($validSet); @@ -545,14 +545,14 @@ public function testGetDataReturnsSubsetOfDataWhenValidationGroupSet() public function testSettingValidationGroupBindsOnlyThoseValuesToModel() { $model = new stdClass; - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid ', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => ' always VALID', - ), - ); + ], + ]; $this->populateForm(); $this->form->setHydrator(new Hydrator\ObjectProperty()); $this->form->bind($model); @@ -569,14 +569,14 @@ public function testSettingValidationGroupBindsOnlyThoseValuesToModel() public function testCanBindModelsToArraySerializableObjects() { $model = new TestAsset\Model(); - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => 'always valid', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => 'always valid', - ), - ); + ], + ]; $this->populateForm(); $this->form->setHydrator(new Hydrator\ArraySerializable()); $this->form->bind($model); @@ -585,10 +585,10 @@ public function testCanBindModelsToArraySerializableObjects() $this->assertEquals('abcde', $model->foo); $this->assertEquals('always valid', $model->bar); - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'abcde', 'bar' => 'always valid', - ), $model->foobar); + ], $model->foobar); } public function testSetsInputFilterToFilterFromBoundModelIfModelImplementsInputLocatorAware() @@ -603,18 +603,18 @@ public function testSetsInputFilterToFilterFromBoundModelIfModelImplementsInputL public function testSettingDataShouldSetElementValues() { $this->populateForm(); - $data = array( + $data = [ 'foo' => 'abcde', 'bar' => 'always valid', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => 'always valid', - ), - ); + ], + ]; $this->form->setData($data); $fieldset = $this->form->get('foobar'); - foreach (array('foo', 'bar') as $name) { + foreach (['foo', 'bar'] as $name) { $element = $this->form->get($name); $this->assertEquals($data[$name], $element->getValue()); @@ -644,10 +644,10 @@ public function testUsesBoundObjectAsDataSourceWhenNoDataSet() $object = new stdClass(); $object->foo = 'foos'; $object->bar = 'bar'; - $object->foobar = array( + $object->foobar = [ 'foo' => 'foos', 'bar' => 'bar', - ); + ]; $this->form->setHydrator(new Hydrator\ObjectProperty()); $this->form->bind($object); @@ -682,14 +682,14 @@ public function testCanDisableBindOnValidateFunctionality() public function testCallingBindValuesWhenBindOnValidateIsDisabledPopulatesBoundObject() { $model = new stdClass; - $validSet = array( + $validSet = [ 'foo' => 'abcde', 'bar' => ' ALWAYS valid ', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => ' always VALID', - ), - ); + ], + ]; $this->populateForm(); $this->form->setHydrator(new Hydrator\ObjectProperty()); $this->form->setBindOnValidate(false); @@ -708,10 +708,10 @@ public function testCallingBindValuesWhenBindOnValidateIsDisabledPopulatesBoundO $this->assertObjectHasAttribute('bar', $model); $this->assertEquals('always valid', $model->bar); $this->assertObjectHasAttribute('foobar', $model); - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'abcde', 'bar' => 'always valid', - ), $model->foobar); + ], $model->foobar); } public function testHasFactoryComposedByDefault() @@ -729,14 +729,14 @@ public function testCanComposeFactory() public function testCanAddElementsUsingSpecs() { - $this->form->add(array( + $this->form->add([ 'name' => 'foo', - 'attributes' => array( + 'attributes' => [ 'type' => 'text', 'class' => 'foo-class', 'data-js-type' => 'my.form.text', - ), - )); + ], + ]); $this->assertTrue($this->form->has('foo')); $element = $this->form->get('foo'); $this->assertInstanceOf('Zend\Form\ElementInterface', $element); @@ -748,15 +748,15 @@ public function testCanAddElementsUsingSpecs() public function testCanAddFieldsetsUsingSpecs() { - $this->form->add(array( + $this->form->add([ 'type' => 'Zend\Form\Fieldset', 'name' => 'foo', - 'attributes' => array( + 'attributes' => [ 'type' => 'fieldset', 'class' => 'foo-class', 'data-js-type' => 'my.form.fieldset', - ), - )); + ], + ]); $this->assertTrue($this->form->has('foo')); $fieldset = $this->form->get('foo'); $this->assertInstanceOf('Zend\Form\FieldsetInterface', $fieldset); @@ -769,25 +769,25 @@ public function testCanAddFieldsetsUsingSpecs() public function testFormAsFieldsetWillBindValuesToObject() { $parentForm = new Form('parent'); - $parentFormObject = new \ArrayObject(array('parentId' => null)); + $parentFormObject = new \ArrayObject(['parentId' => null]); $parentFormElement = new Element('parentId'); $parentForm->setObject($parentFormObject); $parentForm->add($parentFormElement); $childForm = new Form('child'); - $childFormObject = new \ArrayObject(array('childId' => null)); + $childFormObject = new \ArrayObject(['childId' => null]); $childFormElement = new Element('childId'); $childForm->setObject($childFormObject); $childForm->add($childFormElement); $parentForm->add($childForm); - $data = array( + $data = [ 'parentId' => 'mpinkston was here', - 'child' => array( + 'child' => [ 'childId' => 'testing 123' - ) - ); + ] + ]; $parentForm->setData($data); $this->assertTrue($parentForm->isValid()); @@ -865,12 +865,12 @@ public function testWillUseFormInputFilterOverrideOverInputSpecificationFromElem $element = new TestAsset\ElementWithFilter('foo'); $filter = new InputFilter(); $filterFactory = new InputFilterFactory(); - $filter = $filterFactory->createInputFilter(array( - 'foo' => array( + $filter = $filterFactory->createInputFilter([ + 'foo' => [ 'name' => 'foo', 'required' => false, - ), - )); + ], + ]); $this->form->setPreferFormInputFilter(true); $this->form->setInputFilter($filter); $this->form->add($element); @@ -935,16 +935,16 @@ public function testCallingPrepareEnsuresInputFilterRetrievesDefaults() public function testCanProperlyPrepareNestedFieldsets() { - $this->form->add(array( + $this->form->add([ 'name' => 'foo', - 'attributes' => array( + 'attributes' => [ 'type' => 'text' - ) - )); + ] + ]); - $this->form->add(array( + $this->form->add([ 'type' => 'ZendTest\Form\TestAsset\BasicFieldset' - )); + ]); $this->form->prepare(); @@ -980,19 +980,19 @@ public function testCanCorrectlyPopulateDataToComposedEntities() $form = new TestAsset\CreateAddressForm(); $form->bind($emptyAddress); - $data = array( - 'address' => array( + $data = [ + 'address' => [ 'street' => '1 Rue des Champs Elysées', - 'city' => array( + 'city' => [ 'name' => 'Paris', 'zipCode' => '75008', - 'country' => array( + 'country' => [ 'name' => 'France', 'continent' => 'Europe' - ) - ) - ) - ); + ] + ] + ] + ]; $form->setData($data); @@ -1028,20 +1028,20 @@ public function testCanCorrectlyPopulateDataToOneToManyEntites() $form = new TestAsset\NewProductForm(); $form->bind($emptyProduct); - $data = array( - 'product' => array( + $data = [ + 'product' => [ 'name' => 'Chair', 'price' => 10, - 'categories' => array( - array( + 'categories' => [ + [ 'name' => 'Office' - ), - array( + ], + [ 'name' => 'Armchair' - ) - ) - ) - ); + ] + ] + ] + ]; $form->setData($data); @@ -1057,16 +1057,16 @@ public function testCanCorrectlyPopulateOrphanedEntities() $form = new TestAsset\OrphansForm(); - $data = array( - 'test' => array( - array( + $data = [ + 'test' => [ + [ 'name' => 'Foo' - ), - array( + ], + [ 'name' => 'Bar' - ), - ) - ); + ], + ] + ]; $form->setData($data); $valid = $form->isValid(); @@ -1130,13 +1130,13 @@ public function testAssertElementsNamesCanBeWrappedAroundFormName() public function testUnsetValuesNotBound() { $model = new stdClass; - $validSet = array( + $validSet = [ 'bar' => 'always valid', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => 'always valid', - ), - ); + ], + ]; $this->populateForm(); $this->form->setHydrator(new Hydrator\ObjectProperty()); $this->form->bind($model); @@ -1149,53 +1149,53 @@ public function testUnsetValuesNotBound() public function testRemoveCollectionFromValidationGroupWhenZeroCountAndNoData() { - $dataWithoutCollection = array( + $dataWithoutCollection = [ 'foo' => 'bar' - ); + ]; $this->populateForm(); - $this->form->add(array( + $this->form->add([ 'type' => 'Zend\Form\Element\Collection', 'name' => 'categories', - 'options' => array( + 'options' => [ 'count' => 0, - 'target_element' => array( + 'target_element' => [ 'type' => 'ZendTest\Form\TestAsset\CategoryFieldset' - ) - ) - )); - $this->form->setValidationGroup(array( + ] + ] + ]); + $this->form->setValidationGroup([ 'foo', - 'categories' => array( + 'categories' => [ 'name' - ) - )); + ] + ]); $this->form->setData($dataWithoutCollection); $this->assertTrue($this->form->isValid()); } public function testFieldsetValidationGroupStillPreparedWhenEmptyData() { - $emptyData = array(); + $emptyData = []; $this->populateForm(); - $this->form->get('foobar')->add(array( + $this->form->get('foobar')->add([ 'type' => 'Zend\Form\Element\Collection', 'name' => 'categories', - 'options' => array( + 'options' => [ 'count' => 0, - 'target_element' => array( + 'target_element' => [ 'type' => 'ZendTest\Form\TestAsset\CategoryFieldset' - ) - ) - )); + ] + ] + ]); - $this->form->setValidationGroup(array( - 'foobar' => array( - 'categories' => array( + $this->form->setValidationGroup([ + 'foobar' => [ + 'categories' => [ 'name' - ) - ) - )); + ] + ] + ]); $this->form->setData($emptyData); $this->assertFalse($this->form->isValid()); @@ -1207,31 +1207,31 @@ public function testApplyObjectInputFilterToBaseFieldsetAndApplyValidationGroup( $fieldset->add(new Element('foo')); $fieldset->setUseAsBaseFieldset(true); $this->form->add($fieldset); - $this->form->setValidationGroup(array( - 'foobar'=> array( + $this->form->setValidationGroup([ + 'foobar'=> [ 'foo', - ) - )); + ] + ]); $inputFilterFactory = new InputFilterFactory(); - $inputFilter = $inputFilterFactory->createInputFilter(array( - 'foo' => array( + $inputFilter = $inputFilterFactory->createInputFilter([ + 'foo' => [ 'name' => 'foo', 'required' => true, - ), - )); + ], + ]); $model = new TestAsset\ValidatingModel(); $model->setInputFilter($inputFilter); $this->form->bind($model); - $this->form->setData(array()); + $this->form->setData([]); $this->assertFalse($this->form->isValid()); - $validSet = array( - 'foobar' => array( + $validSet = [ + 'foobar' => [ 'foo' => 'abcde', - ) - ); + ] + ]; $this->form->setData($validSet); $this->assertTrue($this->form->isValid()); } @@ -1247,12 +1247,12 @@ public function testDoNotApplyEmptyInputFiltersToSubFieldsetOfCollectionElements $this->form->add($collection); $inputFilterFactory = new InputFilterFactory(); - $inputFilter = $inputFilterFactory->createInputFilter(array( - 'items' => array( + $inputFilter = $inputFilterFactory->createInputFilter([ + 'items' => [ 'type' => 'Zend\InputFilter\CollectionInputFilter', 'input_filter' => new InputFilter(), - ), - )); + ], + ]); $this->form->setInputFilter($inputFilter); @@ -1262,32 +1262,32 @@ public function testDoNotApplyEmptyInputFiltersToSubFieldsetOfCollectionElements public function testFormValidationCanHandleNonConsecutiveKeysOfCollectionInData() { - $dataWithCollection = array( + $dataWithCollection = [ 'foo' => 'bar', - 'categories' => array( - 0 => array('name' => 'cat1'), - 1 => array('name' => 'cat2'), - 3 => array('name' => 'cat3'), - ), - ); + 'categories' => [ + 0 => ['name' => 'cat1'], + 1 => ['name' => 'cat2'], + 3 => ['name' => 'cat3'], + ], + ]; $this->populateForm(); - $this->form->add(array( + $this->form->add([ 'type' => 'Zend\Form\Element\Collection', 'name' => 'categories', - 'options' => array( + 'options' => [ 'count' => 1, 'allow_add' => true, - 'target_element' => array( + 'target_element' => [ 'type' => 'ZendTest\Form\TestAsset\CategoryFieldset' - ) - ) - )); - $this->form->setValidationGroup(array( + ] + ] + ]); + $this->form->setValidationGroup([ 'foo', - 'categories' => array( + 'categories' => [ 'name' - ) - )); + ] + ]); $this->form->setData($dataWithCollection); $this->assertTrue($this->form->isValid()); } @@ -1300,12 +1300,12 @@ public function testAddNonBaseFieldsetObjectInputFilterToFormInputFilter() $this->form->add($fieldset); $inputFilterFactory = new InputFilterFactory(); - $inputFilter = $inputFilterFactory->createInputFilter(array( - 'foo' => array( + $inputFilter = $inputFilterFactory->createInputFilter([ + 'foo' => [ 'name' => 'foo', 'required' => true, - ), - )); + ], + ]); $model = new TestAsset\ValidatingModel(); $model->setInputFilter($inputFilter); @@ -1325,12 +1325,12 @@ public function testExtractDataHydratorStrategy() $model = new TestAsset\HydratorStrategyEntityA(); $this->form->bind($model); - $validSet = array( - 'entities' => array( + $validSet = [ + 'entities' => [ 111, 333 - ), - ); + ], + ]; $this->form->setData($validSet); $this->form->isValid(); @@ -1352,14 +1352,14 @@ public function testSetDataWithNullValues() { $this->populateForm(); - $set = array( + $set = [ 'foo' => null, 'bar' => 'always valid', - 'foobar' => array( + 'foobar' => [ 'foo' => 'abcde', 'bar' => 'always valid', - ), - ); + ], + ]; $this->form->setData($set); $this->assertTrue($this->form->isValid()); } @@ -1397,26 +1397,26 @@ public function testSetDataOnValidateWrongFlagRaisesException() public function testSetDataIsTraversable() { - $this->form->setData(new \ArrayObject(array('foo' => 'bar'))); + $this->form->setData(new \ArrayObject(['foo' => 'bar'])); $this->assertTrue($this->form->isValid()); } public function testResetPasswordValueIfFormIsNotValid() { - $this->form->add(array( + $this->form->add([ 'type' => 'Zend\Form\Element\Password', 'name' => 'password' - )); + ]); - $this->form->add(array( + $this->form->add([ 'type' => 'Zend\Form\Element\Email', 'name' => 'email' - )); + ]); - $this->form->setData(array( + $this->form->setData([ 'password' => 'azerty', 'email' => 'wrongEmail' - )); + ]); $this->assertFalse($this->form->isValid()); $this->form->prepare(); @@ -1427,9 +1427,9 @@ public function testResetPasswordValueIfFormIsNotValid() public function testCorrectlyHydrateBaseFieldsetWhenHydratorThatDoesNotIgnoreInvalidDataIsUsed() { $fieldset = new Fieldset('example'); - $fieldset->add(array( + $fieldset->add([ 'name' => 'foo' - )); + ]); // Add a hydrator that ignores if values does not exist in the $fieldset->setObject(new Entity\SimplePublicProperty()); @@ -1440,20 +1440,20 @@ public function testCorrectlyHydrateBaseFieldsetWhenHydratorThatDoesNotIgnoreInv $this->form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty()); // Add some inputs that do not belong to the base fieldset - $this->form->add(array( + $this->form->add([ 'type' => 'Zend\Form\Element\Submit', 'name' => 'submit' - )); + ]); $object = new Entity\SimplePublicProperty(); $this->form->bind($object); - $this->form->setData(array( + $this->form->setData([ 'submit' => 'Confirm', - 'example' => array( + 'example' => [ 'foo' => 'value example' - ) - )); + ] + ]); $this->assertTrue($this->form->isValid()); @@ -1463,13 +1463,13 @@ public function testCorrectlyHydrateBaseFieldsetWhenHydratorThatDoesNotIgnoreInv public function testPrepareBindDataAllowsFilterToConvertStringToArray() { - $data = array( + $data = [ 'foo' => '1,2', - ); + ]; - $filteredData = array( - 'foo' => array(1, 2) - ); + $filteredData = [ + 'foo' => [1, 2] + ]; $element = new TestAsset\ElementWithStringToArrayFilter('foo'); $hydrator = $this->getMock('Zend\Stdlib\Hydrator\ArraySerializable'); @@ -1484,7 +1484,7 @@ public function testPrepareBindDataAllowsFilterToConvertStringToArray() public function testGetValidationGroup() { - $group = array('foo'); + $group = ['foo']; $this->form->setValidationGroup($group); $this->assertEquals($group, $this->form->getValidationGroup()); } @@ -1517,21 +1517,21 @@ public function testPreserveEntitiesBoundToCollectionAfterValidation() $c2->setId(2); $c2->setName('Second Category'); - $product->setCategories(array($c1, $c2)); + $product->setCategories([$c1, $c2]); $this->form->add($fieldset); $this->form->bind($product); - $data = array( - 'product' => array( + $data = [ + 'product' => [ 'name' => 'Barbar', 'price' => 200, - 'categories' => array( - array('name' => 'Something else'), - array('name' => 'Totally different'), - ), - ), - ); + 'categories' => [ + ['name' => 'Something else'], + ['name' => 'Totally different'], + ], + ], + ]; $hash1 = spl_object_hash($this->form->getObject()->getCategory(0)); $this->form->setData($data); @@ -1593,25 +1593,25 @@ public function testCanOverrideDefaultInputSettings() public function testComplexFormInputFilterMergesIntoExisting() { $this->form->setPreferFormInputFilter(true); - $this->form->add(array( + $this->form->add([ 'name' => 'importance', 'type' => 'Zend\Form\Element\Select', - 'options' => array( + 'options' => [ 'label' => 'Importance', 'empty_option' => '', - 'value_options' => array( + 'value_options' => [ 'normal' => 'Normal', 'important' => 'Important' - ), - ), - )); + ], + ], + ]); $inputFilter = new \Zend\InputFilter\BaseInputFilter(); $factory = new \Zend\InputFilter\Factory(); - $inputFilter->add($factory->createInput(array( + $inputFilter->add($factory->createInput([ 'name' => 'importance', 'required' => false, - ))); + ])); $this->assertTrue($this->form->getInputFilter()->get('importance')->isRequired()); $this->assertFalse($inputFilter->get('importance')->isRequired()); @@ -1625,43 +1625,43 @@ public function testComplexFormInputFilterMergesIntoExisting() */ public function testInputFilterOrderOfPrecedence1() { - $spec = array( + $spec = [ 'name' => 'test', - 'elements' => array( - array( - 'spec' => array( + 'elements' => [ + [ + 'spec' => [ 'name' => 'element', 'type' => 'Zend\Form\Element\Checkbox', - 'options' => array( + 'options' => [ 'use_hidden_element' => true, 'checked_value' => '1', 'unchecked_value' => '0' - ) - ) - ) - ), - 'input_filter' => array( - 'element' => array( + ] + ] + ] + ], + 'input_filter' => [ + 'element' => [ 'required' => false, - 'filters' => array( - array( + 'filters' => [ + [ 'name' => 'Boolean' - ) - ), - 'validators' => array( - array( + ] + ], + 'validators' => [ + [ 'name' => 'InArray', - 'options' => array( - 'haystack' => array( + 'options' => [ + 'haystack' => [ "0", "1" - ) - ) - ) - ) - ) - ) - ); + ] + ] + ] + ] + ] + ] + ]; $factory = new Factory(); $this->form = $factory->createForm($spec); @@ -1677,9 +1677,9 @@ public function testInputFilterOrderOfPrecedence1() public function testCanSetPreferFormInputFilterFlagViaSetOptions() { $flag = ! $this->form->getPreferFormInputFilter(); - $this->form->setOptions(array( + $this->form->setOptions([ 'prefer_form_input_filter' => $flag, - )); + ]); $this->assertSame($flag, $this->form->getPreferFormInputFilter()); } @@ -1689,13 +1689,13 @@ public function testCanSetPreferFormInputFilterFlagViaSetOptions() public function testFactoryCanSetPreferFormInputFilterFlag() { $factory = new Factory(); - foreach (array(true, false) as $flag) { - $form = $factory->createForm(array( + foreach ([true, false] as $flag) { + $form = $factory->createForm([ 'name' => 'form', - 'options' => array( + 'options' => [ 'prefer_form_input_filter' => $flag, - ), - )); + ], + ]); $this->assertSame($flag, $form->getPreferFormInputFilter()); } } @@ -1737,138 +1737,138 @@ public function testInputFilterNotAddedTwiceWhenUsingFieldsets() public function testFormWithNestedCollections() { - $spec = array( + $spec = [ 'name' => 'test', - 'elements' => array( - array( - 'spec' => array( + 'elements' => [ + [ + 'spec' => [ 'name' => 'name', 'type' => 'Zend\Form\Element\Text', - ), - 'spec' => array( + ], + 'spec' => [ 'name' => 'groups', 'type' => 'Zend\Form\Element\Collection', - 'options' => array( - 'target_element' => array( + 'options' => [ + 'target_element' => [ 'type' => 'Zend\Form\Fieldset', 'name' => 'group', - 'elements' => array( - array( - 'spec' => array( + 'elements' => [ + [ + 'spec' => [ 'type' => 'Zend\Form\Element\Text', 'name' => 'group_class', - ), - ), - array( - 'spec' => array( + ], + ], + [ + 'spec' => [ 'type' => 'Zend\Form\Element\Collection', 'name' => 'items', - 'options' => array( - 'target_element' => array( + 'options' => [ + 'target_element' => [ 'type' => 'Zend\Form\Fieldset', 'name' => 'item', - 'elements' => array( - array( - 'spec' => array( + 'elements' => [ + [ + 'spec' => [ 'type' => 'Zend\Form\Element\Text', 'name' => 'id', - ), - ), - array( - 'spec' => array( + ], + ], + [ + 'spec' => [ 'type' => 'Zend\Form\Element\Text', 'name' => 'type', - ), - ), - ), - ), - ), - ), - ), - ), - ), - ), - ) - ) - ), - 'input_filter' => array( + ], + ], + ], + ], + ], + ], + ], + ], + ], + ], + ] + ] + ], + 'input_filter' => [ 'type' => 'Zend\InputFilter\InputFilter', - 'name' => array( - 'filters' => array( - array('name' => 'StringTrim'), - array('name' => 'Null'), - ), - 'validators' => array( - array( + 'name' => [ + 'filters' => [ + ['name' => 'StringTrim'], + ['name' => 'Null'], + ], + 'validators' => [ + [ 'name' => 'StringLength', - 'options' => array( + 'options' => [ 'max' => 255, - ), - ), - ), - ), - 'groups' => array( + ], + ], + ], + ], + 'groups' => [ 'type' => 'Zend\InputFilter\CollectionInputFilter', - 'input_filter' => array( + 'input_filter' => [ 'type' => 'Zend\InputFilter\InputFilter', - 'group_class' => array( + 'group_class' => [ 'required' => false, - ), - 'items' => array( + ], + 'items' => [ 'type' => 'Zend\InputFilter\CollectionInputFilter', - 'input_filter' => array( + 'input_filter' => [ 'type' => 'Zend\InputFilter\InputFilter', - 'id' => array( + 'id' => [ 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'required' => false, - ), - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ], + ]; $factory = new Factory(); $this->form = $factory->createForm($spec); - $data = array( + $data = [ 'name' => 'foo', - 'groups' => array( - array( + 'groups' => [ + [ 'group_class' => 'bar', - 'items' => array( - array( + 'items' => [ + [ 'id' => 100, 'type' => 'item-1', - ), - ), - ), - array( + ], + ], + ], + [ 'group_class' => 'bar', - 'items' => array( - array( + 'items' => [ + [ 'id' => 200, 'type' => 'item-2', - ), - array( + ], + [ 'id' => 300, 'type' => 'item-3', - ), - array( + ], + [ 'id' => 400, 'type' => 'item-4', - ), - ), - ), - array( + ], + ], + ], + [ 'group_class' => 'biz', - 'items' => array(), - ), - ), - ); + 'items' => [], + ], + ], + ]; $this->form->setData($data); @@ -1878,17 +1878,17 @@ public function testFormWithNestedCollections() public function testFormWithCollectionsAndNestedFieldsetsWithInputFilterProviderInterface() { - $this->form->add(array( + $this->form->add([ 'type' => 'Zend\Form\Element\Collection', 'name' => 'nested_fieldset_with_input_filter_provider', - 'options' => array( + 'options' => [ 'label' => 'InputFilterProviderFieldset', 'count' => 1, - 'target_element' => array( + 'target_element' => [ 'type' => 'ZendTest\Form\TestAsset\InputFilterProviderFieldset' - ) - ), - )); + ] + ], + ]); $this->assertTrue( $this->form->getInputFilter() @@ -1901,35 +1901,35 @@ public function testFormWithCollectionsAndNestedFieldsetsWithInputFilterProvider public function testFormElementValidatorsMergeIntoAppliedInputFilter() { - $this->form->add(array( + $this->form->add([ 'name' => 'importance', 'type' => 'Zend\Form\Element\Select', - 'options' => array( + 'options' => [ 'label' => 'Importance', 'empty_option' => '', - 'value_options' => array( + 'value_options' => [ 'normal' => 'Normal', 'important' => 'Important' - ), - ), - )); + ], + ], + ]); $inputFilter = new BaseInputFilter(); $factory = new InputFilterFactory(); - $inputFilter->add($factory->createInput(array( + $inputFilter->add($factory->createInput([ 'name' => 'importance', 'required' => false, - ))); + ])); - $data = array( + $data = [ 'importance' => 'unimporant' - ); + ]; $this->form->setInputFilter($inputFilter); $this->form->setData($data); $this->assertFalse($this->form->isValid()); - $data = array(); + $data = []; $this->form->setData($data); $this->assertTrue($this->form->isValid()); @@ -1950,20 +1950,20 @@ public function testFormWithSelectMultipleAndEmptyUnselectedValue( $unselectedValue, $useHiddenElement ) { - $this->form->add(array( + $this->form->add([ 'name' => 'multipleSelect', 'type' => 'Zend\Form\Element\Select', - 'attributes' => array('multiple' => 'multiple'), - 'options' => array( + 'attributes' => ['multiple' => 'multiple'], + 'options' => [ 'label' => 'Importance', 'use_hidden_element' => $useHiddenElement, 'unselected_value' => $unselectedValue, - 'value_options' => array( + 'value_options' => [ 'foo' => 'Foo', 'bar' => 'Bar' - ), - ), - )); + ], + ], + ]); $actualIsValid = $this->form->setData($data)->isValid(); $this->assertEquals($expectedIsValid, $actualIsValid); @@ -1977,60 +1977,60 @@ public function testFormWithSelectMultipleAndEmptyUnselectedValue( */ public function formWithSelectMultipleAndEmptyUnselectedValueDataProvider() { - return array( - array( + return [ + [ true, - array('multipleSelect' => array('foo')), - array('multipleSelect' => array('foo')), + ['multipleSelect' => ['foo']], + ['multipleSelect' => ['foo']], '', true - ), - array( + ], + [ true, - array('multipleSelect' => array()), - array('multipleSelect' => ''), + ['multipleSelect' => []], + ['multipleSelect' => ''], '', true - ), - array( + ], + [ true, - array('multipleSelect' => array()), - array('multipleSelect' => 'empty'), + ['multipleSelect' => []], + ['multipleSelect' => 'empty'], 'empty', true - ), - array( + ], + [ false, - array('multipleSelect' => ''), - array('multipleSelect' => ''), + ['multipleSelect' => ''], + ['multipleSelect' => ''], 'empty', true - ), - array( + ], + [ false, - array('multipleSelect' => ''), - array('multipleSelect' => ''), + ['multipleSelect' => ''], + ['multipleSelect' => ''], '', false - ), - array( + ], + [ true, - array('multipleSelect' => array()), - array('multipleSelect' => 'foo'), + ['multipleSelect' => []], + ['multipleSelect' => 'foo'], 'foo', true - ), - ); + ], + ]; } public function testCanSetUseInputFilterDefaultsViaArray() { - $spec = array( + $spec = [ 'name' => 'test', - 'options' => array( + 'options' => [ 'use_input_filter_defaults' => false - ) - ); + ] + ]; $factory = new Factory(); $this->form = $factory->createForm($spec); @@ -2046,35 +2046,35 @@ public function testSetValidationGroupOnFormWithNestedCollectionsRaisesInvalidAr { $this->form = new TestAsset\NestedCollectionsForm; - $data = array( - 'testFieldset' => array( - 'groups' => array( - array( + $data = [ + 'testFieldset' => [ + 'groups' => [ + [ 'name' => 'first', - 'items' => array( - array( + 'items' => [ + [ 'itemId' => 1, - ), - array( + ], + [ 'itemId' => 2, - ), - ), - ), - array( + ], + ], + ], + [ 'name' => 'second', - 'items' => array( - array( + 'items' => [ + [ 'itemId' => 3, - ), - ), - ), - array( + ], + ], + ], + [ 'name' => 'third', - 'items' => array(), - ), - ), - ), - ); + 'items' => [], + ], + ], + ], + ]; $this->form->setData($data); $this->form->isValid(); @@ -2090,45 +2090,45 @@ public function testSetValidationGroupOnFormWithNestedCollectionsPopulatesOnlyFi { $this->form = new TestAsset\NestedCollectionsForm; - $data = array( - 'testFieldset' => array( - 'groups' => array( - array( + $data = [ + 'testFieldset' => [ + 'groups' => [ + [ 'name' => 'first', - 'items' => array( - array( + 'items' => [ + [ 'itemId' => 1, - ), - array( + ], + [ 'itemId' => 2, - ), - ), - ), - array( + ], + ], + ], + [ 'name' => 'second', - 'items' => array( - array( + 'items' => [ + [ 'itemId' => 3, - ), - array( + ], + [ 'itemId' => 4, - ), - ), - ), - array( + ], + ], + ], + [ 'name' => 'third', - 'items' => array( - array( + 'items' => [ + [ 'itemId' => 5, - ), - array( + ], + [ 'itemId' => 6, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->form->setData($data); $this->form->isValid(); diff --git a/test/InputFilterProviderFieldsetTest.php b/test/InputFilterProviderFieldsetTest.php index 0fe65bab..31dfbf79 100644 --- a/test/InputFilterProviderFieldsetTest.php +++ b/test/InputFilterProviderFieldsetTest.php @@ -21,7 +21,7 @@ public function setUp() public function testCanSetInputFilterSpec() { - $filterSpec = array('filter'=>array('filter_options')); + $filterSpec = ['filter'=>['filter_options']]; $this->fieldset->setInputFilterSpecification($filterSpec); $this->assertEquals($filterSpec, $this->fieldset->getInputFilterSpecification()); @@ -29,9 +29,9 @@ public function testCanSetInputFilterSpec() public function testCanSetInputFilterSpecViaOptions() { - $filterSpec = array('filter'=>array('filter_options')); + $filterSpec = ['filter'=>['filter_options']]; - $this->fieldset->setOptions(array('input_filter_spec'=>$filterSpec)); + $this->fieldset->setOptions(['input_filter_spec'=>$filterSpec]); $this->assertEquals($filterSpec, $this->fieldset->getInputFilterSpecification()); } diff --git a/test/View/Helper/AbstractHelperTest.php b/test/View/Helper/AbstractHelperTest.php index 25ca6f94..36fe6bfb 100644 --- a/test/View/Helper/AbstractHelperTest.php +++ b/test/View/Helper/AbstractHelperTest.php @@ -32,7 +32,7 @@ public function testWillEscapeValueAttributeValuesCorrectly() { $this->assertSame( 'data-value="breaking your HTML like a boss! \"', - $this->helper->createAttributesString(array('data-value' => 'breaking your HTML like a boss! \\')) + $this->helper->createAttributesString(['data-value' => 'breaking your HTML like a boss! \\']) ); } @@ -44,7 +44,7 @@ public function testWillEncodeValueAttributeValuesCorrectly() $this->assertSame( 'data-value="' . $escaper->escapeHtmlAttr('TÃtulo') . '"', - $this->helper->createAttributesString(array('data-value' => 'TÃtulo')) + $this->helper->createAttributesString(['data-value' => 'TÃtulo']) ); } @@ -54,7 +54,7 @@ public function testWillNotEncodeValueAttributeValuesCorrectly() $this->assertNotSame( 'data-value="' . $escaper->escapeHtmlAttr('TÃtulo') . '"', - $this->helper->createAttributesString(array('data-value' => 'TÃtulo')) + $this->helper->createAttributesString(['data-value' => 'TÃtulo']) ); } } diff --git a/test/View/Helper/Captcha/ImageTest.php b/test/View/Helper/Captcha/ImageTest.php index 2c6cbd58..10a177b4 100644 --- a/test/View/Helper/Captcha/ImageTest.php +++ b/test/View/Helper/Captcha/ImageTest.php @@ -40,10 +40,10 @@ public function setUp() $this->helper = new ImageCaptchaHelper(); - $this->captcha = new ImageCaptcha(array( + $this->captcha = new ImageCaptcha([ 'imgDir' => $this->testDir, 'font' => __DIR__. '/_files/Vera.ttf', - )); + ]); parent::setUp(); } diff --git a/test/View/Helper/FormButtonTest.php b/test/View/Helper/FormButtonTest.php index b70a4dc0..c6523fad 100644 --- a/test/View/Helper/FormButtonTest.php +++ b/test/View/Helper/FormButtonTest.php @@ -29,11 +29,11 @@ public function testCanEmitStartTagOnly() public function testPassingArrayToOpenTagRendersAttributes() { - $attributes = array( + $attributes = [ 'name' => 'my-button', 'class' => 'email-button', 'type' => 'button', - ); + ]; $markup = $this->helper->openTag($attributes); foreach ($attributes as $key => $value) { @@ -87,16 +87,16 @@ public function testGeneratesButtonTagWithElementsTypeAttribute() public function inputTypes() { - return array( - array('submit', 'assertContains'), - array('button', 'assertContains'), - array('reset', 'assertContains'), - array('lunar', 'assertNotContains'), - array('name', 'assertNotContains'), - array('username', 'assertNotContains'), - array('text', 'assertNotContains'), - array('checkbox', 'assertNotContains'), - ); + return [ + ['submit', 'assertContains'], + ['button', 'assertContains'], + ['reset', 'assertContains'], + ['lunar', 'assertNotContains'], + ['name', 'assertNotContains'], + ['username', 'assertNotContains'], + ['text', 'assertNotContains'], + ['checkbox', 'assertNotContains'], + ]; } /** @@ -113,43 +113,43 @@ public function testOpenTagOnlyAllowsValidButtonTypes($type, $assertion) public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertNotContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertContains'), - array('formenctype', 'assertContains'), - array('formmethod', 'assertContains'), - array('formnovalidate', 'assertContains'), - array('formtarget', 'assertContains'), - array('height', 'assertNotContains'), - array('list', 'assertNotContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertNotContains'), - array('required', 'assertNotContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertNotContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertContains'], + ['formenctype', 'assertContains'], + ['formmethod', 'assertContains'], + ['formnovalidate', 'assertContains'], + ['formtarget', 'assertContains'], + ['height', 'assertNotContains'], + ['list', 'assertNotContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertNotContains'], + ['required', 'assertNotContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -179,7 +179,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } @@ -321,7 +321,7 @@ public function testCanDisableLabelHtmlEscape() { $element = new Element('foo'); $element->setLabel('Click me'); - $element->setLabelOptions(array('disable_html_escape' => true)); + $element->setLabelOptions(['disable_html_escape' => true]); $markup = $this->helper->__invoke($element); $this->assertRegexp('#]*)>Click me#', $markup); } diff --git a/test/View/Helper/FormCaptchaTest.php b/test/View/Helper/FormCaptchaTest.php index 11be8ec0..850143f1 100644 --- a/test/View/Helper/FormCaptchaTest.php +++ b/test/View/Helper/FormCaptchaTest.php @@ -115,10 +115,10 @@ public function testPassingElementWithImageCaptchaRendersCorrectly() @mkdir($this->testDir); } - $captcha = new Captcha\Image(array( + $captcha = new Captcha\Image([ 'imgDir' => $this->testDir, 'font' => __DIR__. '/Captcha/_files/Vera.ttf', - )); + ]); $element = $this->getElement(); $element->setCaptcha($captcha); $element->setAttribute('id', 'foo'); diff --git a/test/View/Helper/FormCheckboxTest.php b/test/View/Helper/FormCheckboxTest.php index 72e789d4..3d6ed36e 100644 --- a/test/View/Helper/FormCheckboxTest.php +++ b/test/View/Helper/FormCheckboxTest.php @@ -23,10 +23,10 @@ public function setUp() public function getElement() { $element = new Element\Checkbox('foo'); - $options = array( + $options = [ 'checked_value' => 'checked', 'unchecked_value' => 'unchecked', - ); + ]; $element->setOptions($options); return $element; } diff --git a/test/View/Helper/FormCollectionTest.php b/test/View/Helper/FormCollectionTest.php index c4c1b564..a8e388ac 100644 --- a/test/View/Helper/FormCollectionTest.php +++ b/test/View/Helper/FormCollectionTest.php @@ -232,10 +232,10 @@ public function testCanRenderFieldsetWithoutAttributes() public function testCanRenderFieldsetWithAttributes() { $form = $this->getForm(); - $form->setAttributes(array( + $form->setAttributes([ 'id' => 'foo-id', 'class' => 'foo', - )); + ]); $html = $this->helper->render($form); $this->assertRegexp('##', $html); $this->assertContains('id="foo-id"', $html); @@ -398,7 +398,7 @@ public function testCanDisableLabelHtmlEscape() $form = $this->getForm(); $collection = $form->get('colors'); $collection->setLabel('Some label'); - $collection->setLabelOptions(array('disable_html_escape' => true)); + $collection->setLabelOptions(['disable_html_escape' => true]); $markup = $this->helper->render($collection); $this->assertRegexp('#Some label<\/legend>(.*?)<\/fieldset>#', $markup); } diff --git a/test/View/Helper/FormColorTest.php b/test/View/Helper/FormColorTest.php index 5041a0c1..a5b9c169 100644 --- a/test/View/Helper/FormColorTest.php +++ b/test/View/Helper/FormColorTest.php @@ -46,43 +46,43 @@ public function testGeneratesColorInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertNotContains'), - array('required', 'assertNotContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertNotContains'], + ['required', 'assertNotContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormDateTest.php b/test/View/Helper/FormDateTest.php index 69674953..fbc63b0f 100644 --- a/test/View/Helper/FormDateTest.php +++ b/test/View/Helper/FormDateTest.php @@ -49,43 +49,43 @@ public function testGeneratesInputTagRegardlessOfElementType() */ public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -115,7 +115,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormDateTimeLocalTest.php b/test/View/Helper/FormDateTimeLocalTest.php index e3b24bc0..8f2f6896 100644 --- a/test/View/Helper/FormDateTimeLocalTest.php +++ b/test/View/Helper/FormDateTimeLocalTest.php @@ -46,43 +46,43 @@ public function testGeneratesInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormDateTimeSelectTest.php b/test/View/Helper/FormDateTimeSelectTest.php index d4d39e30..392ee9ad 100644 --- a/test/View/Helper/FormDateTimeSelectTest.php +++ b/test/View/Helper/FormDateTimeSelectTest.php @@ -112,14 +112,14 @@ public function testInvokeWithNoElementChainsHelper() public function testNoMinutesDelimiterIfSecondsNotShown() { $element = new DateTimeSelect('foo'); - $element->setValue(array( + $element->setValue([ 'year' => '2012', 'month' => '09', 'day' => '24', 'hour' => '03', 'minute' => '04', 'second' => '59', - )); + ]); $element->setShouldShowSeconds(false); $element->shouldRenderDelimiters(true); diff --git a/test/View/Helper/FormDateTimeTest.php b/test/View/Helper/FormDateTimeTest.php index 3734fccf..cd26664f 100644 --- a/test/View/Helper/FormDateTimeTest.php +++ b/test/View/Helper/FormDateTimeTest.php @@ -46,43 +46,43 @@ public function testGeneratesInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormElementErrorsTest.php b/test/View/Helper/FormElementErrorsTest.php index 2df592b1..89fcdaa5 100644 --- a/test/View/Helper/FormElementErrorsTest.php +++ b/test/View/Helper/FormElementErrorsTest.php @@ -22,11 +22,11 @@ public function setUp() public function getMessageList() { - return array( + return [ 'First error message', 'Second error message', 'Third error message', - ); + ]; } public function testLackOfMessagesResultsInEmptyMarkup() @@ -52,7 +52,7 @@ public function testCanSpecifyAttributesForOpeningTag() $element = new Element('foo'); $element->setMessages($messages); - $markup = $this->helper->render($element, array('class' => 'error')); + $markup = $this->helper->render($element, ['class' => 'error']); $this->assertContains('ul class="error"', $markup); } @@ -63,7 +63,7 @@ public function testCanSpecifyAttributesForOpeningTagUsingInvoke() $element = new Element('foo'); $element->setMessages($messages); - $markup = $helper($element, array('class' => 'error')); + $markup = $helper($element, ['class' => 'error']); $this->assertContains('ul class="error"', $markup); } @@ -76,7 +76,7 @@ public function testCanSpecifyAlternateMarkupStringsViaSetters() $this->helper->setMessageOpenFormat('') ->setMessageCloseString('') ->setMessageSeparatorString('') - ->setAttributes(array('class' => 'error')); + ->setAttributes(['class' => 'error']); $markup = $this->helper->render($element); $this->assertRegexp('#\s*First error message\s*Second error message\s*Third error message\s*#s', $markup); @@ -87,9 +87,9 @@ public function testSpecifiedAttributesOverrideDefaults() $messages = $this->getMessageList(); $element = new Element('foo'); $element->setMessages($messages); - $element->setAttributes(array('class' => 'foo')); + $element->setAttributes(['class' => 'foo']); - $markup = $this->helper->render($element, array('class' => 'error')); + $markup = $this->helper->render($element, ['class' => 'error']); $this->assertContains('ul class="error"', $markup); } @@ -99,28 +99,28 @@ public function testGetAttributes() $element = new Element('foo'); $element->setMessages($messages); - $this->helper->setAttributes(array('class' => 'error')); + $this->helper->setAttributes(['class' => 'error']); $this->helper->render($element); - $this->assertEquals(array('class' => 'error'), $this->helper->getAttributes()); + $this->assertEquals(['class' => 'error'], $this->helper->getAttributes()); } public function testRendersNestedMessageSetsAsAFlatList() { - $messages = array( - array( + $messages = [ + [ 'First validator message', - ), - array( + ], + [ 'Second validator first message', 'Second validator second message', - ), - ); + ], + ]; $element = new Element('foo'); $element->setMessages($messages); - $markup = $this->helper->render($element, array('class' => 'error')); + $markup = $this->helper->render($element, ['class' => 'error']); $this->assertRegexp('#\s*First validator message\s*Second validator first message\s*Second validator second message\s*#s', $markup); } diff --git a/test/View/Helper/FormElementTest.php b/test/View/Helper/FormElementTest.php index 25193f27..be90fd73 100644 --- a/test/View/Helper/FormElementTest.php +++ b/test/View/Helper/FormElementTest.php @@ -38,31 +38,31 @@ public function setUp() public function getInputElements() { - return array( - array('text'), - array('password'), - array('checkbox'), - array('radio'), - array('submit'), - array('reset'), - array('file'), - array('hidden'), - array('image'), - array('button'), - array('number'), - array('range'), - array('date'), - array('color'), - array('search'), - array('tel'), - array('email'), - array('url'), - array('datetime'), - array('datetime-local'), - array('month'), - array('week'), - array('time'), - ); + return [ + ['text'], + ['password'], + ['checkbox'], + ['radio'], + ['submit'], + ['reset'], + ['file'], + ['hidden'], + ['image'], + ['button'], + ['number'], + ['range'], + ['date'], + ['color'], + ['search'], + ['tel'], + ['email'], + ['url'], + ['datetime'], + ['datetime-local'], + ['month'], + ['week'], + ['time'], + ]; } /** @@ -81,7 +81,7 @@ public function testRendersExpectedInputElement($type) } $element->setAttribute('type', $type); - $element->setAttribute('options', array('option' => 'value')); + $element->setAttribute('options', ['option' => 'value']); $element->setAttribute('src', 'http://zend.com/img.png'); $markup = $this->helper->render($element); @@ -91,11 +91,11 @@ public function testRendersExpectedInputElement($type) public function getMultiElements() { - return array( - array('radio', 'input', 'type="radio"'), - array('multi_checkbox', 'input', 'type="checkbox"'), - array('select', 'option', 'setAttribute('type', $type); - $element->setValueOptions(array( + $element->setValueOptions([ 'value1' => 'option', 'value2' => 'label', 'value3' => 'last', - )); + ]); $element->setAttribute('value', 'value2'); $markup = $this->helper->render($element); diff --git a/test/View/Helper/FormEmailTest.php b/test/View/Helper/FormEmailTest.php index 80a7b16f..e1d808dc 100644 --- a/test/View/Helper/FormEmailTest.php +++ b/test/View/Helper/FormEmailTest.php @@ -46,43 +46,43 @@ public function testGeneratesEmailInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertContains'), - array('pattern', 'assertContains'), - array('placeholder', 'assertContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertContains'], + ['pattern', 'assertContains'], + ['placeholder', 'assertContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormFileTest.php b/test/View/Helper/FormFileTest.php index be02ef6a..ae53f1ad 100644 --- a/test/View/Helper/FormFileTest.php +++ b/test/View/Helper/FormFileTest.php @@ -62,13 +62,13 @@ public function testGeneratesFileInputTagRegardlessOfElementType() public function testRendersElementWithFileIgnoresValue() { $element = new Element\File('foo'); - $element->setValue(array( + $element->setValue([ 'tmp_name' => '/tmp/foofile', 'name' => 'foofile', 'type' => 'text', 'size' => 200, 'error' => 2, - )); + ]); $markup = $this->helper->render($element); $this->assertContains('assertContains('type="file"', $markup); @@ -80,36 +80,36 @@ public function testRendersElementWithFileIgnoresValue() */ public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertNotContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertNotContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertNotContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertNotContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertNotContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertNotContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['width', 'assertNotContains'], + ]; } /** @@ -118,7 +118,7 @@ public function validAttributes() public function getCompleteElement() { $element = new Element\File('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -148,7 +148,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormHiddenTest.php b/test/View/Helper/FormHiddenTest.php index 78311252..c4ad7ac0 100644 --- a/test/View/Helper/FormHiddenTest.php +++ b/test/View/Helper/FormHiddenTest.php @@ -46,43 +46,43 @@ public function testGeneratesHiddenInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertNotContains'), - array('autofocus', 'assertNotContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertNotContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertNotContains'), - array('required', 'assertNotContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertNotContains'], + ['autofocus', 'assertNotContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertNotContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertNotContains'], + ['required', 'assertNotContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormImageTest.php b/test/View/Helper/FormImageTest.php index 9e57af2d..599bb393 100644 --- a/test/View/Helper/FormImageTest.php +++ b/test/View/Helper/FormImageTest.php @@ -58,43 +58,43 @@ public function testGeneratesImageInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertContains'), - array('autocomplete', 'assertNotContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertContains'), - array('formenctype', 'assertContains'), - array('formmethod', 'assertContains'), - array('formnovalidate', 'assertContains'), - array('formtarget', 'assertContains'), - array('height', 'assertContains'), - array('list', 'assertNotContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertNotContains'), - array('required', 'assertNotContains'), - array('size', 'assertNotContains'), - array('src', 'assertContains'), - array('step', 'assertNotContains'), - array('value', 'assertNotContains'), - array('width', 'assertContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertContains'], + ['autocomplete', 'assertNotContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertContains'], + ['formenctype', 'assertContains'], + ['formmethod', 'assertContains'], + ['formnovalidate', 'assertContains'], + ['formtarget', 'assertContains'], + ['height', 'assertContains'], + ['list', 'assertNotContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertNotContains'], + ['required', 'assertNotContains'], + ['size', 'assertNotContains'], + ['src', 'assertContains'], + ['step', 'assertNotContains'], + ['value', 'assertNotContains'], + ['width', 'assertContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -124,7 +124,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormInputTest.php b/test/View/Helper/FormInputTest.php index 7c9caabc..b605a1c9 100644 --- a/test/View/Helper/FormInputTest.php +++ b/test/View/Helper/FormInputTest.php @@ -46,37 +46,37 @@ public function testGeneratesInputTagWithElementsTypeAttribute() public function inputTypes() { - return array( - array('text', 'assertContains'), - array('button', 'assertContains'), - array('checkbox', 'assertContains'), - array('file', 'assertContains'), - array('hidden', 'assertContains'), - array('image', 'assertContains'), - array('password', 'assertContains'), - array('radio', 'assertContains'), - array('reset', 'assertContains'), - array('select', 'assertContains'), - array('submit', 'assertContains'), - array('color', 'assertContains'), - array('date', 'assertContains'), - array('datetime', 'assertContains'), - array('datetime-local', 'assertContains'), - array('email', 'assertContains'), - array('month', 'assertContains'), - array('number', 'assertContains'), - array('range', 'assertContains'), - array('search', 'assertContains'), - array('tel', 'assertContains'), - array('time', 'assertContains'), - array('url', 'assertContains'), - array('week', 'assertContains'), - array('lunar', 'assertNotContains'), - array('name', 'assertNotContains'), - array('username', 'assertNotContains'), - array('address', 'assertNotContains'), - array('homepage', 'assertNotContains'), - ); + return [ + ['text', 'assertContains'], + ['button', 'assertContains'], + ['checkbox', 'assertContains'], + ['file', 'assertContains'], + ['hidden', 'assertContains'], + ['image', 'assertContains'], + ['password', 'assertContains'], + ['radio', 'assertContains'], + ['reset', 'assertContains'], + ['select', 'assertContains'], + ['submit', 'assertContains'], + ['color', 'assertContains'], + ['date', 'assertContains'], + ['datetime', 'assertContains'], + ['datetime-local', 'assertContains'], + ['email', 'assertContains'], + ['month', 'assertContains'], + ['number', 'assertContains'], + ['range', 'assertContains'], + ['search', 'assertContains'], + ['tel', 'assertContains'], + ['time', 'assertContains'], + ['url', 'assertContains'], + ['week', 'assertContains'], + ['lunar', 'assertNotContains'], + ['name', 'assertNotContains'], + ['username', 'assertNotContains'], + ['address', 'assertNotContains'], + ['homepage', 'assertNotContains'], + ]; } /** @@ -96,126 +96,126 @@ public function testOnlyAllowsValidInputTypes($type, $assertion) */ public function validAttributes() { - return array( - array('accept', 'assertContains'), - array('accesskey', 'assertContains'), - array('alt', 'assertContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertContains'), - array('class', 'assertContains'), - array('contenteditable', 'assertContains'), - array('contextmenu', 'assertContains'), - array('dir', 'assertContains'), - array('dirname', 'assertContains'), - array('disabled', 'assertContains'), - array('draggable', 'assertContains'), - array('dropzone', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertContains'), - array('formenctype', 'assertContains'), - array('formmethod', 'assertContains'), - array('formnovalidate', 'assertContains'), - array('formtarget', 'assertContains'), - array('height', 'assertContains'), - array('hidden', 'assertContains'), - array('id', 'assertContains'), - array('lang', 'assertContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertContains'), - array('min', 'assertContains'), - array('multiple', 'assertContains'), - array('name', 'assertContains'), - array('onabort', 'assertContains'), - array('onblur', 'assertContains'), - array('oncanplay', 'assertContains'), - array('oncanplaythrough', 'assertContains'), - array('onchange', 'assertContains'), - array('onclick', 'assertContains'), - array('oncontextmenu', 'assertContains'), - array('ondblclick', 'assertContains'), - array('ondrag', 'assertContains'), - array('ondragend', 'assertContains'), - array('ondragenter', 'assertContains'), - array('ondragleave', 'assertContains'), - array('ondragover', 'assertContains'), - array('ondragstart', 'assertContains'), - array('ondrop', 'assertContains'), - array('ondurationchange', 'assertContains'), - array('onemptied', 'assertContains'), - array('onended', 'assertContains'), - array('onerror', 'assertContains'), - array('onfocus', 'assertContains'), - array('oninput', 'assertContains'), - array('oninvalid', 'assertContains'), - array('onkeydown', 'assertContains'), - array('onkeypress', 'assertContains'), - array('onkeyup', 'assertContains'), - array('onload', 'assertContains'), - array('onloadeddata', 'assertContains'), - array('onloadedmetadata', 'assertContains'), - array('onloadstart', 'assertContains'), - array('onmousedown', 'assertContains'), - array('onmousemove', 'assertContains'), - array('onmouseout', 'assertContains'), - array('onmouseover', 'assertContains'), - array('onmouseup', 'assertContains'), - array('onmousewheel', 'assertContains'), - array('onpause', 'assertContains'), - array('onplay', 'assertContains'), - array('onplaying', 'assertContains'), - array('onprogress', 'assertContains'), - array('onratechange', 'assertContains'), - array('onreadystatechange', 'assertContains'), - array('onreset', 'assertContains'), - array('onscroll', 'assertContains'), - array('onseeked', 'assertContains'), - array('onseeking', 'assertContains'), - array('onselect', 'assertContains'), - array('onshow', 'assertContains'), - array('onstalled', 'assertContains'), - array('onsubmit', 'assertContains'), - array('onsuspend', 'assertContains'), - array('ontimeupdate', 'assertContains'), - array('onvolumechange', 'assertContains'), - array('onwaiting', 'assertContains'), - array('role', 'assertContains'), - ); + return [ + ['accept', 'assertContains'], + ['accesskey', 'assertContains'], + ['alt', 'assertContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertContains'], + ['class', 'assertContains'], + ['contenteditable', 'assertContains'], + ['contextmenu', 'assertContains'], + ['dir', 'assertContains'], + ['dirname', 'assertContains'], + ['disabled', 'assertContains'], + ['draggable', 'assertContains'], + ['dropzone', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertContains'], + ['formenctype', 'assertContains'], + ['formmethod', 'assertContains'], + ['formnovalidate', 'assertContains'], + ['formtarget', 'assertContains'], + ['height', 'assertContains'], + ['hidden', 'assertContains'], + ['id', 'assertContains'], + ['lang', 'assertContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertContains'], + ['min', 'assertContains'], + ['multiple', 'assertContains'], + ['name', 'assertContains'], + ['onabort', 'assertContains'], + ['onblur', 'assertContains'], + ['oncanplay', 'assertContains'], + ['oncanplaythrough', 'assertContains'], + ['onchange', 'assertContains'], + ['onclick', 'assertContains'], + ['oncontextmenu', 'assertContains'], + ['ondblclick', 'assertContains'], + ['ondrag', 'assertContains'], + ['ondragend', 'assertContains'], + ['ondragenter', 'assertContains'], + ['ondragleave', 'assertContains'], + ['ondragover', 'assertContains'], + ['ondragstart', 'assertContains'], + ['ondrop', 'assertContains'], + ['ondurationchange', 'assertContains'], + ['onemptied', 'assertContains'], + ['onended', 'assertContains'], + ['onerror', 'assertContains'], + ['onfocus', 'assertContains'], + ['oninput', 'assertContains'], + ['oninvalid', 'assertContains'], + ['onkeydown', 'assertContains'], + ['onkeypress', 'assertContains'], + ['onkeyup', 'assertContains'], + ['onload', 'assertContains'], + ['onloadeddata', 'assertContains'], + ['onloadedmetadata', 'assertContains'], + ['onloadstart', 'assertContains'], + ['onmousedown', 'assertContains'], + ['onmousemove', 'assertContains'], + ['onmouseout', 'assertContains'], + ['onmouseover', 'assertContains'], + ['onmouseup', 'assertContains'], + ['onmousewheel', 'assertContains'], + ['onpause', 'assertContains'], + ['onplay', 'assertContains'], + ['onplaying', 'assertContains'], + ['onprogress', 'assertContains'], + ['onratechange', 'assertContains'], + ['onreadystatechange', 'assertContains'], + ['onreset', 'assertContains'], + ['onscroll', 'assertContains'], + ['onseeked', 'assertContains'], + ['onseeking', 'assertContains'], + ['onselect', 'assertContains'], + ['onshow', 'assertContains'], + ['onstalled', 'assertContains'], + ['onsubmit', 'assertContains'], + ['onsuspend', 'assertContains'], + ['ontimeupdate', 'assertContains'], + ['onvolumechange', 'assertContains'], + ['onwaiting', 'assertContains'], + ['role', 'assertContains'], + ]; } public function validAttributes2() { - return array( - array('pattern', 'assertContains'), - array('placeholder', 'assertContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertContains'), - array('spellcheck', 'assertContains'), - array('src', 'assertContains'), - array('step', 'assertContains'), - array('style', 'assertContains'), - array('tabindex', 'assertContains'), - array('title', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertContains'), - array('xml:base', 'assertContains'), - array('xml:lang', 'assertContains'), - array('xml:space', 'assertContains'), - array('data-some-key', 'assertContains'), - array('option', 'assertNotContains'), - array('optgroup', 'assertNotContains'), - array('arbitrary', 'assertNotContains'), - array('meta', 'assertNotContains'), - array('role', 'assertContains'), - ); + return [ + ['pattern', 'assertContains'], + ['placeholder', 'assertContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertContains'], + ['spellcheck', 'assertContains'], + ['src', 'assertContains'], + ['step', 'assertContains'], + ['style', 'assertContains'], + ['tabindex', 'assertContains'], + ['title', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertContains'], + ['xml:base', 'assertContains'], + ['xml:lang', 'assertContains'], + ['xml:space', 'assertContains'], + ['data-some-key', 'assertContains'], + ['option', 'assertNotContains'], + ['optgroup', 'assertNotContains'], + ['arbitrary', 'assertNotContains'], + ['meta', 'assertNotContains'], + ['role', 'assertContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'accesskey' => 'value', 'alt' => 'value', @@ -321,7 +321,7 @@ public function getCompleteElement() 'arbitrary' => 'value', 'meta' => 'value', 'role' => 'value', - )); + ]); $element->setValue('value'); return $element; } @@ -347,12 +347,12 @@ public function testAllValidFormMarkupAttributesPresentInElementAreRendered($att public function nonXhtmlDoctypes() { - return array( - array('HTML4_STRICT'), - array('HTML4_LOOSE'), - array('HTML4_FRAMESET'), - array('HTML5'), - ); + return [ + ['HTML4_STRICT'], + ['HTML4_LOOSE'], + ['HTML4_FRAMESET'], + ['HTML5'], + ]; } /** @@ -368,15 +368,15 @@ public function testRenderingOmitsClosingSlashWhenDoctypeIsNotXhtml($doctype) public function xhtmlDoctypes() { - return array( - array('XHTML11'), - array('XHTML1_STRICT'), - array('XHTML1_TRANSITIONAL'), - array('XHTML1_FRAMESET'), - array('XHTML1_RDFA'), - array('XHTML_BASIC1'), - array('XHTML5'), - ); + return [ + ['XHTML11'], + ['XHTML1_STRICT'], + ['XHTML1_TRANSITIONAL'], + ['XHTML1_FRAMESET'], + ['XHTML1_RDFA'], + ['XHTML_BASIC1'], + ['XHTML5'], + ]; } /** @@ -397,14 +397,14 @@ public function testRenderingIncludesClosingSlashWhenDoctypeIsXhtml($doctype) */ public function booleanAttributeTypes() { - return array( - array('autofocus', 'autofocus', ''), - array('disabled', 'disabled', ''), - array('multiple', 'multiple', ''), - array('readonly', 'readonly', ''), - array('required', 'required', ''), - array('checked', 'checked', ''), - ); + return [ + ['autofocus', 'autofocus', ''], + ['disabled', 'disabled', ''], + ['multiple', 'multiple', ''], + ['readonly', 'readonly', ''], + ['required', 'required', ''], + ['checked', 'checked', ''], + ]; } /** diff --git a/test/View/Helper/FormLabelTest.php b/test/View/Helper/FormLabelTest.php index c1191016..e7d04e84 100644 --- a/test/View/Helper/FormLabelTest.php +++ b/test/View/Helper/FormLabelTest.php @@ -35,10 +35,10 @@ public function testOpenTagWithWrongElementRaisesException() public function testPassingArrayToOpenTagRendersAttributes() { - $attributes = array( + $attributes = [ 'class' => 'email-label', 'data-type' => 'label', - ); + ]; $markup = $this->helper->openTag($attributes); foreach ($attributes as $key => $value) { @@ -129,7 +129,7 @@ public function testsetLabelAttributes() { $element = new Element('foo'); $element->setLabel('The value for foo:'); - $element->setLabelAttributes(array('id' => 'bar')); + $element->setLabelAttributes(['id' => 'bar']); $markup = $this->helper->__invoke($element, '', FormLabelHelper::APPEND); $this->assertContains('"foo" />The value for foo:', $markup); $this->assertContains('id="bar" for="foo"', $markup); @@ -196,7 +196,7 @@ public function testCanDisableLabelHtmlEscape() { $element = new Element('foo'); $element->setLabel('The value for foo:'); - $element->setLabelOptions(array('disable_html_escape' => true)); + $element->setLabelOptions(['disable_html_escape' => true]); $markup = $this->helper->__invoke($element); $this->assertContains('for', $markup); } diff --git a/test/View/Helper/FormMonthTest.php b/test/View/Helper/FormMonthTest.php index c7135f7b..f81084ad 100644 --- a/test/View/Helper/FormMonthTest.php +++ b/test/View/Helper/FormMonthTest.php @@ -46,43 +46,43 @@ public function testGeneratesInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormMultiCheckboxTest.php b/test/View/Helper/FormMultiCheckboxTest.php index 31c141ef..adba265b 100644 --- a/test/View/Helper/FormMultiCheckboxTest.php +++ b/test/View/Helper/FormMultiCheckboxTest.php @@ -24,11 +24,11 @@ public function setUp() public function getElement() { $element = new MultiCheckboxElement('foo'); - $options = array( + $options = [ 'value1' => 'This is the first label', 'value2' => 'This is the second label', 'value3' => 'This is the third label', - ); + ]; $element->setValueOptions($options); return $element; } @@ -36,17 +36,17 @@ public function getElement() public function getElementWithOptionSpec() { $element = new MultiCheckboxElement('foo'); - $options = array( + $options = [ 'value1' => 'This is the first label', - 1 => array( + 1 => [ 'value' => 'value2', 'label' => 'This is the second label (overridden)', 'disabled' => false, - 'label_attributes' => array('class' => 'label-class'), - 'attributes' => array('class' => 'input-class'), - ), + 'label_attributes' => ['class' => 'label-class'], + 'attributes' => ['class' => 'input-class'], + ], 'value3' => 'This is the third label', - ); + ]; $element->setValueOptions($options); return $element; } @@ -121,7 +121,7 @@ public function testGenerateCheckBoxesAndHiddenElement() public function testUsesElementValueToDetermineCheckboxStatus() { $element = $this->getElement(); - $element->setAttribute('value', array('value1', 'value3')); + $element->setAttribute('value', ['value1', 'value3']); $markup = $this->helper->render($element); $this->assertRegexp('#value="value1"\s+checked="checked"#', $markup); @@ -159,7 +159,7 @@ public function testAllowsSpecifyingLabelAttributes() $element = $this->getElement(); $markup = $this->helper - ->setLabelAttributes(array('class' => 'checkbox')) + ->setLabelAttributes(['class' => 'checkbox']) ->render($element); $this->assertEquals(3, substr_count($markup, 'getElement(); - $element->setLabelAttributes(array('class' => 'checkbox')); + $element->setLabelAttributes(['class' => 'checkbox']); $markup = $this->helper->render($element); $this->assertEquals(3, substr_count($markup, 'setName('codeType'); - $element->setOptions(array('label' => 'Code Type')); - $element->setAttributes(array( + $element->setOptions(['label' => 'Code Type']); + $element->setAttributes([ 'type' => 'radio', - 'value' => array('markdown'), - )); - $element->setValueOptions(array( + 'value' => ['markdown'], + ]); + $element->setValueOptions([ 'Markdown' => 'markdown', 'HTML' => 'html', 'Wiki' => 'wiki', - )); + ]); $markup = $this->helper->render($element); $this->assertNotContains('type="hidden"', $markup); @@ -226,12 +226,12 @@ public function testEnsureUseHiddenElementMethodExists() public function testCanTranslateContent() { $element = new MultiCheckboxElement('foo'); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $mockTranslator = $this->getMock('Zend\I18n\Translator\Translator'); @@ -278,18 +278,18 @@ public function testRenderElementWithNoNameRaisesException() public function testCanMarkSingleOptionAsSelected() { $element = new MultiCheckboxElement('foo'); - $options = array( + $options = [ 'value1' => 'This is the first label', - 1 => array( + 1 => [ 'value' => 'value2', 'label' => 'This is the second label (overridden)', 'disabled' => false, 'selected' => true, - 'label_attributes' => array('class' => 'label-class'), - 'attributes' => array('class' => 'input-class'), - ), + 'label_attributes' => ['class' => 'label-class'], + 'attributes' => ['class' => 'input-class'], + ], 'value3' => 'This is the third label', - ); + ]; $element->setValueOptions($options); $markup = $this->helper->render($element); @@ -301,12 +301,12 @@ public function testCanMarkSingleOptionAsSelected() public function testInvokeSetLabelPositionToAppend() { $element = new MultiCheckboxElement('foo'); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $this->helper->__invoke($element, 'append'); $this->assertSame('append', $this->helper->getLabelPosition()); @@ -320,8 +320,8 @@ public function testSetLabelPositionInputNullRaisesException() public function testSetLabelAttributes() { - $this->helper->setLabelAttributes(array('foo', 'bar')); - $this->assertEquals(array(0 => 'foo', 1 => 'bar'), $this->helper->getLabelAttributes()); + $this->helper->setLabelAttributes(['foo', 'bar']); + $this->assertEquals([0 => 'foo', 1 => 'bar'], $this->helper->getLabelAttributes()); } public function testGetUseHiddenElementReturnsDefaultFalse() @@ -368,12 +368,12 @@ public function testGetDisableAttributeForGroupReturnTrue() { $element = new MultiCheckboxElement('foo'); $element->setAttribute('disabled', 'true'); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $this->assertRegexp('#disabled="disabled" value="value1"#', $markup); } @@ -382,12 +382,12 @@ public function testGetSelectedAttributeForGroupReturnTrue() { $element = new MultiCheckboxElement('foo'); $element->setAttribute('selected', 'true'); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $this->assertRegexp('#value="value1" checked="checked"#', $markup); } @@ -395,15 +395,15 @@ public function testGetSelectedAttributeForGroupReturnTrue() public function testDisableEscapeHtmlHelper() { $element = new MultiCheckboxElement('foo'); - $element->setLabelOptions(array( + $element->setLabelOptions([ 'disable_html_escape' => true, - )); - $element->setValueOptions(array( - array( + ]); + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $this->assertRegexp('#label1#', $markup); } diff --git a/test/View/Helper/FormNumberTest.php b/test/View/Helper/FormNumberTest.php index 3c8a5f74..278649a9 100644 --- a/test/View/Helper/FormNumberTest.php +++ b/test/View/Helper/FormNumberTest.php @@ -46,43 +46,43 @@ public function testGeneratesNumberInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => '1', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormPasswordTest.php b/test/View/Helper/FormPasswordTest.php index 20e6b54f..1ef0a910 100644 --- a/test/View/Helper/FormPasswordTest.php +++ b/test/View/Helper/FormPasswordTest.php @@ -46,43 +46,43 @@ public function testGeneratesPasswordInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertNotContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertContains'), - array('placeholder', 'assertContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertNotContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertContains'], + ['placeholder', 'assertContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormRadioTest.php b/test/View/Helper/FormRadioTest.php index 42c9db59..4f33f76f 100644 --- a/test/View/Helper/FormRadioTest.php +++ b/test/View/Helper/FormRadioTest.php @@ -23,11 +23,11 @@ public function setUp() public function getElement() { $element = new RadioElement('foo'); - $options = array( + $options = [ 'value1' => 'This is the first label', 'value2' => 'This is the second label', 'value3' => 'This is the third label', - ); + ]; $element->setValueOptions($options); return $element; } @@ -35,17 +35,17 @@ public function getElement() public function getElementWithOptionSpec() { $element = new RadioElement('foo'); - $options = array( + $options = [ 'value1' => 'This is the first label', - 1 => array( + 1 => [ 'value' => 'value2', 'label' => 'This is the second label (overridden)', 'disabled' => false, - 'label_attributes' => array('class' => 'label-class'), - 'attributes' => array('class' => 'input-class'), - ), + 'label_attributes' => ['class' => 'label-class'], + 'attributes' => ['class' => 'input-class'], + ], 'value3' => 'This is the third label', - ); + ]; $element->setValueOptions($options); return $element; } @@ -120,7 +120,7 @@ public function testGenerateRadioOptionsAndHiddenElement() public function testUsesElementValueToDetermineRadioStatus() { $element = $this->getElement(); - $element->setAttribute('value', array('value1', 'value3')); + $element->setAttribute('value', ['value1', 'value3']); $markup = $this->helper->render($element); $this->assertRegexp('#value="value1"\s+checked="checked"#', $markup); @@ -167,7 +167,7 @@ public function testAllowsSpecifyingLabelAttributes() $element = $this->getElement(); $markup = $this->helper - ->setLabelAttributes(array('class' => 'radio')) + ->setLabelAttributes(['class' => 'radio']) ->render($element); $this->assertEquals(3, substr_count($markup, 'getElement(); - $element->setLabelAttributes(array('class' => 'radio')); + $element->setLabelAttributes(['class' => 'radio']); $markup = $this->helper->render($element); @@ -209,12 +209,12 @@ public function testNameShouldNotHaveBracketsAppended() public function testCanTranslateContent() { $element = new RadioElement('foo'); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $mockTranslator = $this->getMock('Zend\I18n\Translator\Translator'); diff --git a/test/View/Helper/FormRangeTest.php b/test/View/Helper/FormRangeTest.php index a92f8f2a..c234bf0b 100644 --- a/test/View/Helper/FormRangeTest.php +++ b/test/View/Helper/FormRangeTest.php @@ -46,43 +46,43 @@ public function testGeneratesNumberInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertNotContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertNotContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => '1', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormResetTest.php b/test/View/Helper/FormResetTest.php index e50365a3..da6b3ee2 100644 --- a/test/View/Helper/FormResetTest.php +++ b/test/View/Helper/FormResetTest.php @@ -46,43 +46,43 @@ public function testGeneratesResetInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertNotContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertNotContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertNotContains'), - array('required', 'assertNotContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertNotContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertNotContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertNotContains'], + ['required', 'assertNotContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; diff --git a/test/View/Helper/FormRowTest.php b/test/View/Helper/FormRowTest.php index da92c888..88ee95d3 100644 --- a/test/View/Helper/FormRowTest.php +++ b/test/View/Helper/FormRowTest.php @@ -63,9 +63,9 @@ public function testCanCreateLabelValueBeforeInput() public function testCanCreateLabelValueAfterInput() { $element = new Element('foo'); - $element->setOptions(array( + $element->setOptions([ 'label' => 'The value for foo:', - )); + ]); $this->helper->setLabelPosition('append'); $markup = $this->helper->render($element); $this->assertContains('setOptions(array( + $fooElement->setOptions([ 'label' => 'The value for foo:', - 'label_options' => array( + 'label_options' => [ 'label_position' =>'prepend' - ), - )); + ], + ]); $barElement = new Element('bar'); - $barElement->setOptions(array( + $barElement->setOptions([ 'label' => 'The value for bar:', - )); + ]); $this->helper->setLabelPosition('append'); @@ -102,7 +102,7 @@ public function testCanRenderRowLabelAttributes() { $element = new Element('foo'); $element->setLabel('The value for foo:'); - $element->setLabelAttributes(array('class' => 'bar')); + $element->setLabelAttributes(['class' => 'bar']); $this->helper->setLabelPosition('append'); $markup = $this->helper->render($element); $this->assertContains("", $markup); @@ -126,11 +126,11 @@ public function testIgnoreLabelForHidden() public function testCanHandleMultiCheckboxesCorrectly() { - $options = array( + $options = [ 'This is the first label' => 'value1', 'This is the second label' => 'value2', 'This is the third label' => 'value3', - ); + ]; $element = new Element\MultiCheckbox('foo'); $element->setAttribute('type', 'multi_checkbox'); @@ -157,11 +157,11 @@ public function testRenderAttributeId() public function testCanRenderErrors() { $element = new Element('foo'); - $element->setMessages(array( + $element->setMessages([ 'First error message', 'Second error message', 'Third error message', - )); + ]); $markup = $this->helper->render($element); $this->assertRegexp('#\s*First error message\s*Second error message\s*Third error message\s*#s', $markup); @@ -170,11 +170,11 @@ public function testCanRenderErrors() public function testDoesNotRenderErrorsListIfSetToFalse() { $element = new Element('foo'); - $element->setMessages(array( + $element->setMessages([ 'First error message', 'Second error message', 'Third error message', - )); + ]); $markup = $this->helper->setRenderErrors(false)->render($element); $this->assertRegexp('/]*\/?>/', $markup); @@ -183,9 +183,9 @@ public function testDoesNotRenderErrorsListIfSetToFalse() public function testCanModifyDefaultErrorClass() { $element = new Element('foo'); - $element->setMessages(array( + $element->setMessages([ 'Error message' - )); + ]); $markup = $this->helper->setInputErrorClass('custom-error-class')->render($element); $this->assertRegexp('/]*\/?>/', $markup); @@ -194,9 +194,9 @@ public function testCanModifyDefaultErrorClass() public function testDoesNotOverrideClassesIfAlreadyPresentWhenThereAreErrors() { $element = new Element('foo'); - $element->setMessages(array( + $element->setMessages([ 'Error message' - )); + ]); $element->setAttribute('class', 'foo bar'); $markup = $this->helper->setInputErrorClass('custom-error-class')->render($element); @@ -282,8 +282,8 @@ public function testGetRenderErrorsSetToFalse() public function testSetLabelAttributes() { - $this->helper->setLabelAttributes(array('foo', 'bar')); - $this->assertEquals(array(0 => 'foo', 1 => 'bar'), $this->helper->getLabelAttributes()); + $this->helper->setLabelAttributes(['foo', 'bar']); + $this->assertEquals([0 => 'foo', 1 => 'bar'], $this->helper->getLabelAttributes()); } public function testWhenUsingIdAndLabelBecomesEmptyRemoveSpan() @@ -306,13 +306,13 @@ public function testShowErrorInMultiCheckbox() { $element = new Element\MultiCheckbox('hobby'); $element->setLabel("Hobby"); - $element->setValueOptions(array( + $element->setValueOptions([ '0'=>'working', '1'=>'coding' - )); - $element->setMessages(array( + ]); + $element->setMessages([ 'Error message' - )); + ]); $markup = $this->helper->__invoke($element); $this->assertContains('Error message', $markup); @@ -322,13 +322,13 @@ public function testShowErrorInRadio() { $element = new Element\Radio('direction'); $element->setLabel("Direction"); - $element->setValueOptions(array( + $element->setValueOptions([ '0'=>'programming', '1'=>'design' - )); - $element->setMessages(array( + ]); + $element->setMessages([ 'Error message' - )); + ]); $markup = $this->helper->__invoke($element); $this->assertContains('Error message', $markup); @@ -350,7 +350,7 @@ public function testErrorShowTwice() public function testInvokeWithNoRenderErrors() { - $mock = $this->getMock(get_class($this->helper), array('setRenderErrors')); + $mock = $this->getMock(get_class($this->helper), ['setRenderErrors']); $mock->expects($this->never()) ->method('setRenderErrors'); @@ -359,7 +359,7 @@ public function testInvokeWithNoRenderErrors() public function testInvokeWithRenderErrorsTrue() { - $mock = $this->getMock(get_class($this->helper), array('setRenderErrors')); + $mock = $this->getMock(get_class($this->helper), ['setRenderErrors']); $mock->expects($this->once()) ->method('setRenderErrors') ->with(true); @@ -419,7 +419,7 @@ public function testCanDisableLabelHtmlEscape() $label = 'foo'; $element = new Element('fooname'); $element->setLabel($label); - $element->setLabelOptions(array('disable_html_escape' => true)); + $element->setLabelOptions(['disable_html_escape' => true]); $markup = $this->helper->__invoke($element); @@ -503,11 +503,11 @@ public function testLabelOptionAlwaysWrapDefaultsToFalse() public function testCanSetOptionToWrapElementInLabel() { - $element = new Element('foo', array( - 'label_options' => array( + $element = new Element('foo', [ + 'label_options' => [ 'always_wrap' => true - ) - )); + ] + ]); $element->setAttribute('id', 'bar'); $element->setLabel('baz'); @@ -526,10 +526,10 @@ public function testWrapFieldsetAroundCaptchaWithLabel() . '' . '' . '<\/fieldset>$#', - $this->helper->render(new Captcha('captcha', array( - 'captcha' => array('class' => 'dumb'), + $this->helper->render(new Captcha('captcha', [ + 'captcha' => ['class' => 'dumb'], 'label' => 'baz' - ))) + ])) ); } } diff --git a/test/View/Helper/FormSelectTest.php b/test/View/Helper/FormSelectTest.php index 83dff142..24888791 100644 --- a/test/View/Helper/FormSelectTest.php +++ b/test/View/Helper/FormSelectTest.php @@ -24,23 +24,23 @@ public function setUp() public function getElement() { $element = new SelectElement('foo'); - $options = array( - array( + $options = [ + [ 'label' => 'This is the first label', 'value' => 'value1', - ), - array( + ], + [ 'label' => 'This is the second label', 'value' => 'value2', - ), - array( + ], + [ 'label' => 'This is the third label', 'value' => 'value3', - 'attributes' => array( + 'attributes' => [ 'class' => 'test-class', - ), - ), - ); + ], + ], + ]; $element->setValueOptions($options); return $element; } @@ -79,7 +79,7 @@ public function testCanMarkSingleOptionAsSelected() public function testCanOnlyMarkSingleOptionAsSelectedIfMultipleAttributeIsDisabled() { $element = $this->getElement(); - $element->setAttribute('value', array('value1', 'value2')); + $element->setAttribute('value', ['value1', 'value2']); $this->setExpectedException('Zend\Form\Exception\ExceptionInterface', 'multiple'); $markup = $this->helper->render($element); @@ -89,7 +89,7 @@ public function testCanMarkManyOptionsAsSelectedIfMultipleAttributeIsEnabled() { $element = $this->getElement(); $element->setAttribute('multiple', true); - $element->setAttribute('value', array('value1', 'value2')); + $element->setAttribute('value', ['value1', 'value2']); $markup = $this->helper->render($element); $this->assertRegexp('#select .*?multiple="multiple"#', $markup); @@ -124,12 +124,12 @@ public function testOptgroupsAreCreatedWhenAnOptionHasAnOptionsKey() { $element = $this->getElement(); $options = $element->getValueOptions('options'); - $options[1]['options'] = array( - array( + $options[1]['options'] = [ + [ 'label' => 'foo', 'value' => 'bar', - ) - ); + ] + ]; $element->setValueOptions($options); $markup = $this->helper->render($element); @@ -141,12 +141,12 @@ public function testCanDisableAnOptgroup() $element = $this->getElement(); $options = $element->getValueOptions('options'); $options[1]['disabled'] = true; - $options[1]['options'] = array( - array( + $options[1]['options'] = [ + [ 'label' => 'foo', 'value' => 'bar', - ) - ); + ] + ]; $element->setValueOptions($options); $markup = $this->helper->render($element); @@ -181,25 +181,25 @@ public function testNameShouldHaveArrayNotationWhenMultipleIsSpecified() { $element = $this->getElement(); $element->setAttribute('multiple', true); - $element->setAttribute('value', array('value1', 'value2')); + $element->setAttribute('value', ['value1', 'value2']); $markup = $this->helper->render($element); $this->assertRegexp('#]*?(name="foo\&\#x5B\;\&\#x5D\;")#', $markup); } public function getScalarOptionsDataProvider() { - return array( - array(array('value' => 'string')), - array(array(1 => 'int')), - array(array(-1 => 'int-neg')), - array(array(0x1A => 'hex')), - array(array(0123 => 'oct')), - array(array(2.1 => 'float')), - array(array(1.2e3 => 'float-e')), - array(array(7E-10 => 'float-E')), - array(array(true => 'bool-t')), - array(array(false => 'bool-f')), - ); + return [ + [['value' => 'string']], + [[1 => 'int']], + [[-1 => 'int-neg']], + [[0x1A => 'hex']], + [[0123 => 'oct']], + [[2.1 => 'float']], + [[1.2e3 => 'float-e']], + [[7E-10 => 'float-E']], + [[true => 'bool-t']], + [[false => 'bool-f']], + ]; } /** @@ -224,12 +224,12 @@ public function testInvokeWithNoElementChainsHelper() public function testCanTranslateContent() { $element = new SelectElement('foo'); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $mockTranslator = $this->getMock('Zend\I18n\Translator\Translator'); @@ -247,15 +247,15 @@ public function testCanTranslateContent() public function testCanTranslateOptGroupLabel() { $element = new SelectElement('test'); - $element->setValueOptions(array( - 'optgroup' => array( + $element->setValueOptions([ + 'optgroup' => [ 'label' => 'translate me', - 'options' => array( + 'options' => [ '0' => 'foo', '1' => 'bar', - ), - ), - )); + ], + ], + ]); $mockTranslator = $this->getMock('Zend\I18n\Translator\Translator'); $mockTranslator->expects($this->at(0)) @@ -309,12 +309,12 @@ public function testCanCreateEmptyOption() { $element = new SelectElement('foo'); $element->setEmptyOption('empty'); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $this->assertContains('empty', $markup); @@ -324,12 +324,12 @@ public function testCanCreateEmptyOptionWithEmptyString() { $element = new SelectElement('foo'); $element->setEmptyOption(''); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $this->assertContains('', $markup); @@ -338,12 +338,12 @@ public function testCanCreateEmptyOptionWithEmptyString() public function testDoesNotRenderEmptyOptionByDefault() { $element = new SelectElement('foo'); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $this->assertNotContains('', $markup); @@ -353,12 +353,12 @@ public function testNullEmptyOptionDoesNotRenderEmptyOption() { $element = new SelectElement('foo'); $element->setEmptyOption(null); - $element->setValueOptions(array( - array( + $element->setValueOptions([ + [ 'label' => 'label1', 'value' => 'value1', - ), - )); + ], + ]); $markup = $this->helper->render($element); $this->assertNotContains('', $markup); @@ -368,10 +368,10 @@ public function testCanMarkOptionsAsSelectedWhenEmptyOptionOrZeroValueSelected() { $element = new SelectElement('foo'); $element->setEmptyOption('empty'); - $element->setValueOptions(array( + $element->setValueOptions([ 0 => 'label0', 1 => 'label1', - )); + ]); $element->setValue(''); $markup = $this->helper->render($element); diff --git a/test/View/Helper/FormSubmitTest.php b/test/View/Helper/FormSubmitTest.php index bddfa5e2..673d3867 100644 --- a/test/View/Helper/FormSubmitTest.php +++ b/test/View/Helper/FormSubmitTest.php @@ -46,43 +46,43 @@ public function testGeneratesSubmitInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertNotContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertContains'), - array('formenctype', 'assertContains'), - array('formmethod', 'assertContains'), - array('formnovalidate', 'assertContains'), - array('formtarget', 'assertContains'), - array('height', 'assertNotContains'), - array('list', 'assertNotContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertNotContains'), - array('required', 'assertNotContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertNotContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertContains'], + ['formenctype', 'assertContains'], + ['formmethod', 'assertContains'], + ['formnovalidate', 'assertContains'], + ['formtarget', 'assertContains'], + ['height', 'assertNotContains'], + ['list', 'assertNotContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertNotContains'], + ['required', 'assertNotContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormTelTest.php b/test/View/Helper/FormTelTest.php index e3a53f32..cc335dfa 100644 --- a/test/View/Helper/FormTelTest.php +++ b/test/View/Helper/FormTelTest.php @@ -46,43 +46,43 @@ public function testGeneratesTelInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertContains'), - array('placeholder', 'assertContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertContains'], + ['placeholder', 'assertContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormTest.php b/test/View/Helper/FormTest.php index ff96dde6..5de6a6f3 100644 --- a/test/View/Helper/FormTest.php +++ b/test/View/Helper/FormTest.php @@ -45,14 +45,14 @@ public function testCallingCloseTagEmitsClosingFormTag() public function testCallingOpenTagWithFormUsesFormAttributes() { $form = new Form(); - $attributes = array( + $attributes = [ 'method' => 'post', 'action' => 'http://localhost/endpoint', 'class' => 'login', 'id' => 'form-login', 'enctype' => 'application/x-www-form-urlencoded', 'target' => '_self', - ); + ]; $form->setAttributes($attributes); $markup = $this->helper->openTag($form); @@ -66,9 +66,9 @@ public function testCallingOpenTagWithFormUsesFormAttributes() public function testOpenTagUsesNameAsIdIfNoIdAttributePresent() { $form = new Form(); - $attributes = array( + $attributes = [ 'name' => 'login-form', - ); + ]; $form->setAttributes($attributes); $markup = $this->helper->openTag($form); @@ -79,7 +79,7 @@ public function testOpenTagUsesNameAsIdIfNoIdAttributePresent() public function testRender() { $form = new Form(); - $attributes = array('name' => 'login-form'); + $attributes = ['name' => 'login-form']; $form->setAttributes($attributes); $form->add(new CityFieldset()); $form->add(new Submit('send')); @@ -98,8 +98,8 @@ public function testRenderPreparesForm() { $form = $this->getMock('Zend\\Form\\Form'); $form->expects($this->once())->method('prepare'); - $form->expects($this->any())->method('getAttributes')->will($this->returnValue(array())); - $form->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator(array()))); + $form->expects($this->any())->method('getAttributes')->will($this->returnValue([])); + $form->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([]))); $markup = $this->helper->__invoke($form); diff --git a/test/View/Helper/FormTextTest.php b/test/View/Helper/FormTextTest.php index b2354f7f..1edbdf23 100644 --- a/test/View/Helper/FormTextTest.php +++ b/test/View/Helper/FormTextTest.php @@ -46,43 +46,43 @@ public function testGeneratesTextInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertContains'), - array('placeholder', 'assertContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertContains'], + ['placeholder', 'assertContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormTextareaTest.php b/test/View/Helper/FormTextareaTest.php index 29fa3fb9..811b3aec 100644 --- a/test/View/Helper/FormTextareaTest.php +++ b/test/View/Helper/FormTextareaTest.php @@ -36,103 +36,103 @@ public function testGeneratesEmptyTextareaWhenNoValueAttributePresent() public function validAttributes() { - return array( - array('accesskey', 'assertContains'), - array('class', 'assertContains'), - array('contenteditable', 'assertContains'), - array('contextmenu', 'assertContains'), - array('dir', 'assertContains'), - array('draggable', 'assertContains'), - array('dropzone', 'assertContains'), - array('hidden', 'assertContains'), - array('id', 'assertContains'), - array('lang', 'assertContains'), - array('onabort', 'assertContains'), - array('onblur', 'assertContains'), - array('oncanplay', 'assertContains'), - array('oncanplaythrough', 'assertContains'), - array('onchange', 'assertContains'), - array('onclick', 'assertContains'), - array('oncontextmenu', 'assertContains'), - array('ondblclick', 'assertContains'), - array('ondrag', 'assertContains'), - array('ondragend', 'assertContains'), - array('ondragenter', 'assertContains'), - array('ondragleave', 'assertContains'), - array('ondragover', 'assertContains'), - array('ondragstart', 'assertContains'), - array('ondrop', 'assertContains'), - array('ondurationchange', 'assertContains'), - array('onemptied', 'assertContains'), - array('onended', 'assertContains'), - array('onerror', 'assertContains'), - array('onfocus', 'assertContains'), - array('oninput', 'assertContains'), - array('oninvalid', 'assertContains'), - array('onkeydown', 'assertContains'), - array('onkeypress', 'assertContains'), - array('onkeyup', 'assertContains'), - array('onload', 'assertContains'), - array('onloadeddata', 'assertContains'), - array('onloadedmetadata', 'assertContains'), - array('onloadstart', 'assertContains'), - array('onmousedown', 'assertContains'), - array('onmousemove', 'assertContains'), - array('onmouseout', 'assertContains'), - array('onmouseover', 'assertContains'), - array('onmouseup', 'assertContains'), - array('onmousewheel', 'assertContains'), - array('onpause', 'assertContains'), - array('onplay', 'assertContains'), - array('onplaying', 'assertContains'), - array('onprogress', 'assertContains'), - array('onratechange', 'assertContains'), - array('onreadystatechange', 'assertContains'), - array('onreset', 'assertContains'), - array('onscroll', 'assertContains'), - array('onseeked', 'assertContains'), - array('onseeking', 'assertContains'), - array('onselect', 'assertContains'), - array('onshow', 'assertContains'), - array('onstalled', 'assertContains'), - array('onsubmit', 'assertContains'), - array('onsuspend', 'assertContains'), - array('ontimeupdate', 'assertContains'), - array('onvolumechange', 'assertContains'), - array('onwaiting', 'assertContains'), - array('spellcheck', 'assertContains'), - array('style', 'assertContains'), - array('tabindex', 'assertContains'), - array('title', 'assertContains'), - array('xml:base', 'assertContains'), - array('xml:lang', 'assertContains'), - array('xml:space', 'assertContains'), - array('data-some-key', 'assertContains'), - array('autofocus', 'assertContains'), - array('cols', 'assertContains'), - array('dirname', 'assertContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('maxlength', 'assertContains'), - array('name', 'assertContains'), - array('placeholder', 'assertContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('rows', 'assertContains'), - array('wrap', 'assertContains'), - array('content', 'assertNotContains'), - array('option', 'assertNotContains'), - array('optgroup', 'assertNotContains'), - array('arbitrary', 'assertNotContains'), - array('meta', 'assertNotContains'), - array('role', 'assertContains'), - ); + return [ + ['accesskey', 'assertContains'], + ['class', 'assertContains'], + ['contenteditable', 'assertContains'], + ['contextmenu', 'assertContains'], + ['dir', 'assertContains'], + ['draggable', 'assertContains'], + ['dropzone', 'assertContains'], + ['hidden', 'assertContains'], + ['id', 'assertContains'], + ['lang', 'assertContains'], + ['onabort', 'assertContains'], + ['onblur', 'assertContains'], + ['oncanplay', 'assertContains'], + ['oncanplaythrough', 'assertContains'], + ['onchange', 'assertContains'], + ['onclick', 'assertContains'], + ['oncontextmenu', 'assertContains'], + ['ondblclick', 'assertContains'], + ['ondrag', 'assertContains'], + ['ondragend', 'assertContains'], + ['ondragenter', 'assertContains'], + ['ondragleave', 'assertContains'], + ['ondragover', 'assertContains'], + ['ondragstart', 'assertContains'], + ['ondrop', 'assertContains'], + ['ondurationchange', 'assertContains'], + ['onemptied', 'assertContains'], + ['onended', 'assertContains'], + ['onerror', 'assertContains'], + ['onfocus', 'assertContains'], + ['oninput', 'assertContains'], + ['oninvalid', 'assertContains'], + ['onkeydown', 'assertContains'], + ['onkeypress', 'assertContains'], + ['onkeyup', 'assertContains'], + ['onload', 'assertContains'], + ['onloadeddata', 'assertContains'], + ['onloadedmetadata', 'assertContains'], + ['onloadstart', 'assertContains'], + ['onmousedown', 'assertContains'], + ['onmousemove', 'assertContains'], + ['onmouseout', 'assertContains'], + ['onmouseover', 'assertContains'], + ['onmouseup', 'assertContains'], + ['onmousewheel', 'assertContains'], + ['onpause', 'assertContains'], + ['onplay', 'assertContains'], + ['onplaying', 'assertContains'], + ['onprogress', 'assertContains'], + ['onratechange', 'assertContains'], + ['onreadystatechange', 'assertContains'], + ['onreset', 'assertContains'], + ['onscroll', 'assertContains'], + ['onseeked', 'assertContains'], + ['onseeking', 'assertContains'], + ['onselect', 'assertContains'], + ['onshow', 'assertContains'], + ['onstalled', 'assertContains'], + ['onsubmit', 'assertContains'], + ['onsuspend', 'assertContains'], + ['ontimeupdate', 'assertContains'], + ['onvolumechange', 'assertContains'], + ['onwaiting', 'assertContains'], + ['spellcheck', 'assertContains'], + ['style', 'assertContains'], + ['tabindex', 'assertContains'], + ['title', 'assertContains'], + ['xml:base', 'assertContains'], + ['xml:lang', 'assertContains'], + ['xml:space', 'assertContains'], + ['data-some-key', 'assertContains'], + ['autofocus', 'assertContains'], + ['cols', 'assertContains'], + ['dirname', 'assertContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['maxlength', 'assertContains'], + ['name', 'assertContains'], + ['placeholder', 'assertContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['rows', 'assertContains'], + ['wrap', 'assertContains'], + ['content', 'assertNotContains'], + ['option', 'assertNotContains'], + ['optgroup', 'assertNotContains'], + ['arbitrary', 'assertNotContains'], + ['meta', 'assertNotContains'], + ['role', 'assertContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accesskey' => 'value', 'class' => 'value', 'contenteditable' => 'value', @@ -222,7 +222,7 @@ public function getCompleteElement() 'arbitrary' => 'value', 'meta' => 'value', 'role' => 'value', - )); + ]); return $element; } @@ -239,12 +239,12 @@ public function testAllValidFormMarkupAttributesPresentInElementAreRendered($att public function booleanAttributeTypes() { - return array( - array('autofocus', 'autofocus', ''), - array('disabled', 'disabled', ''), - array('readonly', 'readonly', ''), - array('required', 'required', ''), - ); + return [ + ['autofocus', 'autofocus', ''], + ['disabled', 'disabled', ''], + ['readonly', 'readonly', ''], + ['required', 'required', ''], + ]; } /** diff --git a/test/View/Helper/FormTimeTest.php b/test/View/Helper/FormTimeTest.php index 9c9cb048..6664cbc5 100644 --- a/test/View/Helper/FormTimeTest.php +++ b/test/View/Helper/FormTimeTest.php @@ -46,43 +46,43 @@ public function testGeneratesInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormUrlTest.php b/test/View/Helper/FormUrlTest.php index 0dcfc5e8..1b04ccb7 100644 --- a/test/View/Helper/FormUrlTest.php +++ b/test/View/Helper/FormUrlTest.php @@ -46,43 +46,43 @@ public function testGeneratesUrlInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertNotContains'), - array('maxlength', 'assertContains'), - array('min', 'assertNotContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertContains'), - array('placeholder', 'assertContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertContains'), - array('src', 'assertNotContains'), - array('step', 'assertNotContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertNotContains'], + ['maxlength', 'assertContains'], + ['min', 'assertNotContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertContains'], + ['placeholder', 'assertContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertContains'], + ['src', 'assertNotContains'], + ['step', 'assertNotContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; } diff --git a/test/View/Helper/FormWeekTest.php b/test/View/Helper/FormWeekTest.php index bc067e9b..9f724f3a 100644 --- a/test/View/Helper/FormWeekTest.php +++ b/test/View/Helper/FormWeekTest.php @@ -46,43 +46,43 @@ public function testGeneratesInputTagRegardlessOfElementType() public function validAttributes() { - return array( - array('name', 'assertContains'), - array('accept', 'assertNotContains'), - array('alt', 'assertNotContains'), - array('autocomplete', 'assertContains'), - array('autofocus', 'assertContains'), - array('checked', 'assertNotContains'), - array('dirname', 'assertNotContains'), - array('disabled', 'assertContains'), - array('form', 'assertContains'), - array('formaction', 'assertNotContains'), - array('formenctype', 'assertNotContains'), - array('formmethod', 'assertNotContains'), - array('formnovalidate', 'assertNotContains'), - array('formtarget', 'assertNotContains'), - array('height', 'assertNotContains'), - array('list', 'assertContains'), - array('max', 'assertContains'), - array('maxlength', 'assertNotContains'), - array('min', 'assertContains'), - array('multiple', 'assertNotContains'), - array('pattern', 'assertNotContains'), - array('placeholder', 'assertNotContains'), - array('readonly', 'assertContains'), - array('required', 'assertContains'), - array('size', 'assertNotContains'), - array('src', 'assertNotContains'), - array('step', 'assertContains'), - array('value', 'assertContains'), - array('width', 'assertNotContains'), - ); + return [ + ['name', 'assertContains'], + ['accept', 'assertNotContains'], + ['alt', 'assertNotContains'], + ['autocomplete', 'assertContains'], + ['autofocus', 'assertContains'], + ['checked', 'assertNotContains'], + ['dirname', 'assertNotContains'], + ['disabled', 'assertContains'], + ['form', 'assertContains'], + ['formaction', 'assertNotContains'], + ['formenctype', 'assertNotContains'], + ['formmethod', 'assertNotContains'], + ['formnovalidate', 'assertNotContains'], + ['formtarget', 'assertNotContains'], + ['height', 'assertNotContains'], + ['list', 'assertContains'], + ['max', 'assertContains'], + ['maxlength', 'assertNotContains'], + ['min', 'assertContains'], + ['multiple', 'assertNotContains'], + ['pattern', 'assertNotContains'], + ['placeholder', 'assertNotContains'], + ['readonly', 'assertContains'], + ['required', 'assertContains'], + ['size', 'assertNotContains'], + ['src', 'assertNotContains'], + ['step', 'assertContains'], + ['value', 'assertContains'], + ['width', 'assertNotContains'], + ]; } public function getCompleteElement() { $element = new Element('foo'); - $element->setAttributes(array( + $element->setAttributes([ 'accept' => 'value', 'alt' => 'value', 'autocomplete' => 'on', @@ -112,7 +112,7 @@ public function getCompleteElement() 'src' => 'value', 'step' => 'value', 'width' => 'value', - )); + ]); $element->setValue('value'); return $element; }