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

Commit 1b75b19

Browse files
committed
Consistency, CS changes for #194
- Updates docblocks of changed files to match new standards. - Updates docblocks of new properties, methods to match formatting of others. Adds `@throws` annotations to methods throwing exceptions. - Adds labels to each datum in a data provider.
1 parent 7af96d9 commit 1b75b19

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

src/View/Helper/AbstractHelper.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,9 @@ protected function translateHtmlAttributeValue($key, $value)
468468
* Adds an HTML attribute to the list of valid attributes
469469
*
470470
* @param string $attribute
471-
*
472471
* @return AbstractHelper
472+
* @throws InvalidArgumentException for attribute names that are invalid
473+
* per the HTML specifications.
473474
*/
474475
public function addValidAttribute($attribute)
475476
{
@@ -485,8 +486,9 @@ public function addValidAttribute($attribute)
485486
* Adds a prefix to the list of valid attribute prefixes
486487
*
487488
* @param string $prefix
488-
*
489489
* @return AbstractHelper
490+
* @throws InvalidArgumentException for attribute prefixes that are invalid
491+
* per the HTML specifications for attribute names.
490492
*/
491493
public function addValidAttributePrefix($prefix)
492494
{
@@ -549,10 +551,9 @@ public static function addDefaultTranslatableAttributePrefix($prefix)
549551
/**
550552
* Whether the passed attribute is valid or not
551553
*
552-
* @see https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 Description of valid attributes
553-
*
554-
* @param string $attribute
555-
*
554+
* @see https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
555+
* Description of valid attributes
556+
* @param string $attribute
556557
* @return bool
557558
*/
558559
protected function isValidAttributeName($attribute)
@@ -562,7 +563,8 @@ protected function isValidAttributeName($attribute)
562563

563564
/**
564565
* Whether the passed attribute has a valid prefix or not
565-
* @param string $attribute
566+
*
567+
* @param string $attribute
566568
* @return bool
567569
*/
568570
protected function hasAllowedPrefix($attribute)

test/View/Helper/AbstractHelperTest.php

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22
/**
3-
* Zend Framework (http://framework.zend.com/)
4-
*
5-
* @link http://github.com/zendframework/zf2 for the canonical source repository
6-
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7-
* @license http://framework.zend.com/license/new-bsd New BSD License
3+
* @see https://github.com/zendframework/zend-form for the canonical source repository
4+
* @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-form/blob/master/LICENSE.md New BSD License
86
*/
97

108
namespace ZendTest\Form\View\Helper;
@@ -24,7 +22,6 @@ class AbstractHelperTest extends CommonTestCase
2422
public function setUp()
2523
{
2624
$this->helper = $this->getMockForAbstractClass('Zend\Form\View\Helper\AbstractHelper');
27-
2825
parent::setUp();
2926
}
3027

@@ -64,18 +61,18 @@ public function testWillNotEncodeValueAttributeValuesCorrectly()
6461
public function addAttributesData()
6562
{
6663
return [
67-
[ 'valid', 'valid="value"' ],
68-
[ 'px-custom', 'px-custom="value"' ],
69-
[ 'xlink:custom', 'xlink:custom="value"' ],
70-
[ 'attr/', null, true ],
71-
[ 'attr"', null, true ],
72-
[ 'attr\'', null, true ],
73-
[ 'attr>', null, true ],
74-
[ 'attr=value', null, true ],
75-
[ 'at tr', null, true ],
76-
[ "at\ntr", null, true ],
77-
[ "at\ttr", null, true ],
78-
[ "at\ftr", null, true ],
64+
'valid' => ['valid', 'valid="value"'],
65+
'valid-prefix' => ['px-custom', 'px-custom="value"'],
66+
'xml-ns' => ['xlink:custom', 'xlink:custom="value"'],
67+
'invalid-slash' => ['attr/', null, true],
68+
'invalid-double-quote' => ['attr"', null, true],
69+
'invalid-quote' => ['attr\'', null, true],
70+
'invalid-gt' => ['attr>', null, true],
71+
'invalid-equals' => ['attr=value', null, true],
72+
'invalid-space' => ['at tr', null, true],
73+
'invalid-newline' => ["at\ntr", null, true],
74+
'invalid-tab' => ["at\ttr", null, true],
75+
'invalid-formfeed' => ["at\ftr", null, true],
7976
];
8077
}
8178

@@ -99,19 +96,19 @@ public function testWillIncludeAdditionalAttributes($attribute, $expected = null
9996
public function addAttributesPrefixData()
10097
{
10198
return [
102-
[ 'v-', 'v-attr="value"' ],
103-
[ 'custom-', 'custom-attr="value"' ],
104-
[ 'xlink:', 'xlink:attr="value"' ],
105-
[ 'abc', 'abcattr="value"' ],
106-
[ 'custom/', null, true ],
107-
[ 'custom"', null, true ],
108-
[ 'custom\'', null, true ],
109-
[ 'custom>', null, true ],
110-
[ 'custom=', null, true ],
111-
[ 'custom ', null, true ],
112-
[ "cus\ntom", null, true ],
113-
[ "cus\ttom", null, true ],
114-
[ "cus\ftom", null, true ],
99+
'valid' => ['v-', 'v-attr="value"'],
100+
'valid-dash' => ['custom-', 'custom-attr="value"'],
101+
'xml-ns' => ['xlink:', 'xlink:attr="value"'],
102+
'valid-nodash' => ['abc', 'abcattr="value"'],
103+
'invalid-slash' => ['custom/', null, true],
104+
'invalid-double-quote' => ['custom"', null, true],
105+
'invalid-quote' => ['custom\'', null, true],
106+
'invalid-gt' => ['custom>', null, true],
107+
'invalid-equals' => ['custom=', null, true],
108+
'invalid-space' => ['custom ', null, true],
109+
'invalid-newline' => ["cus\ntom", null, true],
110+
'invalid-tab' => ["cus\ttom", null, true],
111+
'invalid-formfeed' => ["cus\ftom", null, true],
115112
];
116113
}
117114

0 commit comments

Comments
 (0)