Bug #72906 [NEW]: getType() now returns FQCN with leading \

From: Date: Sat, 20 Aug 2016 16:17:37 +0000
Subject: Bug #72906 [NEW]: getType() now returns FQCN with leading \
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203423@lists.php.net to get a copy of this message
From:             wouter at wouterj dot nl
Operating system: 
PHP version:      7.1.0beta3
Package:          Reflection related
Bug Type:         Bug
Bug description:getType() now returns FQCN with leading \

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"

-- 
Edit bug report at https://bugs.php.net/bug.php?id=72906&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72906&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72906&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72906&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72906&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72906&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72906&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72906&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72906&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72906&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72906&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72906&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72906&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72906&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72906&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72906&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72906&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72906&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72906&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72906&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72906&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#203423) next »