@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | public const BASE_10 = 1000; |
31 | 31 | public const BASE_2 = 1024; |
32 | 32 | |
33 | - /** |
|
34 | - * @var array<string,ConvertHelper_StorageSizeEnum_Size> |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var array<string,ConvertHelper_StorageSizeEnum_Size> |
|
35 | + */ |
|
36 | 36 | protected static $sizes = array(); |
37 | 37 | |
38 | - /** |
|
39 | - * Initializes the supported unit notations, and |
|
40 | - * how they are supposed to be calculated. |
|
41 | - * |
|
42 | - * @see ConvertHelper_SizeNotation::parseSize() |
|
43 | - */ |
|
38 | + /** |
|
39 | + * Initializes the supported unit notations, and |
|
40 | + * how they are supposed to be calculated. |
|
41 | + * |
|
42 | + * @see ConvertHelper_SizeNotation::parseSize() |
|
43 | + */ |
|
44 | 44 | protected static function init() : void |
45 | 45 | { |
46 | 46 | if(!empty(self::$sizes)) { |
@@ -67,28 +67,28 @@ discard block |
||
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - /** |
|
71 | - * Called whenever the application locale is changed, |
|
72 | - * to reset the size definitions so the labels get |
|
73 | - * translated to the new locale. |
|
74 | - */ |
|
70 | + /** |
|
71 | + * Called whenever the application locale is changed, |
|
72 | + * to reset the size definitions so the labels get |
|
73 | + * translated to the new locale. |
|
74 | + */ |
|
75 | 75 | public static function handle_localeChanged() : void |
76 | 76 | { |
77 | 77 | self::$sizes = array(); |
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * Adds a storage size to the internal collection. |
|
82 | - * |
|
83 | - * @param string $name The lowercase size name, e.g. "kb", "mib" |
|
84 | - * @param int $base This defines how many bytes there are in a kilobyte, to differentiate with the two common way to calculate sizes: base 10 or base 2. See the Wikipedia link for more details. |
|
85 | - * @param int $exponent The multiplier of the base to get the byte value |
|
86 | - * @param string $suffix The localized short suffix, e.g. "KB", "MiB" |
|
87 | - * @param string $singular The localized singular label of the size, e.g. "Kilobyte". |
|
88 | - * @param string $plural The localized plural label of the size, e.g. "Kilobytes". |
|
89 | - * |
|
90 | - * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
91 | - */ |
|
80 | + /** |
|
81 | + * Adds a storage size to the internal collection. |
|
82 | + * |
|
83 | + * @param string $name The lowercase size name, e.g. "kb", "mib" |
|
84 | + * @param int $base This defines how many bytes there are in a kilobyte, to differentiate with the two common way to calculate sizes: base 10 or base 2. See the Wikipedia link for more details. |
|
85 | + * @param int $exponent The multiplier of the base to get the byte value |
|
86 | + * @param string $suffix The localized short suffix, e.g. "KB", "MiB" |
|
87 | + * @param string $singular The localized singular label of the size, e.g. "Kilobyte". |
|
88 | + * @param string $plural The localized plural label of the size, e.g. "Kilobytes". |
|
89 | + * |
|
90 | + * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
91 | + */ |
|
92 | 92 | protected static function addSize(string $name, int $base, int $exponent, string $suffix, string $singular, string $plural) : void |
93 | 93 | { |
94 | 94 | self::$sizes[$name] = new ConvertHelper_StorageSizeEnum_Size( |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
104 | - /** |
|
105 | - * Retrieves all known sizes. |
|
106 | - * |
|
107 | - * @return ConvertHelper_StorageSizeEnum_Size[] |
|
108 | - */ |
|
104 | + /** |
|
105 | + * Retrieves all known sizes. |
|
106 | + * |
|
107 | + * @return ConvertHelper_StorageSizeEnum_Size[] |
|
108 | + */ |
|
109 | 109 | public static function getSizes() : array |
110 | 110 | { |
111 | 111 | self::init(); |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | return array_values(self::$sizes); |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Retrieves a size definition instance by its name. |
|
118 | - * |
|
119 | - * @param string $name Case-insensitive. For example "kb", "MiB"... |
|
120 | - * @throws ConvertHelper_Exception |
|
121 | - * @return ConvertHelper_StorageSizeEnum_Size |
|
122 | - * |
|
123 | - * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME |
|
124 | - */ |
|
116 | + /** |
|
117 | + * Retrieves a size definition instance by its name. |
|
118 | + * |
|
119 | + * @param string $name Case-insensitive. For example "kb", "MiB"... |
|
120 | + * @throws ConvertHelper_Exception |
|
121 | + * @return ConvertHelper_StorageSizeEnum_Size |
|
122 | + * |
|
123 | + * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME |
|
124 | + */ |
|
125 | 125 | public static function getSizeByName(string $name) : ConvertHelper_StorageSizeEnum_Size |
126 | 126 | { |
127 | 127 | self::init(); |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | - /** |
|
147 | - * Retrieves a list of all size names, e.g. "mb", "kib" (lowercase). |
|
148 | - * @return string[] |
|
149 | - */ |
|
146 | + /** |
|
147 | + * Retrieves a list of all size names, e.g. "mb", "kib" (lowercase). |
|
148 | + * @return string[] |
|
149 | + */ |
|
150 | 150 | public static function getSizeNames() : array |
151 | 151 | { |
152 | 152 | self::init(); |
@@ -154,16 +154,16 @@ discard block |
||
154 | 154 | return array_keys(self::$sizes); |
155 | 155 | } |
156 | 156 | |
157 | - /** |
|
158 | - * Retrieves all available storage sizes for the specified |
|
159 | - * base value. |
|
160 | - * |
|
161 | - * @param int $base |
|
162 | - * @return ConvertHelper_StorageSizeEnum_Size[] |
|
163 | - * |
|
164 | - * @see ConvertHelper_StorageSizeEnum::BASE_10 |
|
165 | - * @see ConvertHelper_StorageSizeEnum::BASE_2 |
|
166 | - */ |
|
157 | + /** |
|
158 | + * Retrieves all available storage sizes for the specified |
|
159 | + * base value. |
|
160 | + * |
|
161 | + * @param int $base |
|
162 | + * @return ConvertHelper_StorageSizeEnum_Size[] |
|
163 | + * |
|
164 | + * @see ConvertHelper_StorageSizeEnum::BASE_10 |
|
165 | + * @see ConvertHelper_StorageSizeEnum::BASE_2 |
|
166 | + */ |
|
167 | 167 | public static function getSizesByBase(int $base) : array |
168 | 168 | { |
169 | 169 | self::init(); |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | public const ERROR_MALFORMATTED_STRING = 53801; |
24 | 24 | |
25 | - /** |
|
26 | - * @var string[] |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var string[] |
|
27 | + */ |
|
28 | 28 | protected static $controlChars = array( |
29 | 29 | '0000-0008', // control chars |
30 | 30 | '000E-000F', // control chars |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | '2000-200F', // non-breaking space and co |
33 | 33 | ); |
34 | 34 | |
35 | - /** |
|
36 | - * @var string|NULL |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var string|NULL |
|
37 | + */ |
|
38 | 38 | protected static $controlCharsRegex; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string[] |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string[] |
|
42 | + */ |
|
43 | 43 | protected static $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
44 | 44 | |
45 | - /** |
|
46 | - * @var string[]|NULL |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string[]|NULL |
|
47 | + */ |
|
48 | 48 | protected static $charsAsHex; |
49 | 49 | |
50 | 50 | public function __construct() |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - /** |
|
71 | - * Retrieves the HEX character codes for all control |
|
72 | - * characters that the {@link stripControlCharacters()} |
|
73 | - * method will remove. |
|
74 | - * |
|
75 | - * @return string[] |
|
76 | - */ |
|
70 | + /** |
|
71 | + * Retrieves the HEX character codes for all control |
|
72 | + * characters that the {@link stripControlCharacters()} |
|
73 | + * method will remove. |
|
74 | + * |
|
75 | + * @return string[] |
|
76 | + */ |
|
77 | 77 | public function getCharsAsHex() : array |
78 | 78 | { |
79 | 79 | if (isset(self::$charsAsHex)) |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | return $stack; |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Retrieves an array of all control characters that |
|
125 | - * the {@link stripControlCharacters()} method will |
|
126 | - * remove, as the actual UTF-8 characters. |
|
127 | - * |
|
128 | - * @return string[] |
|
129 | - */ |
|
123 | + /** |
|
124 | + * Retrieves an array of all control characters that |
|
125 | + * the {@link stripControlCharacters()} method will |
|
126 | + * remove, as the actual UTF-8 characters. |
|
127 | + * |
|
128 | + * @return string[] |
|
129 | + */ |
|
130 | 130 | public function getCharsAsUTF8() : array |
131 | 131 | { |
132 | 132 | $chars = $this->getCharsAsHex(); |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | return $result; |
140 | 140 | } |
141 | 141 | |
142 | - /** |
|
143 | - * Retrieves all control characters as JSON encoded |
|
144 | - * characters, e.g. "\u200b". |
|
145 | - * |
|
146 | - * @return string[] |
|
147 | - */ |
|
142 | + /** |
|
143 | + * Retrieves all control characters as JSON encoded |
|
144 | + * characters, e.g. "\u200b". |
|
145 | + * |
|
146 | + * @return string[] |
|
147 | + */ |
|
148 | 148 | public function getCharsAsJSON() : array |
149 | 149 | { |
150 | 150 | $chars = $this->getCharsAsHex(); |
@@ -157,17 +157,17 @@ discard block |
||
157 | 157 | return $result; |
158 | 158 | } |
159 | 159 | |
160 | - /** |
|
161 | - * Removes all control characters from the specified string |
|
162 | - * that can cause problems in some cases, like creating |
|
163 | - * valid XML documents. This includes invisible non-breaking |
|
164 | - * spaces. |
|
165 | - * |
|
166 | - * @param string $string |
|
167 | - * @return string |
|
168 | - * @see https://stackoverflow.com/a/8171868/2298192 |
|
169 | - * @see https://unicode-table.com/en |
|
170 | - */ |
|
160 | + /** |
|
161 | + * Removes all control characters from the specified string |
|
162 | + * that can cause problems in some cases, like creating |
|
163 | + * valid XML documents. This includes invisible non-breaking |
|
164 | + * spaces. |
|
165 | + * |
|
166 | + * @param string $string |
|
167 | + * @return string |
|
168 | + * @see https://stackoverflow.com/a/8171868/2298192 |
|
169 | + * @see https://unicode-table.com/en |
|
170 | + */ |
|
171 | 171 | public function stripControlCharacters(string $string) : string |
172 | 172 | { |
173 | 173 | if(empty($string)) |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | |
43 | 43 | public const REGEX_MD5 = '/^[a-f0-9]{32}$/i'; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string |
|
47 | - * @see https://en.wikipedia.org/wiki/Email_address#Local-part |
|
48 | - */ |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + * @see https://en.wikipedia.org/wiki/Email_address#Local-part |
|
48 | + */ |
|
49 | 49 | public const REGEX_EMAIL = '/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i'; |
50 | 50 | |
51 | 51 | public const REGEX_PHONE = '/\A[+0-9][0-9 +\-()]+\z/m'; |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public const REGEX_IS_HTML = '%<{0,1}[a-z\/][\s\S]*>|<[a-z\/][\s\S]*>{0,1}%i'; |
99 | 99 | |
100 | - /** |
|
101 | - * Hexadecimal color codes. Allows the following formats: |
|
102 | - * |
|
103 | - * FFFFFF |
|
104 | - * FFF |
|
105 | - * |
|
106 | - * @var string |
|
107 | - */ |
|
100 | + /** |
|
101 | + * Hexadecimal color codes. Allows the following formats: |
|
102 | + * |
|
103 | + * FFFFFF |
|
104 | + * FFF |
|
105 | + * |
|
106 | + * @var string |
|
107 | + */ |
|
108 | 108 | public const REGEX_HEX_COLOR_CODE = '/\A(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\z/iU'; |
109 | 109 | |
110 | 110 | /** |
@@ -22,44 +22,44 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class FileHelper_PHPClassInfo_Class |
24 | 24 | { |
25 | - /** |
|
26 | - * @var FileHelper_PHPClassInfo |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var FileHelper_PHPClassInfo |
|
27 | + */ |
|
28 | 28 | protected $info; |
29 | 29 | |
30 | - /** |
|
31 | - * @var bool |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var bool |
|
32 | + */ |
|
33 | 33 | protected $abstract = false; |
34 | 34 | |
35 | - /** |
|
36 | - * @var bool |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | 38 | protected $final = false; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $extends = ''; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string[] |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string[] |
|
47 | + */ |
|
48 | 48 | protected $implements = array(); |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $name; |
54 | 54 | |
55 | - /** |
|
56 | - * @var string |
|
57 | - */ |
|
55 | + /** |
|
56 | + * @var string |
|
57 | + */ |
|
58 | 58 | protected $declaration; |
59 | 59 | |
60 | - /** |
|
61 | - * @var string |
|
62 | - */ |
|
60 | + /** |
|
61 | + * @var string |
|
62 | + */ |
|
63 | 63 | protected $keyword; |
64 | 64 | |
65 | 65 | /** |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | private $type; |
69 | 69 | |
70 | 70 | /** |
71 | - * @param FileHelper_PHPClassInfo $info The class info instance. |
|
72 | - * @param string $declaration The full class declaration, e.g. "class SomeName extends SomeOtherClass". |
|
73 | - * @param string $keyword The class keyword, if any, i.e. "abstract" or "final". |
|
74 | - */ |
|
71 | + * @param FileHelper_PHPClassInfo $info The class info instance. |
|
72 | + * @param string $declaration The full class declaration, e.g. "class SomeName extends SomeOtherClass". |
|
73 | + * @param string $keyword The class keyword, if any, i.e. "abstract" or "final". |
|
74 | + */ |
|
75 | 75 | public function __construct(FileHelper_PHPClassInfo $info, string $declaration, string $keyword, string $type) |
76 | 76 | { |
77 | 77 | $this->info = $info; |
@@ -82,31 +82,31 @@ discard block |
||
82 | 82 | $this->analyzeCode(); |
83 | 83 | } |
84 | 84 | |
85 | - /** |
|
86 | - * Check if this class is a subclass of the specified |
|
87 | - * class name. |
|
88 | - * |
|
89 | - * @param string $className |
|
90 | - * @return bool |
|
91 | - */ |
|
85 | + /** |
|
86 | + * Check if this class is a subclass of the specified |
|
87 | + * class name. |
|
88 | + * |
|
89 | + * @param string $className |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | 92 | public function isSublassOf(string $className) : bool |
93 | 93 | { |
94 | 94 | return is_subclass_of($this->getNameNS(), $className); |
95 | 95 | } |
96 | 96 | |
97 | - /** |
|
98 | - * The class name without namespace. |
|
99 | - * @return string |
|
100 | - */ |
|
97 | + /** |
|
98 | + * The class name without namespace. |
|
99 | + * @return string |
|
100 | + */ |
|
101 | 101 | public function getName() : string |
102 | 102 | { |
103 | 103 | return $this->name; |
104 | 104 | } |
105 | 105 | |
106 | - /** |
|
107 | - * The absolute class name with namespace (if any). |
|
108 | - * @return string |
|
109 | - */ |
|
106 | + /** |
|
107 | + * The absolute class name with namespace (if any). |
|
108 | + * @return string |
|
109 | + */ |
|
110 | 110 | public function getNameNS() : string |
111 | 111 | { |
112 | 112 | $name = $this->getName(); |
@@ -118,48 +118,48 @@ discard block |
||
118 | 118 | return $name; |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Whether it is an abstract class. |
|
123 | - * @return bool |
|
124 | - */ |
|
121 | + /** |
|
122 | + * Whether it is an abstract class. |
|
123 | + * @return bool |
|
124 | + */ |
|
125 | 125 | public function isAbstract() : bool |
126 | 126 | { |
127 | 127 | return $this->abstract; |
128 | 128 | } |
129 | 129 | |
130 | - /** |
|
131 | - * Whether it is a final class. |
|
132 | - * @return bool |
|
133 | - */ |
|
130 | + /** |
|
131 | + * Whether it is a final class. |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | 134 | public function isFinal() : bool |
135 | 135 | { |
136 | 136 | return $this->final; |
137 | 137 | } |
138 | 138 | |
139 | - /** |
|
140 | - * The name of the class that this class extends (with namespace, if specified). |
|
141 | - * @return string |
|
142 | - */ |
|
139 | + /** |
|
140 | + * The name of the class that this class extends (with namespace, if specified). |
|
141 | + * @return string |
|
142 | + */ |
|
143 | 143 | public function getExtends() : string |
144 | 144 | { |
145 | 145 | return $this->extends; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * A list of interfaces the class implements, if any. |
|
150 | - * @return string[] |
|
151 | - */ |
|
148 | + /** |
|
149 | + * A list of interfaces the class implements, if any. |
|
150 | + * @return string[] |
|
151 | + */ |
|
152 | 152 | public function getImplements() : array |
153 | 153 | { |
154 | 154 | return $this->implements; |
155 | 155 | } |
156 | 156 | |
157 | - /** |
|
158 | - * The class declaration string, with normalized spaces and sorted interface names. |
|
159 | - * NOTE: does not include the keyword "abstract" or "final". |
|
160 | - * |
|
161 | - * @return string |
|
162 | - */ |
|
157 | + /** |
|
158 | + * The class declaration string, with normalized spaces and sorted interface names. |
|
159 | + * NOTE: does not include the keyword "abstract" or "final". |
|
160 | + * |
|
161 | + * @return string |
|
162 | + */ |
|
163 | 163 | public function getDeclaration() : string |
164 | 164 | { |
165 | 165 | $parts = array(); |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | return implode(' ', $parts); |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * The keyword before "class", e.g. "abstract". |
|
184 | - * @return string |
|
185 | - */ |
|
182 | + /** |
|
183 | + * The keyword before "class", e.g. "abstract". |
|
184 | + * @return string |
|
185 | + */ |
|
186 | 186 | public function getKeyword() : string |
187 | 187 | { |
188 | 188 | return $this->keyword; |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | public const SVN_ERROR_TYPE_WARNING = 'warning'; |
22 | 22 | |
23 | 23 | /** |
24 | - * @var SVNHelper |
|
25 | - */ |
|
24 | + * @var SVNHelper |
|
25 | + */ |
|
26 | 26 | protected $helper; |
27 | 27 | |
28 | - /** |
|
29 | - * @var SVNHelper_Target |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var SVNHelper_Target |
|
30 | + */ |
|
31 | 31 | protected $target; |
32 | 32 | |
33 | - /** |
|
34 | - * @var SVNHelper_CommandResult|NULL |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var SVNHelper_CommandResult|NULL |
|
35 | + */ |
|
36 | 36 | protected ?SVNHelper_CommandResult $result; |
37 | 37 | |
38 | 38 | public function __construct(SVNHelper $helper, SVNHelper_Target $target) |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | $this->target = $target; |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * @return SVNHelper |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @return SVNHelper |
|
46 | + */ |
|
47 | 47 | public function getSVN() |
48 | 48 | { |
49 | 49 | return $this->helper; |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | return $cmd; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Executes the specified command, and returns a result |
|
105 | - * instance to read the results. |
|
106 | - * |
|
107 | - * @param string $mode The command mode, e.g. commit / update... |
|
108 | - * @param string $path The path to apply the command to |
|
109 | - * @param array $params |
|
110 | - * @return SVNHelper_CommandResult |
|
111 | - */ |
|
103 | + /** |
|
104 | + * Executes the specified command, and returns a result |
|
105 | + * instance to read the results. |
|
106 | + * |
|
107 | + * @param string $mode The command mode, e.g. commit / update... |
|
108 | + * @param string $path The path to apply the command to |
|
109 | + * @param array $params |
|
110 | + * @return SVNHelper_CommandResult |
|
111 | + */ |
|
112 | 112 | protected function execCommand($mode, $path=null, $params=array()) |
113 | 113 | { |
114 | 114 | $relative = $this->helper->relativizePath($path); |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | return $this->result; |
196 | 196 | } |
197 | 197 | |
198 | - /** |
|
199 | - * Retrieves the type of command, e.g. "Commit" |
|
200 | - * @return string |
|
201 | - */ |
|
198 | + /** |
|
199 | + * Retrieves the type of command, e.g. "Commit" |
|
200 | + * @return string |
|
201 | + */ |
|
202 | 202 | public function getType() |
203 | 203 | { |
204 | 204 | return str_replace('SVNHelper_Command_', '', get_class($this)); |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | { |
38 | 38 | public const ERROR_CALLABLE_THREW_ERROR = 99601; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $separator = ' '; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string[] |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string[] |
|
47 | + */ |
|
48 | 48 | protected $strings = array(); |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $noSeparator = '§!§'; |
54 | 54 | |
55 | 55 | public function __construct() |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | return $this; |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Adds a subject as a string. Is ignored if empty. |
|
68 | - * |
|
69 | - * @param string|number|Interface_Stringable|NULL $string |
|
70 | - * @return $this |
|
71 | - */ |
|
66 | + /** |
|
67 | + * Adds a subject as a string. Is ignored if empty. |
|
68 | + * |
|
69 | + * @param string|number|Interface_Stringable|NULL $string |
|
70 | + * @return $this |
|
71 | + */ |
|
72 | 72 | public function add($string) : StringBuilder |
73 | 73 | { |
74 | 74 | $string = (string)$string; |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | return $this; |
82 | 82 | } |
83 | 83 | |
84 | - /** |
|
85 | - * Adds a string without appending an automatic space. |
|
86 | - * |
|
87 | - * @param string|number|Interface_Stringable|NULL $string |
|
88 | - * @return $this |
|
89 | - */ |
|
84 | + /** |
|
85 | + * Adds a string without appending an automatic space. |
|
86 | + * |
|
87 | + * @param string|number|Interface_Stringable|NULL $string |
|
88 | + * @return $this |
|
89 | + */ |
|
90 | 90 | public function nospace($string) : StringBuilder |
91 | 91 | { |
92 | 92 | $flattened = (string)$string; |
@@ -99,46 +99,46 @@ discard block |
||
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Adds raw HTML code. Does not add an automatic space. |
|
104 | - * |
|
105 | - * @param string|number|Interface_Stringable $html |
|
106 | - * @return $this |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Adds raw HTML code. Does not add an automatic space. |
|
104 | + * |
|
105 | + * @param string|number|Interface_Stringable $html |
|
106 | + * @return $this |
|
107 | + */ |
|
108 | 108 | public function html($html) : StringBuilder |
109 | 109 | { |
110 | 110 | return $this->nospace($html); |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Adds an unordered list with the specified items. |
|
115 | - * |
|
116 | - * @param array<int,string|number|Interface_Stringable> $items |
|
117 | - * @return $this |
|
118 | - */ |
|
113 | + /** |
|
114 | + * Adds an unordered list with the specified items. |
|
115 | + * |
|
116 | + * @param array<int,string|number|Interface_Stringable> $items |
|
117 | + * @return $this |
|
118 | + */ |
|
119 | 119 | public function ul(array $items) : StringBuilder |
120 | 120 | { |
121 | 121 | return $this->list('ul', $items); |
122 | 122 | } |
123 | 123 | |
124 | - /** |
|
125 | - * Adds an ordered list with the specified items. |
|
126 | - * |
|
127 | - * @param array<int,string|number|Interface_Stringable> $items |
|
128 | - * @return $this |
|
129 | - */ |
|
124 | + /** |
|
125 | + * Adds an ordered list with the specified items. |
|
126 | + * |
|
127 | + * @param array<int,string|number|Interface_Stringable> $items |
|
128 | + * @return $this |
|
129 | + */ |
|
130 | 130 | public function ol(array $items) : StringBuilder |
131 | 131 | { |
132 | 132 | return $this->list('ol', $items); |
133 | 133 | } |
134 | 134 | |
135 | - /** |
|
136 | - * Creates a list tag with the items list. |
|
137 | - * |
|
138 | - * @param string $type The list type, `ol` or `ul`. |
|
139 | - * @param array<int,string|number|Interface_Stringable> $items |
|
140 | - * @return $this |
|
141 | - */ |
|
135 | + /** |
|
136 | + * Creates a list tag with the items list. |
|
137 | + * |
|
138 | + * @param string $type The list type, `ol` or `ul`. |
|
139 | + * @param array<int,string|number|Interface_Stringable> $items |
|
140 | + * @return $this |
|
141 | + */ |
|
142 | 142 | protected function list(string $type, array $items) : StringBuilder |
143 | 143 | { |
144 | 144 | return $this->html(sprintf( |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | )); |
149 | 149 | } |
150 | 150 | |
151 | - /** |
|
152 | - * Add a translated string. |
|
153 | - * |
|
154 | - * @param string $format The native string to translate. |
|
155 | - * @param array<int,mixed> $arguments The variables to inject into the translated string, if any. |
|
156 | - * @return $this |
|
157 | - */ |
|
151 | + /** |
|
152 | + * Add a translated string. |
|
153 | + * |
|
154 | + * @param string $format The native string to translate. |
|
155 | + * @param array<int,mixed> $arguments The variables to inject into the translated string, if any. |
|
156 | + * @return $this |
|
157 | + */ |
|
158 | 158 | public function t(string $format, ...$arguments) : StringBuilder |
159 | 159 | { |
160 | 160 | if(!class_exists('\AppLocalize\Localization')) |
@@ -207,36 +207,36 @@ discard block |
||
207 | 207 | return $this->add(ConvertHelper::duration2string($since)); |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Adds HTML double quotes around the string. |
|
212 | - * |
|
213 | - * @param string|number|Interface_Stringable $string |
|
214 | - * @return $this |
|
215 | - */ |
|
210 | + /** |
|
211 | + * Adds HTML double quotes around the string. |
|
212 | + * |
|
213 | + * @param string|number|Interface_Stringable $string |
|
214 | + * @return $this |
|
215 | + */ |
|
216 | 216 | public function quote($string) : StringBuilder |
217 | 217 | { |
218 | 218 | return $this->sf('"%s"', (string)$string); |
219 | 219 | } |
220 | 220 | |
221 | - /** |
|
222 | - * Adds a text that is meant as a reference to a UI element, |
|
223 | - * like a menu item, button, etc. |
|
224 | - * |
|
225 | - * @param string|number|Interface_Stringable $string |
|
226 | - * @return $this |
|
227 | - */ |
|
221 | + /** |
|
222 | + * Adds a text that is meant as a reference to a UI element, |
|
223 | + * like a menu item, button, etc. |
|
224 | + * |
|
225 | + * @param string|number|Interface_Stringable $string |
|
226 | + * @return $this |
|
227 | + */ |
|
228 | 228 | public function reference($string) : StringBuilder |
229 | 229 | { |
230 | 230 | return $this->sf('"%s"', $string); |
231 | 231 | } |
232 | 232 | |
233 | - /** |
|
234 | - * Add a string using the `sprintf` method. |
|
235 | - * |
|
236 | - * @param string $format The format string |
|
237 | - * @param string|number|Interface_Stringable ...$arguments The variables to inject |
|
238 | - * @return $this |
|
239 | - */ |
|
233 | + /** |
|
234 | + * Add a string using the `sprintf` method. |
|
235 | + * |
|
236 | + * @param string $format The format string |
|
237 | + * @param string|number|Interface_Stringable ...$arguments The variables to inject |
|
238 | + * @return $this |
|
239 | + */ |
|
240 | 240 | public function sf(string $format, ...$arguments) : StringBuilder |
241 | 241 | { |
242 | 242 | array_unshift($arguments, $format); |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | return $this->add(sprintf(...$arguments)); |
245 | 245 | } |
246 | 246 | |
247 | - /** |
|
248 | - * Adds a bold string. |
|
249 | - * |
|
250 | - * @param string|number|Interface_Stringable $string |
|
251 | - * @return $this |
|
252 | - */ |
|
247 | + /** |
|
248 | + * Adds a bold string. |
|
249 | + * |
|
250 | + * @param string|number|Interface_Stringable $string |
|
251 | + * @return $this |
|
252 | + */ |
|
253 | 253 | public function bold($string) : StringBuilder |
254 | 254 | { |
255 | 255 | return $this->sf( |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | ); |
259 | 259 | } |
260 | 260 | |
261 | - /** |
|
262 | - * Adds an HTML `<br>` tag. |
|
263 | - * |
|
264 | - * Note: for adding a newline character instead, |
|
265 | - * use {@see StringBuilder::eol()}. |
|
266 | - * |
|
267 | - * @return $this |
|
268 | - * @see StringBuilder::eol() |
|
269 | - */ |
|
261 | + /** |
|
262 | + * Adds an HTML `<br>` tag. |
|
263 | + * |
|
264 | + * Note: for adding a newline character instead, |
|
265 | + * use {@see StringBuilder::eol()}. |
|
266 | + * |
|
267 | + * @return $this |
|
268 | + * @see StringBuilder::eol() |
|
269 | + */ |
|
270 | 270 | public function nl() : StringBuilder |
271 | 271 | { |
272 | 272 | return $this->html('<br>'); |
@@ -283,42 +283,42 @@ discard block |
||
283 | 283 | return $this->nospace(PHP_EOL); |
284 | 284 | } |
285 | 285 | |
286 | - /** |
|
287 | - * Adds the current time, in the format <code>H:i:s</code>. |
|
288 | - * |
|
289 | - * @return $this |
|
290 | - */ |
|
286 | + /** |
|
287 | + * Adds the current time, in the format <code>H:i:s</code>. |
|
288 | + * |
|
289 | + * @return $this |
|
290 | + */ |
|
291 | 291 | public function time() : StringBuilder |
292 | 292 | { |
293 | 293 | return $this->add(date('H:i:s')); |
294 | 294 | } |
295 | 295 | |
296 | - /** |
|
297 | - * Adds the "Note:" text. |
|
298 | - * |
|
299 | - * @return $this |
|
300 | - */ |
|
296 | + /** |
|
297 | + * Adds the "Note:" text. |
|
298 | + * |
|
299 | + * @return $this |
|
300 | + */ |
|
301 | 301 | public function note() : StringBuilder |
302 | 302 | { |
303 | 303 | return $this->t('Note:'); |
304 | 304 | } |
305 | 305 | |
306 | - /** |
|
307 | - * Like {@see StringBuilder::note()}, but as bold text. |
|
308 | - * |
|
309 | - * @return $this |
|
310 | - */ |
|
306 | + /** |
|
307 | + * Like {@see StringBuilder::note()}, but as bold text. |
|
308 | + * |
|
309 | + * @return $this |
|
310 | + */ |
|
311 | 311 | public function noteBold() : StringBuilder |
312 | 312 | { |
313 | 313 | return $this->bold(sb()->note()); |
314 | 314 | } |
315 | 315 | |
316 | - /** |
|
317 | - * Adds the "Hint:" text. |
|
318 | - * |
|
319 | - * @return $this |
|
320 | - * @see StringBuilder::hintBold() |
|
321 | - */ |
|
316 | + /** |
|
317 | + * Adds the "Hint:" text. |
|
318 | + * |
|
319 | + * @return $this |
|
320 | + * @see StringBuilder::hintBold() |
|
321 | + */ |
|
322 | 322 | public function hint() : StringBuilder |
323 | 323 | { |
324 | 324 | return $this->t('Hint:'); |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | return $this->bold(sb()->hint()); |
335 | 335 | } |
336 | 336 | |
337 | - /** |
|
338 | - * Adds two linebreaks. |
|
339 | - * |
|
340 | - * @param StringBuilder_Interface|string|NULL $content |
|
341 | - * @return $this |
|
342 | - */ |
|
337 | + /** |
|
338 | + * Adds two linebreaks. |
|
339 | + * |
|
340 | + * @param StringBuilder_Interface|string|NULL $content |
|
341 | + * @return $this |
|
342 | + */ |
|
343 | 343 | public function para($content=null) : StringBuilder |
344 | 344 | { |
345 | 345 | if($content !== null) { |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | return $this->html(HTMLTag::create('a')->renderClose()); |
392 | 392 | } |
393 | 393 | |
394 | - /** |
|
395 | - * Wraps the string in a `code` tag. |
|
396 | - * |
|
397 | - * @param string|number|Interface_Stringable $string |
|
398 | - * @return $this |
|
399 | - */ |
|
394 | + /** |
|
395 | + * Wraps the string in a `code` tag. |
|
396 | + * |
|
397 | + * @param string|number|Interface_Stringable $string |
|
398 | + * @return $this |
|
399 | + */ |
|
400 | 400 | public function code($string) : StringBuilder |
401 | 401 | { |
402 | 402 | return $this->sf( |
@@ -405,24 +405,24 @@ discard block |
||
405 | 405 | ); |
406 | 406 | } |
407 | 407 | |
408 | - /** |
|
409 | - * Wraps the string in a `pre` tag. |
|
410 | - * |
|
411 | - * @param string|number|Interface_Stringable $string |
|
412 | - * @return $this |
|
413 | - */ |
|
408 | + /** |
|
409 | + * Wraps the string in a `pre` tag. |
|
410 | + * |
|
411 | + * @param string|number|Interface_Stringable $string |
|
412 | + * @return $this |
|
413 | + */ |
|
414 | 414 | public function pre($string) : StringBuilder |
415 | 415 | { |
416 | 416 | return $this->sf('<pre>%s</pre>', (string)$string); |
417 | 417 | } |
418 | 418 | |
419 | - /** |
|
420 | - * Wraps the text in a `span` tag with the specified classes. |
|
421 | - * |
|
422 | - * @param string|number|Interface_Stringable $string |
|
423 | - * @param string|string[] $classes |
|
424 | - * @return $this |
|
425 | - */ |
|
419 | + /** |
|
420 | + * Wraps the text in a `span` tag with the specified classes. |
|
421 | + * |
|
422 | + * @param string|number|Interface_Stringable $string |
|
423 | + * @param string|string[] $classes |
|
424 | + * @return $this |
|
425 | + */ |
|
426 | 426 | public function spanned($string, $classes) : StringBuilder |
427 | 427 | { |
428 | 428 | if(!is_array($classes)) |
@@ -29,28 +29,28 @@ discard block |
||
29 | 29 | public const QUOTE_STYLE_SINGLE = 1; |
30 | 30 | public const QUOTE_STYLE_DOUBLE = 2; |
31 | 31 | |
32 | - /** |
|
33 | - * @var array<string,string> |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var array<string,string> |
|
34 | + */ |
|
35 | 35 | protected static array $variableCache = array(); |
36 | 36 | protected static int $elementCounter = 0; |
37 | 37 | protected static string $idPrefix = 'E'; |
38 | 38 | |
39 | - /** |
|
40 | - * Builds a javascript statement. The first parameter is the |
|
41 | - * javascript function to call, any additional parameters are |
|
42 | - * used as arguments for the javascript function call. Variable |
|
43 | - * types are automagically converted to the javascript equivalents. |
|
44 | - * |
|
45 | - * Examples: |
|
46 | - * |
|
47 | - * // add an alert(); statement: |
|
48 | - * JSHelper::buildStatement('alert'); |
|
49 | - * |
|
50 | - * // add an alert('Alert text'); statement |
|
51 | - * JSHelper::buildStatement('alert', 'Alert text'); |
|
52 | - * |
|
53 | - */ |
|
39 | + /** |
|
40 | + * Builds a javascript statement. The first parameter is the |
|
41 | + * javascript function to call, any additional parameters are |
|
42 | + * used as arguments for the javascript function call. Variable |
|
43 | + * types are automagically converted to the javascript equivalents. |
|
44 | + * |
|
45 | + * Examples: |
|
46 | + * |
|
47 | + * // add an alert(); statement: |
|
48 | + * JSHelper::buildStatement('alert'); |
|
49 | + * |
|
50 | + * // add an alert('Alert text'); statement |
|
51 | + * JSHelper::buildStatement('alert', 'Alert text'); |
|
52 | + * |
|
53 | + */ |
|
54 | 54 | public static function buildStatement() : string |
55 | 55 | { |
56 | 56 | $args = func_get_args(); |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | return call_user_func_array(array(self::class, 'buildStatementQuoteStyle'), $args); |
59 | 59 | } |
60 | 60 | |
61 | - /** |
|
62 | - * Like {@link JSHelper::buildStatement()}, but using single quotes |
|
63 | - * to make it possible to use the statement in an HTML tag attribute. |
|
64 | - * |
|
65 | - * @return string |
|
66 | - * @see JSHelper::buildStatement() |
|
67 | - */ |
|
61 | + /** |
|
62 | + * Like {@link JSHelper::buildStatement()}, but using single quotes |
|
63 | + * to make it possible to use the statement in an HTML tag attribute. |
|
64 | + * |
|
65 | + * @return string |
|
66 | + * @see JSHelper::buildStatement() |
|
67 | + */ |
|
68 | 68 | public static function buildStatementAttribute() : string |
69 | 69 | { |
70 | 70 | $args = func_get_args(); |
@@ -94,39 +94,39 @@ discard block |
||
94 | 94 | return $call . ');'; |
95 | 95 | } |
96 | 96 | |
97 | - /** |
|
98 | - * Builds a set variable statement. The variable value is |
|
99 | - * automatically converted to the javascript equivalent. |
|
100 | - * |
|
101 | - * Examples: |
|
102 | - * |
|
103 | - * // foo = 'bar'; |
|
104 | - * JSHelper::buildVariable('foo', 'bar'); |
|
105 | - * |
|
106 | - * // foo = 42; |
|
107 | - * JSHelper::buildVariable('foo', 42); |
|
108 | - * |
|
109 | - * // foo = true; |
|
110 | - * JSHelper::buildVariable('foo', true); |
|
111 | - * |
|
112 | - * @param string $varName |
|
113 | - * @param mixed $varValue |
|
114 | - * @return string |
|
115 | - */ |
|
97 | + /** |
|
98 | + * Builds a set variable statement. The variable value is |
|
99 | + * automatically converted to the javascript equivalent. |
|
100 | + * |
|
101 | + * Examples: |
|
102 | + * |
|
103 | + * // foo = 'bar'; |
|
104 | + * JSHelper::buildVariable('foo', 'bar'); |
|
105 | + * |
|
106 | + * // foo = 42; |
|
107 | + * JSHelper::buildVariable('foo', 42); |
|
108 | + * |
|
109 | + * // foo = true; |
|
110 | + * JSHelper::buildVariable('foo', true); |
|
111 | + * |
|
112 | + * @param string $varName |
|
113 | + * @param mixed $varValue |
|
114 | + * @return string |
|
115 | + */ |
|
116 | 116 | public static function buildVariable(string $varName, $varValue) : string |
117 | 117 | { |
118 | 118 | return $varName . "=" . self::phpVariable2JS($varValue) . ';'; |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Converts a PHP variable to its javascript equivalent. Note that |
|
123 | - * if a variable cannot be converted (like a PHP resource), this will |
|
124 | - * return a javascript "null". |
|
125 | - * |
|
126 | - * @param mixed $variable |
|
127 | - * @param int $quoteStyle The quote style to use for strings |
|
128 | - * @return string |
|
129 | - */ |
|
121 | + /** |
|
122 | + * Converts a PHP variable to its javascript equivalent. Note that |
|
123 | + * if a variable cannot be converted (like a PHP resource), this will |
|
124 | + * return a javascript "null". |
|
125 | + * |
|
126 | + * @param mixed $variable |
|
127 | + * @param int $quoteStyle The quote style to use for strings |
|
128 | + * @return string |
|
129 | + */ |
|
130 | 130 | public static function phpVariable2JS($variable, int $quoteStyle=self::QUOTE_STYLE_DOUBLE) : string |
131 | 131 | { |
132 | 132 | // after much profiling, this variant of the method offers |
@@ -204,26 +204,26 @@ discard block |
||
204 | 204 | return $result; |
205 | 205 | } |
206 | 206 | |
207 | - /** |
|
208 | - * Converts a variable to a JS string that can be |
|
209 | - * used in an HTML attribute: it uses single quotes |
|
210 | - * instead of the default double quotes. |
|
211 | - * |
|
212 | - * @param mixed $variable |
|
213 | - * @return string |
|
214 | - */ |
|
207 | + /** |
|
208 | + * Converts a variable to a JS string that can be |
|
209 | + * used in an HTML attribute: it uses single quotes |
|
210 | + * instead of the default double quotes. |
|
211 | + * |
|
212 | + * @param mixed $variable |
|
213 | + * @return string |
|
214 | + */ |
|
215 | 215 | public static function phpVariable2AttributeJS($variable) : string |
216 | 216 | { |
217 | 217 | return self::phpVariable2JS($variable, self::QUOTE_STYLE_SINGLE); |
218 | 218 | } |
219 | 219 | |
220 | - /** |
|
221 | - * Generates a dynamic element ID to be used with dynamically generated |
|
222 | - * HTML code to tie in with clientside javascript when compact but unique |
|
223 | - * IDs are needed in a request. |
|
224 | - * |
|
225 | - * @return string |
|
226 | - */ |
|
220 | + /** |
|
221 | + * Generates a dynamic element ID to be used with dynamically generated |
|
222 | + * HTML code to tie in with clientside javascript when compact but unique |
|
223 | + * IDs are needed in a request. |
|
224 | + * |
|
225 | + * @return string |
|
226 | + */ |
|
227 | 227 | public static function nextElementID() : string |
228 | 228 | { |
229 | 229 | self::$elementCounter++; |
@@ -231,33 +231,33 @@ discard block |
||
231 | 231 | return self::$idPrefix . self::$elementCounter; |
232 | 232 | } |
233 | 233 | |
234 | - /** |
|
235 | - * Retrieves the ID prefix currently used. |
|
236 | - * |
|
237 | - * @return string |
|
238 | - */ |
|
234 | + /** |
|
235 | + * Retrieves the ID prefix currently used. |
|
236 | + * |
|
237 | + * @return string |
|
238 | + */ |
|
239 | 239 | public static function getIDPrefix() : string |
240 | 240 | { |
241 | 241 | return self::$idPrefix; |
242 | 242 | } |
243 | 243 | |
244 | - /** |
|
245 | - * Retrieves the value of the internal elements counter. |
|
246 | - * |
|
247 | - * @return integer |
|
248 | - */ |
|
244 | + /** |
|
245 | + * Retrieves the value of the internal elements counter. |
|
246 | + * |
|
247 | + * @return integer |
|
248 | + */ |
|
249 | 249 | public static function getElementCounter() : int |
250 | 250 | { |
251 | 251 | return self::$elementCounter; |
252 | 252 | } |
253 | 253 | |
254 | - /** |
|
255 | - * Sets the prefix that is added in front of all IDs |
|
256 | - * retrieved using the {@link nextElementID()} method. |
|
257 | - * |
|
258 | - * @param string $prefix |
|
259 | - * @see JSHelper::nextElementID() |
|
260 | - */ |
|
254 | + /** |
|
255 | + * Sets the prefix that is added in front of all IDs |
|
256 | + * retrieved using the {@link nextElementID()} method. |
|
257 | + * |
|
258 | + * @param string $prefix |
|
259 | + * @see JSHelper::nextElementID() |
|
260 | + */ |
|
261 | 261 | public static function setIDPrefix(string $prefix) : void |
262 | 262 | { |
263 | 263 | self::$idPrefix = $prefix; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | */ |
26 | 26 | trait Traits_Classable |
27 | 27 | { |
28 | - /** |
|
29 | - * @var string[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string[] |
|
30 | + */ |
|
31 | 31 | protected array $classes = array(); |
32 | 32 | |
33 | 33 | public function hasClasses() : bool |
@@ -82,30 +82,30 @@ discard block |
||
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | - /** |
|
86 | - * Retrieves a list of all classes, if any. |
|
87 | - * |
|
88 | - * @return string[] |
|
89 | - */ |
|
85 | + /** |
|
86 | + * Retrieves a list of all classes, if any. |
|
87 | + * |
|
88 | + * @return string[] |
|
89 | + */ |
|
90 | 90 | public function getClasses() : array |
91 | 91 | { |
92 | 92 | return $this->classes; |
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Renders the class names list as space-separated string for use in an HTML tag. |
|
97 | - * |
|
98 | - * @return string |
|
99 | - */ |
|
95 | + /** |
|
96 | + * Renders the class names list as space-separated string for use in an HTML tag. |
|
97 | + * |
|
98 | + * @return string |
|
99 | + */ |
|
100 | 100 | public function classesToString() : string |
101 | 101 | { |
102 | 102 | return implode(' ', $this->classes); |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * Renders the "class" attribute string for inserting into an HTML tag. |
|
107 | - * @return string |
|
108 | - */ |
|
105 | + /** |
|
106 | + * Renders the "class" attribute string for inserting into an HTML tag. |
|
107 | + * @return string |
|
108 | + */ |
|
109 | 109 | public function classesToAttribute() : string |
110 | 110 | { |
111 | 111 | if(!empty($this->classes)) |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | trait Traits_Optionable |
28 | 28 | { |
29 | - /** |
|
30 | - * @var array<string,mixed>|NULL |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var array<string,mixed>|NULL |
|
31 | + */ |
|
32 | 32 | protected ?array $options = null; |
33 | 33 | |
34 | 34 | /** |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | return $this; |
50 | 50 | } |
51 | 51 | |
52 | - /** |
|
53 | - * Sets a collection of options at once, from an |
|
54 | - * associative array. |
|
55 | - * |
|
56 | - * @param array<string,mixed> $options |
|
57 | - * @return $this |
|
58 | - */ |
|
52 | + /** |
|
53 | + * Sets a collection of options at once, from an |
|
54 | + * associative array. |
|
55 | + * |
|
56 | + * @param array<string,mixed> $options |
|
57 | + * @return $this |
|
58 | + */ |
|
59 | 59 | public function setOptions(array $options) : self |
60 | 60 | { |
61 | 61 | foreach($options as $name => $value) { |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * Retrieves an option's value. |
|
70 | - * |
|
71 | - * NOTE: Use the specialized type getters to ensure an option |
|
72 | - * contains the expected type (for ex. getArrayOption()). |
|
73 | - * |
|
74 | - * @param string $name |
|
75 | - * @param mixed $default The default value to return if the option does not exist. |
|
76 | - * @return mixed |
|
77 | - */ |
|
68 | + /** |
|
69 | + * Retrieves an option's value. |
|
70 | + * |
|
71 | + * NOTE: Use the specialized type getters to ensure an option |
|
72 | + * contains the expected type (for ex. getArrayOption()). |
|
73 | + * |
|
74 | + * @param string $name |
|
75 | + * @param mixed $default The default value to return if the option does not exist. |
|
76 | + * @return mixed |
|
77 | + */ |
|
78 | 78 | public function getOption(string $name, $default=null) |
79 | 79 | { |
80 | 80 | if(!isset($this->options)) |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | return $this->options[$name] ?? $default; |
86 | 86 | } |
87 | 87 | |
88 | - /** |
|
89 | - * Enforces that the option value is a string. Numbers are converted |
|
90 | - * to string, strings are passed through, and all other types will |
|
91 | - * return the default value. The default value is also returned if |
|
92 | - * the string is empty. |
|
93 | - * |
|
94 | - * @param string $name |
|
95 | - * @param string $default Used if the option does not exist, is invalid, or empty. |
|
96 | - * @return string |
|
97 | - */ |
|
88 | + /** |
|
89 | + * Enforces that the option value is a string. Numbers are converted |
|
90 | + * to string, strings are passed through, and all other types will |
|
91 | + * return the default value. The default value is also returned if |
|
92 | + * the string is empty. |
|
93 | + * |
|
94 | + * @param string $name |
|
95 | + * @param string $default Used if the option does not exist, is invalid, or empty. |
|
96 | + * @return string |
|
97 | + */ |
|
98 | 98 | public function getStringOption(string $name, string $default='') : string |
99 | 99 | { |
100 | 100 | $value = $this->getOption($name, false); |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | return $default; |
127 | 127 | } |
128 | 128 | |
129 | - /** |
|
130 | - * Treats the option value as an integer value: will return |
|
131 | - * valid integer values (also from integer strings), or the |
|
132 | - * default value otherwise. |
|
133 | - * |
|
134 | - * @param string $name |
|
135 | - * @param int $default |
|
136 | - * @return int |
|
137 | - */ |
|
129 | + /** |
|
130 | + * Treats the option value as an integer value: will return |
|
131 | + * valid integer values (also from integer strings), or the |
|
132 | + * default value otherwise. |
|
133 | + * |
|
134 | + * @param string $name |
|
135 | + * @param int $default |
|
136 | + * @return int |
|
137 | + */ |
|
138 | 138 | public function getIntOption(string $name, int $default=0) : int |
139 | 139 | { |
140 | 140 | $value = $this->getOption($name); |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | return $default; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * Treats an option as an array, and returns its value |
|
150 | - * only if it contains an array - otherwise, an empty |
|
151 | - * array is returned. |
|
152 | - * |
|
153 | - * @param string $name |
|
154 | - * @return array<int|string,mixed> |
|
155 | - */ |
|
148 | + /** |
|
149 | + * Treats an option as an array, and returns its value |
|
150 | + * only if it contains an array - otherwise, an empty |
|
151 | + * array is returned. |
|
152 | + * |
|
153 | + * @param string $name |
|
154 | + * @return array<int|string,mixed> |
|
155 | + */ |
|
156 | 156 | public function getArrayOption(string $name) : array |
157 | 157 | { |
158 | 158 | $val = $this->getOption($name); |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | return array(); |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Checks whether the specified option exists - even |
|
168 | - * if it has a NULL value. |
|
169 | - * |
|
170 | - * @param string $name |
|
171 | - * @return bool |
|
172 | - */ |
|
166 | + /** |
|
167 | + * Checks whether the specified option exists - even |
|
168 | + * if it has a NULL value. |
|
169 | + * |
|
170 | + * @param string $name |
|
171 | + * @return bool |
|
172 | + */ |
|
173 | 173 | public function hasOption(string $name) : bool |
174 | 174 | { |
175 | 175 | if(!isset($this->options)) { |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | return array_key_exists($name, $this->options); |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Returns all options in one associative array. |
|
184 | - * |
|
185 | - * @return array<string,mixed> |
|
186 | - */ |
|
182 | + /** |
|
183 | + * Returns all options in one associative array. |
|
184 | + * |
|
185 | + * @return array<string,mixed> |
|
186 | + */ |
|
187 | 187 | public function getOptions() : array |
188 | 188 | { |
189 | 189 | if(!isset($this->options)) { |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | return $this->options; |
194 | 194 | } |
195 | 195 | |
196 | - /** |
|
197 | - * Checks whether the option's value is the one specified. |
|
198 | - * |
|
199 | - * @param string $name |
|
200 | - * @param mixed $value |
|
201 | - * @return bool |
|
202 | - */ |
|
196 | + /** |
|
197 | + * Checks whether the option's value is the one specified. |
|
198 | + * |
|
199 | + * @param string $name |
|
200 | + * @param mixed $value |
|
201 | + * @return bool |
|
202 | + */ |
|
203 | 203 | public function isOption(string $name, $value) : bool |
204 | 204 | { |
205 | 205 | return $this->getOption($name) === $value; |