Skip to content

Commit

Permalink
cs fixes (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
chekalsky authored Feb 20, 2020
1 parent 4a43283 commit 770df8e
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
vendor
composer.lock
.phpunit.result.cache
.php_cs.cache
45 changes: 34 additions & 11 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
<?php

return PhpCsFixer\Config::create()
->setUsingCache(false)
->setUsingCache(true)
->setCacheFile(__DIR__ . '/.php_cs.cache')
->setRules([
'@PSR2' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => true,
'no_whitespace_in_blank_line' => true,
'no_unused_imports' => true,
'blank_line_before_return' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => ['statements' => ['return']],
'cast_spaces' => true,
'concat_space' => ['spacing' => 'one'],
'constant_case' => true,
'declare_equal_normalize' => true,
'lowercase_cast' => true,
'method_argument_space' => true,
'method_separation' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'trim_array_spaces' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => true,
'phpdoc_scalar' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'no_empty_statement' => true,
'concat_space' => ['spacing' => 'one'],
'no_multiline_whitespace_before_semicolons' => true,
'no_leading_import_slash' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types_order' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'single_quote' => true,
'short_scalar_cast' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'ternary_to_null_coalescing' => true,
'trim_array_spaces' => true,
'visibility_required' => ['elements' => ['property', 'method', 'const']],
'yoda_style' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('db')
->in(__DIR__)
);
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: php
php:
- 7.2
- 7.3
- 7.4

install:
- travis_retry composer self-update
Expand Down
17 changes: 12 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
"description": "PHP bank cards IIN/BIN database. Get bank info by card number",
"license": "MIT",
"keywords": ["bin", "card", "creditcard", "iin", "issuer identification numbers"],
"homepage": "https://github.com/chekalskiy/php-banks-db",
"homepage": "https://github.com/chekalsky/php-banks-db",
"authors": [
{
"name": "Ilya Chekalskiy",
"email": "ilya@chekalskiy.ru",
"homepage": "http://chekalskiy.ru"
"name": "Ilya Chekalsky",
"email": "ilya@chekalsky.com",
"homepage": "https://chekalsky.com"
}
],
"require": {
"php": ">=7.2"
},
"require-dev": {
"phpunit/phpunit": "^8"
"ext-json": "*",
"friendsofphp/php-cs-fixer": "^2.16",
"phpunit/phpunit": "^8",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
"psr-4": {
Expand All @@ -26,6 +29,10 @@
"test": [
"vendor/bin/phpunit --coverage-clover=coverage.xml"
],
"lint": [
"vendor/bin/php-cs-fixer fix --config=.php_cs",
"vendor/bin/phpcbf -w"
],
"rebuild": [
"php parse.php"
]
Expand Down
11 changes: 8 additions & 3 deletions parse.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* This script needed only for one-time building the database after the submodule update
*/
Expand Down Expand Up @@ -78,9 +81,11 @@
$database_export = sprintf('<?php return %s;', var_export($database, true));

if (file_put_contents('db/bank_db.php', $database_export)) {
echo sprintf("Successfully exported %d prefixes for %d banks with prefixes\n",
echo sprintf(
"Successfully exported %d prefixes for %d banks with prefixes\n",
count($database['prefixes']),
count($database['banks']));
count($database['banks'])
);
}

function printError(string $text)
Expand All @@ -97,4 +102,4 @@ function addPrefix(int $prefix, int $bank_id, array &$database)
}

$database['prefixes'][$prefix] = $bank_id;
}
}
18 changes: 18 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg value="np"/>

<rule ref="PSR12"/>

<file>parse.php</file>
<file>src/</file>
<file>tests/</file>

</ruleset>
5 changes: 3 additions & 2 deletions src/BankDb.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace BankDb;
Expand All @@ -18,7 +19,7 @@ class BankDb
/**
* BankDb constructor.
*
* @param string|null $db_file_path
* @param null|string $db_file_path
*
* @throws BankDbException
*/
Expand Down Expand Up @@ -50,7 +51,7 @@ public function getBankInfo(string $card_number): BankInfo
/**
* Database init
*
* @param string|null $file_path
* @param null|string $file_path
*
* @throws BankDbException
*/
Expand Down
1 change: 1 addition & 0 deletions src/BankDbException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace BankDb;
Expand Down
1 change: 1 addition & 0 deletions src/BankInfo.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace BankDb;
Expand Down
1 change: 1 addition & 0 deletions tests/BankDbTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace BankDb;
Expand Down
1 change: 1 addition & 0 deletions tests/BankInfoTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace BankDb;
Expand Down

0 comments on commit 770df8e

Please sign in to comment.