bootstrap.php 831B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', 1);
  4. $composer_autoload = __DIR__ . "/../vendor/autoload.php";
  5. require_once($composer_autoload);
  6. /**
  7. * Used in many of the tests to to output known-correct
  8. * strings for use in tests.
  9. */
  10. function friendlyBinary($in)
  11. {
  12. if (is_array($in)) {
  13. $out = array();
  14. foreach ($in as $line) {
  15. $out[] = friendlyBinary($line);
  16. }
  17. return "[" . implode(", ", $out) . "]";
  18. }
  19. if (strlen($in) == 0) {
  20. return $in;
  21. }
  22. /* Print out binary data with PHP \x00 escape codes,
  23. for builting test cases. */
  24. $chars = str_split($in);
  25. foreach ($chars as $i => $c) {
  26. $code = ord($c);
  27. if ($code < 32 || $code > 126) {
  28. $chars[$i] = "\\x" . bin2hex($c);
  29. }
  30. }
  31. return implode($chars);
  32. }