Skip to content

Commit

Permalink
apply php cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Feb 10, 2018
1 parent d4138a0 commit f8b63f8
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 20 deletions.
10 changes: 10 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$config = new Prooph\CS\Config\Prooph();
$config->getFinder()->in(__DIR__);

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;

$config->setCacheFile($cacheDir . '/.php_cs.cache');

return $config;
4 changes: 2 additions & 2 deletions bin/fpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace Fpp;

if (! isset($argv[1])) {
echo "Missing input directory or file argument";
echo 'Missing input directory or file argument';
exit(1);
}

if (! isset($argv[2])) {
echo "Missing output file argument";
echo 'Missing output file argument';
exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Deriving.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final public function __construct()
{
$valid = false;

foreach(self::OPTIONS as $value) {
foreach (self::OPTIONS as $value) {
if ($this instanceof $value) {
$valid = true;
break;
Expand Down
15 changes: 7 additions & 8 deletions src/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ private function generateDataClass(Definition $definition): string
$code .= "\$this->{$argument->name()} === \$other->{$argument->name()}\n$indent && ";
}


$code = substr($code, 0, -(strlen($indent) + 16)) . ";\n$indent }\n";

break;
Expand Down Expand Up @@ -324,7 +323,7 @@ private function generateAggregateChangedClass(Definition $definition): string
$code = "namespace {$definition->namespace()} {\n ";
$indent = ' ';

if (null == $definition->messageName()) {
if (null === $definition->messageName()) {
$messageName = '\\' . $definition->namespace() . $messageName;
}
}
Expand Down Expand Up @@ -417,7 +416,7 @@ private function generateCommandClass(Definition $definition): string
$code = "namespace {$definition->namespace()} {\n ";
$indent = ' ';

if (null == $definition->messageName()) {
if (null === $definition->messageName()) {
$messageName = '\\' . $definition->namespace() . $messageName;
}
}
Expand Down Expand Up @@ -491,7 +490,7 @@ private function generateEventClass(Definition $definition): string
$code = "namespace {$definition->namespace()} {\n ";
$indent = ' ';

if (null == $definition->messageName()) {
if (null === $definition->messageName()) {
$messageName = '\\' . $definition->namespace() . $messageName;
}
}
Expand Down Expand Up @@ -578,7 +577,7 @@ private function generateQueryClass(Definition $definition): string
$code = "namespace {$definition->namespace()} {\n ";
$indent = ' ';

if (null == $definition->messageName()) {
if (null === $definition->messageName()) {
$messageName = '\\' . $definition->namespace() . $messageName;
}
}
Expand Down Expand Up @@ -657,7 +656,7 @@ private function generateFunctionalConstructor(Definition $definition): string
$code .= "{$argument->typehint()} ";
}

$code.= "\${$argument->name()}, ";
$code .= "\${$argument->name()}, ";
}

if (! empty($definition->arguments())) {
Expand All @@ -668,7 +667,7 @@ private function generateFunctionalConstructor(Definition $definition): string
$code .= "{\n return new $type(";

foreach ($definition->arguments() as $argument) {
$code.= "\${$argument->name()}, ";
$code .= "\${$argument->name()}, ";
}

if (! empty($definition->arguments())) {
Expand All @@ -686,7 +685,7 @@ private function generateFunctionalEnumConstructors(Definition $definition): str
? '\\' . $definition->namespace() . '\\'
: '\\';

$code = "";
$code = '';
foreach ($definition->arguments() as $argument) {
$code .= " const {$argument->name()} = '$prefix{$definition->name()}\\";
$code .= <<<CODE
Expand Down
2 changes: 1 addition & 1 deletion src/ParseError.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ public static function unknownDeriving(int $line): ParseError
{
return new self('Unknown deriving at line ' . $line);
}
}
}
4 changes: 2 additions & 2 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function nextToken(array $tokens, int &$position): array
$token = [
T_OTHER,
$token,
$this->line
$this->line,
];
} else {
$token[2] = $token[2] - 2;
Expand Down Expand Up @@ -431,7 +431,7 @@ private function parseDerivings(array $tokens, int &$position, bool $allow): arr
}

$fqcn = __NAMESPACE__ . '\\Deriving\\' . $token[1];
$derivings[] = new $fqcn;
$derivings[] = new $fqcn();

$token = $this->nextToken($tokens, $position);

Expand Down
2 changes: 1 addition & 1 deletion src/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final public function __construct()
{
$valid = false;

foreach(self::OPTIONS as $value) {
foreach (self::OPTIONS as $value) {
if ($this instanceof $value) {
$valid = true;
break;
Expand Down
10 changes: 6 additions & 4 deletions tests/DumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ public function it_dumps_data(): void
$collection = new DefinitionCollection();
$collection->addDefinition($definition);

$code = (new Dumper)->dump($collection);
$code = (new Dumper())->dump($collection);

echo $code; die;
echo $code;
die;
}

/**
Expand All @@ -46,8 +47,9 @@ public function it_dumps_data_without_namespace(): void
$collection = new DefinitionCollection();
$collection->addDefinition($definition);

$code = (new Dumper)->dump($collection);
$code = (new Dumper())->dump($collection);

echo $code; die;
echo $code;
die;
}
}
3 changes: 2 additions & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function it_parses_dump_and_executes(): void
$dumper = new Dumper();
$code = $dumper->dump($collection);

echo $code; die;
echo $code;
die;
eval(substr($code, 5));

$p = \Model\Foo\Person\Person('sasa', 36);
Expand Down

0 comments on commit f8b63f8

Please sign in to comment.