In php, I'm wondering if the following are functionally equivalent?
class Foo {
public $bar;
...
public function setBar($bar) {
$this->bar = (array)$bar;
}
}
class Foo {
public $bar;
...
public function setBar(array $bar) {
$this->bar = $bar;
}
}
Which of the two is considered best practice? Does it make sense to do both?:
class Foo {
public $bar;
...
public function setBar(array $bar) {
$this->bar = (array)$bar;
}
}