1 | <?php |
||
8 | class Attribute extends ValueObject |
||
9 | { |
||
10 | /** |
||
11 | * @var array $global |
||
12 | */ |
||
13 | private $global = [ |
||
14 | 'accesskey', |
||
15 | 'class', |
||
16 | 'contenteditable', |
||
17 | 'contextmenu', |
||
18 | 'data', |
||
19 | 'dir', |
||
20 | 'draggable', |
||
21 | 'hidden', |
||
22 | 'id', |
||
23 | 'is', |
||
24 | 'itemid', |
||
25 | 'itemprop', |
||
26 | 'itemref', |
||
27 | 'itemscope', |
||
28 | 'itemtype', |
||
29 | 'lang', |
||
30 | 'onabort', |
||
31 | 'onautocomplete', |
||
32 | 'onautocompleteerror', |
||
33 | 'onblur', |
||
34 | 'oncancel', |
||
35 | 'oncanplay', |
||
36 | 'oncanplaythrough', |
||
37 | 'onchange', |
||
38 | 'onclick', |
||
39 | 'onclose', |
||
40 | 'oncontextmenu', |
||
41 | 'oncuechange', |
||
42 | 'ondblclick', |
||
43 | 'ondrag', |
||
44 | 'ondragend', |
||
45 | 'ondragenter', |
||
46 | 'ondragexit', |
||
47 | 'ondragleave', |
||
48 | 'ondragover', |
||
49 | 'ondragstart', |
||
50 | 'ondrop', |
||
51 | 'ondurationchange', |
||
52 | 'onemptied', |
||
53 | 'onended', |
||
54 | 'onerror', |
||
55 | 'onfocus', |
||
56 | 'oninput', |
||
57 | 'oninvalid', |
||
58 | 'onkeydown', |
||
59 | 'onkeypress', |
||
60 | 'onkeyup', |
||
61 | 'onload', |
||
62 | 'onloadeddata', |
||
63 | 'onloadedmetadata', |
||
64 | 'onloadstart', |
||
65 | 'onmousedown', |
||
66 | 'onmouseenter', |
||
67 | 'onmouseleave', |
||
68 | 'onmousemove', |
||
69 | 'onmouseout', |
||
70 | 'onmouseover', |
||
71 | 'onmouseup', |
||
72 | 'onmousewheel', |
||
73 | 'onpause', |
||
74 | 'onplay', |
||
75 | 'onplaying', |
||
76 | 'onprogress', |
||
77 | 'onratechange', |
||
78 | 'onreset', |
||
79 | 'onresize', |
||
80 | 'onscroll', |
||
81 | 'onseeked', |
||
82 | 'onseeking', |
||
83 | 'onselect', |
||
84 | 'onshow', |
||
85 | 'onsort', |
||
86 | 'onstalled', |
||
87 | 'onsubmit', |
||
88 | 'onsuspend', |
||
89 | 'ontimeupdate', |
||
90 | 'ontoggle', |
||
91 | 'onvolumechange', |
||
92 | 'onwaiting', |
||
93 | 'spellcheck', |
||
94 | 'style', |
||
95 | 'tabindex', |
||
96 | 'title', |
||
97 | 'translate', |
||
98 | 'xml:lang', |
||
99 | 'xml:base' |
||
100 | ]; |
||
101 | |||
102 | /** |
||
103 | * @var array $elements |
||
104 | */ |
||
105 | private $elements = [ |
||
106 | 'accept' => [ 'form', 'input' ], |
||
107 | 'accesskey' => [ 'form' ], |
||
108 | 'action' => [ 'form' ], |
||
109 | 'align' => [ 'applet', 'caption', 'col', 'colgroup', 'hr', 'iframe', 'img', 'table', 'tbody', 'td', |
||
110 | 'tfoot', 'th', 'thead', 'tr' ], |
||
111 | 'alt' => [ 'applet', 'area', 'img', 'input' ], |
||
112 | 'async' => [ 'script' ], |
||
113 | 'autocomplete' => [ 'form', 'input' ], |
||
114 | 'autofocus' => [ 'button', 'input', 'keygen', 'select', 'textarea' ], |
||
115 | 'autoplay' => [ 'audio', 'video' ], |
||
116 | 'autosave' => [ 'input' ], |
||
117 | 'bgcolor' => [ 'body', 'col', 'colgroup', 'table', 'tbody', 'tfoot', 'td', 'th', 'tr' ], |
||
118 | 'border' => [ 'img', 'object', 'table' ], |
||
119 | 'buffered' => [ 'audio', 'video' ], |
||
120 | 'challenge' => [ 'keygen' ], |
||
121 | 'charset' => [ 'meta', 'script' ], |
||
122 | 'checked' => [ 'command', 'input' ], |
||
123 | 'cite' => [ 'blockquote', 'del', 'ins', 'q' ], |
||
124 | 'code' => [ 'applet' ], |
||
125 | 'codebase' => [ 'applet' ], |
||
126 | 'color' => [ 'basefont', 'font', 'hr' ], |
||
127 | 'cols' => [ 'textarea' ], |
||
128 | 'colspan' => [ 'td', 'th' ], |
||
129 | 'content' => [ 'meta' ], |
||
130 | 'controls' => [ 'audio', 'video' ], |
||
131 | 'coords' => [ 'area' ], |
||
132 | 'data' => [ 'object' ], |
||
133 | 'datetime' => [ 'del', 'ins', 'time' ], |
||
134 | 'default' => [ 'track' ], |
||
135 | 'defer' => [ 'script' ], |
||
136 | 'dirname' => [ 'input', 'textarea' ], |
||
137 | 'disabled' => [ 'button', 'command', 'fieldset', 'input', 'keygen', 'optgroup', 'option', 'select', |
||
138 | 'textearea' ], |
||
139 | 'download' => [ 'a', 'area' ], |
||
140 | 'enctype' => [ 'form' ], |
||
141 | 'for' => [ 'label', 'output' ], |
||
142 | 'form' => [ 'button', 'fieldset', 'input', 'keygen', 'label', 'meter', 'object', 'output', 'prgress', |
||
143 | 'select', 'textarea' ], |
||
144 | 'formaction' => [ 'input', 'button' ], |
||
145 | 'headers' => [ 'td', 'th' ], |
||
146 | 'height' => [ 'canvas', 'embed', 'iframe', 'img', 'input', 'object', 'video' ], |
||
147 | 'high' => [ 'meter' ], |
||
148 | 'href' => [ 'a', 'area', 'base', 'link' ], |
||
149 | 'hreflang' => [ 'a', 'area', 'link' ], |
||
150 | 'http-equiv' => [ 'meta' ], |
||
151 | 'icon' => [ 'command' ], |
||
152 | 'integrity' => [ 'link', 'script' ], |
||
153 | 'ismap' => [ 'img' ], |
||
154 | 'keytype' => [ 'keygen' ], |
||
155 | 'kind' => [ 'track' ], |
||
156 | 'label' => [ 'track' ], |
||
157 | 'lang' => [ 'track' ], |
||
158 | 'language' => [ 'script' ], |
||
159 | 'list' => [ 'input' ], |
||
160 | 'loop' => [ 'audio', 'bgsound', 'video' ], |
||
161 | 'low' => [ 'meter' ], |
||
162 | 'manifest' => [ 'html' ], |
||
163 | 'max' => [ 'input', 'meter', 'progress' ], |
||
164 | 'maxlength' => [ 'input', 'textarea' ], |
||
165 | 'media' => [ 'a', 'area', 'link', 'source', 'style' ], |
||
166 | 'method' => [ 'form' ], |
||
167 | 'min' => [ 'input', 'meter' ], |
||
168 | 'multiple' => [ 'input', 'select' ], |
||
169 | 'muted' => [ 'video' ], |
||
170 | 'name' => [ 'button', 'form', 'fieldset', 'iframe', 'input', 'keygen', 'object', 'output', 'select', |
||
171 | 'textarea', 'map', 'meta', 'param' ], |
||
172 | 'novalidate' => [ 'form' ], |
||
173 | 'open' => [ 'details' ], |
||
174 | 'optimum' => [ 'meter' ], |
||
175 | 'pattern' => [ 'input' ], |
||
176 | 'ping' => [ 'a', 'area' ], |
||
177 | 'placeholder' => [ 'input', 'textarea' ], |
||
178 | 'poster' => [ 'video' ], |
||
179 | 'preload' => [ 'audio', 'video' ], |
||
180 | 'radiogroup' => [ 'command' ], |
||
181 | 'readonly' => [ 'input', 'textarea' ], |
||
182 | 'rel' => [ 'a', 'area', 'link' ], |
||
183 | 'required' => [ 'input', 'select', 'textarea' ], |
||
184 | 'reversed' => [ 'ol' ], |
||
185 | 'rows' => [ 'textarea' ], |
||
186 | 'rowspan' => [ 'td', 'th' ], |
||
187 | 'sandbox' => [ 'iframe' ], |
||
188 | 'scope' => [ 'th' ], |
||
189 | 'scoped' => [ 'style' ], |
||
190 | 'seamless' => [ 'iframe' ], |
||
191 | 'selected' => [ 'option' ], |
||
192 | 'shape' => [ 'a', 'area' ], |
||
193 | 'size' => [ 'input', 'select' ], |
||
194 | 'sizes' => [ 'link', 'img', 'source' ], |
||
195 | 'span' => [ 'col', 'colgroup' ], |
||
196 | 'src' => [ 'audio', 'embed', 'iframe', 'img', 'input', 'script', 'source', 'track', 'video' ], |
||
197 | 'srcdoc' => [ 'iframe' ], |
||
198 | 'srclang' => [ 'track' ], |
||
199 | 'srcset' => [ 'img' ], |
||
200 | 'start' => [ 'ol' ], |
||
201 | 'step' => [ 'input' ], |
||
202 | 'summary' => [ 'table' ], |
||
203 | 'target' => [ 'a', 'area', 'base', 'form' ], |
||
204 | 'type' => [ 'button', 'input', 'command', 'embed', 'object', 'script', 'source', 'style', 'menu' ], |
||
205 | 'usemap' => [ 'img', 'input', 'object' ], |
||
206 | 'value' => [ 'button', 'option', 'input', 'li', 'meter', 'progress', 'param' ], |
||
207 | 'width' => [ 'canvas', 'embed', 'iframe', 'img', 'input', 'object', 'video' ], |
||
208 | 'wrap' => [ 'textarea' ] |
||
209 | ]; |
||
210 | |||
211 | /** |
||
212 | * Attribute constructor. |
||
213 | * |
||
214 | * @param $value |
||
215 | */ |
||
216 | 2 | public function __construct($value) |
|
224 | |||
225 | /** |
||
226 | * @param $element |
||
227 | * @return bool |
||
228 | */ |
||
229 | 1 | public function validForElement(Element $element) |
|
234 | } |
||
235 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.