|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
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-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 13:01:29 2024 UTC