Bom dia, estou com dificuldade na hora de inserir um aluno ao banco de dados, ele está retornando o seguinte erro:
c:\curso php\doctrine>php commands\criar-aluno.php "Marcos Silva" "937612857" "77981442272" "991091311"
PHP Fatal error: A function with return type must return a value in C:\curso php\doctrine\src\Entity\Telefone.php on line 45
Fatal error: A function with return type must return a value in C:\curso php\doctrine\src\Entity\Telefone.php on line 45
``
o meu criar-aluno.php
<?php
use Alura\Doctrine\Entity\Aluno;
use Alura\Doctrine\Entity\Telefone;
use Alura\Doctrine\Helper\EntityManagerFactory;
require_once __DIR__ . '/../vendor/autoload.php';
$entityManagerFactory = new EntityManagerFactory();
$entityManager = $entityManagerFactory->getEntityManager();
$aluno = new Aluno();
$aluno->setNome($argv[1]);
for ($i = 2; $i < $argc; $i++){
$numeroTelefone = $argv[$i];
$telefone = new Telefone();
$telefone->setNumero($numeroTelefone);
$entityManager->presist($telefone);
$aluno->addTelefone($telefone);
}
$entityManager->persist($aluno);
$entityManager->flush();
o aluno.php
<?php
namespace Alura\Doctrine\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use doctrine\Common\Colections\Collenction;
/**
* @Entity
*/
class Aluno
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
private $id;
/**
* @Column(type="string")
*/
private $nome;
/**
* @OneToMany(targetEntity="Telefone", mappedBy="aluno")
*/
private $telefones;
public function __construct()
{
$this->telefones = new arrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function getNome(): string
{
return $this->nome;
}
public function setNome(string $nome): self
{
$this->nome = $nome;
return $this;
}
public function addTelefone(Telefone $telefone){
$this->telefones->add($telefone);
$telefone->setAluno($this);
return $this;
}
public function getTelefones(): Collection{
return $this->telefones;
}
}
e o telefone.php
<?php
namespace alura\Doctrine\Entity;
/**
* @Entity
*/
class Telefone {
/**
* @Id
*@GeratedValue
*@Column(type="integer")
*/
private $id;
/**
* @Column (type="string")
*/
private $numero;
/**
* @ManyToOne (targetEntity="Aluno")
*/
private $aluno;
public function getId(): int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
}
public function getNumero(): string
{
return $this->numero;
}
public function setNumero(string $numero): self
{
$this->numero = $numero;
return;
}
public function getAluno(): Aluno
{
return $this->aluno;
}
public function setAluno(Aluno $aluno): self
{
$this->aluno = $aluno;
return $this;
}
}
?>
o que pode ser?