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 ', $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, '