@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | protected SimpleXMLElement $xml; |
51 | 51 | |
52 | - /** |
|
53 | - * @var string|NULL |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var string|NULL |
|
54 | + */ |
|
55 | 55 | protected ?string $json; |
56 | 56 | |
57 | 57 | protected function __construct(SimpleXMLElement $element) |
@@ -96,34 +96,34 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
101 | - * |
|
102 | - * @param SimpleXMLElement $element |
|
103 | - * @return XMLHelper_Converter |
|
104 | - */ |
|
99 | + /** |
|
100 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
101 | + * |
|
102 | + * @param SimpleXMLElement $element |
|
103 | + * @return XMLHelper_Converter |
|
104 | + */ |
|
105 | 105 | public static function fromElement(SimpleXMLElement $element) : XMLHelper_Converter |
106 | 106 | { |
107 | 107 | return new XMLHelper_Converter($element); |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
112 | - * |
|
113 | - * @param DOMElement $element |
|
114 | - * @return XMLHelper_Converter |
|
115 | - */ |
|
110 | + /** |
|
111 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
112 | + * |
|
113 | + * @param DOMElement $element |
|
114 | + * @return XMLHelper_Converter |
|
115 | + */ |
|
116 | 116 | public static function fromDOMElement(DOMElement $element) : XMLHelper_Converter |
117 | 117 | { |
118 | 118 | return new XMLHelper_Converter(simplexml_import_dom($element)); |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Converts the XML to JSON. |
|
123 | - * |
|
124 | - * @return string |
|
125 | - * @throws XMLHelper_Exception|JsonException |
|
126 | - */ |
|
121 | + /** |
|
122 | + * Converts the XML to JSON. |
|
123 | + * |
|
124 | + * @return string |
|
125 | + * @throws XMLHelper_Exception|JsonException |
|
126 | + */ |
|
127 | 127 | public function toJSON() : string |
128 | 128 | { |
129 | 129 | if (isset($this->json)) |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - /** |
|
160 | - * Converts the XML to an associative array. |
|
161 | - * @return array<mixed> |
|
162 | - * @throws XMLHelper_Exception |
|
163 | - * @throws JsonException |
|
164 | - */ |
|
159 | + /** |
|
160 | + * Converts the XML to an associative array. |
|
161 | + * @return array<mixed> |
|
162 | + * @throws XMLHelper_Exception |
|
163 | + * @throws JsonException |
|
164 | + */ |
|
165 | 165 | public function toArray() : array |
166 | 166 | { |
167 | 167 | $json = $this->toJSON(); |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | { |
26 | 26 | public const SERIALIZE_SEPARATOR = '__SERIALIZE_SEP__'; |
27 | 27 | |
28 | - /** |
|
29 | - * @var XMLHelper_DOMErrors_Error[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var XMLHelper_DOMErrors_Error[] |
|
30 | + */ |
|
31 | 31 | private array $errors = array(); |
32 | 32 | |
33 | - /** |
|
34 | - * @param LibXMLError[]|XMLHelper_DOMErrors_Error[] $libxmlErrors |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @param LibXMLError[]|XMLHelper_DOMErrors_Error[] $libxmlErrors |
|
35 | + */ |
|
36 | 36 | public function __construct(array $libxmlErrors) |
37 | 37 | { |
38 | 38 | foreach($libxmlErrors as $error) |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | return $this->errors; |
62 | 62 | } |
63 | 63 | |
64 | - /** |
|
65 | - * Retrieves all warnings, if any. |
|
66 | - * |
|
67 | - * @return XMLHelper_DOMErrors_Error[] |
|
68 | - */ |
|
64 | + /** |
|
65 | + * Retrieves all warnings, if any. |
|
66 | + * |
|
67 | + * @return XMLHelper_DOMErrors_Error[] |
|
68 | + */ |
|
69 | 69 | public function getWarnings() : array |
70 | 70 | { |
71 | 71 | return $this->getByLevel(LIBXML_ERR_WARNING); |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * Retrieves all errors by the specified libxml error level. |
|
126 | - * |
|
127 | - * @param int $level |
|
128 | - * @return XMLHelper_DOMErrors_Error[] |
|
129 | - */ |
|
124 | + /** |
|
125 | + * Retrieves all errors by the specified libxml error level. |
|
126 | + * |
|
127 | + * @param int $level |
|
128 | + * @return XMLHelper_DOMErrors_Error[] |
|
129 | + */ |
|
130 | 130 | public function getByLevel(int $level) : array |
131 | 131 | { |
132 | 132 | $result = array(); |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | return $result; |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Retrieves all errors by the specified libxml error code. |
|
147 | - * |
|
148 | - * @param int $code |
|
149 | - * @return XMLHelper_DOMErrors_Error[] |
|
150 | - */ |
|
145 | + /** |
|
146 | + * Retrieves all errors by the specified libxml error code. |
|
147 | + * |
|
148 | + * @param int $code |
|
149 | + * @return XMLHelper_DOMErrors_Error[] |
|
150 | + */ |
|
151 | 151 | public function getByCode(int $code) : array |
152 | 152 | { |
153 | 153 | $result = array(); |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | return $result; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Checks whether there are errors matching the libxml error level. |
|
168 | - * |
|
169 | - * @param int $level |
|
170 | - * @return bool |
|
171 | - */ |
|
166 | + /** |
|
167 | + * Checks whether there are errors matching the libxml error level. |
|
168 | + * |
|
169 | + * @param int $level |
|
170 | + * @return bool |
|
171 | + */ |
|
172 | 172 | public function hasErrorsByLevel(int $level) : bool |
173 | 173 | { |
174 | 174 | foreach($this->errors as $error) |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | |
185 | - /** |
|
186 | - * Checks whether there are any errors matching the libxml error code. |
|
187 | - * |
|
188 | - * @param int $code |
|
189 | - * @return bool |
|
190 | - */ |
|
185 | + /** |
|
186 | + * Checks whether there are any errors matching the libxml error code. |
|
187 | + * |
|
188 | + * @param int $code |
|
189 | + * @return bool |
|
190 | + */ |
|
191 | 191 | public function hasErrorsByCode(int $code) : bool |
192 | 192 | { |
193 | 193 | foreach($this->errors as $error) |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | return $result; |
217 | 217 | } |
218 | 218 | |
219 | - /** |
|
220 | - * Serializes the error collection, so it can be stored and |
|
221 | - * restored as needed, using the `fromSerialized()` method. |
|
222 | - * |
|
223 | - * @return string |
|
224 | - * @see XMLHelper_DOMErrors::fromSerialized() |
|
225 | - */ |
|
219 | + /** |
|
220 | + * Serializes the error collection, so it can be stored and |
|
221 | + * restored as needed, using the `fromSerialized()` method. |
|
222 | + * |
|
223 | + * @return string |
|
224 | + * @see XMLHelper_DOMErrors::fromSerialized() |
|
225 | + */ |
|
226 | 226 | public function serialize() : string |
227 | 227 | { |
228 | 228 | $data = array(); |
@@ -27,9 +27,9 @@ |
||
27 | 27 | public const ERROR_CANNOT_UNSERIALIZE_ERROR_DATA = 57201; |
28 | 28 | public const ERROR_ERROR_DATA_KEY_MISSING = 57202; |
29 | 29 | |
30 | - /** |
|
31 | - * @var LibXMLError |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var LibXMLError |
|
32 | + */ |
|
33 | 33 | private LibXMLError $error; |
34 | 34 | |
35 | 35 | /** |
@@ -28,32 +28,32 @@ |
||
28 | 28 | |
29 | 29 | private ?SimpleXMLElement $element = null; |
30 | 30 | |
31 | - /** |
|
32 | - * @var XMLHelper_SimpleXML_Error[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var XMLHelper_SimpleXML_Error[] |
|
33 | + */ |
|
34 | 34 | private array $errors = array(); |
35 | 35 | |
36 | - /** |
|
37 | - * Creates a simplexml instance from an XML string. |
|
38 | - * |
|
39 | - * NOTE: returns false in case of a fatal error. |
|
40 | - * |
|
41 | - * @param string $string |
|
42 | - * @return SimpleXMLElement|NULL |
|
43 | - */ |
|
36 | + /** |
|
37 | + * Creates a simplexml instance from an XML string. |
|
38 | + * |
|
39 | + * NOTE: returns false in case of a fatal error. |
|
40 | + * |
|
41 | + * @param string $string |
|
42 | + * @return SimpleXMLElement|NULL |
|
43 | + */ |
|
44 | 44 | public function loadString(string $string) : ?SimpleXMLElement |
45 | 45 | { |
46 | 46 | return $this->load('string', $string); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Creates a simplexml instance from an XML file. |
|
51 | - * |
|
52 | - * NOTE: returns false in case of a fatal error. |
|
53 | - * |
|
54 | - * @param string $file |
|
55 | - * @return SimpleXMLElement|NULL |
|
56 | - */ |
|
49 | + /** |
|
50 | + * Creates a simplexml instance from an XML file. |
|
51 | + * |
|
52 | + * NOTE: returns false in case of a fatal error. |
|
53 | + * |
|
54 | + * @param string $file |
|
55 | + * @return SimpleXMLElement|NULL |
|
56 | + */ |
|
57 | 57 | public function loadFile(string $file) : ?SimpleXMLElement |
58 | 58 | { |
59 | 59 | return $this->load('file', $file); |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | { |
40 | 40 | public const ERROR_STRING_ALREADY_HAS_BODY_TAG = 57001; |
41 | 41 | |
42 | - /** |
|
43 | - * @var \DOMElement |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var \DOMElement |
|
44 | + */ |
|
45 | 45 | private $bodyNode; |
46 | 46 | |
47 | - /** |
|
48 | - * @var XMLHelper_DOMErrors |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var XMLHelper_DOMErrors |
|
49 | + */ |
|
50 | 50 | private $errors; |
51 | 51 | |
52 | - /** |
|
53 | - * @var string |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var string |
|
54 | + */ |
|
55 | 55 | private static $htmlTemplate = |
56 | 56 | '<!DOCTYPE html>'. |
57 | 57 | '<html>'. |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | '</body>'. |
64 | 64 | '</html>'; |
65 | 65 | |
66 | - /** |
|
67 | - * @var \DOMDocument |
|
68 | - */ |
|
66 | + /** |
|
67 | + * @var \DOMDocument |
|
68 | + */ |
|
69 | 69 | private $dom; |
70 | 70 | |
71 | 71 | private function __construct(string $html) |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | $this->load($html); |
74 | 74 | } |
75 | 75 | |
76 | - /** |
|
77 | - * Creates an HTML loader from an HTML fragment (without |
|
78 | - * doctype, head and body elements). |
|
79 | - * |
|
80 | - * @param string $fragment |
|
81 | - * @return XMLHelper_HTMLLoader |
|
82 | - */ |
|
76 | + /** |
|
77 | + * Creates an HTML loader from an HTML fragment (without |
|
78 | + * doctype, head and body elements). |
|
79 | + * |
|
80 | + * @param string $fragment |
|
81 | + * @return XMLHelper_HTMLLoader |
|
82 | + */ |
|
83 | 83 | public static function loadFragment(string $fragment) : XMLHelper_HTMLLoader |
84 | 84 | { |
85 | 85 | self::checkFragment($fragment); |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | return new XMLHelper_HTMLLoader($pseudoHTML); |
91 | 91 | } |
92 | 92 | |
93 | - /** |
|
94 | - * Creates an HTML loader from a full HTML document (including |
|
95 | - * doctype, head and body elements). |
|
96 | - * |
|
97 | - * @param string $html |
|
98 | - * @return XMLHelper_HTMLLoader |
|
99 | - */ |
|
93 | + /** |
|
94 | + * Creates an HTML loader from a full HTML document (including |
|
95 | + * doctype, head and body elements). |
|
96 | + * |
|
97 | + * @param string $html |
|
98 | + * @return XMLHelper_HTMLLoader |
|
99 | + */ |
|
100 | 100 | public static function loadHTML(string $html) : XMLHelper_HTMLLoader |
101 | 101 | { |
102 | 102 | return new XMLHelper_HTMLLoader($html); |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * Verifies that the fragment does not already contain a body element or doctype. |
|
107 | - * |
|
108 | - * @param string $fragment |
|
109 | - * @throws XMLHelper_Exception |
|
110 | - */ |
|
105 | + /** |
|
106 | + * Verifies that the fragment does not already contain a body element or doctype. |
|
107 | + * |
|
108 | + * @param string $fragment |
|
109 | + * @throws XMLHelper_Exception |
|
110 | + */ |
|
111 | 111 | private static function checkFragment(string $fragment) : void |
112 | 112 | { |
113 | 113 | if(!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
@@ -145,65 +145,65 @@ discard block |
||
145 | 145 | return $this->bodyNode; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * Retrieves the document's `<body>` tag node. |
|
150 | - * |
|
151 | - * @return \DOMDocument |
|
152 | - */ |
|
148 | + /** |
|
149 | + * Retrieves the document's `<body>` tag node. |
|
150 | + * |
|
151 | + * @return \DOMDocument |
|
152 | + */ |
|
153 | 153 | public function getDOM() : \DOMDocument |
154 | 154 | { |
155 | 155 | return $this->dom; |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * Retrieves all nodes from the HTML fragment (= child nodes |
|
160 | - * of the `<body>` element). |
|
161 | - * |
|
162 | - * @return DOMNodeList<DOMNode> |
|
163 | - */ |
|
158 | + /** |
|
159 | + * Retrieves all nodes from the HTML fragment (= child nodes |
|
160 | + * of the `<body>` element). |
|
161 | + * |
|
162 | + * @return DOMNodeList<DOMNode> |
|
163 | + */ |
|
164 | 164 | public function getFragmentNodes() : DOMNodeList |
165 | 165 | { |
166 | 166 | return $this->bodyNode->childNodes; |
167 | 167 | } |
168 | 168 | |
169 | - /** |
|
170 | - * Retrieves the LibXML HTML parsing errors collection, which |
|
171 | - * can be used to review any errors that occurred while loading |
|
172 | - * the HTML document. |
|
173 | - * |
|
174 | - * @return XMLHelper_DOMErrors |
|
175 | - */ |
|
169 | + /** |
|
170 | + * Retrieves the LibXML HTML parsing errors collection, which |
|
171 | + * can be used to review any errors that occurred while loading |
|
172 | + * the HTML document. |
|
173 | + * |
|
174 | + * @return XMLHelper_DOMErrors |
|
175 | + */ |
|
176 | 176 | public function getErrors() : XMLHelper_DOMErrors |
177 | 177 | { |
178 | 178 | return $this->errors; |
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Returns a valid HTML string. |
|
183 | - * |
|
184 | - * @return string |
|
185 | - */ |
|
181 | + /** |
|
182 | + * Returns a valid HTML string. |
|
183 | + * |
|
184 | + * @return string |
|
185 | + */ |
|
186 | 186 | public function toHTML() : string |
187 | 187 | { |
188 | 188 | return $this->dom->saveHTML(); |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Returns a valid XML string. |
|
193 | - * |
|
194 | - * @return string |
|
195 | - */ |
|
191 | + /** |
|
192 | + * Returns a valid XML string. |
|
193 | + * |
|
194 | + * @return string |
|
195 | + */ |
|
196 | 196 | public function toXML() : string |
197 | 197 | { |
198 | 198 | return $this->dom->saveXML(); |
199 | 199 | } |
200 | 200 | |
201 | - /** |
|
202 | - * Converts the HTML fragment to valid XML (= all |
|
203 | - * child nodes of the `<body>` element). |
|
204 | - * |
|
205 | - * @return string |
|
206 | - */ |
|
201 | + /** |
|
202 | + * Converts the HTML fragment to valid XML (= all |
|
203 | + * child nodes of the `<body>` element). |
|
204 | + * |
|
205 | + * @return string |
|
206 | + */ |
|
207 | 207 | public function fragmentToXML() : string |
208 | 208 | { |
209 | 209 | $nodes = $this->getFragmentNodes(); |
@@ -10,9 +10,9 @@ |
||
10 | 10 | { |
11 | 11 | protected XMLHelper_SimpleXML $xml; |
12 | 12 | |
13 | - /** |
|
14 | - * @var LibXMLError |
|
15 | - */ |
|
13 | + /** |
|
14 | + * @var LibXMLError |
|
15 | + */ |
|
16 | 16 | protected LibXMLError $nativeError; |
17 | 17 | |
18 | 18 | public function __construct(XMLHelper_SimpleXML $xml, LibXMLError $nativeError) |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | protected bool $isValid = false; |
43 | 43 | protected bool $encodeUTF = false; |
44 | 44 | |
45 | - /** |
|
46 | - * @var array{code:int,message:string}|NULL |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var array{code:int,message:string}|NULL |
|
47 | + */ |
|
48 | 48 | protected ?array $error = null; |
49 | 49 | |
50 | - /** |
|
51 | - * Stores a list of all unicode characters in the URL |
|
52 | - * that have been filtered out before parsing it with |
|
53 | - * parse_url. |
|
54 | - * |
|
55 | - * @var array<string,string> |
|
56 | - */ |
|
50 | + /** |
|
51 | + * Stores a list of all unicode characters in the URL |
|
52 | + * that have been filtered out before parsing it with |
|
53 | + * parse_url. |
|
54 | + * |
|
55 | + * @var array<string,string> |
|
56 | + */ |
|
57 | 57 | protected array $unicodeChars = array(); |
58 | 58 | |
59 | 59 | /** |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | ); |
79 | 79 | |
80 | 80 | /** |
81 | - * |
|
82 | - * @param string $url The target URL. |
|
83 | - * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
84 | - */ |
|
81 | + * |
|
82 | + * @param string $url The target URL. |
|
83 | + * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
84 | + */ |
|
85 | 85 | public function __construct(string $url, bool $encodeUTF) |
86 | 86 | { |
87 | 87 | $this->url = $url; |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | $this->validate(); |
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Retrieves the array as parsed by PHP's parse_url, |
|
97 | - * filtered and adjusted as necessary. |
|
98 | - * |
|
99 | - * @return array<string,mixed> |
|
100 | - */ |
|
95 | + /** |
|
96 | + * Retrieves the array as parsed by PHP's parse_url, |
|
97 | + * filtered and adjusted as necessary. |
|
98 | + * |
|
99 | + * @return array<string,mixed> |
|
100 | + */ |
|
101 | 101 | public function getInfo() : array |
102 | 102 | { |
103 | 103 | return $this->info; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - /** |
|
123 | - * Finds any non-url encoded unicode characters in |
|
124 | - * the URL, and encodes them before the URL is |
|
125 | - * passed to parse_url. |
|
126 | - */ |
|
122 | + /** |
|
123 | + * Finds any non-url encoded unicode characters in |
|
124 | + * the URL, and encodes them before the URL is |
|
125 | + * passed to parse_url. |
|
126 | + */ |
|
127 | 127 | protected function filterUnicodeChars() : void |
128 | 128 | { |
129 | 129 | $chars = ConvertHelper::string2array($this->url); |
@@ -194,23 +194,23 @@ discard block |
||
194 | 194 | $this->isValid = true; |
195 | 195 | } |
196 | 196 | |
197 | - /** |
|
198 | - * Goes through all information in the parse_url result |
|
199 | - * array, and attempts to fix any user errors in formatting |
|
200 | - * that can be recovered from, mostly regarding stray spaces. |
|
201 | - */ |
|
197 | + /** |
|
198 | + * Goes through all information in the parse_url result |
|
199 | + * array, and attempts to fix any user errors in formatting |
|
200 | + * that can be recovered from, mostly regarding stray spaces. |
|
201 | + */ |
|
202 | 202 | protected function filterParsed() : void |
203 | 203 | { |
204 | 204 | $this->info = (new ParsedInfoFilter($this->url, $this->info))->filter(); |
205 | 205 | } |
206 | 206 | |
207 | - /** |
|
208 | - * Recursively goes through the array, and converts all previously |
|
209 | - * URL encoded characters with their unicode character counterparts. |
|
210 | - * |
|
211 | - * @param array<string,mixed> $subject |
|
212 | - * @return array<string,mixed> |
|
213 | - */ |
|
207 | + /** |
|
208 | + * Recursively goes through the array, and converts all previously |
|
209 | + * URL encoded characters with their unicode character counterparts. |
|
210 | + * |
|
211 | + * @param array<string,mixed> $subject |
|
212 | + * @return array<string,mixed> |
|
213 | + */ |
|
214 | 214 | protected function restoreUnicodeChars(array $subject) : array |
215 | 215 | { |
216 | 216 | $result = array(); |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | return $result; |
235 | 235 | } |
236 | 236 | |
237 | - /** |
|
238 | - * Replaces all URL encoded unicode characters |
|
239 | - * in the string with the unicode character. |
|
240 | - * |
|
241 | - * @param string $string |
|
242 | - * @return string |
|
243 | - */ |
|
237 | + /** |
|
238 | + * Replaces all URL encoded unicode characters |
|
239 | + * in the string with the unicode character. |
|
240 | + * |
|
241 | + * @param string $string |
|
242 | + * @return string |
|
243 | + */ |
|
244 | 244 | protected function restoreUnicodeChar(string $string) : string |
245 | 245 | { |
246 | 246 | if(strpos($string, '%') !== false) |
@@ -261,32 +261,32 @@ discard block |
||
261 | 261 | ); |
262 | 262 | } |
263 | 263 | |
264 | - /** |
|
265 | - * Checks whether the URL that was parsed is valid. |
|
266 | - * @return bool |
|
267 | - */ |
|
264 | + /** |
|
265 | + * Checks whether the URL that was parsed is valid. |
|
266 | + * @return bool |
|
267 | + */ |
|
268 | 268 | public function isValid() : bool |
269 | 269 | { |
270 | 270 | return $this->isValid; |
271 | 271 | } |
272 | 272 | |
273 | - /** |
|
274 | - * If the validation failed, retrieves the validation |
|
275 | - * error message. |
|
276 | - * |
|
277 | - * @return string |
|
278 | - */ |
|
273 | + /** |
|
274 | + * If the validation failed, retrieves the validation |
|
275 | + * error message. |
|
276 | + * |
|
277 | + * @return string |
|
278 | + */ |
|
279 | 279 | public function getErrorMessage() : string |
280 | 280 | { |
281 | 281 | return $this->error['message'] ?? ''; |
282 | 282 | } |
283 | 283 | |
284 | - /** |
|
285 | - * If the validation failed, retrieves the validation |
|
286 | - * error code. |
|
287 | - * |
|
288 | - * @return int |
|
289 | - */ |
|
284 | + /** |
|
285 | + * If the validation failed, retrieves the validation |
|
286 | + * error code. |
|
287 | + * |
|
288 | + * @return int |
|
289 | + */ |
|
290 | 290 | public function getErrorCode() : int |
291 | 291 | { |
292 | 292 | return $this->error['code'] ?? -1; |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | { |
24 | 24 | use Traits_Optionable; |
25 | 25 | |
26 | - /** |
|
27 | - * @var array<string,mixed> |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var array<string,mixed> |
|
28 | + */ |
|
29 | 29 | private array $overrides = array(); |
30 | 30 | |
31 | - /** |
|
32 | - * @var Request_RefreshParams_Exclude[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var Request_RefreshParams_Exclude[] |
|
33 | + */ |
|
34 | 34 | private array $excludes = array(); |
35 | 35 | |
36 | 36 | public function getDefaultOptions() : array |
@@ -41,27 +41,27 @@ discard block |
||
41 | 41 | ); |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Whether to automatically exclude the session variable |
|
46 | - * from the parameters. |
|
47 | - * |
|
48 | - * @param bool $exclude |
|
49 | - * @return Request_RefreshParams |
|
50 | - */ |
|
44 | + /** |
|
45 | + * Whether to automatically exclude the session variable |
|
46 | + * from the parameters. |
|
47 | + * |
|
48 | + * @param bool $exclude |
|
49 | + * @return Request_RefreshParams |
|
50 | + */ |
|
51 | 51 | public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams |
52 | 52 | { |
53 | 53 | $this->setOption('exclude-session-name', $exclude); |
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * Whether to automatically exclude the HTML_QuickForm2 |
|
59 | - * request variable used to track whether a form has been |
|
60 | - * submitted. |
|
61 | - * |
|
62 | - * @param bool $exclude |
|
63 | - * @return Request_RefreshParams |
|
64 | - */ |
|
57 | + /** |
|
58 | + * Whether to automatically exclude the HTML_QuickForm2 |
|
59 | + * request variable used to track whether a form has been |
|
60 | + * submitted. |
|
61 | + * |
|
62 | + * @param bool $exclude |
|
63 | + * @return Request_RefreshParams |
|
64 | + */ |
|
65 | 65 | public function setExcludeQuickform(bool $exclude) : Request_RefreshParams |
66 | 66 | { |
67 | 67 | $this->setOption('exclude-quickform-submitter', $exclude); |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Excludes a request parameter by name. |
|
104 | - * |
|
105 | - * @param array<int,string|number> $paramNames |
|
106 | - * @return Request_RefreshParams |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Excludes a request parameter by name. |
|
104 | + * |
|
105 | + * @param array<int,string|number> $paramNames |
|
106 | + * @return Request_RefreshParams |
|
107 | + */ |
|
108 | 108 | public function excludeParamsByName(array $paramNames) : Request_RefreshParams |
109 | 109 | { |
110 | 110 | foreach($paramNames as $name) |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | return $this; |
116 | 116 | } |
117 | 117 | |
118 | - /** |
|
119 | - * Overrides a parameter: even if it exists, this |
|
120 | - * value will be used instead - even if it is on |
|
121 | - * the list of excluded parameters. |
|
122 | - * |
|
123 | - * @param string $paramName |
|
124 | - * @param mixed $paramValue |
|
125 | - * @return Request_RefreshParams |
|
126 | - */ |
|
118 | + /** |
|
119 | + * Overrides a parameter: even if it exists, this |
|
120 | + * value will be used instead - even if it is on |
|
121 | + * the list of excluded parameters. |
|
122 | + * |
|
123 | + * @param string $paramName |
|
124 | + * @param mixed $paramValue |
|
125 | + * @return Request_RefreshParams |
|
126 | + */ |
|
127 | 127 | public function overrideParam(string $paramName, $paramValue) : Request_RefreshParams |
128 | 128 | { |
129 | 129 | $this->overrides[$paramName] = $paramValue; |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | return $this; |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Overrides an array of parameters. |
|
136 | - * |
|
137 | - * @param array<string|number,mixed> $params |
|
138 | - * @return Request_RefreshParams |
|
139 | - */ |
|
134 | + /** |
|
135 | + * Overrides an array of parameters. |
|
136 | + * |
|
137 | + * @param array<string|number,mixed> $params |
|
138 | + * @return Request_RefreshParams |
|
139 | + */ |
|
140 | 140 | public function overrideParams(array $params) : Request_RefreshParams |
141 | 141 | { |
142 | 142 | foreach($params as $name => $value) |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | return $this; |
148 | 148 | } |
149 | 149 | |
150 | - /** |
|
151 | - * Resolves all the parameter exclusions that should |
|
152 | - * be applied to the list of parameters. This includes |
|
153 | - * the manually added exclusions and the dynamic exclusions |
|
154 | - * like the session name. |
|
155 | - * |
|
156 | - * @return Request_RefreshParams_Exclude[] |
|
157 | - */ |
|
150 | + /** |
|
151 | + * Resolves all the parameter exclusions that should |
|
152 | + * be applied to the list of parameters. This includes |
|
153 | + * the manually added exclusions and the dynamic exclusions |
|
154 | + * like the session name. |
|
155 | + * |
|
156 | + * @return Request_RefreshParams_Exclude[] |
|
157 | + */ |
|
158 | 158 | private function resolveExcludes() : array |
159 | 159 | { |
160 | 160 | $excludes = $this->excludes; |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | return $excludes; |
166 | 166 | } |
167 | 167 | |
168 | - /** |
|
169 | - * Automatically excludes the session name from the |
|
170 | - * parameters, if present. |
|
171 | - * |
|
172 | - * @param Request_RefreshParams_Exclude[] $excludes |
|
173 | - */ |
|
168 | + /** |
|
169 | + * Automatically excludes the session name from the |
|
170 | + * parameters, if present. |
|
171 | + * |
|
172 | + * @param Request_RefreshParams_Exclude[] $excludes |
|
173 | + */ |
|
174 | 174 | private function autoExcludeSessionName(array &$excludes) : void |
175 | 175 | { |
176 | 176 | if($this->getBoolOption('exclude-session-name')) |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Automatically excludes the HTML_QuickForm2 submit |
|
184 | - * tracking variable, when enabled. |
|
185 | - * |
|
186 | - * @param Request_RefreshParams_Exclude[] $excludes |
|
187 | - */ |
|
182 | + /** |
|
183 | + * Automatically excludes the HTML_QuickForm2 submit |
|
184 | + * tracking variable, when enabled. |
|
185 | + * |
|
186 | + * @param Request_RefreshParams_Exclude[] $excludes |
|
187 | + */ |
|
188 | 188 | private function autoExcludeQuickform(array &$excludes) : void |
189 | 189 | { |
190 | 190 | if($this->getBoolOption('exclude-quickform-submitter')) |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - /** |
|
200 | - * Retrieves the list of parameters matching the |
|
201 | - * current settings. |
|
202 | - * |
|
203 | - * @return array<string,mixed> |
|
204 | - */ |
|
199 | + /** |
|
200 | + * Retrieves the list of parameters matching the |
|
201 | + * current settings. |
|
202 | + * |
|
203 | + * @return array<string,mixed> |
|
204 | + */ |
|
205 | 205 | public function getParams() : array |
206 | 206 | { |
207 | 207 | $params = $this->removeExcluded($_REQUEST); |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | return $params; |
218 | 218 | } |
219 | 219 | |
220 | - /** |
|
221 | - * Removes all excluded parameters from the array. |
|
222 | - * |
|
223 | - * @param array<string,mixed> $params |
|
224 | - * @return array<string,mixed> |
|
225 | - */ |
|
220 | + /** |
|
221 | + * Removes all excluded parameters from the array. |
|
222 | + * |
|
223 | + * @param array<string,mixed> $params |
|
224 | + * @return array<string,mixed> |
|
225 | + */ |
|
226 | 226 | private function removeExcluded(array $params) : array |
227 | 227 | { |
228 | 228 | $result = array(); |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | return $result; |
241 | 241 | } |
242 | 242 | |
243 | - /** |
|
244 | - * Checks all configured exclusions to see if the |
|
245 | - * parameter should be excluded or not. |
|
246 | - * |
|
247 | - * @param string $paramName |
|
248 | - * @param mixed $paramValue |
|
249 | - * @return bool |
|
250 | - */ |
|
243 | + /** |
|
244 | + * Checks all configured exclusions to see if the |
|
245 | + * parameter should be excluded or not. |
|
246 | + * |
|
247 | + * @param string $paramName |
|
248 | + * @param mixed $paramValue |
|
249 | + * @return bool |
|
250 | + */ |
|
251 | 251 | public function isExcluded(string $paramName, $paramValue) : bool |
252 | 252 | { |
253 | 253 | $excludes = $this->resolveExcludes(); |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | class Request_RefreshParams_Exclude_Callback extends Request_RefreshParams_Exclude |
22 | 22 | { |
23 | - /** |
|
24 | - * @var callable |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var callable |
|
25 | + */ |
|
26 | 26 | private $callback; |
27 | 27 | |
28 | 28 | public function __construct(callable $callback) |