Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like ApiResult often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ApiResult, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
33 | class ApiResult implements ApiSerializable { |
||
34 | |||
35 | /** |
||
36 | * Override existing value in addValue(), setValue(), and similar functions |
||
37 | * @since 1.21 |
||
38 | */ |
||
39 | const OVERRIDE = 1; |
||
40 | |||
41 | /** |
||
42 | * For addValue(), setValue() and similar functions, if the value does not |
||
43 | * exist, add it as the first element. In case the new value has no name |
||
44 | * (numerical index), all indexes will be renumbered. |
||
45 | * @since 1.21 |
||
46 | */ |
||
47 | const ADD_ON_TOP = 2; |
||
48 | |||
49 | /** |
||
50 | * For addValue() and similar functions, do not check size while adding a value |
||
51 | * Don't use this unless you REALLY know what you're doing. |
||
52 | * Values added while the size checking was disabled will never be counted. |
||
53 | * Ignored for setValue() and similar functions. |
||
54 | * @since 1.24 |
||
55 | */ |
||
56 | const NO_SIZE_CHECK = 4; |
||
57 | |||
58 | /** |
||
59 | * For addValue(), setValue() and similar functions, do not validate data. |
||
60 | * Also disables size checking. If you think you need to use this, you're |
||
61 | * probably wrong. |
||
62 | * @since 1.25 |
||
63 | */ |
||
64 | const NO_VALIDATE = 12; |
||
65 | |||
66 | /** |
||
67 | * Key for the 'indexed tag name' metadata item. Value is string. |
||
68 | * @since 1.25 |
||
69 | */ |
||
70 | const META_INDEXED_TAG_NAME = '_element'; |
||
71 | |||
72 | /** |
||
73 | * Key for the 'subelements' metadata item. Value is string[]. |
||
74 | * @since 1.25 |
||
75 | */ |
||
76 | const META_SUBELEMENTS = '_subelements'; |
||
77 | |||
78 | /** |
||
79 | * Key for the 'preserve keys' metadata item. Value is string[]. |
||
80 | * @since 1.25 |
||
81 | */ |
||
82 | const META_PRESERVE_KEYS = '_preservekeys'; |
||
83 | |||
84 | /** |
||
85 | * Key for the 'content' metadata item. Value is string. |
||
86 | * @since 1.25 |
||
87 | */ |
||
88 | const META_CONTENT = '_content'; |
||
89 | |||
90 | /** |
||
91 | * Key for the 'type' metadata item. Value is one of the following strings: |
||
92 | * - default: Like 'array' if all (non-metadata) keys are numeric with no |
||
93 | * gaps, otherwise like 'assoc'. |
||
94 | * - array: Keys are used for ordering, but are not output. In a format |
||
95 | * like JSON, outputs as []. |
||
96 | * - assoc: In a format like JSON, outputs as {}. |
||
97 | * - kvp: For a format like XML where object keys have a restricted |
||
98 | * character set, use an alternative output format. For example, |
||
99 | * <container><item name="key">value</item></container> rather than |
||
100 | * <container key="value" /> |
||
101 | * - BCarray: Like 'array' normally, 'default' in backwards-compatibility mode. |
||
102 | * - BCassoc: Like 'assoc' normally, 'default' in backwards-compatibility mode. |
||
103 | * - BCkvp: Like 'kvp' normally. In backwards-compatibility mode, forces |
||
104 | * the alternative output format for all formats, for example |
||
105 | * [{"name":key,"*":value}] in JSON. META_KVP_KEY_NAME must also be set. |
||
106 | * @since 1.25 |
||
107 | */ |
||
108 | const META_TYPE = '_type'; |
||
109 | |||
110 | /** |
||
111 | * Key for the metadata item whose value specifies the name used for the |
||
112 | * kvp key in the alternative output format with META_TYPE 'kvp' or |
||
113 | * 'BCkvp', i.e. the "name" in <container><item name="key">value</item></container>. |
||
114 | * Value is string. |
||
115 | * @since 1.25 |
||
116 | */ |
||
117 | const META_KVP_KEY_NAME = '_kvpkeyname'; |
||
118 | |||
119 | /** |
||
120 | * Key for the metadata item that indicates that the KVP key should be |
||
121 | * added into an assoc value, i.e. {"key":{"val1":"a","val2":"b"}} |
||
122 | * transforms to {"name":"key","val1":"a","val2":"b"} rather than |
||
123 | * {"name":"key","value":{"val1":"a","val2":"b"}}. |
||
124 | * Value is boolean. |
||
125 | * @since 1.26 |
||
126 | */ |
||
127 | const META_KVP_MERGE = '_kvpmerge'; |
||
128 | |||
129 | /** |
||
130 | * Key for the 'BC bools' metadata item. Value is string[]. |
||
131 | * Note no setter is provided. |
||
132 | * @since 1.25 |
||
133 | */ |
||
134 | const META_BC_BOOLS = '_BC_bools'; |
||
135 | |||
136 | /** |
||
137 | * Key for the 'BC subelements' metadata item. Value is string[]. |
||
138 | * Note no setter is provided. |
||
139 | * @since 1.25 |
||
140 | */ |
||
141 | const META_BC_SUBELEMENTS = '_BC_subelements'; |
||
142 | |||
143 | private $data, $size, $maxSize; |
||
|
|||
144 | private $errorFormatter; |
||
145 | |||
146 | // Deprecated fields |
||
147 | private $checkingSize, $mainForContinuation; |
||
148 | |||
149 | /** |
||
150 | * @param int|bool $maxSize Maximum result "size", or false for no limit |
||
151 | * @since 1.25 Takes an integer|bool rather than an ApiMain |
||
152 | */ |
||
153 | public function __construct( $maxSize ) { |
||
165 | |||
166 | /** |
||
167 | * Set the error formatter |
||
168 | * @since 1.25 |
||
169 | * @param ApiErrorFormatter $formatter |
||
170 | */ |
||
171 | public function setErrorFormatter( ApiErrorFormatter $formatter ) { |
||
174 | |||
175 | /** |
||
176 | * Allow for adding one ApiResult into another |
||
177 | * @since 1.25 |
||
178 | * @return mixed |
||
179 | */ |
||
180 | public function serializeForApiResult() { |
||
183 | |||
184 | /************************************************************************//** |
||
185 | * @name Content |
||
186 | * @{ |
||
187 | */ |
||
188 | |||
189 | /** |
||
190 | * Clear the current result data. |
||
191 | */ |
||
192 | public function reset() { |
||
198 | |||
199 | /** |
||
200 | * Get the result data array |
||
201 | * |
||
202 | * The returned value should be considered read-only. |
||
203 | * |
||
204 | * Transformations include: |
||
205 | * |
||
206 | * Custom: (callable) Applied before other transformations. Signature is |
||
207 | * function ( &$data, &$metadata ), return value is ignored. Called for |
||
208 | * each nested array. |
||
209 | * |
||
210 | * BC: (array) This transformation does various adjustments to bring the |
||
211 | * output in line with the pre-1.25 result format. The value array is a |
||
212 | * list of flags: 'nobool', 'no*', 'nosub'. |
||
213 | * - Boolean-valued items are changed to '' if true or removed if false, |
||
214 | * unless listed in META_BC_BOOLS. This may be skipped by including |
||
215 | * 'nobool' in the value array. |
||
216 | * - The tag named by META_CONTENT is renamed to '*', and META_CONTENT is |
||
217 | * set to '*'. This may be skipped by including 'no*' in the value |
||
218 | * array. |
||
219 | * - Tags listed in META_BC_SUBELEMENTS will have their values changed to |
||
220 | * [ '*' => $value ]. This may be skipped by including 'nosub' in |
||
221 | * the value array. |
||
222 | * - If META_TYPE is 'BCarray', set it to 'default' |
||
223 | * - If META_TYPE is 'BCassoc', set it to 'default' |
||
224 | * - If META_TYPE is 'BCkvp', perform the transformation (even if |
||
225 | * the Types transformation is not being applied). |
||
226 | * |
||
227 | * Types: (assoc) Apply transformations based on META_TYPE. The values |
||
228 | * array is an associative array with the following possible keys: |
||
229 | * - AssocAsObject: (bool) If true, return arrays with META_TYPE 'assoc' |
||
230 | * as objects. |
||
231 | * - ArmorKVP: (string) If provided, transform arrays with META_TYPE 'kvp' |
||
232 | * and 'BCkvp' into arrays of two-element arrays, something like this: |
||
233 | * $output = []; |
||
234 | * foreach ( $input as $key => $value ) { |
||
235 | * $pair = []; |
||
236 | * $pair[$META_KVP_KEY_NAME ?: $ArmorKVP_value] = $key; |
||
237 | * ApiResult::setContentValue( $pair, 'value', $value ); |
||
238 | * $output[] = $pair; |
||
239 | * } |
||
240 | * |
||
241 | * Strip: (string) Strips metadata keys from the result. |
||
242 | * - 'all': Strip all metadata, recursively |
||
243 | * - 'base': Strip metadata at the top-level only. |
||
244 | * - 'none': Do not strip metadata. |
||
245 | * - 'bc': Like 'all', but leave certain pre-1.25 keys. |
||
246 | * |
||
247 | * @since 1.25 |
||
248 | * @param array|string|null $path Path to fetch, see ApiResult::addValue |
||
249 | * @param array $transforms See above |
||
250 | * @return mixed Result data, or null if not found |
||
251 | */ |
||
252 | public function getResultData( $path = [], $transforms = [] ) { |
||
268 | |||
269 | /** |
||
270 | * Get the size of the result, i.e. the amount of bytes in it |
||
271 | * @return int |
||
272 | */ |
||
273 | public function getSize() { |
||
276 | |||
277 | /** |
||
278 | * Add an output value to the array by name. |
||
279 | * |
||
280 | * Verifies that value with the same name has not been added before. |
||
281 | * |
||
282 | * @since 1.25 |
||
283 | * @param array &$arr To add $value to |
||
284 | * @param string|int|null $name Index of $arr to add $value at, |
||
285 | * or null to use the next numeric index. |
||
286 | * @param mixed $value |
||
287 | * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. |
||
288 | */ |
||
289 | public static function setValue( array &$arr, $name, $value, $flags = 0 ) { |
||
326 | |||
327 | /** |
||
328 | * Validate a value for addition to the result |
||
329 | * @param mixed $value |
||
330 | * @return array|mixed|string |
||
331 | */ |
||
332 | private static function validateValue( $value ) { |
||
388 | |||
389 | /** |
||
390 | * Add value to the output data at the given path. |
||
391 | * |
||
392 | * Path can be an indexed array, each element specifying the branch at which to add the new |
||
393 | * value. Setting $path to [ 'a', 'b', 'c' ] is equivalent to data['a']['b']['c'] = $value. |
||
394 | * If $path is null, the value will be inserted at the data root. |
||
395 | * |
||
396 | * @param array|string|int|null $path |
||
397 | * @param string|int|null $name See ApiResult::setValue() |
||
398 | * @param mixed $value |
||
399 | * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. |
||
400 | * This parameter used to be boolean, and the value of OVERRIDE=1 was specifically |
||
401 | * chosen so that it would be backwards compatible with the new method signature. |
||
402 | * @return bool True if $value fits in the result, false if not |
||
403 | * @since 1.21 int $flags replaced boolean $override |
||
404 | */ |
||
405 | public function addValue( $path, $name, $value, $flags = 0 ) { |
||
429 | |||
430 | /** |
||
431 | * Remove an output value to the array by name. |
||
432 | * @param array &$arr To remove $value from |
||
433 | * @param string|int $name Index of $arr to remove |
||
434 | * @return mixed Old value, or null |
||
435 | */ |
||
436 | public static function unsetValue( array &$arr, $name ) { |
||
444 | |||
445 | /** |
||
446 | * Remove value from the output data at the given path. |
||
447 | * |
||
448 | * @since 1.25 |
||
449 | * @param array|string|null $path See ApiResult::addValue() |
||
450 | * @param string|int|null $name Index to remove at $path. |
||
451 | * If null, $path itself is removed. |
||
452 | * @param int $flags Flags used when adding the value |
||
453 | * @return mixed Old value, or null |
||
454 | */ |
||
455 | public function removeValue( $path, $name, $flags = 0 ) { |
||
470 | |||
471 | /** |
||
472 | * Add an output value to the array by name and mark as META_CONTENT. |
||
473 | * |
||
474 | * @since 1.25 |
||
475 | * @param array &$arr To add $value to |
||
476 | * @param string|int $name Index of $arr to add $value at. |
||
477 | * @param mixed $value |
||
478 | * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. |
||
479 | */ |
||
480 | public static function setContentValue( array &$arr, $name, $value, $flags = 0 ) { |
||
487 | |||
488 | /** |
||
489 | * Add value to the output data at the given path and mark as META_CONTENT |
||
490 | * |
||
491 | * @since 1.25 |
||
492 | * @param array|string|null $path See ApiResult::addValue() |
||
493 | * @param string|int $name See ApiResult::setValue() |
||
494 | * @param mixed $value |
||
495 | * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. |
||
496 | * @return bool True if $value fits in the result, false if not |
||
497 | */ |
||
498 | public function addContentValue( $path, $name, $value, $flags = 0 ) { |
||
505 | |||
506 | /** |
||
507 | * Add the numeric limit for a limit=max to the result. |
||
508 | * |
||
509 | * @since 1.25 |
||
510 | * @param string $moduleName |
||
511 | * @param int $limit |
||
512 | */ |
||
513 | public function addParsedLimit( $moduleName, $limit ) { |
||
518 | |||
519 | /**@}*/ |
||
520 | |||
521 | /************************************************************************//** |
||
522 | * @name Metadata |
||
523 | * @{ |
||
524 | */ |
||
525 | |||
526 | /** |
||
527 | * Set the name of the content field name (META_CONTENT) |
||
528 | * |
||
529 | * @since 1.25 |
||
530 | * @param array &$arr |
||
531 | * @param string|int $name Name of the field |
||
532 | * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. |
||
533 | */ |
||
534 | public static function setContentField( array &$arr, $name, $flags = 0 ) { |
||
546 | |||
547 | /** |
||
548 | * Set the name of the content field name (META_CONTENT) |
||
549 | * |
||
550 | * @since 1.25 |
||
551 | * @param array|string|null $path See ApiResult::addValue() |
||
552 | * @param string|int $name Name of the field |
||
553 | * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. |
||
554 | */ |
||
555 | public function addContentField( $path, $name, $flags = 0 ) { |
||
559 | |||
560 | /** |
||
561 | * Causes the elements with the specified names to be output as |
||
562 | * subelements rather than attributes. |
||
563 | * @since 1.25 is static |
||
564 | * @param array &$arr |
||
565 | * @param array|string|int $names The element name(s) to be output as subelements |
||
566 | */ |
||
567 | View Code Duplication | public static function setSubelementsList( array &$arr, $names ) { |
|
574 | |||
575 | /** |
||
576 | * Causes the elements with the specified names to be output as |
||
577 | * subelements rather than attributes. |
||
578 | * @since 1.25 |
||
579 | * @param array|string|null $path See ApiResult::addValue() |
||
580 | * @param array|string|int $names The element name(s) to be output as subelements |
||
581 | */ |
||
582 | public function addSubelementsList( $path, $names ) { |
||
586 | |||
587 | /** |
||
588 | * Causes the elements with the specified names to be output as |
||
589 | * attributes (when possible) rather than as subelements. |
||
590 | * @since 1.25 |
||
591 | * @param array &$arr |
||
592 | * @param array|string|int $names The element name(s) to not be output as subelements |
||
593 | */ |
||
594 | public static function unsetSubelementsList( array &$arr, $names ) { |
||
599 | |||
600 | /** |
||
601 | * Causes the elements with the specified names to be output as |
||
602 | * attributes (when possible) rather than as subelements. |
||
603 | * @since 1.25 |
||
604 | * @param array|string|null $path See ApiResult::addValue() |
||
605 | * @param array|string|int $names The element name(s) to not be output as subelements |
||
606 | */ |
||
607 | public function removeSubelementsList( $path, $names ) { |
||
611 | |||
612 | /** |
||
613 | * Set the tag name for numeric-keyed values in XML format |
||
614 | * @since 1.25 is static |
||
615 | * @param array &$arr |
||
616 | * @param string $tag Tag name |
||
617 | */ |
||
618 | public static function setIndexedTagName( array &$arr, $tag ) { |
||
624 | |||
625 | /** |
||
626 | * Set the tag name for numeric-keyed values in XML format |
||
627 | * @since 1.25 |
||
628 | * @param array|string|null $path See ApiResult::addValue() |
||
629 | * @param string $tag Tag name |
||
630 | */ |
||
631 | public function addIndexedTagName( $path, $tag ) { |
||
635 | |||
636 | /** |
||
637 | * Set indexed tag name on $arr and all subarrays |
||
638 | * |
||
639 | * @since 1.25 |
||
640 | * @param array &$arr |
||
641 | * @param string $tag Tag name |
||
642 | */ |
||
643 | public static function setIndexedTagNameRecursive( array &$arr, $tag ) { |
||
654 | |||
655 | /** |
||
656 | * Set indexed tag name on $path and all subarrays |
||
657 | * |
||
658 | * @since 1.25 |
||
659 | * @param array|string|null $path See ApiResult::addValue() |
||
660 | * @param string $tag Tag name |
||
661 | */ |
||
662 | public function addIndexedTagNameRecursive( $path, $tag ) { |
||
666 | |||
667 | /** |
||
668 | * Preserve specified keys. |
||
669 | * |
||
670 | * This prevents XML name mangling and preventing keys from being removed |
||
671 | * by self::stripMetadata(). |
||
672 | * |
||
673 | * @since 1.25 |
||
674 | * @param array &$arr |
||
675 | * @param array|string $names The element name(s) to preserve |
||
676 | */ |
||
677 | View Code Duplication | public static function setPreserveKeysList( array &$arr, $names ) { |
|
684 | |||
685 | /** |
||
686 | * Preserve specified keys. |
||
687 | * @since 1.25 |
||
688 | * @see self::setPreserveKeysList() |
||
689 | * @param array|string|null $path See ApiResult::addValue() |
||
690 | * @param array|string $names The element name(s) to preserve |
||
691 | */ |
||
692 | public function addPreserveKeysList( $path, $names ) { |
||
696 | |||
697 | /** |
||
698 | * Don't preserve specified keys. |
||
699 | * @since 1.25 |
||
700 | * @see self::setPreserveKeysList() |
||
701 | * @param array &$arr |
||
702 | * @param array|string $names The element name(s) to not preserve |
||
703 | */ |
||
704 | public static function unsetPreserveKeysList( array &$arr, $names ) { |
||
709 | |||
710 | /** |
||
711 | * Don't preserve specified keys. |
||
712 | * @since 1.25 |
||
713 | * @see self::setPreserveKeysList() |
||
714 | * @param array|string|null $path See ApiResult::addValue() |
||
715 | * @param array|string $names The element name(s) to not preserve |
||
716 | */ |
||
717 | public function removePreserveKeysList( $path, $names ) { |
||
721 | |||
722 | /** |
||
723 | * Set the array data type |
||
724 | * |
||
725 | * @since 1.25 |
||
726 | * @param array &$arr |
||
727 | * @param string $type See ApiResult::META_TYPE |
||
728 | * @param string $kvpKeyName See ApiResult::META_KVP_KEY_NAME |
||
729 | */ |
||
730 | public static function setArrayType( array &$arr, $type, $kvpKeyName = null ) { |
||
741 | |||
742 | /** |
||
743 | * Set the array data type for a path |
||
744 | * @since 1.25 |
||
745 | * @param array|string|null $path See ApiResult::addValue() |
||
746 | * @param string $tag See ApiResult::META_TYPE |
||
747 | * @param string $kvpKeyName See ApiResult::META_KVP_KEY_NAME |
||
748 | */ |
||
749 | public function addArrayType( $path, $tag, $kvpKeyName = null ) { |
||
753 | |||
754 | /** |
||
755 | * Set the array data type recursively |
||
756 | * @since 1.25 |
||
757 | * @param array &$arr |
||
758 | * @param string $type See ApiResult::META_TYPE |
||
759 | * @param string $kvpKeyName See ApiResult::META_KVP_KEY_NAME |
||
760 | */ |
||
761 | public static function setArrayTypeRecursive( array &$arr, $type, $kvpKeyName = null ) { |
||
769 | |||
770 | /** |
||
771 | * Set the array data type for a path recursively |
||
772 | * @since 1.25 |
||
773 | * @param array|string|null $path See ApiResult::addValue() |
||
774 | * @param string $tag See ApiResult::META_TYPE |
||
775 | * @param string $kvpKeyName See ApiResult::META_KVP_KEY_NAME |
||
776 | */ |
||
777 | public function addArrayTypeRecursive( $path, $tag, $kvpKeyName = null ) { |
||
781 | |||
782 | /**@}*/ |
||
783 | |||
784 | /************************************************************************//** |
||
785 | * @name Utility |
||
786 | * @{ |
||
787 | */ |
||
788 | |||
789 | /** |
||
790 | * Test whether a key should be considered metadata |
||
791 | * |
||
792 | * @param string $key |
||
793 | * @return bool |
||
794 | */ |
||
795 | public static function isMetadataKey( $key ) { |
||
798 | |||
799 | /** |
||
800 | * Apply transformations to an array, returning the transformed array. |
||
801 | * |
||
802 | * @see ApiResult::getResultData() |
||
803 | * @since 1.25 |
||
804 | * @param array $dataIn |
||
805 | * @param array $transforms |
||
806 | * @return array|object |
||
807 | */ |
||
808 | protected static function applyTransformations( array $dataIn, array $transforms ) { |
||
1015 | |||
1016 | /** |
||
1017 | * Recursively remove metadata keys from a data array or object |
||
1018 | * |
||
1019 | * Note this removes all potential metadata keys, not just the defined |
||
1020 | * ones. |
||
1021 | * |
||
1022 | * @since 1.25 |
||
1023 | * @param array|object $data |
||
1024 | * @return array|object |
||
1025 | */ |
||
1026 | public static function stripMetadata( $data ) { |
||
1048 | |||
1049 | /** |
||
1050 | * Remove metadata keys from a data array or object, non-recursive |
||
1051 | * |
||
1052 | * Note this removes all potential metadata keys, not just the defined |
||
1053 | * ones. |
||
1054 | * |
||
1055 | * @since 1.25 |
||
1056 | * @param array|object $data |
||
1057 | * @param array &$metadata Store metadata here, if provided |
||
1058 | * @return array|object |
||
1059 | */ |
||
1060 | public static function stripMetadataNonRecursive( $data, &$metadata = null ) { |
||
1084 | |||
1085 | /** |
||
1086 | * Get the 'real' size of a result item. This means the strlen() of the item, |
||
1087 | * or the sum of the strlen()s of the elements if the item is an array. |
||
1088 | * @param mixed $value Validated value (see self::validateValue()) |
||
1089 | * @return int |
||
1090 | */ |
||
1091 | private static function size( $value ) { |
||
1105 | |||
1106 | /** |
||
1107 | * Return a reference to the internal data at $path |
||
1108 | * |
||
1109 | * @param array|string|null $path |
||
1110 | * @param string $create |
||
1111 | * If 'append', append empty arrays. |
||
1112 | * If 'prepend', prepend empty arrays. |
||
1113 | * If 'dummy', return a dummy array. |
||
1114 | * Else, raise an error. |
||
1115 | * @return array |
||
1116 | */ |
||
1117 | private function &path( $path, $create = 'append' ) { |
||
1145 | |||
1146 | /** |
||
1147 | * Add the correct metadata to an array of vars we want to export through |
||
1148 | * the API. |
||
1149 | * |
||
1150 | * @param array $vars |
||
1151 | * @param bool $forceHash |
||
1152 | * @return array |
||
1153 | */ |
||
1154 | public static function addMetadataToResultVars( $vars, $forceHash = true ) { |
||
1200 | |||
1201 | /**@}*/ |
||
1202 | |||
1203 | } |
||
1204 | |||
1209 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.