bug29523.phpt 703 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Reflection Bug #29523 (ReflectionParameter::isOptional() is incorrect)
  3. --FILE--
  4. <?php
  5. class TestClass
  6. {
  7. }
  8. function optionalTest(TestClass $a, TestClass $b, $c = 3)
  9. {
  10. }
  11. $function = new ReflectionFunction('optionalTest');
  12. $numberOfNotOptionalParameters = 0;
  13. $numberOfOptionalParameters = 0;
  14. foreach($function->getParameters() as $parameter)
  15. {
  16. var_dump($parameter->isOptional());
  17. if ($parameter->isOptional())
  18. {
  19. ++$numberOfOptionalParameters;
  20. }
  21. else
  22. {
  23. ++$numberOfNotOptionalParameters;
  24. }
  25. }
  26. var_dump($function->getNumberOfRequiredParameters());
  27. var_dump($numberOfNotOptionalParameters);
  28. ?>
  29. --EXPECT--
  30. bool(false)
  31. bool(false)
  32. bool(true)
  33. int(2)
  34. int(2)