A linha 22 é a da data de nascimento, tentei colar o código da aula pensando que eu avia feito algo de errado mas não resolveu
erro:
PHP Fatal error: Uncaught TypeError: Argument 2 passed to Alunos\Student::__construct() must be of the type string, null given, called in C:\Users\pheli\OneDrive\Documentos\php\Alunos\buscarAluno.php on line 22 and defined in C:\Users\pheli\OneDrive\Documentos\php\Alunos\Student.php:11 Stack trace:
#0 C:\Users\pheli\OneDrive\Documentos\php\Alunos\buscarAluno.php(22): Alunos\Student->__construct(1, NULL, Object(DateTimeImmutable))
#1 {main} thrown in C:\Users\pheli\OneDrive\Documentos\php\Alunos\Student.php on line 11
Fatal error: Uncaught TypeError: Argument 2 passed to Alunos\Student::__construct() must be of the type string, null given, called in C:\Users\pheli\OneDrive\Documentos\php\Alunos\buscarAluno.php on line 22 and defined in C:\Users\pheli\OneDrive\Documentos\php\Alunos\Student.php:11 Stack trace:
#0 C:\Users\pheli\OneDrive\Documentos\php\Alunos\buscarAluno.php(22): Alunos\Student->__construct(1, NULL, Object(DateTimeImmutable))
#1 {main} thrown in C:\Users\pheli\OneDrive\Documentos\php\Alunos\Student.php on line 11
$databasePath = __DIR__ . '/banco.sqlite';
$pdo = new PDO('sqlite:' . $databasePath);
$statement = $pdo->query('SELECT * FROM students;');
$studentDataList = $statement->fetchAll(PDO::FETCH_ASSOC);
$studentList = [];
foreach ($studentDataList as $studentData) {
$studentList[] = new Student(
$studentData['id'],
$studentData['name'],
new \DateTimeImmutable($studentData['birth_date'])
);
}
var_dump($studentList);
o construtor não mudei nada