Skip to content

Commit

Permalink
Merge branch 'v0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Faugeron committed Jul 20, 2017
2 parents 5bcf565 + 99341bf commit 29a5a77
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 43 deletions.
18 changes: 9 additions & 9 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
$finder = PhpCsFixer\Finder::create()
->exclude('bin')
->exclude('doc')
->exclude('vendor')
->exclude('fixtures')
->in(__DIR__)
;

return Symfony\CS\Config\Config::create()
->fixers([
'-visibility',
'-multiple_use',
'short_array_syntax',
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'visibility_required' => false,
'array_syntax' => [
'syntax' => 'short',
],
])
->setUsingCache(true)
->finder($finder)
->setFinder($finder)
;
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 0.8.0: phpspec 4

Upgraded phpspec to v4.0@rc, meaning:

* phpspec v2 and v3 support was dropped

## 0.7.0: Scalar Type Hints

Upgraded Memio to v2.0@alpha, meaning:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 Loïc Faugeron
Copyright (c) 2015-2017 Loïc Faugeron

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This extension for [phpspec](http://phpspec.net/) provides a powerful code gener

First install it using [Composer](https://getcomposer.org/download):

composer require --dev memio/spec-gen:^0.7
composer require --dev memio/spec-gen:^0.8

> **Note**: you'll also need to set in your `composer.json` the
> `minimum-stability` parameter to `alpha`.
Expand All @@ -33,9 +33,10 @@ extensions:

> **Version guide**:
>
> * using phpspec 2? Then use spec-gen v0.4
> * using phpspec 4? Then use spec-gen v0.8 and above
> * using phpspec 3 and PHP 7? Then use spec-gen v0.7
> * using phpspec 3 and PHP 5.6? Then use spec-gen v0.6
> * using phpspec 3 and PHP 7? Then use spec-gen v0.7 and above
> * using phpspec 2? Then use spec-gen v0.4
## Full example

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
"memio/pretty-printer": "^2.0@alpha",
"memio/twig-template-engine": "^2.0@alpha",
"php": "^7.0",
"phpspec/phpspec": "^3.0",
"symfony/event-dispatcher": "^2.7 || ^3.0"
"phpspec/phpspec": "^4.0@rc",
"symfony/event-dispatcher": "^2.7 || ^3.0 || ^4.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^1.6",
"phpunit/phpunit": "^5.4"
"friendsofphp/php-cs-fixer": "^2.0",
"phpunit/phpunit": "^6.0"
}
}
2 changes: 1 addition & 1 deletion src/Memio/SpecGen/CodeEditor/CodeEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(CommandBus $commandBus, Editor $editor)
$this->editor = $editor;
}

public function open(string $filename) : File
public function open(string $filename): File
{
return $this->editor->open($filename);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/SpecGen/CodeEditor/InsertConstructorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(Editor $editor, PrettyPrinter $prettyPrinter)
$this->prettyPrinter = $prettyPrinter;
}

public function supports(Command $command) : bool
public function supports(Command $command): bool
{
return $command instanceof InsertConstructor;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/SpecGen/CodeEditor/InsertMethodHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(Editor $editor, PrettyPrinter $prettyPrinter)
$this->prettyPrinter = $prettyPrinter;
}

public function supports(Command $command) : bool
public function supports(Command $command): bool
{
return $command instanceof InsertMethod;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/SpecGen/CodeEditor/InsertPropertiesHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(InsertPropertyHandler $insertPropertyHandler)
$this->insertPropertyHandler = $insertPropertyHandler;
}

public function supports(Command $command) : bool
public function supports(Command $command): bool
{
return $command instanceof InsertProperties;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/SpecGen/CodeEditor/InsertPropertyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(Editor $editor, PrettyPrinter $prettyPrinter)
$this->prettyPrinter = $prettyPrinter;
}

public function supports(Command $command) : bool
public function supports(Command $command): bool
{
return $command instanceof InsertProperty;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/SpecGen/CodeEditor/InsertUseStatementHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(Editor $editor)
$this->editor = $editor;
}

