Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

PHP cs fixer V2.0.0 compatibility #41

Merged
merged 6 commits into from
Dec 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist: trusty

language: php

sudo: false
Expand All @@ -11,7 +13,7 @@ php:
- 5.5
- 5.6
- 7.0
- hhvm
- hhvm-3.9

env:
global:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
},
"require-dev": {
"phpunit/phpunit": "^4.7",
"friendsofphp/php-cs-fixer": "v2.0.0-alpha",
"friendsofphp/php-cs-fixer": "v2.0@stable",
"sllh/php-cs-fixer-styleci-bridge": "^2.1"
},
"conflict": {
"friendsofphp/php-cs-fixer": "<2.0.0-alpha|>2.0.0-alpha"
},
"suggest": {
"friendsofphp/php-cs-fixer": "To have a nice formatting of the generated files"
},
"config": {
"process-timeout": 1200
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
Expand Down
48 changes: 26 additions & 22 deletions src/JaneOpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
use PhpCsFixer\Differ\NullDiffer;
use PhpCsFixer\Error\ErrorsManager;
use PhpCsFixer\Finder;
use PhpCsFixer\Linter\NullLinter;
use PhpCsFixer\Runner\Runner;
use PhpParser\PrettyPrinter\Standard as StandardPrettyPrinter;
use PhpParser\PrettyPrinterAbstract;
use Symfony\Component\Serializer\Encoder\JsonDecode;
use Symfony\Component\Serializer\Encoder\JsonEncode;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Serializer;
use PhpCsFixer\Cache\NullCacheManager;
use PhpCsFixer\Linter\Linter;

class JaneOpenApi
{
Expand Down Expand Up @@ -192,32 +193,35 @@ protected function fix($directory)
if (null === $fixerConfig) {
$fixerConfig = Config::create()
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
'simplified_null_return' => false,
'concat_without_spaces' => false,
'double_arrow_multiline_whitespaces' => false,
'unalign_equals' => false,
'unalign_double_arrow' => false,
'align_double_arrow' => true,
'align_equals' => true,
'concat_with_spaces' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'short_array_syntax' => true,
))
;

$resolver = new ConfigurationResolver();
$resolver->setDefaultConfig($fixerConfig);
$resolver->resolve();
->setRules(
array(
'@Symfony' => true,
'array_syntax' => array('syntax' => 'short'),
'simplified_null_return' => false,
'ordered_imports' => true,
'phpdoc_order' => true,
'binary_operator_spaces' => array('align_equals'=>true),
'concat_space' => false
)
);
}
$resolverOptions = array('allow-risky' => true);
$resolver = new ConfigurationResolver($fixerConfig, $resolverOptions, $directory);

$finder = new Finder();
$finder->in($directory);
$fixerConfig->finder($finder);
$fixerConfig->setFinder($finder);

$runner = new Runner($fixerConfig, new NullDiffer(), null, new ErrorsManager(), new NullLinter(), false);
$runner = new Runner(
$resolver->getConfig()->getFinder(),
$resolver->getFixers(),
new NullDiffer(),
null,
new ErrorsManager(),
new Linter(),
false,
new NullCacheManager()
);

return $runner->fix();
}
Expand Down
1 change: 0 additions & 1 deletion tests/JaneOpenApiResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Joli\Jane\OpenApi\Tests;

use Joli\Jane\OpenApi\Command\GenerateCommand;
use Joli\Jane\OpenApi\JaneOpenApi;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Filesystem\Filesystem;
Expand Down