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 2d6ac3c
Show file tree
Hide file tree
Showing 77 changed files with 557 additions and 555 deletions.
2 changes: 1 addition & 1 deletion src/DI/Compiler.php
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion src/DI/ContainerBuilder.php
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion src/DI/Extensions/DecoratorExtension.php
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion src/DI/Extensions/InjectExtension.php
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions tests/DI/Compiler.addExtension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 10 additions & 10 deletions tests/DI/Compiler.arguments.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
10 changes: 5 additions & 5 deletions tests/DI/Compiler.extension.defaultServices.phpt
Original file line number Diff line number Diff line change
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);
14 changes: 7 additions & 7 deletions tests/DI/Compiler.extension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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%']));
42 changes: 21 additions & 21 deletions tests/DI/Compiler.extensionOverride.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -117,109 +117,109 @@ $compiler->addExtension('database', $extension);
$container = createContainer($compiler, 'files/compiler.extensionOverride.neon');


Assert::type( 'Ipsum', $container->getService('one1') );
Assert::type('Ipsum', $container->getService('one1'));
Assert::same([
'Ipsum::__construct ',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('one2') );
Assert::type('Ipsum', $container->getService('one2'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('one3') );
Assert::type('Ipsum', $container->getService('one3'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Lorem', $container->getService('one4') );
Assert::type('Lorem', $container->getService('one4'));
Assert::same([
'Lorem::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('one5') );
Assert::type('Ipsum', $container->getService('one5'));
Assert::same([
'Ipsum::__construct ',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('one6') );
Assert::type('Ipsum', $container->getService('one6'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('one7') );
Assert::type('Ipsum', $container->getService('one7'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());


Assert::type( 'Ipsum', $container->getService('two1') );
Assert::type('Ipsum', $container->getService('two1'));
Assert::same([
'Ipsum::__construct ',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('two2') );
Assert::type('Ipsum', $container->getService('two2'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('two3') );
Assert::type('Ipsum', $container->getService('two3'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Lorem', $container->getService('two4') );
Assert::type('Lorem', $container->getService('two4'));
Assert::same([
'Lorem::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('two5') );
Assert::type('Ipsum', $container->getService('two5'));
Assert::same([
'Ipsum::__construct ',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('two6') );
Assert::type('Ipsum', $container->getService('two6'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('two7') );
Assert::type('Ipsum', $container->getService('two7'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());


Assert::type( 'Ipsum', $container->getService('three1') );
Assert::type('Ipsum', $container->getService('three1'));
Assert::same([
'Ipsum::__construct ',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('three2') );
Assert::type('Ipsum', $container->getService('three2'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('three3') );
Assert::type('Ipsum', $container->getService('three3'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Lorem', $container->getService('three4') );
Assert::type('Lorem', $container->getService('three4'));
Assert::same([
'Lorem::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('three5') );
Assert::type('Ipsum', $container->getService('three5'));
Assert::same([
'Ipsum::__construct ',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('three6') );
Assert::type('Ipsum', $container->getService('three6'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());

Assert::type( 'Ipsum', $container->getService('three7') );
Assert::type('Ipsum', $container->getService('three7'));
Assert::same([
'Ipsum::__construct 2',
], Notes::fetch());
20 changes: 10 additions & 10 deletions tests/DI/Compiler.generatedAccessor.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ services:
');


Assert::type( 'Lorem', $container->getService('lorem') );
Assert::notSame( $container->getService('lorem'), $container->getService('lorem2') );
Assert::type('Lorem', $container->getService('lorem'));
Assert::notSame($container->getService('lorem'), $container->getService('lorem2'));

Assert::type( 'ILoremAccessor', $container->getService('one') );
Assert::same( $container->getService('one')->get(), $container->getService('lorem') );
Assert::type('ILoremAccessor', $container->getService('one'));
Assert::same($container->getService('one')->get(), $container->getService('lorem'));

Assert::type( 'ILoremAccessor', $container->getService('two') );
Assert::same( $container->getService('two')->get(), $container->getService('lorem') );
Assert::type('ILoremAccessor', $container->getService('two'));
Assert::same($container->getService('two')->get(), $container->getService('lorem'));

Assert::type( 'ILoremAccessor', $container->getService('three') );
Assert::same( $container->getService('three')->get(), $container->getService('lorem2') );
Assert::type('ILoremAccessor', $container->getService('three'));
Assert::same($container->getService('three')->get(), $container->getService('lorem2'));

Assert::type( 'ILoremAccessor', $container->getService('four') );
Assert::same( $container->getService('four')->get(), $container->getService('lorem') );
Assert::type('ILoremAccessor', $container->getService('four'));
Assert::same($container->getService('four')->get(), $container->getService('lorem'));
Loading

0 comments on commit 2d6ac3c

Please sign in to comment.