mesmo o codigo estando correcto ele apresenta o erro:
Undefined index: Aluno in /Users/roquelaecio/Documents/aluraPHP/Doctrine-Parte01/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php on line 1779
Notice: Undefined index: Aluno in /Users/roquelaecio/Documents/aluraPHP/Doctrine-Parte01/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php on line 1779
PHP Notice: Trying to access array offset on value of type null in /Users/roquelaecio/Documents/aluraPHP/Doctrine-Parte01/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php on line 1783
Codigo abaixo;
<?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();
$alunoRepository = $entityManager->getRepository(Aluno::class);
/**
* @var Aluno[] $alunoList
*/
$alunoList = $alunoRepository->findAll();
foreach ($alunoList as $aluno) {
$telefones = $aluno
->getTelefones()
->map(function (Telefone $telefone) {
return $telefone->getNumero();
})
->toArray();
echo "Id: {$aluno->getId()}\nNome: {$aluno->getNome()}\n\n";
echo "Telefones: " . implode(',', $telefones);
}