PhpMigration\Utils\ParserHelper::isSameClass PHP Méthode

isSameClass() public static méthode

public static isSameClass ( $name, $const )
    public static function isSameClass($name, $const)
    {
        if (!is_string($name) && !method_exists($name, '__toString')) {
            return false;
        }
        return strcasecmp($name, $const) === 0;
    }

Usage Example

 public function leaveNode($node)
 {
     /**
      * set_exception_handler() is no longer guaranteed to receive Exception
      * objects
      *
      * @see http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.error-handling
      */
     if (!$node instanceof Expr\FuncCall || !ParserHelper::isSameFunc($node->name, 'set_exception_handler') || !isset($node->args[0])) {
         return;
     }
     $affected = true;
     $certain = false;
     $callback = $node->args[0]->value;
     if ($callback instanceof Expr\Closure) {
         if (!isset($callback->params[0]) || !isset($callback->params[0]->type)) {
             $affected = false;
             $certain = true;
         } elseif (ParserHelper::isSameClass($callback->params[0]->type, 'Exception')) {
             $affected = true;
             $certain = true;
         }
     }
     if ($affected) {
         $this->addSpot('WARNING', $certain, 'set_exception_handler() is no longer guaranteed to receive Exception objects');
     }
 }