public function supports(Command $command) : bool
public function supports(Command $command): bool
{
return $command instanceof InsertUseStatement;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(
$this->insertUseStatementHandler = $insertUseStatementHandler;
}

public function supports(Command $command) : bool
public function supports(Command $command): bool
{
return $command instanceof InsertUseStatements;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Memio/SpecGen/CommandBus/CommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
interface CommandHandler
{
public function supports(Command $command) : bool;
public function supports(Command $command): bool;

public function handle(Command $command);
}
4 changes: 2 additions & 2 deletions src/Memio/SpecGen/ConstructorGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(CommandBus $commandBus)
$this->commandBus = $commandBus;
}

public function supports(Resource $resource, $generation, array $data) : bool
public function supports(Resource $resource, string $generation, array $data): bool
{
return 'method' === $generation && '__construct' === $data['name'];
}
Expand All @@ -47,7 +47,7 @@ public function generate(Resource $resource, array $data = [])
/**
* {@inheritdoc}
*/
public function getPriority()
public function getPriority(): int
{
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
$this->variableArgumentMarshaller = $variableArgumentMarshaller;
}

public function supports(Command $command) : bool
public function supports(Command $command): bool
{
return $command instanceof GenerateConstructor;
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public function handle(Command $command)
$this->eventDispatcher->dispatch(GeneratedConstructor::EVENT_NAME, $generatedConstructor);
}

private function shouldAddUseStatement(File $file, FullyQualifiedName $fullyQualifiedName) : bool
private function shouldAddUseStatement(File $file, FullyQualifiedName $fullyQualifiedName): bool
{
$type = $fullyQualifiedName->getFullyQualifiedName();
if (in_array($type, self::NON_OBJECT_TYPES, true)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Memio/SpecGen/GenerateMethod/GenerateMethodHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
$this->variableArgumentMarshaller = $variableArgumentMarshaller;
}

public function supports(Command $command) : bool
public function supports(Command $command): bool
{
return $command instanceof GenerateMethod;
}
Expand All @@ -70,7 +70,7 @@ public function handle(Command $command)
$this->eventDispatcher->dispatch(GeneratedMethod::EVENT_NAME, $generatedMethod);
}

private function shouldAddUseStatement(File $file, FullyQualifiedName $fullyQualifiedName) : bool
private function shouldAddUseStatement(File $file, FullyQualifiedName $fullyQualifiedName): bool
{
$type = $fullyQualifiedName->getFullyQualifiedName();
if (in_array($type, self::NON_OBJECT_TYPES, true)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
class LogGeneratedMethodListener
{
private $io;

public function __construct(IO $io)
{
$this->io = $io;
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/SpecGen/Marshaller/Model/ArgumentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function add(string $type, string $name)
}
}

public function all() : array
public function all(): array
{
return $this->arguments;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/SpecGen/Marshaller/Service/NameGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NameGuesser
'mixed',
];

public function guess(string $type) : string
public function guess(string $type): string
{
if (in_array($type, self::NON_OBJECT_TYPES, true)) {
return 'argument';
Expand Down
4 changes: 2 additions & 2 deletions src/Memio/SpecGen/Marshaller/Service/TypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class TypeGuesser
{
public function guess($variable) : string
public function guess($variable): string
{
if (is_callable($variable)) {
return 'callable';
Expand All @@ -38,7 +38,7 @@ public function guess($variable) : string
return get_class($variable);
}

private function getNonObjectType($variable) : string
private function getNonObjectType($variable): string
{
$normalizations = [
'boolean' => 'bool',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(NameGuesser $nameGuesser, TypeGuesser $typeGuesser)
$this->typeGuesser = $typeGuesser;
}

public function marshal(array $variables) : array
public function marshal(array $variables): array
{
$argumentCollection = new ArgumentCollection();
foreach ($variables as $variable) {
Expand Down
4 changes: 2 additions & 2 deletions src/Memio/SpecGen/MethodGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(CommandBus $commandBus)
$this->commandBus = $commandBus;
}

public function supports(Resource $resource, $generation, array $data)
public function supports(Resource $resource, string $generation, array $data): bool
{
return 'method' === $generation;
}
Expand All @@ -44,7 +44,7 @@ public function generate(Resource $resource, array $data = [])
$this->commandBus->handle($generateMethod);
}

public function getPriority()
public function getPriority(): int
{
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Memio/SpecGen/GeneratorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class GeneratorTestCase extends TestCase
{
protected function getFixtureFilename() : string
protected function getFixtureFilename(): string
{
$path = $this->getPath();
$method = $this->getMethod();
Expand All @@ -36,7 +36,7 @@ protected function assertExpectedCode(string $actualFilename)
$this->assertFileEquals($expectedFilename, $actualFilename);
}

private function getPath() : string
private function getPath(): string
{
$trace = debug_backtrace();
$testFqcn = $trace[2]['class'];
Expand All @@ -45,7 +45,7 @@ private function getPath() : string
return str_replace('\\', '/', $type);
}

private function getMethod() : string
private function getMethod(): string
{
$trace = debug_backtrace();

Expand Down
4 changes: 2 additions & 2 deletions tests/Memio/SpecGen/NullIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

class NullIO implements IO
{
public function write($message)
public function write(string $message)
{
}

public function isVerbose()
public function isVerbose(): bool
{
return false;
}
Expand Down

0 comments on commit 29a5a77

Please sign in to comment.