Updated PhpArray to expand paths using __DIR__ #5880

Merged
merged 3 commits into from Feb 28, 2014

Projects

None yet

5 participants

@spiffyjr
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
Member

Same for __FILE__

@spiffyjr
Contributor

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
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
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
Contributor
devosc commented Feb 28, 2014

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

@weierophinney weierophinney added a commit that referenced this pull request Feb 28, 2014
@weierophinney weierophinney [#5880] CS fixes
- EOF ending
2b75e3b
@weierophinney weierophinney added a commit that referenced this pull request Feb 28, 2014
@weierophinney weierophinney Merge branch 'feature/5880' into develop
Close #5880
20a9f88
@weierophinney weierophinney merged commit 700729e into zendframework:develop Feb 28, 2014

1 check failed

default The Travis CI build could not complete due to an error
Details
@weierophinney weierophinney added this to the 2.3.0 milestone Feb 28, 2014
@weierophinney weierophinney self-assigned this Feb 28, 2014
@DASPRiD
Member
DASPRiD commented Feb 28, 2014

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

@weierophinney weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge pull request zendframework/zendframework#5880 from spiffyjr/fea…
…ture/php-array-fix-dir

Updated PhpArray to expand paths using __DIR__
ac99f6a
@weierophinney weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
@weierophinney weierophinney [zendframework/zendframework#5880] CS fixes
- EOF ending
a1c0f25
@weierophinney weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'feature/5880' into develop 0161ac6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment