Skip to content

Commit

Permalink
Remove dead code after #3505
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Nov 10, 2019
1 parent acdad29 commit 16440c1
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions includes/validation/class-amp-validation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1426,31 +1426,21 @@ public static function decorate_filter_source( $value ) {
* @type string $type Source type (core, plugin, mu-plugin, or theme).
* @type string $name Source name.
* @type string $function Normalized function name.
* @type ReflectionMethod|ReflectionFunction $reflection
* @type ReflectionMethod|ReflectionFunction $reflection Reflection.
* }
*/
public static function get_source( $callback ) {
$reflection = null;
$class_name = null; // Because ReflectionMethod::getDeclaringClass() can return a parent class.
try {
if ( is_string( $callback ) && is_callable( $callback ) ) {
// The $callback is a function or static method.
$exploded_callback = explode( '::', $callback, 2 );
if ( 2 === count( $exploded_callback ) ) {
$class_name = $exploded_callback[0];
$reflection = new ReflectionMethod( $exploded_callback[0], $exploded_callback[1] );
} else {
$reflection = new ReflectionFunction( $callback );
}
} elseif ( is_array( $callback ) && isset( $callback[0], $callback[1] ) && method_exists( $callback[0], $callback[1] ) ) {
// The $callback is a method.
if ( is_string( $callback[0] ) ) {
$class_name = $callback[0];
} elseif ( is_object( $callback[0] ) ) {
$class_name = get_class( $callback[0] );
}

// This is needed later for AMP_Validation_Manager::has_parameters_passed_by_reference().
$reflection = new ReflectionMethod( $callback[0], $callback[1] );

// Handle the special case of the class being a widget, in which case the display_callback method should
Expand All @@ -1465,6 +1455,7 @@ public static function get_source( $callback ) {
return null;
}

// The reflection is needed later for AMP_Validation_Manager::has_parameters_passed_by_reference().
if ( ! $reflection ) {
return null;
}
Expand Down Expand Up @@ -1501,8 +1492,8 @@ public static function get_source( $callback ) {
$source['line'] = $reflection->getStartLine();
}

if ( $class_name ) {
$source['function'] = $class_name . '::' . $reflection->getName();
if ( $reflection instanceof ReflectionMethod ) {
$source['function'] = $reflection->getDeclaringClass()->getName() . '::' . $reflection->getName();
} else {
$source['function'] = $reflection->getName();
}
Expand Down

0 comments on commit 16440c1

Please sign in to comment.