1 | <?php |
||
11 | class Stencil_Handler_Factory implements Stencil_Handler_Factory_Interface { |
||
12 | /** |
||
13 | * List of registered Handlers |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | private static $handlers = array(); |
||
18 | |||
19 | /** |
||
20 | * Set a hierarchy handler for a page |
||
21 | * |
||
22 | * @param string $page Page to set. |
||
23 | * @param array|Traversable|null $handler Optional. Handler to use. |
||
24 | */ |
||
25 | public static function set_hierarchy_handler( $page, $handler = null ) { |
||
28 | |||
29 | /** |
||
30 | * Set a page type handler |
||
31 | * |
||
32 | * @param string $page Page to set. |
||
33 | * @param callable $handler Handler to use. |
||
34 | */ |
||
35 | public static function set_page_type_handler( $page, $handler ) { |
||
38 | |||
39 | /** |
||
40 | * Remove handler for a page. |
||
41 | * |
||
42 | * @param string $page Page to remove from. |
||
43 | */ |
||
44 | public static function remove_page_type_handler( $page ) { |
||
47 | |||
48 | /** |
||
49 | * Set page type hooking function |
||
50 | * |
||
51 | * @param string $page Page to set to. |
||
52 | * @param callable $handler Handler to use. |
||
53 | */ |
||
54 | public static function set_page_type_hooker( $page, $handler ) { |
||
57 | |||
58 | /** |
||
59 | * Remove page hooker from page |
||
60 | * |
||
61 | * @param string $page Page to remove from. |
||
62 | */ |
||
63 | public static function remove_page_type_hooker( $page ) { |
||
66 | |||
67 | /** |
||
68 | * Get current hierarchy handler for page |
||
69 | * |
||
70 | * @param string $page Page to get from. |
||
71 | * |
||
72 | * @return array|Traversable |
||
73 | */ |
||
74 | public static function get_hierarchy_handler( $page ) { |
||
77 | |||
78 | /** |
||
79 | * Get the current page type handler |
||
80 | * |
||
81 | * @param string $page Page to get from. |
||
82 | * |
||
83 | * @return callable |
||
84 | */ |
||
85 | public static function get_page_type_handler( $page ) { |
||
88 | |||
89 | /** |
||
90 | * Get the current page type hooker |
||
91 | * |
||
92 | * @param string $page Page to get from. |
||
93 | * |
||
94 | * @return callable |
||
95 | */ |
||
96 | public static function get_page_type_hooker( $page ) { |
||
99 | |||
100 | /** |
||
101 | * Run the handler for the specified page |
||
102 | * |
||
103 | * @param string $page Page to call handler for |
||
104 | * @param Stencil_Handler_Interface $controller Controller that initiated the call |
||
105 | */ |
||
106 | public static function run_page_type_handler( $page, Stencil_Handler_Interface $controller ) { |
||
109 | |||
110 | /** |
||
111 | * Run the hooker for the specified page |
||
112 | * |
||
113 | * @param string $page Page to call handler for |
||
114 | * @param Stencil_Handler_Interface $controller Controller that initiated the call |
||
115 | */ |
||
116 | public static function run_page_type_hook( $page, Stencil_Handler_Interface $controller ) { |
||
119 | |||
120 | /** |
||
121 | * Execute a handler if it is callable |
||
122 | * |
||
123 | * @param string $handler The handler for the page requested |
||
124 | * @param Stencil_Handler_Interface $controller Controller that initiated the call |
||
125 | */ |
||
126 | private static function execute_handler( $handler, Stencil_Handler_Interface $controller ) { |
||
131 | |||
132 | /** |
||
133 | * Unified setter function |
||
134 | * |
||
135 | * @param string $type Type of object. |
||
136 | * @param string $page Page name. |
||
137 | * @param mixed|null $handler Handler to apply. |
||
138 | * |
||
139 | * @throws InvalidArgumentException For invalid argument types. |
||
140 | */ |
||
141 | private static function set_settable_handler( $type, $page, $handler = null ) { |
||
163 | |||
164 | /** |
||
165 | * Unified getter function |
||
166 | * |
||
167 | * @param string $page Page to get from. |
||
168 | * @param string $type Type to get. |
||
169 | * |
||
170 | * @return array Callable function |
||
171 | */ |
||
172 | private static function get_settable_handler( $page, $type ) { |
||
189 | } |
||
190 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: