Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 4b78d2e

Browse files
committed
Merge branch 'hotfix/qa-typos-and-optimizations'
Close #189 Close #191 Close #197 Close #199 Close #200
2 parents 48b0284 + 224ef72 commit 4b78d2e

File tree

8 files changed

+12
-14
lines changed

8 files changed

+12
-14
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cache:
1515
env:
1616
global:
1717
- COMPOSER_ARGS="--no-interaction"
18-
- COVERAGE_DEPS="satooshi/php-coveralls"
18+
- COVERAGE_DEPS="php-coveralls/php-coveralls"
1919
- TESTS_ZEND_FORM_ANNOTATION_SUPPORT=true
2020
- TESTS_ZEND_FORM_RECAPTCHA_SUPPORT=true
2121

@@ -78,7 +78,7 @@ script:
7878
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
7979

8080
after_script:
81-
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi
81+
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry php vendor/bin/php-coveralls -v ; fi
8282

8383
notifications:
8484
email: false

composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
"cs-check": "phpcs",
8383
"cs-fix": "phpcbf",
8484
"test": "phpunit --colors=always",
85-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
86-
"upload-coverage": "coveralls -v"
85+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
8786
}
8887
}

docs/book/quick-start.md

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ $captcha->setCaptcha(new Captcha\Dumb());
5353
$captcha->setLabel('Please verify you are human');
5454

5555
// Create a CSRF token:
56-
$captcha = new Element\Captcha('captcha');
5756
$csrf = new Element\Csrf('security');
5857

5958
// Create a submit button:

src/Element/Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function setObject($object)
172172
}
173173

174174
$this->object = $object;
175-
$this->count = count($object) > $this->count ? count($object) : $this->count;
175+
$this->count = max(count($object), $this->count);
176176

177177
return $this;
178178
}

src/Element/Select.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function unsetValueOption($key)
112112
* - label: label to associate with the element
113113
* - label_attributes: attributes to use when the label is rendered
114114
* - value_options: list of values and labels for the select options
115-
* _ empty_option: should an empty option be prepended to the options ?
115+
* - empty_option: should an empty option be prepended to the options ?
116116
*
117117
* @param array|Traversable $options
118118
* @return Select|ElementInterface

src/View/Helper/AbstractHelper.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ protected function prepareAttributes(array $attributes)
370370

371371
if (! isset($this->validGlobalAttributes[$attribute])
372372
&& ! isset($this->validTagAttributes[$attribute])
373-
&& 'data-' != substr($attribute, 0, 5)
374-
&& 'aria-' != substr($attribute, 0, 5)
375-
&& 'x-' != substr($attribute, 0, 2)
373+
&& 0 !== strpos($attribute, 'data-')
374+
&& 0 !== strpos($attribute, 'aria-')
375+
&& 0 !== strpos($attribute, 'x-')
376376
) {
377377
// Invalid attribute for the current tag
378378
unset($attributes[$key]);
@@ -434,13 +434,13 @@ protected function translateHtmlAttributeValue($key, $value)
434434
return $this->getTranslator()->translate($value, $this->getTranslatorTextDomain());
435435
} else {
436436
foreach ($this->translatableAttributePrefixes as $prefix) {
437-
if (mb_substr($key, 0, mb_strlen($prefix)) === $prefix) {
437+
if (0 === mb_strpos($key, $prefix)) {
438438
// prefix matches => return translated $value
439439
return $this->getTranslator()->translate($value, $this->getTranslatorTextDomain());
440440
}
441441
}
442442
foreach (self::$defaultTranslatableHtmlAttributePrefixes as $prefix) {
443-
if (mb_substr($key, 0, mb_strlen($prefix)) === $prefix) {
443+
if (0 === mb_strpos($key, $prefix)) {
444444
// default prefix matches => return translated $value
445445
return $this->getTranslator()->translate($value, $this->getTranslatorTextDomain());
446446
}

src/View/Helper/FormCollection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function render(ElementInterface $element)
123123
if ($this->shouldWrap) {
124124
$attributes = $element->getAttributes();
125125
unset($attributes['name']);
126-
$attributesString = count($attributes) ? ' ' . $this->createAttributesString($attributes) : '';
126+
$attributesString = $attributes ? ' ' . $this->createAttributesString($attributes) : '';
127127

128128
$label = $element->getLabel();
129129
$legend = '';

src/View/Helper/FormRow.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function render(ElementInterface $element, $labelPosition = null)
141141
}
142142

143143
// Does this element have errors ?
144-
if (count($element->getMessages()) > 0 && ! empty($inputErrorClass)) {
144+
if ($element->getMessages() && $inputErrorClass) {
145145
$classAttributes = ($element->hasAttribute('class') ? $element->getAttribute('class') . ' ' : '');
146146
$classAttributes = $classAttributes . $inputErrorClass;
147147

0 commit comments

Comments
 (0)