erro ( ! ) Fatal error: Uncaught TypeError: Argument 1 passed to TocadorDeMusica::adicionarMusicas() must be an instance of SplFixedArray, string given, called in C:\wamp1\www\bismarque\alura\phpcollections\aula1.php on line 20 and defined in C:\wamp1\www\bismarque\alura\phpcollections\TocadorDeMusica.php on line 15 ( ! ) TypeError: Argument 1 passed to TocadorDeMusica::adicionarMusicas() must be an instance of SplFixedArray, string given, called in C:\wamp1\www\bismarque\alura\phpcollections\aula1.php on line 20 in C:\wamp1\www\bismarque\alura\phpcollections\TocadorDeMusica.php on line 15
<?php
//error_reporting(0);
class TocadorDeMusica {
private $musicas;
public function __construct() {
//spldoublylinkedlist lista ligada
$this->musicas = new SplDoublyLinkedList();
$this->musicas->rewind();
}
public function adicionarMusicas(SplFixedArray $musicas) {
for($musicas->rewind(); $musicas->valid(); $musicas->next()) {
$this->musicas->push($musicas->current());
}
$this->musicas->rewind();
}
public function tocarMusica() {
if ($this->musicas->count() === 0) {
echo "Nenhuma música encontrada<br>";
} else {
echo "Tocando música: " . $this->musicas->current() . "<br>";
}
}
public function adicionarMusica($musica) {
$this->musicas->push($musica);
}
public function avancarMusica($musica) {
$this->musicas->next();
if(!$this->musicas->valid()) {
$this->musicas->rewind();
}
}
public function voltarMusica($musica) {
$this->musicas->prev();
if(!$this->musicas->valid()) {
$this->musicas->rewind();
}
}
}
?>