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: -
From: tandre@php.net Assigned:
Status: Open 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

 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 21 03:03:36 2021 UTC