php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74879 Wrong path returned by ReflectionClass::getFileName
Submitted: 2017-07-07 23:13 UTC Modified: -
From: waldermort at gmail dot com Assigned:
Status: Open Package: Reflection related
PHP Version: 7.1.7 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: waldermort at gmail dot com
New email:
PHP Version: OS:

 

 [2017-07-07 23:13 UTC] waldermort at gmail dot com
Description:
------------
When a StreamWrapper is used in combination with the ReflectionClass API, the scheme is stripped from the path returned by getFileName().

For example: If a create an in-memory file at 'vfs:://foo/bar.php' which contains valid PHP code (something like '<?php namespace Suite { class Test {} }'). I can include or exec the file and create an instance of the class.

Note, this is done as part of a test suite for a package which generates PHP classes from templates.

So:

include 'vfs:://foo/bar.php';

$inst = new Suite\Test();
$refl = new \ReflectionClass($inst);

I would now expect $refl->getFileName() to return 'vfs:://foo/bar.php', but it actually returns '/foo/bar.php'.

If this is the intended behaviour, perhaps the docs could be updated to mention it.


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 12:01:26 2019 UTC