| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Core\Base; |
| 4 | 4 | |
| 5 | 5 | if ( ! defined( 'ABSPATH' ) ) { |
| 6 | - exit; // Exit if accessed directly. | |
| 6 | + exit; // Exit if accessed directly | |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Base Object |
| @@ -66,9 +66,8 @@ | ||
| 66 | 66 | /** |
| 67 | 67 | * Delete setting. |
| 68 | 68 | * |
| 69 | 69 | * Deletes the settings array or a specific key of the settings array if `$key` is specified. |
| 70 | - * | |
| 71 | 70 | * @since 2.3.0 |
| 72 | 71 | * @access public |
| 73 | 72 | * |
| 74 | 73 | * @param string $key Optional. Default is null. |
| @@ -147,48 +146,21 @@ | ||
| 147 | 146 | /** |
| 148 | 147 | * Has Own Method |
| 149 | 148 | * |
| 150 | 149 | * Used for check whether the method passed as a parameter was declared in the current instance or inherited. |
| 151 | - * If a base_class_name is passed, it checks whether the method was declared in that class. If the method's | |
| 152 | - * declaring class is the class passed as $base_class_name, it returns false. Otherwise (method was NOT declared | |
| 153 | - * in $base_class_name), it returns true. | |
| 154 | 150 | * |
| 155 | - * Example #1 - only $method_name is passed: | |
| 156 | - * The initial declaration of `register_controls()` happens in the `Controls_Stack` class. However, all | |
| 157 | - * widgets which have their own controls declare this function as well, overriding the original | |
| 158 | - * declaration. If `has_own_method()` would be called by a Widget's class which implements `register_controls()`, | |
| 159 | - * with 'register_controls' passed as the first parameter - `has_own_method()` will return true. If the Widget | |
| 160 | - * does not declare `register_controls()`, `has_own_method()` will return false. | |
| 161 | - * | |
| 162 | - * Example #2 - both $method_name and $base_class_name are passed | |
| 163 | - * In this example, the widget class inherits from a base class `Widget_Base`, and the base implements | |
| 164 | - * `register_controls()` to add certain controls to all widgets inheriting from it. `has_own_method()` is called by | |
| 165 | - * the widget, with the string 'register_controls' passed as the first parameter, and 'Elementor\Widget_Base' (its full name | |
| 166 | - * including the namespace) passed as the second parameter. If the widget class implements `register_controls()`, | |
| 167 | - * `has_own_method` will return true. If the widget class DOESN'T implement `register_controls()`, it will return | |
| 168 | - * false (because `Widget_Base` is the declaring class for `register_controls()`, and not the class that called | |
| 169 | - * `has_own_method()`). | |
| 170 | - * | |
| 171 | 151 | * @since 3.1.0 |
| 172 | 152 | * |
| 173 | 153 | * @param string $method_name |
| 174 | - * @param string $base_class_name | |
| 175 | 154 | * |
| 155 | + * @throws \ReflectionException | |
| 176 | 156 | * @return bool True if the method was declared by the current instance, False if it was inherited. |
| 177 | 157 | */ |
| 178 | - public function has_own_method( $method_name, $base_class_name = null ) { | |
| 179 | - try { | |
| 180 | - $reflection_method = new \ReflectionMethod( $this, $method_name ); | |
| 158 | + public function has_own_method( $method_name ) { | |
| 159 | + $reflection_method = new \ReflectionMethod( $this, $method_name ); | |
| 181 | 160 | |
| 182 | - // If a ReflectionMethod is successfully created, get its declaring class. | |
| 183 | - $declaring_class = $reflection_method->getDeclaringClass(); | |
| 184 | - } catch ( \Exception $e ) { | |
| 185 | - return false; | |
| 186 | - } | |
| 187 | - | |
| 188 | - if ( $base_class_name ) { | |
| 189 | - return $base_class_name !== $declaring_class->name; | |
| 190 | - } | |
| 161 | + // If a ReflectionMethod is successfully created, get its declaring class. | |
| 162 | + $declaring_class = $reflection_method->getDeclaringClass(); | |
| 191 | 163 | |
| 192 | 164 | return get_called_class() === $declaring_class->name; |
| 193 | 165 | } |
| 194 | 166 | } |