Skip to content

Commit

Permalink
improved coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 19, 2015
1 parent 58ed2d8 commit 1d7d277
Show file tree
Hide file tree
Showing 90 changed files with 739 additions and 737 deletions.
6 changes: 3 additions & 3 deletions src/Bridges/DITracy/ContainerPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

namespace Nette\Bridges\DITracy;

use Nette,
Nette\DI\Container,
Tracy;
use Nette;
use Nette\DI\Container;
use Tracy;


/**
Expand Down
6 changes: 3 additions & 3 deletions src/DI/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\DI;

use Nette,
Nette\Utils\Validators;
use Nette;
use Nette\Utils\Validators;


/**
Expand Down Expand Up @@ -60,7 +60,7 @@ public function addExtension($name, CompilerExtension $extension)
public function getExtensions($type = NULL)
{
return $type
? array_filter($this->extensions, function($item) use ($type) { return $item instanceof $type; })
? array_filter($this->extensions, function ($item) use ($type) { return $item instanceof $type; })
: $this->extensions;
}

Expand Down
4 changes: 2 additions & 2 deletions src/DI/Config/Adapters/IniAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\DI\Config\Adapters;

use Nette,
Nette\DI\Config\Helpers;
use Nette;
use Nette\DI\Config\Helpers;


/**
Expand Down
8 changes: 4 additions & 4 deletions src/DI/Config/Adapters/NeonAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

namespace Nette\DI\Config\Adapters;

use Nette,
Nette\DI\Config\Helpers,
Nette\DI\Statement,
Nette\Neon;
use Nette;
use Nette\DI\Config\Helpers;
use Nette\DI\Statement;
use Nette\Neon;


/**
Expand Down
4 changes: 2 additions & 2 deletions src/DI/Config/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\DI\Config;

use Nette,
Nette\Utils\Validators;
use Nette;
use Nette\Utils\Validators;


/**
Expand Down
12 changes: 6 additions & 6 deletions src/DI/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace Nette\DI;

use Nette,
Nette\Utils\Validators,
Nette\Utils\Strings,
Nette\PhpGenerator\Helpers as PhpHelpers,
ReflectionClass;
use Nette;
use Nette\Utils\Validators;
use Nette\Utils\Strings;
use Nette\PhpGenerator\Helpers as PhpHelpers;
use ReflectionClass;


/**
Expand Down Expand Up @@ -757,7 +757,7 @@ public function formatStatement(Statement $statement)
*/
public function formatPhp($statement, $args)
{
array_walk_recursive($args, function(& $val) {
array_walk_recursive($args, function (& $val) {
if ($val instanceof Statement) {
$val = self::literal($this->formatStatement($val));

Expand Down
2 changes: 1 addition & 1 deletion src/DI/ContainerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct($tempDirectory, $autoRebuild = FALSE)

/**
* @param mixed
* @param callable function(Nette\DI\Compiler $compiler): string|NULL
* @param callable function (Nette\DI\Compiler $compiler): string|NULL
* @return string
*/
public function load($key, $generator)
Expand Down
2 changes: 1 addition & 1 deletion src/DI/Extensions/DIExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
if ($this->debugMode && $this->config['debugger']) {
Nette\Bridges\DITracy\ContainerPanel::$compilationTime = $this->time;
$initialize->addBody($container->formatPhp('?;', [
new Nette\DI\Statement('@Tracy\Bar::addPanel', [new Nette\DI\Statement('Nette\Bridges\DITracy\ContainerPanel')])
new Nette\DI\Statement('@Tracy\Bar::addPanel', [new Nette\DI\Statement('Nette\Bridges\DITracy\ContainerPanel')]),
]));
}

Expand Down
6 changes: 3 additions & 3 deletions src/DI/Extensions/DecoratorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\DI\Extensions;

use Nette,
Nette\DI\Statement;
use Nette;
use Nette\DI\Statement;


/**
Expand Down Expand Up @@ -61,7 +61,7 @@ public function addTags($type, array $tags)
private function findByType($type)
{
$type = ltrim($type, '\\');
return array_filter($this->getContainerBuilder()->getDefinitions(), function($def) use ($type) {
return array_filter($this->getContainerBuilder()->getDefinitions(), function ($def) use ($type) {
return $def->getClass() === $type || is_subclass_of($def->getClass(), $type);
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/DI/Extensions/InjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

namespace Nette\DI\Extensions;

use Nette,
Nette\DI,
Nette\DI\PhpReflection;
use Nette;
use Nette\DI;
use Nette\DI\PhpReflection;


/**
Expand Down Expand Up @@ -67,7 +67,7 @@ private function updateDefinition($def)
*/
public static function getInjectMethods($class)
{
return array_values(array_filter(get_class_methods($class), function($name) {
return array_values(array_filter(get_class_methods($class), function ($name) {
return substr($name, 0, 6) === 'inject';
}));
}
Expand Down
8 changes: 4 additions & 4 deletions tests/DI/Compiler.addExtension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Test: Nette\DI\Compiler and addExtension on loadConfiguration stage.
*/

use Nette\DI,
Tester\Assert;
use Nette\DI;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand All @@ -20,14 +20,14 @@ class FooExtension extends DI\CompilerExtension
}


Assert::exception(function() {
Assert::exception(function () {
$compiler = new DI\Compiler;
$compiler->addExtension('foo', new FooExtension);
$container = createContainer($compiler);
}, 'Nette\DeprecatedException', "Extensions 'bar' were added while container was being compiled.");


Assert::exception(function() {
Assert::exception(function () {
$compiler = new DI\Compiler;
$compiler->addExtension('foo', new FooExtension);
$compiler->addExtension('foo', new FooExtension);
Expand Down
24 changes: 12 additions & 12 deletions tests/DI/Compiler.arguments.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Test: Nette\DI\Compiler: arguments in config.
*/

use Nette\DI,
Tester\Assert;
use Nette\DI;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand All @@ -26,7 +26,7 @@ class Lorem

function method()
{
$this->args[] = func_get_args();
$this->args[] = func_get_args();
}

function add($a, $b)
Expand All @@ -36,7 +36,7 @@ class Lorem

}

define('MY_CONSTANT_TEST', "one");
define('MY_CONSTANT_TEST', 'one');


Assert::error(function () use (& $container) {
Expand All @@ -63,23 +63,23 @@ $lorem = $container->getService('lorem');
$dolor = $container->getService('dolor');

// constants
Assert::same( ['one', Lorem::DOLOR_SIT, 'MY_FAILING_CONSTANT_TEST'], $lorem->args[0] );
Assert::same( [NULL], $dolor->args[0] );
Assert::same(['one', Lorem::DOLOR_SIT, 'MY_FAILING_CONSTANT_TEST'], $lorem->args[0]);
Assert::same([NULL], $dolor->args[0]);

// services
Assert::same( [$lorem, $lorem, $container], $lorem->args[1] );
Assert::same([$lorem, $lorem, $container], $lorem->args[1]);

// statements
Assert::same( [3, ['x' => 'HELLO']], $lorem->args[2] );
Assert::same([3, ['x' => 'HELLO']], $lorem->args[2]);

// non-statements
Assert::same( [['Lorem', 'method'], 'Lorem::add', 'Lorem::add'], $lorem->args[3] );
Assert::same([['Lorem', 'method'], 'Lorem::add', 'Lorem::add'], $lorem->args[3]);

// special
Assert::same( [FALSE], $lorem->args[4] );
Assert::same([FALSE], $lorem->args[4]);

// service variables
Assert::same( [$lorem->var, $lorem->var, $container->parameters], $lorem->args[5] );
Assert::same([$lorem->var, $lorem->var, $container->parameters], $lorem->args[5]);

// service constant
Assert::same( [Lorem::DOLOR_SIT, Lorem::DOLOR_SIT, DI\Container::TAGS], $lorem->args[6] );
Assert::same([Lorem::DOLOR_SIT, Lorem::DOLOR_SIT, DI\Container::TAGS], $lorem->args[6]);
4 changes: 2 additions & 2 deletions tests/DI/Compiler.config.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Test: Nette\DI\Compiler and config.
*/

use Nette\DI,
Tester\Assert;
use Nette\DI;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand Down
4 changes: 2 additions & 2 deletions tests/DI/Compiler.dependencies.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Test: Nette\DI\Compiler and dependencies.
*/

use Nette\DI,
Tester\Assert;
use Nette\DI;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand Down
14 changes: 7 additions & 7 deletions tests/DI/Compiler.extension.defaultServices.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Test: Working with user defined services in CompilerExtension.
*/

use Nette\DI,
Tester\Assert;
use Nette\DI;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand Down Expand Up @@ -81,9 +81,9 @@ services:
');


Assert::type( 'Foo', $container->getService('one') );
Assert::type( 'Bar', $container->getService('two') );
Assert::type( 'Lorem', $container->getService('three') );
Assert::type( 'IIpsumFactory', $container->getService('four') );
Assert::type('Foo', $container->getService('one'));
Assert::type('Bar', $container->getService('two'));
Assert::type('Lorem', $container->getService('three'));
Assert::type('IIpsumFactory', $container->getService('four'));

Assert::type( 'FooBar', $container->getByType('IFooBar') );
Assert::type('FooBar', $container->getByType('IFooBar'));
2 changes: 1 addition & 1 deletion tests/DI/Compiler.extension.getConfig.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ bar:
lorem: ipsum
');

Assert::same( ['lorem' => 'ipsum'], $foo->barConfig );
Assert::same(['lorem' => 'ipsum'], $foo->barConfig);
18 changes: 9 additions & 9 deletions tests/DI/Compiler.extension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Test: Nette\DI\Compiler and user extension.
*/

use Nette\DI,
Tester\Assert;
use Nette\DI;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand All @@ -16,7 +16,7 @@ class DatabaseExtension extends Nette\DI\CompilerExtension

public function loadConfiguration()
{
Assert::same( ['foo' => 'hello'], $this->config );
Assert::same(['foo' => 'hello'], $this->config);
Notes::add(__METHOD__);
}

Expand Down Expand Up @@ -59,11 +59,11 @@ Assert::same([
], Notes::fetch());


Assert::same( 'database.', $extension->prefix('') );
Assert::same( 'database.member', $extension->prefix('member') );
Assert::same( '@database.member', $extension->prefix('@member') );
Assert::same('database.', $extension->prefix(''));
Assert::same('database.member', $extension->prefix('member'));
Assert::same('@database.member', $extension->prefix('@member'));


Assert::same( ['foo' => 'hello'], $extension->getConfig() );
Assert::same( ['foo' => 'hello'], $extension->getConfig(['foo' => 'bar']) );
Assert::same( ['foo2' => 'hello', 'foo' => 'hello'], $extension->getConfig(['foo2' => '%bar%']) );
Assert::same(['foo' => 'hello'], $extension->getConfig());
Assert::same(['foo' => 'hello'], $extension->getConfig(['foo' => 'bar']));
Assert::same(['foo2' => 'hello', 'foo' => 'hello'], $extension->getConfig(['foo2' => '%bar%']));
Loading

0 comments on commit 1d7d277

Please sign in to comment.