-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from cordoval/4-adding-collateral-files
merge #4 adding collateral files (cordoval) This PR was merged into cordoval:master branch. Discussion ---------- Commits ------- 9396bfa plug bldr and php_cs (cordoval) d44290c @sstok said vendor is included by default? (cordoval) 2466c66 cut unfinished calls (cordoval) f8ca7dc plug fixer (cordoval) 09ea076 plug some cs fixes (cordoval) 7bf8147 short array syntax (cordoval)
- Loading branch information
Showing
15 changed files
with
373 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
bldr: | ||
name: cordoval/matthew-7-12 | ||
description: Matthew 7:12 project | ||
profiles: | ||
travisBeforeScript: | ||
description: Travis Profile for running server:run | ||
tasks: | ||
- prepare | ||
- lint | ||
- phpcs | ||
travisScript: | ||
description: Travis Profile to run test suite | ||
tasks: | ||
- test | ||
tdd: | ||
description: Local Development Profile | ||
tasks: | ||
- testLocal | ||
- watch | ||
docker: | ||
description: Docker setup | ||
tasks: | ||
- bootstrap | ||
cs: | ||
description: fix cs for once | ||
tasks: | ||
- runFixer | ||
tasks: | ||
bootstrap: | ||
calls: | ||
- | ||
type: exec | ||
failOnError: true | ||
executable: composer | ||
arguments: [-q, install, --prefer-dist] | ||
- | ||
type: exec | ||
failOnError: true | ||
executable: cp | ||
arguments: [app/config/parameters.yml.docker, app/config/parameters.yml] | ||
- | ||
type: exec | ||
failOnError: true | ||
executable: php | ||
arguments: [app/console, doctrine:schema:update, --force, --env=dev] | ||
- | ||
type: exec | ||
failOnError: true | ||
executable: php | ||
arguments: [app/console, doctrine:mongodb:schema:update, --env=dev] | ||
- | ||
type: exec | ||
failOnError: true | ||
executable: php | ||
arguments: [app/console, cache:clear, --env=dev] | ||
prepare: | ||
calls: | ||
- | ||
type: exec | ||
failOnError: true | ||
executable: cp | ||
arguments: [app/config/parameters.yml.travis, app/config/parameters.yml] | ||
- | ||
type: exec | ||
failOnError: true | ||
executable: composer | ||
arguments: [-q, install, --prefer-dist] | ||
- | ||
type: exec | ||
executable: php | ||
arguments: [app/console, doctrine:database:create, --env=test] | ||
- | ||
type: exec | ||
executable: php | ||
arguments: [app/console, doctrine:schema:create, --env=test] | ||
- | ||
type: exec | ||
executable: php | ||
arguments: [app/console, doctrine:schema:update, --force, --env=test] | ||
- | ||
type: exec | ||
executable: php | ||
arguments: [app/console, doctrine:mongodb:schema:update, --env=test] | ||
- | ||
type: exec | ||
executable: php | ||
arguments: [app/console, cache:clear, --env=test] | ||
lint: | ||
description: Lints the files of the project | ||
calls: | ||
- | ||
type: apply | ||
failOnError: true | ||
src: | ||
- { path: [src], files: *.php, recursive: true } | ||
output: /dev/null | ||
executable: php | ||
arguments: [-l] | ||
phpcs: | ||
description: Runs the PHP Code Sniffer | ||
calls: | ||
- | ||
type: exec | ||
executable: php | ||
arguments: | ||
- bin/phpcs | ||
- --standard=PSR2 | ||
- --report=full | ||
- src/ | ||
- | ||
type: exec | ||
output: /dev/null | ||
append: false | ||
executable: php | ||
arguments: | ||
- bin/phpcs | ||
- --standard=PSR2 | ||
- --report=checkstyle | ||
- --report-file=build/logs/checkstyle.xml | ||
- src/ | ||
test: | ||
description: Runs the PHPUnit Tests | ||
calls: | ||
- | ||
type: background | ||
failOnEror: false | ||
executable: ./dev_built_in_server | ||
arguments: [] | ||
- | ||
type: exec | ||
failOnError: true | ||
executable: php | ||
arguments: | ||
- bin/phpunit | ||
#- --exclude-group=travis | ||
#- --coverage-text=php://stdout | ||
testLocal: | ||
description: Runs the PHPUnit Tests | ||
calls: | ||
- | ||
type: exec | ||
executable: clear | ||
- | ||
type: exec | ||
executable: php | ||
arguments: | ||
- bin/phpunit | ||
- --stop-on-failure | ||
- --group=now | ||
watch: | ||
description: Watch Task for Local Development | ||
calls: | ||
- | ||
type: watch | ||
src: | ||
- { path: [src], files: *.php, recursive: true } | ||
task: testLocal | ||
runFixer: | ||
description: Installs if not already and runs php-cs-fixer with custom .php_cs | ||
calls: | ||
- | ||
type: exec | ||
executable: curl | ||
arguments: | ||
- http://cs.sensiolabs.org/get/php-cs-fixer.phar | ||
- -S | ||
- -o | ||
- php-cs-fixer.phar | ||
- | ||
type: exec | ||
executable: php | ||
arguments: | ||
- php-cs-fixer.phar | ||
- fix | ||
- . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = spaces | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
require_once __DIR__.'/src/Decoupling/Fixer/ShortArraySyntaxFixer.php'; | ||
|
||
$finder = Symfony\CS\Finder\DefaultFinder::create() | ||
->notName('README.md') | ||
->notName('composer.*') | ||
->notName('phpunit.xml') | ||
->exclude('app') | ||
->exclude('build') | ||
->exclude('web/bundles') | ||
->in(__DIR__) | ||
; | ||
|
||
return Symfony\CS\Config\Config::create() | ||
->addCustomFixer(new Decoupling\Fixer\ShortArraySyntaxFixer) | ||
->fixers( | ||
[ | ||
'encoding', | ||
'linefeed', | ||
'indentation', | ||
'trailing_spaces', | ||
'object_operator', | ||
'phpdoc_params', | ||
'visibility', | ||
'short_tag', | ||
'php_closing_tag', | ||
'return', | ||
'extra_empty_lines', | ||
'braces', | ||
'lowercase_constants', | ||
'lowercase_keywords', | ||
'include', | ||
'function_declaration', | ||
'controls_spaces', | ||
'spaces_cast', | ||
'elseif', | ||
'eof_ending', | ||
'one_class_per_file', | ||
'unused_use', | ||
'short_array_syntax' | ||
] | ||
) | ||
->finder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace Decoupling\Fixer; | ||
|
||
use Symfony\CS\FixerInterface; | ||
use Symfony\CS\Tokens; | ||
|
||
class ShortArraySyntaxFixer implements FixerInterface | ||
{ | ||
public function fix(\SplFileInfo $file, $content) | ||
{ | ||
$tokens = Tokens::fromCode($content); | ||
|
||
for ($index = 0, $c = $tokens->count(); $index < $c; $index++) { | ||
$token = $tokens[$index]; | ||
|
||
if (Tokens::isKeyword($token) && T_ARRAY === $token[0] && '(' === $tokens->getNextNonWhitespace($index)) { | ||
$this->fixArray($tokens, $index); | ||
continue; | ||
} | ||
} | ||
|
||
return $tokens->generateCode(); | ||
} | ||
|
||
private function fixArray(Tokens $tokens, &$index) | ||
{ | ||
$bracesLevel = 0; | ||
|
||
unset($tokens[$index]); | ||
$index++; | ||
|
||
for ($c = $tokens->count(); $index < $c; $index++) { | ||
$token = $tokens[$index]; | ||
|
||
if ('(' === $token) { | ||
if (0 === $bracesLevel) { | ||
$tokens[$index] = '['; | ||
} | ||
|
||
++$bracesLevel; | ||
continue; | ||
} | ||
|
||
if (Tokens::isKeyword($token) && T_ARRAY === $token[0] && '(' === $tokens->getNextNonWhitespace($index)) { | ||
$this->fixArray($tokens, $index); | ||
continue; | ||
} | ||
|
||
if (')' === $token) { | ||
--$bracesLevel; | ||
|
||
if (0 === $bracesLevel) { | ||
$tokens[$index] = ']'; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public function getLevel() | ||
{ | ||
return FixerInterface::ALL_LEVEL; | ||
} | ||
|
||
public function getPriority() | ||
{ | ||
return 0; | ||
} | ||
|
||
public function supports(\SplFileInfo $file) | ||
{ | ||
return 'php' === pathinfo($file->getFilename(), PATHINFO_EXTENSION); | ||
} | ||
|
||
public function getName() | ||
{ | ||
return 'short_array_syntax'; | ||
} | ||
|
||
public function getDescription() | ||
{ | ||
return 'PHP array\'s should use the PHP 5.4 short-syntax'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Decoupling\Tests\Fixer; | ||
|
||
use Decoupling\Fixer\ShortArraySyntaxFixer; | ||
|
||
class ShortArraySyntaxFixerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider provideExamples | ||
*/ | ||
public function testFix($expected, $input) | ||
{ | ||
$fixer = new ShortArraySyntaxFixer(); | ||
$file = $this->getTestFile(); | ||
|
||
$this->assertEquals($expected, $fixer->fix($file, $input)); | ||
} | ||
|
||
public function provideExamples() | ||
{ | ||
return [ | ||
['<?php $x = [];', '<?php $x = array();'], | ||
['<?php $x = []; $y = [];', '<?php $x = array(); $y = array();'], | ||
['<?php $x = [ ];', '<?php $x = array( );'], | ||
['<?php $x = [\'foo\'];', '<?php $x = array(\'foo\');'], | ||
['<?php $x = [ \'foo\' ];', '<?php $x = array( \'foo\' );'], | ||
['<?php $x = [($y ? true : false)];', '<?php $x = array(($y ? true : false));'], | ||
['<?php $x = [($y ? [true] : [false])];', '<?php $x = array(($y ? array(true) : array(false)));'],// | ||
['<?php $x = [($y ? [true] : [ false ])];', '<?php $x = array(($y ? array(true) : array( false )));'], | ||
['<?php $x = [($y ? ["t" => true] : ["f" => false])];', '<?php $x = array(($y ? array("t" => true) : array("f" => false)));'], | ||
['<?php print_r([($y ? true : false)]);', '<?php print_r(array(($y ? true : false)));'], | ||
['<?php $x = [[[]]];', '<?php $x = array(array(array()));'], | ||
['<?php $x = [[[]]]; $y = [[[]]];', '<?php $x = array(array(array())); $y = array(array(array()));'], | ||
]; | ||
} | ||
|
||
private function getTestFile($filename = __FILE__) | ||
{ | ||
static $files = []; | ||
|
||
if (!isset($files[$filename])) { | ||
$files[$filename] = new \SplFileInfo($filename); | ||
} | ||
|
||
return $files[$filename]; | ||
} | ||
} |
Oops, something went wrong.