php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79515 Incorrect ReflectionParameter information for bitset methods
Submitted: 2020-04-23 14:58 UTC Modified: 2021-09-21 15:02 UTC
From: tandre@php.net Assigned:
Status: Wont fix Package: Bitset (PECL)
PHP Version: Irrelevant OS:
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:
Package:
Bug Type:
Summary:
From: tandre@php.net
New email:
PHP Version: OS:

 

 [2020-04-23 14:58 UTC] tandre@php.net
Description:
------------
class BitSet is missing reflection parameter information for various methods.
For example, I'd assume that andOp() would take one argument (another BitSet to add to it).

Note that adding param and return type information might be considered a backwards incompatible change if people write classes that override BitSet. I haven't checked if anyone does that.

A compact rendering of the information available from reflection is below (generated by https://github.com/phan/phan/blob/master/tool/make_stubs)

class BitSet {

    // methods
    public function __construct($value) {}
    public function andOp() {}
    public function andNotOp() {}
    public function cardinality() {}
    public function clear() {}
    public static function fromArray($arr) {}
    public static function fromString($str) {}
    public static function fromRawValue($str) {}
    public function get($index) {}
    public function getRawValue() {}
    public function intersects() {}
    public function isEmpty() {}
    public function length() {}
    public function nextClearBit() {}
    public function nextSetBit() {}
    public function orOp() {}
    public function previousClearBit() {}
    public function previousSetBit() {}
    public function set() {}
    public function size() {}
    public function toArray() {}
    public function xorOp() {}
    public function __toString() {}
}


Test script:
---------------
php > var_export((new ReflectionMethod('BitSet', 'andOp'))->getParameters());
array (
)
php > $x = new BitSet(128);
php > $x->andOp();
Warning: BitSet::andOp() expects exactly 1 parameter, 0 given in php shell code on line 1
php > $x->andOp('invalid');
Warning: BitSet::andOp() expects parameter 1 to be BitSet, string given in php shell code on line 1


Expected result:
----------------
ReflectionParameter information should be available for all functions. For example, getParameters() should probably return an array with one Parameter of ReflectionNamedType BitSet.

Actual result:
--------------
Many methods have no reflection information available for parameters

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-21 14:55 UTC] cmb@php.net
It seems to me this extension is abandoned (latest commit almost
four years ago, and no comment on my Xmas present[1] from last
year).  If you like to apply as maintainer, just send mail to the
pecl-dev list (maybe also try to contact Will).

[1] <https://github.com/php/pecl-numbers-bitset/pull/13>
 [2021-09-21 15:02 UTC] tandre@php.net
-Status: Open +Status: Wont fix
 [2021-09-21 15:02 UTC] tandre@php.net
I think it would be easier to close this as "wontfix" if it's abandoned and nobody's planning to do anything, including me, I stopped using this extension shortly after filing this issue.

It turned out that I could instead set bytes of strings manually with similar performance.

Also, the bitset approach was unsafe when I looked at the source code: it would directly modify the bytes of strings, even if the zend_string had a reference count of more than 2, and I don't think the zend_string hash was invalidated, which would break hash table insertions/lookups.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 19:01:31 2024 UTC