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

Commit

Permalink
[PSR-2] fixers=braces,elseif,short_tag,php_closing_tag,trailing_space…
Browse files Browse the repository at this point in the history
…s,linefeed

Applied php-cs-fixer --fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed
  • Loading branch information
Maks3w committed Jul 12, 2012
1 parent 06bba40 commit 24c143c
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 131 deletions.
12 changes: 6 additions & 6 deletions src/Factory.php
Expand Up @@ -43,32 +43,32 @@ class Factory
* Read a config from a file.
*
* @param string $filename
* @param boolean $returnConfigObject
* @param boolean $returnConfigObject
* @return array|Config
* @throws Exception\InvalidArgumentException
* @throws Exception\RuntimeException
*/
public static function fromFile($filename, $returnConfigObject = false)
{
$pathinfo = pathinfo($filename);

if (!isset($pathinfo['extension'])) {
throw new Exception\RuntimeException(sprintf(
'Filename "%s" is missing an extension and cannot be auto-detected',
$filename
));
}

$extension = strtolower($pathinfo['extension']);

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

$config = include $filename;
} elseif (isset(self::$extensions[$extension])) {
$reader = self::$extensions[$extension];
Expand All @@ -93,7 +93,7 @@ public static function fromFile($filename, $returnConfigObject = false)
* Read configuration from multiple files and merge them.
*
* @param array $files
* @param boolean $returnConfigObject
* @param boolean $returnConfigObject
* @return array|Config
*/
public static function fromFiles(array $files, $returnConfigObject = false)
Expand Down
2 changes: 1 addition & 1 deletion src/Processor/Filter.php
Expand Up @@ -56,7 +56,7 @@ public function getFilter()

/**
* Process
*
*
* @param Config $config
* @return Config
* @throws Exception\InvalidArgumentException
Expand Down
4 changes: 2 additions & 2 deletions src/Reader/Ini.php
Expand Up @@ -86,7 +86,7 @@ function($error, $message = '', $file = '', $line = 0) use ($filename) {
);
$ini = parse_ini_file($filename, true);
restore_error_handler();

return $this->process($ini);
}

Expand Down Expand Up @@ -114,7 +114,7 @@ function($error, $message = '', $file = '', $line = 0) {
);
$ini = parse_ini_string($string, true);
restore_error_handler();

return $this->process($ini);
}

Expand Down
18 changes: 9 additions & 9 deletions src/Reader/Json.php
Expand Up @@ -46,15 +46,15 @@ public function fromFile($filename)
$filename
));
}

$this->directory = dirname($filename);

try {
$config = JsonFormat::decode(file_get_contents($filename), JsonFormat::TYPE_ARRAY);
} catch (JsonException\RuntimeException $e) {
throw new Exception\RuntimeException($e->getMessage());
}
}

return $this->process($config);
}

Expand All @@ -73,19 +73,19 @@ public function fromString($string)
}

$this->directory = null;

try {
$config = JsonFormat::decode($string, JsonFormat::TYPE_ARRAY);
} catch (JsonException\RuntimeException $e) {
throw new Exception\RuntimeException($e->getMessage());
}
}

return $this->process($config);
}

/**
* Process the array for @include
*
*
* @param array $data
* @return array
* @throws Exception\RuntimeException
Expand All @@ -103,7 +103,7 @@ protected function process(array $data)
$reader = clone $this;
unset($data[$key]);
$data = array_replace_recursive($data, $reader->fromFile($this->directory . '/' . $value));
}
}
}
return $data;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Reader/Xml.php
Expand Up @@ -80,7 +80,7 @@ function($error, $message = '', $file = '', $line = 0) use ($filename) {
);
$return = $this->process();
restore_error_handler();

return $return;
}

Expand All @@ -98,7 +98,7 @@ public function fromString($string)
return array();
}
$this->reader = new XMLReader();

$this->reader->xml($string, null, LIBXML_XINCLUDE);

$this->directory = null;
Expand All @@ -113,7 +113,7 @@ function($error, $message = '', $file = '', $line = 0) {
);
$return = $this->process();
restore_error_handler();

return $return;
}

Expand Down Expand Up @@ -175,7 +175,7 @@ protected function processNextElement()
$text .= $this->reader->value;
}
}

return $children ?: $text;
}

Expand Down
24 changes: 12 additions & 12 deletions src/Reader/Yaml.php
Expand Up @@ -23,21 +23,21 @@ class Yaml implements ReaderInterface
{
/**
* Directory of the YAML file
*
*
* @var string
*/
protected $directory;

/**
* YAML decoder callback
*
*
* @var callable
*/
protected $yamlDecoder;

/**
* Constructor
*
*
* @param callable $yamlDecoder
*/
public function __construct($yamlDecoder = null)
Expand Down Expand Up @@ -99,14 +99,14 @@ public function fromFile($filename)
if (null === $this->getYamlDecoder()) {
throw new Exception\RuntimeException("You didn't specify a Yaml callback decoder");
}

$this->directory = dirname($filename);

$config = call_user_func($this->getYamlDecoder(), file_get_contents($filename));
if (null === $config) {
throw new Exception\RuntimeException("Error parsing YAML data");
}
}

