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 EE_Registry 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 EE_Registry, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
16 | class EE_Registry implements ResettableInterface { |
||
17 | |||
18 | /** |
||
19 | * EE_Registry Object |
||
20 | * |
||
21 | * @var EE_Registry $_instance |
||
22 | * @access private |
||
23 | */ |
||
24 | private static $_instance = null; |
||
25 | |||
26 | /** |
||
27 | * @var EE_Dependency_Map $_dependency_map |
||
28 | * @access protected |
||
29 | */ |
||
30 | protected $_dependency_map = null; |
||
31 | |||
32 | /** |
||
33 | * @var array $_class_abbreviations |
||
34 | * @access protected |
||
35 | */ |
||
36 | protected $_class_abbreviations = array(); |
||
37 | |||
38 | /** |
||
39 | * EE_Cart Object |
||
40 | * @access public |
||
41 | * @var EE_Cart $CART |
||
42 | */ |
||
43 | public $CART = null; |
||
44 | |||
45 | /** |
||
46 | * EE_Config Object |
||
47 | * @access public |
||
48 | * @var EE_Config $CFG |
||
49 | */ |
||
50 | public $CFG = null; |
||
51 | |||
52 | /** |
||
53 | * EE_Network_Config Object |
||
54 | * @access public |
||
55 | * @var EE_Network_Config $NET_CFG |
||
56 | */ |
||
57 | public $NET_CFG = null; |
||
58 | |||
59 | /** |
||
60 | * StdClass object for storing library classes in |
||
61 | * |
||
62 | * @public LIB |
||
63 | * @var StdClass $LIB |
||
64 | */ |
||
65 | public $LIB = null; |
||
66 | |||
67 | /** |
||
68 | * EE_Request_Handler Object |
||
69 | * @access public |
||
70 | * @var EE_Request_Handler $REQ |
||
71 | */ |
||
72 | public $REQ = null; |
||
73 | |||
74 | /** |
||
75 | * EE_Session Object |
||
76 | * @access public |
||
77 | * @var EE_Session $SSN |
||
78 | */ |
||
79 | public $SSN = null; |
||
80 | |||
81 | /** |
||
82 | * holds the ee capabilities object. |
||
83 | * |
||
84 | * @since 4.5.0 |
||
85 | * |
||
86 | * @var EE_Capabilities |
||
87 | */ |
||
88 | public $CAP = null; |
||
89 | |||
90 | /** |
||
91 | * holds the EE_Message_Resource_Manager object. |
||
92 | * |
||
93 | * @since 4.9.0 |
||
94 | * |
||
95 | * @var EE_Message_Resource_Manager |
||
96 | */ |
||
97 | public $MRM = null; |
||
98 | |||
99 | /** |
||
100 | * $addons - StdClass object for holding addons which have registered themselves to work with EE core |
||
101 | * @access public |
||
102 | * @var EE_Addon[] |
||
103 | */ |
||
104 | public $addons = null; |
||
105 | |||
106 | /** |
||
107 | * $models |
||
108 | * @access public |
||
109 | * @var EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event') |
||
110 | */ |
||
111 | public $models = array(); |
||
112 | |||
113 | /** |
||
114 | * $modules |
||
115 | * @access public |
||
116 | * @var EED_Module[] $modules |
||
117 | */ |
||
118 | public $modules = null; |
||
119 | |||
120 | /** |
||
121 | * $shortcodes |
||
122 | * @access public |
||
123 | * @var EES_Shortcode[] $shortcodes |
||
124 | */ |
||
125 | public $shortcodes = null; |
||
126 | |||
127 | /** |
||
128 | * $widgets |
||
129 | * @access public |
||
130 | * @var WP_Widget[] $widgets |
||
131 | */ |
||
132 | public $widgets = null; |
||
133 | |||
134 | /** |
||
135 | * $non_abstract_db_models |
||
136 | * @access public |
||
137 | * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models |
||
138 | * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)). |
||
139 | * Keys are model "short names" (eg "Event") as used in model relations, and values are |
||
140 | * classnames (eg "EEM_Event") |
||
141 | */ |
||
142 | public $non_abstract_db_models = array(); |
||
143 | |||
144 | /** |
||
145 | * $i18n_js_strings - internationalization for JS strings |
||
146 | * usage: EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' ); |
||
147 | * in js file: var translatedString = eei18n.string_key; |
||
148 | * |
||
149 | * @access public |
||
150 | * @var array |
||
151 | */ |
||
152 | public static $i18n_js_strings = array(); |
||
153 | |||
154 | /** |
||
155 | * $main_file - path to espresso.php |
||
156 | * |
||
157 | * @access public |
||
158 | * @var array |
||
159 | */ |
||
160 | public $main_file; |
||
161 | |||
162 | /** |
||
163 | * array of ReflectionClass objects where the key is the class name |
||
164 | * |
||
165 | * @access public |
||
166 | * @var ReflectionClass[] |
||
167 | */ |
||
168 | public $_reflectors; |
||
169 | |||
170 | /** |
||
171 | * boolean flag to indicate whether or not to load/save dependencies from/to the cache |
||
172 | * |
||
173 | * @access protected |
||
174 | * @var boolean $_cache_on |
||
175 | */ |
||
176 | protected $_cache_on = true; |
||
177 | |||
178 | |||
179 | |||
180 | /** |
||
181 | * @singleton method used to instantiate class object |
||
182 | * @access public |
||
183 | * @param \EE_Dependency_Map $dependency_map |
||
184 | * @return \EE_Registry instance |
||
185 | */ |
||
186 | public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
||
193 | |||
194 | |||
195 | |||
196 | /** |
||
197 | *protected constructor to prevent direct creation |
||
198 | * |
||
199 | * @Constructor |
||
200 | * @access protected |
||
201 | * @param \EE_Dependency_Map $dependency_map |
||
202 | * @return \EE_Registry |
||
203 | */ |
||
204 | protected function __construct( \EE_Dependency_Map $dependency_map ) { |
||
208 | |||
209 | |||
210 | |||
211 | /** |
||
212 | * initialize |
||
213 | */ |
||
214 | public function initialize() { |
||
247 | |||
248 | |||
249 | |||
250 | /** |
||
251 | * init |
||
252 | * |
||
253 | * @access public |
||
254 | * @return void |
||
255 | */ |
||
256 | public function init() { |
||
263 | |||
264 | |||
265 | |||
266 | /** |
||
267 | * localize_i18n_js_strings |
||
268 | * |
||
269 | * @return string |
||
270 | */ |
||
271 | public static function localize_i18n_js_strings() { |
||
281 | |||
282 | |||
283 | |||
284 | /** |
||
285 | * @param mixed string | EED_Module $module |
||
286 | */ |
||
287 | public function add_module( $module ) { |
||
298 | |||
299 | |||
300 | |||
301 | /** |
||
302 | * @param string $module_name |
||
303 | * @return mixed EED_Module | NULL |
||
304 | */ |
||
305 | public function get_module( $module_name = '' ) { |
||
308 | |||
309 | |||
310 | |||
311 | /** |
||
312 | * loads core classes - must be singletons |
||
313 | * |
||
314 | * @access public |
||
315 | * @param string $class_name - simple class name ie: session |
||
316 | * @param mixed $arguments |
||
317 | * @param bool $load_only |
||
318 | * @return mixed |
||
319 | */ |
||
320 | public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
||
335 | |||
336 | |||
337 | |||
338 | /** |
||
339 | * loads service classes |
||
340 | * |
||
341 | * @access public |
||
342 | * @param string $class_name - simple class name ie: session |
||
343 | * @param mixed $arguments |
||
344 | * @param bool $load_only |
||
345 | * @return mixed |
||
346 | */ |
||
347 | public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
||
357 | |||
358 | |||
359 | |||
360 | /** |
||
361 | * loads data_migration_scripts |
||
362 | * |
||
363 | * @access public |
||
364 | * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0 |
||
365 | * @param mixed $arguments |
||
366 | * @return EE_Data_Migration_Script_Base |
||
367 | */ |
||
368 | public function load_dms( $class_name, $arguments = array() ) { |
||
372 | |||
373 | |||
374 | |||
375 | /** |
||
376 | * loads object creating classes - must be singletons |
||
377 | * |
||
378 | * @param string $class_name - simple class name ie: attendee |
||
379 | * @param mixed $arguments - an array of arguments to pass to the class |
||
380 | * @param bool $from_db - some classes are instantiated from the db and thus call a different method to instantiate |
||
381 | * @param bool $cache if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop) |
||
382 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
||
383 | * @return EE_Base_Class | bool |
||
384 | */ |
||
385 | public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
||
394 | |||
395 | |||
396 | |||
397 | /** |
||
398 | * loads helper classes - must be singletons |
||
399 | * |
||
400 | * @param string $class_name - simple class name ie: price |
||
401 | * @param mixed $arguments |
||
402 | * @param bool $load_only |
||
403 | * @return EEH_Base | bool |
||
404 | */ |
||
405 | public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
||
411 | |||
412 | |||
413 | |||
414 | /** |
||
415 | * loads core classes - must be singletons |
||
416 | * |
||
417 | * @access public |
||
418 | * @param string $class_name - simple class name ie: session |
||
419 | * @param mixed $arguments |
||
420 | * @param bool $load_only |
||
421 | * @param bool $cache whether to cache the object or not. |
||
422 | * @return mixed |
||
423 | */ |
||
424 | public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
||
435 | |||
436 | |||
437 | |||
438 | /** |
||
439 | * loads model classes - must be singletons |
||
440 | * |
||
441 | * @param string $class_name - simple class name ie: price |
||
442 | * @param mixed $arguments |
||
443 | * @param bool $load_only |
||
444 | * @return EEM_Base | bool |
||
445 | */ |
||
446 | public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
||
454 | |||
455 | |||
456 | |||
457 | /** |
||
458 | * loads model classes - must be singletons |
||
459 | * |
||
460 | * @param string $class_name - simple class name ie: price |
||
461 | * @param mixed $arguments |
||
462 | * @param bool $load_only |
||
463 | * @return mixed | bool |
||
464 | */ |
||
465 | public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
||
475 | |||
476 | |||
477 | |||
478 | /** |
||
479 | * Determines if $model_name is the name of an actual EE model. |
||
480 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
||
481 | * @return boolean |
||
482 | */ |
||
483 | public function is_model_name( $model_name ) { |
||
486 | |||
487 | |||
488 | |||
489 | /** |
||
490 | * generic class loader |
||
491 | * |
||
492 | * @param string $path_to_file - directory path to file location, not including filename |
||
493 | * @param string $file_name - file name ie: my_file.php, including extension |
||
494 | * @param string $type - file type - core? class? helper? model? |
||
495 | * @param mixed $arguments |
||
496 | * @param bool $load_only |
||
497 | * @return mixed |
||
498 | */ |
||
499 | public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
||
503 | |||
504 | |||
505 | |||
506 | /** |
||
507 | * load_addon |
||
508 | * |
||
509 | * @param string $path_to_file - directory path to file location, not including filename |
||
510 | * @param string $class_name - full class name ie: My_Class |
||
511 | * @param string $type - file type - core? class? helper? model? |
||
512 | * @param mixed $arguments |
||
513 | * @param bool $load_only |
||
514 | * @return EE_Addon |
||
515 | */ |
||
516 | public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
||
520 | |||
521 | |||
522 | |||
523 | /** |
||
524 | * loads and tracks classes |
||
525 | * |
||
526 | * @param array $file_paths |
||
527 | * @param string $class_prefix - EE or EEM or... ??? |
||
528 | * @param bool|string $class_name - $class name |
||
529 | * @param string $type - file type - core? class? helper? model? |
||
530 | * @param mixed $arguments - an argument or array of arguments to pass to the class upon instantiation |
||
531 | * @param bool $from_db - some classes are instantiated from the db and thus call a different method to instantiate |
||
532 | * @param bool $cache |
||
533 | * @param bool $load_only |
||
534 | * @return null|object|bool null = failure to load or instantiate class object. |
||
535 | * object = class loaded and instantiated successfully. |
||
536 | * bool = fail or success when $load_only is true |
||
537 | */ |
||
538 | protected function _load( |
||
593 | |||
594 | |||
595 | |||
596 | /** |
||
597 | * _get_cached_class |
||
598 | * |
||
599 | * attempts to find a cached version of the requested class |
||
600 | * by looking in the following places: |
||
601 | * $this->{$class_abbreviation} ie: $this->CART |
||
602 | * $this->{$class_name} ie: $this->Some_Class |
||
603 | * $this->LIB->{$class_name} ie: $this->LIB->Some_Class |
||
604 | * $this->addon->{$class_name} ie: $this->addon->Some_Addon_Class |
||
605 | * |
||
606 | * @access protected |
||
607 | * @param string $class_name |
||
608 | * @param string $class_prefix |
||
609 | * @return null|object |
||
610 | */ |
||
611 | protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
||
633 | |||
634 | |||
635 | |||
636 | /** |
||
637 | * _resolve_path |
||
638 | * |
||
639 | * attempts to find a full valid filepath for the requested class. |
||
640 | * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php" |
||
641 | * then returns that path if the target file has been found and is readable |
||
642 | * |
||
643 | * @access protected |
||
644 | * @param string $class_name |
||
645 | * @param string $type |
||
646 | * @param array $file_paths |
||
647 | * @return string | bool |
||
648 | */ |
||
649 | protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
||
667 | |||
668 | |||
669 | |||
670 | /** |
||
671 | * _require_file |
||
672 | * |
||
673 | * basically just performs a require_once() |
||
674 | * but with some error handling |
||
675 | * |
||
676 | * @access protected |
||
677 | * @param string $path |
||
678 | * @param string $class_name |
||
679 | * @param string $type |
||
680 | * @param array $file_paths |
||
681 | * @return boolean |
||
682 | * @throws \EE_Error |
||
683 | */ |
||
684 | protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
||
720 | |||
721 | |||
722 | |||
723 | /** |
||
724 | * _create_object |
||
725 | * Attempts to instantiate the requested class via any of the |
||
726 | * commonly used instantiation methods employed throughout EE. |
||
727 | * The priority for instantiation is as follows: |
||
728 | * - abstract classes or any class flagged as "load only" (no instantiation occurs) |
||
729 | * - model objects via their 'new_instance_from_db' method |
||
730 | * - model objects via their 'new_instance' method |
||
731 | * - "singleton" classes" via their 'instance' method |
||
732 | * - standard instantiable classes via their __constructor |
||
733 | * Prior to instantiation, if the classname exists in the dependency_map, |
||
734 | * then the constructor for the requested class will be examined to determine |
||
735 | * if any dependencies exist, and if they can be injected. |
||
736 | * If so, then those classes will be added to the array of arguments passed to the constructor |
||
737 | * |
||
738 | * @access protected |
||
739 | * @param string $class_name |
||
740 | * @param array $arguments |
||
741 | * @param string $type |
||
742 | * @param bool $from_db |
||
743 | * @return null | object |
||
744 | * @throws \EE_Error |
||
745 | */ |
||
746 | protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
||
800 | |||
801 | |||
802 | |||
803 | /** |
||
804 | * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential |
||
805 | * @param array $array |
||
806 | * @return bool |
||
807 | */ |
||
808 | protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
||
811 | |||
812 | |||
813 | |||
814 | /** |
||
815 | * getReflectionClass |
||
816 | * |
||
817 | * checks if a ReflectionClass object has already been generated for a class |
||
818 | * and returns that instead of creating a new one |
||
819 | * |
||
820 | * @access public |
||
821 | * @param string $class_name |
||
822 | * @return ReflectionClass |
||
823 | */ |
||
824 | public function get_ReflectionClass( $class_name ) { |
||
833 | |||
834 | |||
835 | |||
836 | /** |
||
837 | * _resolve_dependencies |
||
838 | * |
||
839 | * examines the constructor for the requested class to determine |
||
840 | * if any dependencies exist, and if they can be injected. |
||
841 | * If so, then those classes will be added to the array of arguments passed to the constructor |
||
842 | * PLZ NOTE: this is achieved by type hinting the constructor params |
||
843 | * For example: |
||
844 | * if attempting to load a class "Foo" with the following constructor: |
||
845 | * __construct( Bar $bar_class, Fighter $grohl_class ) |
||
846 | * then $bar_class and $grohl_class will be added to the $arguments array, |
||
847 | * but only IF they are NOT already present in the incoming arguments array, |
||
848 | * and the correct classes can be loaded |
||
849 | * |
||
850 | * @access protected |
||
851 | * @param ReflectionClass $reflector |
||
852 | * @param string $class_name |
||
853 | * @param array $arguments |
||
854 | * @return array |
||
855 | */ |
||
856 | protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
||
900 | |||
901 | |||
902 | |||
903 | /** |
||
904 | * @access protected |
||
905 | * @param string $class_name |
||
906 | * @param string $param_class |
||
907 | * @param array $arguments |
||
908 | * @param mixed $index |
||
909 | * @return array |
||
910 | */ |
||
911 | protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
||
949 | |||
950 | |||
951 | |||
952 | /** |
||
953 | * _set_cached_class |
||
954 | * |
||
955 | * attempts to cache the instantiated class locally |
||
956 | * in one of the following places, in the following order: |
||
957 | * $this->{class_abbreviation} ie: $this->CART |
||
958 | * $this->{$class_name} ie: $this->Some_Class |
||
959 | * $this->addon->{$$class_name} ie: $this->addon->Some_Addon_Class |
||
960 | * $this->LIB->{$class_name} ie: $this->LIB->Some_Class |
||
961 | * |
||
962 | * @access protected |
||
963 | * @param object $class_obj |
||
964 | * @param string $class_name |
||
965 | * @param string $class_prefix |
||
966 | * @param bool $from_db |
||
967 | * @return void |
||
968 | */ |
||
969 | protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
||
985 | |||
986 | |||
987 | |||
988 | /** |
||
989 | * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array |
||
990 | * |
||
991 | * |
||
992 | * @param string $classname PLEASE NOTE: the class name needs to match what's registered |
||
993 | * in the EE_Dependency_Map::$_class_loaders array, |
||
994 | * including the class prefix, ie: "EE_", "EEM_", "EEH_", etc |
||
995 | * @param array $arguments |
||
996 | * @return object |
||
997 | */ |
||
998 | public static function factory( $classname, $arguments = array() ) { |
||
1007 | |||
1008 | |||
1009 | |||
1010 | /** |
||
1011 | * Gets the addon by its name/slug (not classname. For that, just |
||
1012 | * use the classname as the property name on EE_Config::instance()->addons) |
||
1013 | * @param string $name |
||
1014 | * @return EE_Addon |
||
1015 | */ |
||
1016 | public function get_addon_by_name( $name ) { |
||
1024 | |||
1025 | |||
1026 | |||
1027 | /** |
||
1028 | * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname} |
||
1029 | * |
||
1030 | * @return EE_Addon[] where the KEYS are the addon's name() |
||
1031 | */ |
||
1032 | public function get_addons_by_name() { |
||
1039 | |||
1040 | |||
1041 | |||
1042 | /** |
||
1043 | * Resets the specified model's instance AND makes sure EE_Registry doesn't keep |
||
1044 | * a stale copy of it around |
||
1045 | * |
||
1046 | * @param string $model_name |
||
1047 | * @return \EEM_Base |
||
1048 | * @throws \EE_Error |
||
1049 | */ |
||
1050 | public function reset_model( $model_name ) { |
||
1061 | |||
1062 | |||
1063 | |||
1064 | /** |
||
1065 | * Resets the registry. |
||
1066 | * |
||
1067 | * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog |
||
1068 | * is used in a multisite install. Here is a list of things that are NOT reset. |
||
1069 | * |
||
1070 | * - $_dependency_map |
||
1071 | * - $_class_abbreviations |
||
1072 | * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset. |
||
1073 | * - $REQ: Still on the same request so no need to change. |
||
1074 | * - $CAP: There is no site specific state in the EE_Capability class. |
||
1075 | * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session |
||
1076 | * can be active in a single request. Resetting could resolve in "headers already sent" errors. |
||
1077 | * - $addons: In multisite, the state of the addons is something controlled via hooks etc in a normal request. So |
||
1078 | * for now, we won't reset the addons because it could break calls to an add-ons class/methods in the |
||
1079 | * switch or on the restore. |
||
1080 | * - $modules |
||
1081 | * - $shortcodes |
||
1082 | * - $widgets |
||
1083 | * - $LIB: Only specific classes get unset from $LIB (current EE_Data_Migration_Manager) that persist state. |
||
1084 | * |
||
1085 | * @param boolean $hard whether to reset data in the database too, or just refresh |
||
1086 | * the Registry to its state at the beginning of the request |
||
1087 | * @param boolean $reinstantiate whether to create new instances of EE_Registry's singletons too, |
||
1088 | * or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN |
||
1089 | * currently reinstantiate the singletons at the moment) |
||
1090 | * @param bool $reset_models Defaults to true. When false, then the models are not reset. This is so client |
||
1091 | * code instead can just change the model context to a different blog id if necessary |
||
1092 | * |
||
1093 | * @return EE_Registry |
||
1094 | */ |
||
1095 | public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
||
1113 | |||
1114 | |||
1115 | |||
1116 | /** |
||
1117 | * if passed object implements ResettableInterface, then call it's reset() method |
||
1118 | * if passed object implements InterminableInterface, then return false, |
||
1119 | * to indicate that it should NOT be cleared from the Registry cache |
||
1120 | * |
||
1121 | * @param $object |
||
1122 | * @param bool $reset_models |
||
1123 | * @return bool returns true if cached object should be unset |
||
1124 | */ |
||
1125 | private static function _reset_and_unset_object( $object, $reset_models ) { |
||
1143 | |||
1144 | |||
1145 | |||
1146 | /** |
||
1147 | * @override magic methods |
||
1148 | * @return void |
||
1149 | */ |
||
1150 | final function __destruct() { |
||
1152 | |||
1153 | |||
1154 | |||
1155 | /** |
||
1156 | * @param $a |
||
1157 | * @param $b |
||
1158 | */ |
||
1159 | final function __call( $a, $b ) { |
||
1161 | |||
1162 | |||
1163 | |||
1164 | /** |
||
1165 | * @param $a |
||
1166 | */ |
||
1167 | final function __get( $a ) { |
||
1169 | |||
1170 | |||
1171 | |||
1172 | /** |
||
1173 | * @param $a |
||
1174 | * @param $b |
||
1175 | */ |
||
1176 | final function __set( $a, $b ) { |
||
1178 | |||
1179 | |||
1180 | |||
1181 | /** |
||
1182 | * @param $a |
||
1183 | */ |
||
1184 | final function __isset( $a ) { |
||
1186 | |||
1187 | |||
1188 | |||
1189 | /** |
||
1190 | * @param $a |
||
1191 | */ |
||
1192 | final function __unset( $a ) { |
||
1194 | |||
1195 | |||
1196 | |||
1197 | /** |
||
1198 | * @return array |
||
1199 | */ |
||
1200 | final function __sleep() { |
||
1203 | |||
1204 | |||
1205 | |||
1206 | final function __wakeup() { |
||
1208 | |||
1209 | |||
1210 | |||
1211 | /** |
||
1212 | * @return string |
||
1213 | */ |
||
1214 | final function __toString() { |
||
1217 | |||
1218 | |||
1219 | |||
1220 | final function __invoke() { |
||
1222 | |||
1223 | |||
1224 | |||
1225 | final function __set_state() { |
||
1227 | |||
1228 | |||
1229 | |||
1230 | final function __clone() { |
||
1232 | |||
1233 | |||
1234 | |||
1235 | /** |
||
1236 | * @param $a |
||
1237 | * @param $b |
||
1238 | */ |
||
1239 | final static function __callStatic( $a, $b ) { |
||
1241 | |||
1242 | /** |
||
1243 | * Gets all the custom post type models defined |
||
1244 | * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event") |
||
1245 | */ |
||
1246 | public function cpt_models() { |
||
1255 | |||
1256 | |||
1257 | |||
1258 | public static function CFG() { |
||
1261 | |||
1262 | |||
1263 | } |
||
1264 | // End of file EE_Registry.core.php |
||
1266 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):