Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Updated codestyle and PHPUnit (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ping-localhost authored and mvannes committed May 3, 2019
1 parent 24d2e9c commit 8898581
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 58 deletions.
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "hostnet/asset-bundle",
"type": "symfony-bundle",
"description": "Allows the configuration of the hostnet/asset-lib package in your Symfony application.",
"license": "MIT",
"name": "hostnet/asset-bundle",
"type": "symfony-bundle",
"description": "Allows the configuration of the hostnet/asset-lib package in your Symfony application.",
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Yannick de Lange",
Expand All @@ -25,8 +27,8 @@
"twig/twig": "^1.38.2||^2.7.2"
},
"conflict": {
"twig/twig": "<1.26",
"phpdocumentor/type-resolver" : "<0.3"
"phpdocumentor/type-resolver": "<0.3",
"twig/twig": "<1.26"
},
"autoload": {
"psr-4": {
Expand All @@ -38,8 +40,6 @@
"Hostnet\\Bundle\\AssetBundle\\": "test/"
}
},
"minimum-stability" : "dev",
"prefer-stable" : true,
"archive": {
"exclude": [
"/test"
Expand Down
2 changes: 1 addition & 1 deletion src/Command/CompileCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down
16 changes: 8 additions & 8 deletions src/Command/DebugCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017-2018 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -28,14 +28,14 @@ public function __construct(ConfigInterface $config, ImportFinderInterface $find
$this->finder = $finder;
}

protected function configure()
protected function configure(): void
{
$this
->setDescription('Displays asset information.')
->addArgument('file');
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
if ($input->getArgument('file')) {
$this->checkFile($output, $input->getArgument('file'));
Expand All @@ -44,7 +44,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

private function checkFile(OutputInterface $output, string $file)
private function checkFile(OutputInterface $output, string $file): void
{
$entry_points = $this->config->getEntryPoints();
$assets = $this->config->getAssetFiles();
Expand Down Expand Up @@ -102,7 +102,7 @@ private function checkFile(OutputInterface $output, string $file)
$this->printDependencyTree($output, $file_obj);
}

private function printDependencyTree(OutputInterface $output, File $file, int $depth = 0)
private function printDependencyTree(OutputInterface $output, File $file, int $depth = 0): void
{
$deps = $this->finder->all($file);

Expand All @@ -114,16 +114,16 @@ private function printDependencyTree(OutputInterface $output, File $file, int $d
}
}

private function filesize(string $file)
private function filesize(string $file): string
{
$bytes = filesize($this->config->getProjectRoot() . DIRECTORY_SEPARATOR . $file);
$sizes = 'BKMGTP';
$factor = (int) floor((strlen((string) $bytes) - 1) / 3);
$factor = (int) floor((\strlen((string) $bytes) - 1) / 3);

return sprintf('%.2f', $bytes / (1024 ** $factor)) . @$sizes[$factor];
}

private function printAll(OutputInterface $output)
private function printAll(OutputInterface $output): void
{
$entry_points = $this->config->getEntryPoints();
$assets = $this->config->getAssetFiles();
Expand Down
8 changes: 4 additions & 4 deletions src/DependencyInjection/HostnetAssetExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -145,7 +145,7 @@ private function configurePlugin($class, ContainerBuilder $container): Reference
return new Reference($class);
}

private function configureCommands(ContainerBuilder $container)
private function configureCommands(ContainerBuilder $container): void
{
$compile = (new Definition(CompileCommand::class, [
new Reference('hostnet_asset.config'),
Expand All @@ -171,7 +171,7 @@ private function configureCommands(ContainerBuilder $container)
$container->setDefinition('hostnet_asset.command.debug', $debug);
}

private function configureEventListeners(ContainerBuilder $container)
private function configureEventListeners(ContainerBuilder $container): void
{
if (! $container->getParameter('kernel.debug')) {
return;
Expand All @@ -186,7 +186,7 @@ private function configureEventListeners(ContainerBuilder $container)
$container->setDefinition('hostnet_asset.listener.assets_change', $change_listener);
}

private function configureTwig(ContainerBuilder $container)
private function configureTwig(ContainerBuilder $container): void
{
$ext = (new Definition(AssetExtension::class, [
new Reference('hostnet_asset.config'),
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/AssetsChangeListener.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand All @@ -18,7 +18,7 @@ final class AssetsChangeListener

public function __construct(BundlerInterface $bundler, BuildConfig $build_config)
{
$this->bundler = $bundler;
$this->bundler = $bundler;
$this->build_config = $build_config;
}

Expand Down
2 changes: 1 addition & 1 deletion src/HostnetAssetBundle.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion src/Twig/AssetExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down
10 changes: 5 additions & 5 deletions test/Command/CompileCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -32,7 +32,7 @@ class CompileCommandTest extends TestCase
*/
private $compile_command;

protected function setUp()
protected function setUp(): void
{
$this->config = $this->prophesize(ConfigInterface::class);
$this->bundler = $this->prophesize(BundlerInterface::class);
Expand All @@ -45,7 +45,7 @@ protected function setUp()
);
}

public function testExecute()
public function testExecute(): void
{
$this->config->getProjectRoot()->willReturn(__DIR__);
$this->config->replaceReporter(Argument::type(NullReporter::class))->willReturn(new NullReporter());
Expand All @@ -59,7 +59,7 @@ public function testExecute()
$this->compile_command->run(new ArrayInput([]), $output->reveal());
}

public function testExecuteVerbose()
public function testExecuteVerbose(): void
{
$this->config->getProjectRoot()->willReturn(__DIR__);
$this->config->replaceReporter(Argument::type(ConsoleLoggingReporter::class))->willReturn(new NullReporter());
Expand All @@ -76,7 +76,7 @@ public function testExecuteVerbose()
$this->compile_command->run(new ArrayInput([]), $output->reveal());
}

public function testExecuteVeryVerbose()
public function testExecuteVeryVerbose(): void
{
$this->config->getProjectRoot()->willReturn(__DIR__);
$this->config->replaceReporter(Argument::type(ConsoleReporter::class))->willReturn(new NullReporter());
Expand Down
10 changes: 5 additions & 5 deletions test/Command/DebugCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -29,7 +29,7 @@ class DebugCommandTest extends TestCase
*/
private $compile_command;

protected function setUp()
protected function setUp(): void
{
$this->config = $this->prophesize(ConfigInterface::class);
$this->finder = $this->prophesize(ImportFinderInterface::class);
Expand All @@ -40,7 +40,7 @@ protected function setUp()
);
}

public function testExecute()
public function testExecute(): void
{
$this->config->getProjectRoot()->willReturn(dirname(__DIR__));
$this->config->getSourceRoot()->willReturn(basename(__DIR__));
Expand All @@ -54,7 +54,7 @@ public function testExecute()
self::assertStringEqualsFile(__DIR__ . '/expected.output.txt', $output->fetch());
}

public function testExecuteWithEntryPoint()
public function testExecuteWithEntryPoint(): void
{
$this->config->getProjectRoot()->willReturn(dirname(__DIR__));
$this->config->getSourceRoot()->willReturn(basename(__DIR__));
Expand Down Expand Up @@ -82,7 +82,7 @@ public function testExecuteWithEntryPoint()
), $output->fetch());
}

public function testExecuteWithAsset()
public function testExecuteWithAsset(): void
{
$this->config->getProjectRoot()->willReturn(dirname(__DIR__));
$this->config->getSourceRoot()->willReturn(basename(__DIR__));
Expand Down
26 changes: 13 additions & 13 deletions test/DependencyInjection/HostnetAssetExtensionTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -33,12 +33,12 @@ class HostnetAssetExtensionTest extends TestCase
*/
private $hostnet_asset_extension;

protected function setUp()
protected function setUp(): void
{
$this->hostnet_asset_extension = new HostnetAssetExtension();
}

public function testBlankConfig()
public function testBlankConfig(): void
{
$container = new ContainerBuilder();

Expand Down Expand Up @@ -66,7 +66,7 @@ public function testBlankConfig()
], array_keys($container->getDefinitions()));
}

public function testLoadDebug()
public function testLoadDebug(): void
{
$container = new ContainerBuilder();

Expand Down Expand Up @@ -100,7 +100,7 @@ public function testLoadDebug()
$this->validateBaseServiceDefinitions($container);
}

public function testLoadProd()
public function testLoadProd(): void
{
$container = new ContainerBuilder();

Expand Down Expand Up @@ -132,7 +132,7 @@ public function testLoadProd()
$this->validateBaseServiceDefinitions($container);
}

public function testLoadTypescript()
public function testLoadTypescript(): void
{
$container = new ContainerBuilder();

Expand Down Expand Up @@ -168,7 +168,7 @@ public function testLoadTypescript()
$this->validateBaseServiceDefinitions($container);
}

public function testLoadLess()
public function testLoadLess(): void
{
$container = new ContainerBuilder();

Expand Down Expand Up @@ -204,7 +204,7 @@ public function testLoadLess()
$this->validateBaseServiceDefinitions($container);
}

private function assertConfig(ContainerBuilder $container, bool $is_dev, string $output_folder, array $plugins = [])
private function assertConfig(ContainerBuilder $container, bool $is_dev, string $output_folder, array $plugins = []): void
{
$definition = $container->getDefinition('hostnet_asset.config');

Expand All @@ -221,7 +221,7 @@ private function assertConfig(ContainerBuilder $container, bool $is_dev, string
self::assertEquals($plugin_references, $definition->getArgument(9));
}

private function validateBaseServiceDefinitions(ContainerBuilder $container)
private function validateBaseServiceDefinitions(ContainerBuilder $container): void
{
self::assertEquals((new Definition(Executable::class, [
'/usr/bin/node',
Expand Down Expand Up @@ -270,7 +270,7 @@ private function validateBaseServiceDefinitions(ContainerBuilder $container)
$this->validateDebugServiceDefinitions($container);
}

private function validateDebugServiceDefinitions(ContainerBuilder $container)
private function validateDebugServiceDefinitions(ContainerBuilder $container): void
{
self::assertEquals(
(new Definition(AssetsChangeListener::class, [
Expand All @@ -286,7 +286,7 @@ private function validateDebugServiceDefinitions(ContainerBuilder $container)
);
}

public function testBuild()
public function testBuild(): void
{
$container = new ContainerBuilder();

Expand Down Expand Up @@ -315,7 +315,7 @@ public function testBuild()
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage Class stdClass should implement Hostnet\Component\Resolver\Plugin\PluginInterface.
*/
public function testBuildNonPlugin()
public function testBuildNonPlugin(): void
{
$container = new ContainerBuilder();

Expand All @@ -337,7 +337,7 @@ public function testBuildNonPlugin()
$container->compile();
}

public function testBuildNonBuiltin()
public function testBuildNonBuiltin(): void
{
$container = new ContainerBuilder();

Expand Down
2 changes: 1 addition & 1 deletion test/DependencyInjection/MockPlugin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright 2017 Hostnet B.V.
* @copyright 2017-present Hostnet B.V.
*/
declare(strict_types=1);

Expand Down
Loading

0 comments on commit 8898581

Please sign in to comment.