Question from the PHP8 test

PHP function with named and positional arguments.

Hard

What is the result of the following example?

<?php

class BookRepository
{
    public function findBy(array $criteria = [], array $orderBy = []): array
    {
        return [];
    }
}

$bookRepository = new BookRepository();
$bookList = $bookRepository->findBy(orderBy: ['title' => 'ASC'], ['category' => 1]);

echo count($bookList) === 0 ? "Nothing" : "Some books";
Author: W3D TeamStatus: PublishedQuestion passed 795 times
Edit
3
Community Evaluations
developer avatar
Cyrille
03/10/2023
La valeur de count($bookList) est égale à zéro, par conséquent, l'opérateur ? : retourne la valeur "Nothing".
developer avatar
Auteur anonyme
06/10/2023
Le code s'arrête avant cette ligne à cause des paramètres de la fonction findBy()