php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74742 ReflectionParameter::getType returns "int", gettype returns "integer"
Submitted: 2017-06-11 07:24 UTC Modified: 2017-06-11 08:02 UTC
From: pierre at lgse dot com Assigned:
Status: Wont fix Package: Variables related
PHP Version: 7.0Git-2017-06-11 (Git) OS: CentOS
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: pierre at lgse dot com
New email:
PHP Version: OS:

 

 [2017-06-11 07:24 UTC] pierre at lgse dot com
Description:
------------
ReflectionParameter::getType should return "integer" and not "int" on a constructor parameter of type "int". 

The types returned by ReflectionParameter::getType and the gettype() function should be the same.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-11 07:37 UTC] spam2 at rhsoft dot net
Provide a code sample - I have written a fuzzy testsuite based on reflection and didn't face such issurs6
 [2017-06-11 07:52 UTC] joey@php.net
<?php
class A {
    public function __construct(int $a){
        $this->a = $a;
    }
}

var_dump((string)(new ReflectionClass('A'))->getConstructor()->getParameters()[0]->getType(), gettype(0));
 [2017-06-11 07:53 UTC] joey@php.net
Above code returns:

string(3) "int"
string(7) "integer"
 [2017-06-11 08:02 UTC] requinix@php.net
-Summary: ReflectionParameter::getType +Summary: ReflectionParameter::getType returns "int", gettype returns "integer" -Status: Open +Status: Wont fix -Package: Reflection related +Package: Variables related
 [2017-06-11 08:02 UTC] requinix@php.net
PHP has decided to go with "int", as seen in
  https://wiki.php.net/rfc/scalar_type_hints_v5
  https://wiki.php.net/rfc/reserve_more_types_in_php_7
so gettype() is the one that doesn't match, however it cannot be changed due to backwards compatibility.
Besides, the is_* functions are generally recommended over gettype() anyways.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC