Arrays.first().phpt 372 B

123456789101112131415161718192021
  1. <?php
  2. declare(strict_types=1);
  3. use Nette\Utils\Arrays;
  4. use Tester\Assert;
  5. require __DIR__ . '/../bootstrap.php';
  6. Assert::null(Arrays::first([]));
  7. Assert::null(Arrays::first([null]));
  8. Assert::false(Arrays::first([false]));
  9. Assert::same(1, Arrays::first([1, 2, 3]));
  10. $arr = [1, 2, 3];
  11. end($arr);
  12. Assert::same(1, Arrays::first($arr));
  13. Assert::same(3, current($arr));