Php 请解释这个函数中的参数

Php 请解释这个函数中的参数,php,Php,请参见下面的代码函数isInMatchingSet(卡$Card) 通常我看到的是“一美元二美元” 当我编写代码时,从来没有像“Card”这样的静态值 这张卡是什么?我猜它是类名。 我找不到一个很好的解释,所以我想 我在这里问得太多了 <?php /** * Models an individual card. */ class Card { /** * @var string */ private $number; /** *

请参见下面的代码函数isInMatchingSet(卡$Card) 通常我看到的是“一美元二美元” 当我编写代码时,从来没有像“Card”这样的静态值 这张卡是什么?我猜它是类名。 我找不到一个很好的解释,所以我想 我在这里问得太多了

<?php

/**
 * Models an individual card.
 */
class Card
{
    /**
     * @var string
     */
    private $number;

    /**
     * @var string
     */
    private $suit;

    /**
     * @param string $number
     * @param string $suit
     */
    public function __construct($number, $suit)
    {
        $this->number = $number;
        $this->suit   = $suit;
    }

    /**
     * @return string
     */
    public function getNumber()
    {
        return $this->number;
    }

    /**
     * @return string
     */
    public function getSuit()
    {
        return $this->suit;
    }

    /**
     * Returns true if the given card is in the same set
     * @param Card $card
     * @return bool
     * @assert (new Card(3, 'h'), new Card(3, 's')) == true
     * @assert (new Card(4, 'h'), new Card(3, 's')) == false
     */
    public function isInMatchingSet(Card $card)
    {
        return ($this->getNumber() == $card->getNumber());
    }
}
这被称为。它是在PHP5中引入的

PHP5引入了类型暗示。函数现在可以强制参数为对象(通过在函数原型中指定类的名称)、接口、数组(自PHP5.1起)或可调用(自PHP5.4起)。但是,如果将NULL用作默认参数值,则允许它作为以后任何调用的参数

示例:

// Array — expects an array
function test(Array $array) {
}

// Interface — expects an object of a class implementing the given interface
function test(Countable $interface) {
}

// Class — expects an object of that class (or any sub-classes)
function test(Exception $object) {
}

// Callable  — expects any callable object
function test(callable $callable) {
}
这就是所谓的。它是在PHP5中引入的

PHP5引入了类型暗示。函数现在可以强制参数为对象(通过在函数原型中指定类的名称)、接口、数组(自PHP5.1起)或可调用(自PHP5.4起)。但是,如果将NULL用作默认参数值,则允许它作为以后任何调用的参数

示例:

// Array — expects an array
function test(Array $array) {
}

// Interface — expects an object of a class implementing the given interface
function test(Countable $interface) {
}

// Class — expects an object of that class (or any sub-classes)
function test(Exception $object) {
}

// Callable  — expects any callable object
function test(callable $callable) {
}

指示参数是/应该是哪个类的。谢谢,我假设是,但不太确定指示参数是/应该是哪个类的。谢谢,我假设是,但不太确定