mirror of
https://github.com/Respect/Validation.git
synced 2024-06-22 23:36:33 +02:00
Suggest php-cs-fixer and add default config
See .php_cs for default configuration. Install php-cs-fixer globally and run php-cs-fixer fix to fix common coding standards or style issues.
This commit is contained in:
parent
2de6e0136c
commit
4329252709
29
.php_cs
Normal file
29
.php_cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->files()
|
||||
->name('*.php')
|
||||
->name('*.phpt')
|
||||
->in('library')
|
||||
->in('tests');
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->level(\Symfony\CS\FixerInterface::PSR2_LEVEL)
|
||||
->fixers(array(
|
||||
// All items of the @param, @throws, @return, @var, and @type phpdoc
|
||||
// tags must be aligned vertically.
|
||||
'phpdoc_params',
|
||||
// Convert double quotes to single quotes for simple strings.
|
||||
'single_quote',
|
||||
// Group and seperate @phpdocs with empty lines.
|
||||
'phpdoc_separation',
|
||||
// An empty line feed should precede a return statement.
|
||||
'return',
|
||||
// Remove trailing whitespace at the end of blank lines.
|
||||
'whitespacy_lines',
|
||||
// Removes extra empty lines.
|
||||
'extra_empty_lines',
|
||||
// Unused use statements must be removed.
|
||||
'unused_use'
|
||||
))
|
||||
->finder($finder);
|
|
@ -140,6 +140,21 @@ No test should fail.
|
|||
You can tweak the PHPUnit's settings by copying `phpunit.xml.dist` to `phpunit.xml`
|
||||
and changing it according to your needs.
|
||||
|
||||
## Coding style and standards
|
||||
|
||||
We follow the [PSR-2](http://www.php-fig.org/psr/psr-2/) coding style and
|
||||
[PSR-4](http://www.php-fig.org/psr/psr-4/) autoloading standard.
|
||||
|
||||
There are some preferences regarding code style which you can easily adhere to
|
||||
by using [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer).
|
||||
|
||||
This will format all PHP files consistently using the preferences of this
|
||||
project.
|
||||
|
||||
```sh
|
||||
$ vendor/bin/php-cs-fixer fix
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
See also:
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
"egulias/email-validator": "Strict (RFC compliant) email validation",
|
||||
"malkusch/bav": "German bank account validation",
|
||||
"symfony/validator": "Use Symfony validator through Respect\\Validation",
|
||||
"zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation"
|
||||
"zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation",
|
||||
"fabpot/php-cs-fixer": "Fix PSR2 and other coding style issues"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
@ -92,7 +92,7 @@ class Tld extends AbstractRule
|
|||
'uol', 'vacations', 'vegas', 'ventures', 'versicherung', 'vet', 'viajes', 'video',
|
||||
'villas', 'vision', 'vista', 'vistaprint', 'vlaanderen', 'vodka', 'vote', 'voting',
|
||||
'voto', 'voyage', 'wales', 'walter', 'wang', 'watch', 'webcam', 'website', 'wed',
|
||||
'wedding', 'weir', 'whoswho', 'wien', 'wiki', 'williamhill', 'win', 'windows',
|
||||
'wedding', 'weir', 'whoswho', 'wien', 'wiki', 'williamhill', 'win', 'windows',
|
||||
'wme', 'work', 'works', 'world', 'wtc', 'wtf', 'xbox', 'xerox', 'xin', 'xyz',
|
||||
'yachts', 'yandex', 'yodobashi', 'yoga', 'yokohama', 'youtube', 'zip', 'zone', 'zuerich',
|
||||
//country
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
namespace Respect\Validation\Exceptions;
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
/**
|
||||
* phpunit has an issue with mocking exceptions when in HHVM:
|
||||
* https://github.com/sebastianbergmann/phpunit-mock-objects/issues/207
|
||||
|
|
|
@ -97,12 +97,12 @@ class ValidationExceptionTest extends \PHPUnit_Framework_TestCase
|
|||
array(array(), ''),
|
||||
array(array(array(), 'foo'), "(), 'foo'"),
|
||||
array(array(array(1), 'foo'), "(1), 'foo'"),
|
||||
array(array(1, array(2, array(3))), "1, (2, (3))"),
|
||||
array(array(1, array(2, array(3, array(4)))), "1, (2, (3, (4)))"),
|
||||
array(array(1, array(2, array(3, array(4, array(5))))), "1, (2, (3, (4, ...)))"),
|
||||
array(array(1, array(2, array(3))), '1, (2, (3))'),
|
||||
array(array(1, array(2, array(3, array(4)))), '1, (2, (3, (4)))'),
|
||||
array(array(1, array(2, array(3, array(4, array(5))))), '1, (2, (3, (4, ...)))'),
|
||||
array(array('foo', 'bar'), "'foo', 'bar'"),
|
||||
array(array('foo', -1), "'foo', -1"),
|
||||
array(array(new \stdClass, "foo"), "Object of class stdClass, 'foo'"),
|
||||
array(array(new \stdClass, 'foo'), "Object of class stdClass, 'foo'"),
|
||||
array(new \stdClass, 'Object of class stdClass'),
|
||||
array($x = new \DateTime, $x->format('Y-m-d H:i:s')),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue