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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC