Bug #53533

Class reflection assumes reverse PSR-0, can lead to fail in autoloader

Added by Christian Jul Jensen over 7 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Reflection
Target version:
-
Start date:
2013-11-11
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:
hard

Description

When gathering info about a package Flow currently assumes PSR-0 as bijective which is not the case.

Ie.

The file Pheanstalk/PheanstalkInterface.php does not necessarily hold the class \Pheanstalk\PheanstalkInterface, this situation has already been handled for files containing sideeffects rather than classes fx. autoload.php

The problem is that according to PSR-0 the file can hold the class \Pheanstalk_PheanstalkInterface, and thus the following can happen;

1. Flow analyzes filesystem and adds Pheanstalk/PheanstalkInterface.php to files to be reflected, expecting \Pheanstalk\PheanstalkInterface.
2. During the reflection some other class implements \Pheanstalk_PheanstalkInterface and the autoloader correctly loads this from Pheanstalk/PheanstalkInterface.php
3. The autoloader reaches Pheanstalk/PheanstalkInterface.php for inclusion and fails with 'Fatal error: Cannot redeclare class Pheanstalk_PheanstalkInterface'

This is not trivial to handle since the file could actually hold the expected namespaced class.

Possible ways to fix it:
  • During compiletime let ClassLoader notify ReflectionService on included files so it can be removed from further reflection
  • Let ReflectionService pre-analyze files for expected classes.

No data to display

Also available in: Atom PDF