return $this->process($config);
}

Expand All @@ -126,14 +126,14 @@ public function fromString($string)
if (empty($string)) {
return array();
}

$this->directory = null;

$config = call_user_func($this->getYamlDecoder(), $string);
if (null === $config) {
throw new Exception\RuntimeException("Error parsing YAML data");
}
}

return $this->process($config);
}

Expand All @@ -157,7 +157,7 @@ protected function process(array $data)
$reader = clone $this;
unset($data[$key]);
$data = array_replace_recursive($data, $reader->fromFile($this->directory . '/' . $value));
}
}
}
return $data;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ReaderPluginManager.php
Expand Up @@ -20,7 +20,7 @@ class ReaderPluginManager extends AbstractPluginManager
{
/**
* Default set of readers
*
*
* @var array
*/
protected $invokableClasses = array(
Expand All @@ -33,7 +33,7 @@ class ReaderPluginManager extends AbstractPluginManager
/**
* Validate the plugin
* Checks that the reader loaded is an instance of Reader\ReaderInterface.
*
*
* @param Reader\ReaderInterface $plugin
* @return void
* @throws Exception\InvalidArgumentException if invalid
Expand Down
4 changes: 2 additions & 2 deletions src/Writer/AbstractWriter.php
Expand Up @@ -38,12 +38,12 @@ public function toFile($filename, $config, $exclusiveLock = true)
if (empty($filename)) {
throw new Exception\InvalidArgumentException('No file name specified');
}

$flags = 0;
if ($exclusiveLock) {
$flags |= LOCK_EX;
}

set_error_handler(
function($error, $message = '', $file = '', $line = 0) use ($filename) {
throw new Exception\RuntimeException(sprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/Xml.php
Expand Up @@ -71,7 +71,7 @@ protected function addBranch($branchName, array $config, XMLWriter $writer)
$writer->startElement($branchName);
$branchType = 'string';
}
} else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
} elseif ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
throw new Exception\RuntimeException('Mixing of string and numeric keys is not allowed');
}

Expand Down
8 changes: 4 additions & 4 deletions src/Writer/Yaml.php
Expand Up @@ -21,14 +21,14 @@ class Yaml extends AbstractWriter
{
/**
* YAML encoder callback
*
*
* @var callable
*/
protected $yamlEncoder;

/**
* Constructor
*
*
* @param callable|string|null $yamlEncoder
*/
public function __construct($yamlEncoder = null)
Expand Down Expand Up @@ -80,12 +80,12 @@ public function processConfig(array $config)
if (null === $this->getYamlEncoder()) {
throw new Exception\RuntimeException("You didn't specify a Yaml callback encoder");
}

$config = call_user_func($this->getYamlEncoder(), $config);
if (null === $config) {
throw new Exception\RuntimeException("Error generating YAML data");
}

return $config;
}
}
12 changes: 5 additions & 7 deletions test/ConfigTest.php
Expand Up @@ -483,8 +483,7 @@ public function testUnsettingFirstElementDuringForeachDoesNotSkipAnElement()
), true);

$keyList = array();
foreach ($config as $key => $value)
{
foreach ($config as $key => $value) {
$keyList[] = $key;
if ($key == 'first') {
unset($config->$key); // uses magic Zend\Config\Config::__unset() method
Expand All @@ -509,8 +508,7 @@ public function testUnsettingAMiddleElementDuringForeachDoesNotSkipAnElement()
), true);

$keyList = array();
foreach ($config as $key => $value)
{
foreach ($config as $key => $value) {
$keyList[] = $key;
if ($key == 'second') {
unset($config->$key); // uses magic Zend\Config\Config::__unset() method
Expand All @@ -535,8 +533,7 @@ public function testUnsettingLastElementDuringForeachDoesNotSkipAnElement()
), true);

$keyList = array();
foreach ($config as $key => $value)
{
foreach ($config as $key => $value) {
$keyList[] = $key;
if ($key == 'third') {
unset($config->$key); // uses magic Zend\Config\Config::__unset() method
Expand Down Expand Up @@ -576,7 +573,8 @@ public function testZF6995_toArrayDoesNotDisturbInternalIterator()
* @depends testMerge
* @link http://framework.zend.com/issues/browse/ZF2-186
*/
public function testZF2_186_mergeReplacingUnnamedConfigSettings(){
public function testZF2_186_mergeReplacingUnnamedConfigSettings()
{
$arrayA = array(
'flag' => true,
'text' => 'foo',
Expand Down

0 comments on commit 24c143c

Please sign in to comment.