Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Updated PhpArray to expand paths using __DIR__ #5880

Merged
merged 3 commits into from
Feb 28, 2014
Merged

Updated PhpArray to expand paths using __DIR__ #5880

merged 3 commits into from
Feb 28, 2014

Conversation

spiffyjr
Copy link
Contributor

When using Apigility config files with __DIR__ are var_exported causing the real path to be written instead. This is an issue for development/production setups where the directory may vary from server to server. This change just does a str_replace on the path of the file being written with the __DIR__ constant.

@Ocramius
Copy link
Member

Same for __FILE__

@spiffyjr
Copy link
Contributor Author

That was fast. @Ocramius do you see anyway to reduce the need to copy the entire toFile() method from the AbstractWriter? I couldn't seem to find a way to make this method less of a copy/pasta.

@weierophinney
Copy link
Member

@Ocramius what would be the use case for that in configuration files, exactly? __FILE__ always evaluates to the current file -- I can't think of any time I would reference the config file's path as a configuration value, but __DIR__ would be used often.

@Ocramius
Copy link
Member

@weierophinney if magic constants are going to be replaced, then better handle it completely, no?

__LINE__ and __FILE__ are sufficient as a feature-set here.

@spiffyjr the only way I can think of (without subclassing) is passing some kind of visitor to the abstract writer, but that seems overkill for such a small use case

@devosc
Copy link
Contributor

devosc commented Feb 28, 2014

@spiffyjr, override the toString method instead? @Ocramius, looks like __DIR__ is being restored, not replaced.

weierophinney added a commit that referenced this pull request Feb 28, 2014
Updated PhpArray to expand paths using __DIR__
weierophinney added a commit that referenced this pull request Feb 28, 2014
- EOF ending
weierophinney added a commit that referenced this pull request Feb 28, 2014
@weierophinney weierophinney merged commit 700729e into zendframework:develop Feb 28, 2014
@weierophinney weierophinney added this to the 2.3.0 milestone Feb 28, 2014
@weierophinney weierophinney self-assigned this Feb 28, 2014
@DASPRiD
Copy link
Member

DASPRiD commented Feb 28, 2014

Just wondering, what about the other writers? They have DIR support as well.

weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
…ture/php-array-fix-dir

Updated PhpArray to expand paths using __DIR__
weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants