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

Commit

Permalink
Revert "Merge branch 'superdweebie-rand-bugfix'"
Browse files Browse the repository at this point in the history
This reverts commit 002ce3dee6107f2c71af8e7ce0ed1f43693ddadf, reversing
changes made to 0023a96e4756112661c11dbf4e293f4be110809a.

Note: we will need to revert this revert when merging develop to master for the
2.3.0 release. See http://git-scm.com/blog/2010/03/02/undoing-merges.html - the
section on "Reverting the Revert," for details.
  • Loading branch information
weierophinney committed Aug 19, 2013
1 parent 20fe333 commit 44bad20
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 276 deletions.
36 changes: 7 additions & 29 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,13 @@ class Factory
*
* @param string $filename
* @param bool $returnConfigObject
* @param bool $useIncludePath
* @return array|Config
* @throws Exception\InvalidArgumentException
* @throws Exception\RuntimeException
*/
public static function fromFile($filename, $returnConfigObject = false, $useIncludePath = false)
public static function fromFile($filename, $returnConfigObject = false)
{
$filepath = $filename;
if (!file_exists($filename)) {
if (!$useIncludePath) {
throw new Exception\RuntimeException(sprintf(
'Filename "%s" cannot be found relative to the working directory',
$filename
));
}

$fromIncludePath = stream_resolve_include_path($filename);
if (!$fromIncludePath) {
throw new Exception\RuntimeException(sprintf(
'Filename "%s" cannot be found relative to the working directory or the include_path ("%s")',
$filename,
get_include_path()
));
}
$filepath = $fromIncludePath;
}

$pathinfo = pathinfo($filepath);
$pathinfo = pathinfo($filename);

if (!isset($pathinfo['extension'])) {
throw new Exception\RuntimeException(sprintf(
Expand All @@ -98,14 +77,14 @@ public static function fromFile($filename, $returnConfigObject = false, $useIncl
$extension = strtolower($pathinfo['extension']);

if ($extension === 'php') {
if (!is_file($filepath) || !is_readable($filepath)) {
if (!is_file($filename) || !is_readable($filename)) {
throw new Exception\RuntimeException(sprintf(
"File '%s' doesn't exist or not readable",
$filename
));
}

$config = include $filepath;
$config = include $filename;
} elseif (isset(static::$extensions[$extension])) {
$reader = static::$extensions[$extension];
if (!$reader instanceof Reader\ReaderInterface) {
Expand All @@ -114,7 +93,7 @@ public static function fromFile($filename, $returnConfigObject = false, $useIncl
}

/** @var Reader\ReaderInterface $reader */
$config = $reader->fromFile($filepath);
$config = $reader->fromFile($filename);
} else {
throw new Exception\RuntimeException(sprintf(
'Unsupported config file extension: .%s',
Expand All @@ -130,15 +109,14 @@ public static function fromFile($filename, $returnConfigObject = false, $useIncl
*
* @param array $files
* @param bool $returnConfigObject
* @param bool $useIncludePath
* @return array|Config
*/
public static function fromFiles(array $files, $returnConfigObject = false, $useIncludePath = false)
public static function fromFiles(array $files, $returnConfigObject = false)
{
$config = array();

foreach ($files as $file) {
$config = ArrayUtils::merge($config, static::fromFile($file, false, $useIncludePath));
$config = ArrayUtils::merge($config, static::fromFile($file));
}

return ($returnConfigObject) ? new Config($config) : $config;
Expand Down
139 changes: 0 additions & 139 deletions src/Reader/JavaProperties.php

This file was deleted.

23 changes: 0 additions & 23 deletions test/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
class FactoryTest extends \PHPUnit_Framework_TestCase
{
protected $tmpFiles = array();
protected $originalIncludePath;

protected function getTestAssetFileName($ext)
{
Expand All @@ -27,16 +26,8 @@ protected function getTestAssetFileName($ext)
return $this->tmpfiles[$ext];
}

public function setUp()
{
$this->originalIncludePath = get_include_path();
set_include_path(__DIR__ . '/TestAssets');
}

public function tearDown()
{
set_include_path($this->originalIncludePath);

foreach ($this->tmpFiles as $file) {
if (file_exists($file)) {
if (!is_writable($file)) {
Expand Down Expand Up @@ -111,20 +102,6 @@ public function testFromIniAndXmlAndPhpFiles()
$this->assertEquals('baz', $config['last']['bar']);
}

public function testFromIniAndXmlAndPhpFilesFromIncludePath()
{
$files = array (
'Ini/include-base.ini',
'Xml/include-base2.xml',
'Php/include-base3.php',
);
$config = Factory::fromFiles($files, false, true);

$this->assertEquals('bar', $config['base']['foo']);
$this->assertEquals('baz', $config['test']['bar']);
$this->assertEquals('baz', $config['last']['bar']);
}

public function testReturnsConfigObjectIfRequestedAndArrayOtherwise()
{
$files = array (
Expand Down
79 changes: 0 additions & 79 deletions test/Reader/JavaPropertiesTest.php

This file was deleted.

3 changes: 0 additions & 3 deletions test/Reader/TestAssets/JavaProperties/include-base.properties

This file was deleted.

This file was deleted.

0 comments on commit 44bad20

Please sign in to comment.