1 | <?php |
||
11 | abstract class main_peripheral implements \Serializable, \JsonSerializable { |
||
12 | |||
13 | /** |
||
14 | * Makes sure cloning works as expected |
||
15 | * |
||
16 | * @return void |
||
17 | */ |
||
18 | public function __clone() { |
||
22 | |||
23 | /** |
||
24 | * Custom serialize function |
||
25 | * |
||
26 | * @return string This instance serialized as an RGB string |
||
27 | */ |
||
28 | public function serialize() :string { |
||
31 | |||
32 | /** |
||
33 | * Custom unserialize function |
||
34 | * |
||
35 | * @param string $serialized This instance serialized as an RGB string |
||
36 | * @return void |
||
37 | */ |
||
38 | public function unserialize($serialized) { |
||
39 | $unserialized = (array) json_decode((string) $serialized); |
||
40 | regulate::rgb_array($unserialized); |
||
41 | $this->set($unserialized, 'rgb'); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Custom JSON serialize function |
||
46 | * |
||
47 | * @return string This instance serialized as an JSON RGB string |
||
|
|||
48 | */ |
||
49 | public function jsonSerialize() :array { |
||
52 | |||
53 | protected function get_scheme(string $scheme_name, string $return_type = 'hex', $scheme_class) :array { |
||
61 | |||
62 | /** |
||
63 | * Handles scheme generator callbacks |
||
64 | * |
||
65 | * @param string $scheme_name The name of the scheme algorithm to use |
||
66 | * @param string $callback The return type callback |
||
67 | * @param array $hsl The base color as an HSL array |
||
68 | * @return array The resulting scheme in the proper format, OR an empty array on failure. |
||
69 | */ |
||
70 | protected static function _scheme(string $scheme_name, array $callback, array $hsl) :array { |
||
82 | |||
83 | /** |
||
84 | * Set whether or not caching should be active. |
||
85 | * |
||
86 | * @param bool $active If TRUE caching is turned on, otherwise cashing is turned off. |
||
87 | * @return void |
||
88 | */ |
||
89 | public function cache(bool $active = TRUE) { |
||
92 | |||
93 | /** |
||
94 | * Reset the cache for this instance |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | public function reset_cache() { |
||
101 | } |
||
102 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.If the return type contains the type array, this check recommends the use of a more specific type like
String[]
orarray<String>
.