php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mb at qapp dot de
New email:
PHP Version: OS:

 

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

Reproduce code:
---------------
<?php

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-02 08:52 UTC] johannes@php.net
b is not optional as c isn't.
 [2010-02-02 08:52 UTC] jani@php.net
What he said.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri May 24 15:01:26 2019 UTC