Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weierophinney/php-import-test
https://github.com/weierophinney/php-import-test
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/weierophinney/php-import-test
- Owner: weierophinney
- Created: 2016-08-09T22:26:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-09T22:26:38.000Z (over 8 years ago)
- Last Synced: 2024-11-06T20:53:13.582Z (about 2 months ago)
- Language: PHP
- Size: 1000 Bytes
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Test for zendframework/zend-log#56
This is a repository designed to test how PHP resolves imports when the
imported name might conflict with a class name from the current namespace.My hypothesis was that the imported name takes precedence.
This repository proves that hypothesis.
## Testing
Clone the repository:
```bash
$ git clone https://github.com/weierophinney/php-import-test.git
```Descend into it:
```bash
$ cd php-import-test
```Dump the autoloader:
```bash
$ composer dump-autoload
```Run the code:
```bash
$ php test.php
```You should see:
```text
In Foo\Command:
Plugin Manager class: Foo\PluginManager
```## Observations
Both the namespaces `Foo` and `Foo\Writer` contain a class named
`PluginManager`. `Foo\Writer\Output` imports the former (`Foo\PluginManager`),
and instantiates it during initialization.We can observe that this is what happens when we invoke the command. No errors
are emitted.I observed the exact same behavior in both PHP 5.6 and 7.0.