1
请看下面的代码函数isInMatchingSet(Card $ card) 正在服用“card $ card”通常我看过“$ one,$ two” 当我编码时永远不会有像“卡“ 那么这里的卡是什么?我在猜测它的类名。 我找不到一个很好的解释,所以我想在这里问 。请说明这个函数的参数
<?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());
}
}
指示参数是哪个类/应 –
它是[类型提示]的(http://php.net/manual/en/language.oop5.typehinting.php )。 – naththedeveloper
谢谢我这么认为,但并不太确定 –