Php85.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Polyfill\Php85;
  11. /**
  12. * @author Pierre Ambroise <pierre27.ambroise@gmail.com>
  13. *
  14. * @internal
  15. */
  16. final class Php85
  17. {
  18. public static function get_error_handler(): ?callable
  19. {
  20. $handler = set_error_handler(null);
  21. restore_error_handler();
  22. return $handler;
  23. }
  24. public static function get_exception_handler(): ?callable
  25. {
  26. $handler = set_exception_handler(null);
  27. restore_exception_handler();
  28. return $handler;
  29. }
  30. public static function array_first(array $array)
  31. {
  32. foreach ($array as $value) {
  33. return $value;
  34. }
  35. return null;
  36. }
  37. public static function array_last(array $array)
  38. {
  39. return $array ? current(array_slice($array, -1)) : null;
  40. }
  41. }