php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77326 ReflectionClass::getReflectionConstant() returns false instead of exception
Submitted: 2018-12-20 13:52 UTC Modified: 2021-05-22 09:11 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:0 of 1 (0.0%)
From: me at vasekpurchart dot cz Assigned:
Status: Wont fix Package: Reflection related
PHP Version: 7.2 OS:
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: me at vasekpurchart dot cz
New email:
PHP Version: OS:

 

 [2018-12-20 13:52 UTC] me at vasekpurchart dot cz
Description:
------------
ReflectionClass::getReflectionConstant() returns false when constant is not found. This is unexpected because all other methods like getMethod() or getProperty() which have equivalent signatures and fuction throw a ReflectionException.

The return value is also not documented.

Test script:
---------------
```
<?php

class Foo {}

$barClassReflection = new ReflectionClass(Foo::class);
var_dump($barClassReflection->getReflectionConstant('XXX'));
```

https://3v4l.org/k09Q8

Expected result:
----------------
Throw exception like the other methods on ReflectionClass to behave consistently and document this behavior.


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-20 23:37 UTC] cmb@php.net
-PHP Version: 7.3.0 +PHP Version: 7.2
 [2018-12-27 03:24 UTC]
The following pull request has been associated:

Patch Name: Fixed bug #77326 (ReflectionClass::getReflectionConstant() returns false instead of exception)
On GitHub:  https://github.com/php/php-src/pull/3721
Patch:      https://github.com/php/php-src/pull/3721.patch
 [2021-05-22 09:11 UTC] krakjoe@php.net
-Status: Open +Status: Wont fix
 [2021-05-22 09:11 UTC] krakjoe@php.net
Because of the broken bc, this was rejected on the PR.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 03:01:28 2024 UTC