php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72906 getType() now returns FQCN with leading \
Submitted: 2016-08-20 16:17 UTC Modified: 2016-08-21 05:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: wouter at wouterj dot nl Assigned: stas (profile)
Status: Closed Package: Reflection related
PHP Version: 7.1.0beta3 OS:
Private report: No CVE-ID: None
 [2016-08-20 16:17 UTC] wouter at wouterj dot nl
Description:
------------
Since PHP 7.1.0-beta3, the ReflectionType::__toString() method returns class names with a leading \. This breaks applications comparing the return value with a class string (for instance, Symfony see https://github.com/symfony/symfony/issues/19677)

This behaviour was introduced by https://github.com/php/php-src/pull/2068

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

function test(PDO $reflection) {}

$reflection = new ReflectionFunction('test');

var_dump(PDO::class === (string) $reflection->getParameters()[0]->getType());
var_dump((string) $reflection->getParameters()[0]->getType());

Expected result:
----------------
bool(true)
string(3) "PDO"

Actual result:
--------------
bool(false)
string(3) "\PDO"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-20 16:35 UTC] requinix@php.net
-Status: Open +Status: Verified
 [2016-08-20 16:35 UTC] requinix@php.net
It's being reverted. http://php.markmail.org/thread/7h5nocall4bhsaeh
 [2016-08-21 05:43 UTC] stas@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: stas
 [2016-08-21 05:43 UTC] stas@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 12:01:30 2024 UTC