Skip to content

Commit

Permalink
Code cleanup (PHP7.1, PHPStan, ECS) (#190)
Browse files Browse the repository at this point in the history
* fix for php7.1

* Code style related packages update, analyse script + code style fixes

* .features file style fixes + analyse script added to .travis.yml file

* update composer version

* fix code style
  • Loading branch information
oallain authored and lsmith77 committed Apr 3, 2019
1 parent 08a0315 commit 2b5bb2c
Show file tree
Hide file tree
Showing 46 changed files with 184 additions and 359 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ before_script:

script:
- composer validate --strict
- composer analyse
- bin/phpstan analyse -c phpstan.neon -l max src/
- bin/ecs check src/ spec/ tests/Behat/

Expand Down
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@
"friends-of-behat/variadic-extension": "^1.0",
"lakion/mink-debug-extension": "^1.2.3",
"phpspec/phpspec": "^5.0",
"phpstan/phpstan-symfony": "^0.10.0",
"phpstan/phpstan-webmozart-assert": "^0.10.0",
"phpstan/phpstan-webmozart-assert": "^0.11.1",
"phpstan/phpstan-symfony": "^0.11.2",
"phpstan/phpstan-doctrine": "^0.11.2",
"phpstan/phpstan-shim": "^0.11.4",
"phpunit/phpunit": "^5.6",
"portphp/csv": "^1.1.0",
"portphp/spreadsheet": "^1.0.0-alpha",
"predis/predis": "^1.1",
"se/selenium-server-standalone": "^2.52",
"sylius-labs/coding-standard": "^2.0",
"sylius-labs/coding-standard": "^3.0",
"symplify/easy-coding-standard": "^4.5"
},
"prefer-stable": true,
Expand All @@ -61,6 +63,12 @@
"conflict": {
"sonata-project/core-bundle": ">=3.12 <3.13.4"
},
"scripts": {
"analyse": [
"bin/phpstan analyse -c phpstan.neon -l max src/",
"bin/ecs check src/ spec/"
]
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
Expand Down
20 changes: 10 additions & 10 deletions features/export/cli/exporting_countries_to_csv_via_cli.feature
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@managing_countries
Feature: exporting countries to csv-file
In order to have my countries exported to an external target
As a developer
I want to be able to export country data to csv file from the commandline
Feature: Exporting countries to csv-file
In order to have my countries exported to an external target
As a developer
I want to be able to export country data to csv file from the commandline

Background:
Given I have a working command-line interface
Background:
Given I have a working command-line interface

@cli_importer_exporter
Scenario: Exporting countries to csv-file
When I export "country" data as "csv" to the file "countries_export.csv" with the cli-command
Then I should see "Exported" in the output
@cli_importer_exporter
Scenario: Exporting countries to csv-file
When I export "country" data as "csv" to the file "countries_export.csv" with the cli-command
Then I should see "Exported" in the output
20 changes: 10 additions & 10 deletions features/export/cli/exporting_countries_to_json_via_cli.feature
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@managing_countries
Feature: exporting countries to json-file
In order to have my countries exported to an external target
As a developer
I want to be able to export country data to json file from the commandline
Feature: Exporting countries to json-file
In order to have my countries exported to an external target
As a developer
I want to be able to export country data to json file from the commandline

Background:
Given I have a working command-line interface
Background:
Given I have a working command-line interface

@cli_importer_exporter
Scenario: Exporting countries to json-file
When I export "country" data as "json" to the file "countries_export.json" with the cli-command
Then I should see "Exported" in the output
@cli_importer_exporter
Scenario: Exporting countries to json-file
When I export "country" data as "json" to the file "countries_export.json" with the cli-command
Then I should see "Exported" in the output
20 changes: 10 additions & 10 deletions features/export/cli/exporting_countries_to_xlsx_via_cli.feature
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@managing_countries
Feature: exporting countries to xlsx-file
In order to have my countries exported to an external target
As a Developer
I want to be able to export country data to xlsx file from the commandline
Feature: Exporting countries to xlsx-file
In order to have my countries exported to an external target
As a Developer
I want to be able to export country data to xlsx file from the commandline

Background:
Given I have a working command-line interface
Background:
Given I have a working command-line interface

@cli_importer_exporter
Scenario: Exporting countries to xlsx-file
When I export "country" data as "xlsx" to the file "countries_export.xlsx" with the cli-command
Then I should see "Exported" in the output
@cli_importer_exporter
Scenario: Exporting countries to xlsx-file
When I export "country" data as "xlsx" to the file "countries_export.xlsx" with the cli-command
Then I should see "Exported" in the output
20 changes: 10 additions & 10 deletions features/export/cli/exporting_customers_to_csv_via_cli.feature
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@managing_customers
Feature: exporting customers to csv-file
In order to have my customers exported to an external target
As a Developer
I want to be able to export customer data to csv file from the commandline
Feature: Exporting customers to csv-file
In order to have my customers exported to an external target
As a Developer
I want to be able to export customer data to csv file from the commandline

Background:
Given I have a working command-line interface
Background:
Given I have a working command-line interface

@cli_importer_exporter
Scenario: Exporting customers to csv-file
When I export "customer" data as "csv" to the file "customers_export.csv" with the cli-command
Then I should see "Exported" in the output
@cli_importer_exporter
Scenario: Exporting customers to csv-file
When I export "customer" data as "csv" to the file "customers_export.csv" with the cli-command
Then I should see "Exported" in the output
20 changes: 10 additions & 10 deletions features/export/cli/exporting_orders_to_csv_via_cli.feature
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@managing_orders
Feature: exporting orders to csv-file
In order to have my orders exported to an external target
As a Developer
I want to be able to export order data to csv file from the commandline
Feature: Exporting orders to csv-file
In order to have my orders exported to an external target
As a Developer
I want to be able to export order data to csv file from the commandline

Background:
Given I have a working command-line interface
Background:
Given I have a working command-line interface

@cli_importer_exporter
Scenario: Exporting orders to csv-file
When I export "order" data as "csv" to the file "orders_export.csv" with the cli-command
Then I should see "Exported" in the output
@cli_importer_exporter
Scenario: Exporting orders to csv-file
When I export "order" data as "csv" to the file "orders_export.csv" with the cli-command
Then I should see "Exported" in the output
30 changes: 15 additions & 15 deletions features/export/cli/exporting_tax_categories_via_cli.feature
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
@managing_tax_categories
Feature: exporting tax categories to csv-file
In order to have my tax categories exported to an external target
As a Developer
I want to be able to export tax categories data to csv file from the commandline
In order to have my tax categories exported to an external target
As a Developer
I want to be able to export tax categories data to csv file from the commandline

Background:
Given I have a working command-line interface
And the store has a tax category "cloth"
And this tax category name is "Cloth"
And this tax category description is "Shirts and Jeans"
Background:
Given I have a working command-line interface
And the store has a tax category "cloth"
And this tax category name is "Cloth"
And this tax category description is "Shirts and Jeans"

@cli_importer_exporter
Scenario: Exporting tax categories to csv-file
When I export "tax_category" data as "csv" to the file "tax_categories_export.csv" with the cli-command
Then I should see "Exported" in the output
And I should see in the file:
| Code | Name | Description |
| cloth | Cloth | Shirts and Jeans |
@cli_importer_exporter
Scenario: Exporting tax categories to csv-file
When I export "tax_category" data as "csv" to the file "tax_categories_export.csv" with the cli-command
Then I should see "Exported" in the output
And I should see in the file:
| Code | Name | Description |
| cloth | Cloth | Shirts and Jeans |
13 changes: 5 additions & 8 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
includes:
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon

parameters:
symfony:
container_xml_path: tests/Application/var/cache/dev/appDevDebugProjectContainer.xml

excludes_analyse:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'
Expand All @@ -17,4 +10,8 @@ parameters:
ignoreErrors:
- '/Parameter #1 $configuration of method Symfony\Component\DependencyInjection\Extension\Extension::processConfiguration() expects Symfony\Component\Config\Definition\ConfigurationInterface, Symfony\Component\Config\Definition\ConfigurationInterface|null given./'
- '/Parameter #1 $iterator of function iterator_to_array expects Traversable, array|Traversable given./'
- '#does not call parent constructor from#'
- '/does not call parent constructor from/'
- '/Return type \(void\) of method FriendsOfSylius\\SyliusImportExportPlugin\\Command\\ImportDataFromMessageQueueCommand::execute\(\) should be compatible with return type \(int\|null\) of method Symfony\\Component\\Console\\Command\\Command::execute\(\)/'
- '/Return type \(void\) of method FriendsOfSylius\\SyliusImportExportPlugin\\Command\\ExportDataCommand::execute\(\) should be compatible with return type \(int\|null\) of method Symfony\\Component\\Console\\Command\\Command::execute\(\)/'
- '/Return type \(void\) of method FriendsOfSylius\\SyliusImportExportPlugin\\Command\\ExportDataToMessageQueueCommand::execute\(\) should be compatible with return type \(int\|null\) of method Symfony\\Component\\Console\\Command\\Command::execute\(\)/'
- '/Return type \(void\) of method FriendsOfSylius\\SyliusImportExportPlugin\\Command\\ImportDataCommand::execute\(\) should be compatible with return type \(int\|null\) of method Symfony\\Component\\Console\\Command\\Command::execute\(\)/'
4 changes: 1 addition & 3 deletions src/Command/ExportDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ final class ExportDataCommand extends Command
{
use ContainerAwareTrait;

/**
* @var ExporterRegistry
*/
/** @var ExporterRegistry */
private $exporterRegistry;

public function __construct(ExporterRegistry $exporterRegistry)
Expand Down
4 changes: 1 addition & 3 deletions src/Command/ExportDataToMessageQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ final class ExportDataToMessageQueueCommand extends Command
{
use ContainerAwareTrait;

/**
* @var ExporterRegistry
*/
/** @var ExporterRegistry */
private $exporterRegistry;

public function __construct(ExporterRegistry $exporterRegistry)
Expand Down
4 changes: 1 addition & 3 deletions src/Command/ImportDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

final class ImportDataCommand extends Command
{
/**
* @var ImporterRegistry
*/
/** @var ImporterRegistry */
private $importerRegistry;

public function __construct(ImporterRegistry $importerRegistry)
Expand Down
4 changes: 1 addition & 3 deletions src/Command/ImportDataFromMessageQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ final class ImportDataFromMessageQueueCommand extends Command
{
use ContainerAwareTrait;

/**
* @var ImporterRegistry
*/
/** @var ImporterRegistry */
private $importerRegistry;

public function __construct(ImporterRegistry $importerRegistry)
Expand Down
12 changes: 3 additions & 9 deletions src/Controller/ExportDataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@

final class ExportDataController extends Controller
{
/**
* @var ServiceRegistryInterface
*/
/** @var ServiceRegistryInterface */
private $registry;

/**
* @var RequestConfigurationFactoryInterface
*/
/** @var RequestConfigurationFactoryInterface */
private $requestConfigurationFactory;

/**
* @var ResourcesCollectionProviderInterface
*/
/** @var ResourcesCollectionProviderInterface */
private $resourcesCollectionProvider;

public function __construct(
Expand Down
16 changes: 4 additions & 12 deletions src/Controller/ImportDataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,16 @@

final class ImportDataController
{
/**
* @var ServiceRegistry
*/
/** @var ServiceRegistry */
private $registry;

/**
* @var Session
*/
/** @var Session */
private $session;

/**
* @var FormFactoryInterface
*/
/** @var FormFactoryInterface */
private $formFactory;

/**
* @var \Twig_Environment
*/
/** @var \Twig_Environment */
private $twig;

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/MessageQueuePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class MessageQueuePass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$config = $container->getParameter('sylius.message_queue');

Expand Down
6 changes: 2 additions & 4 deletions src/DependencyInjection/Compiler/RegisterExporterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ final class RegisterExporterPass implements CompilerPassInterface
private const CLASS_CSV_WRITER = CsvWriter::class;
private const CLASS_SPREADSHEET_WRITER = SpreadsheetWriter::class;

/**
* @var array
*/
/** @var array */
private $typesAndFormats = [];

/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$serviceId = 'sylius.exporters_registry';
if ($container->has($serviceId) == false) {
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/RegisterImporterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class RegisterImporterPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$serviceId = 'sylius.importers_registry';
if ($container->has($serviceId) == false) {
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/FOSSyliusImportExportExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FOSSyliusImportExportExtension extends Extension
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs);

Expand Down
2 changes: 1 addition & 1 deletion src/Exporter/ExporterRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class ExporterRegistry extends ServiceRegistry
{
const EVENT_HOOK_NAME_PREFIX_GRID_BUTTONS = 'app.grid_event_listener.admin.crud';
public const EVENT_HOOK_NAME_PREFIX_GRID_BUTTONS = 'app.grid_event_listener.admin.crud';

public static function buildServiceName(string $type, string $format): string
{
Expand Down
4 changes: 1 addition & 3 deletions src/Exporter/JsonResourceExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ final class JsonResourceExporter extends ResourceExporter
{
private $data = [];

/**
* @var string
*/
/** @var string */
private $filename;

/**
Expand Down
Loading

0 comments on commit 2b5bb2c

Please sign in to comment.