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