|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50904 ReflectionClass isOptional() returns wrong result
Submitted: 2010-02-02 08:44 UTC Modified: 2010-02-02 08:52 UTC
From: mb at qapp dot de Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.2.12 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: mb at qapp dot de
New email:
PHP Version: OS:


 [2010-02-02 08:44 UTC] mb at qapp dot de
The method isOptional() doesn't return the correct boolean-value.

Reproduce code:

class Test {
  public function test( $a, $b = 1, $c ) {}

$reflection = new ReflectionClass( 'Test' );

$fparam = $reflection->getMethod( 'test' )->getParameters();

foreach( $fparam as $k => $v ) {
  echo $v->getName() . ' ';
  echo ( $v->isOptional() ? 'is optional' : 'is not optional' ) . "\n";


Expected result:
a is not optional
b is optional
c is not optional

Actual result:
a is not optional
b is not optional
c is not optional


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-02 08:52 UTC]
b is not optional as c isn't.
 [2010-02-02 08:52 UTC]
What he said.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 23 07:01:25 2023 UTC