Skip to content

Commit

Permalink
Updated stable dev deps and fix styles
Browse files Browse the repository at this point in the history
| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -

PHP-CS-FIX and PHPUnit fix after updates up to stables versions
  • Loading branch information
ronanguilloux committed Dec 27, 2020
1 parent 96ef488 commit 1328946
Show file tree
Hide file tree
Showing 84 changed files with 290 additions and 237 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,6 @@
/build/*
/bin/*
/phpunit.xml
.phpunit.result.cache
.php_cs.cache

1 change: 1 addition & 0 deletions .php_cs.php
Expand Up @@ -2,6 +2,7 @@
return PhpCsFixer\Config::create()
->setRules(array(
'@PSR2' => true,
'@Symfony' => true,
'linebreak_after_opening_tag' => true,
'ordered_imports' => true,
'method_argument_space' => [
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -50,7 +50,7 @@ update:
@composer install --optimize-autoloader

.git/hook/pre-commit:
@curl -s -o .git/hooks/pre-commit https://raw.githubusercontent.com/polypodes/Build-and-Deploy/master/hooks/pre-commit
@cp -s -o .git/hooks/pre-commit pre-commit
@chmod +x .git/hooks/pre-commit

############################################################################
Expand Down Expand Up @@ -87,7 +87,7 @@ dry-fix:
cs-fix:
@bin/phpcbf --standard=PSR2 src
@bin/phpcbf --standard=PSR2 tests
@bin/php-cs-fixer fix --config=.php_cs.php --stop-on-violation --using-cache=no -vv
@bin/php-cs-fixer fix --config=.php_cs.php --using-cache=no -vv

#quality must remain quiet, as far as it's used in a pre-commit hook validation
quality: sniff dry-fix
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Expand Up @@ -20,15 +20,15 @@
"giggsey/libphonenumber-for-php": "^7.2|~8.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "~2.5",
"sebastian/phpcpd": "~2.0",
"phploc/phploc" : "~3.0",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "~3",
"sebastian/phpcpd": "~6",
"phploc/phploc" : "~7",
"phpmd/phpmd" : "@stable",
"pdepend/pdepend" : "~2.1",
"pdepend/pdepend" : "~2",
"friendsofphp/php-cs-fixer": "@stable",
"php-coveralls/php-coveralls": "^2.0",
"symfony/phpunit-bridge": "^4.1"
"php-coveralls/php-coveralls": "^2",
"symfony/phpunit-bridge": "^5"
},
"suggest": {
"sllh/iso-codes-validator": "For Symfony or Silex integration with ease",
Expand Down
50 changes: 50 additions & 0 deletions pre-commit
@@ -0,0 +1,50 @@
#!/bin/sh

# @source: https://gist.github.com/ronanguilloux/11f6a788358577474ab4
# @link http://tech.zumba.com/2014/04/14/control-code-quality/


PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`

# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
'
SFILES="$1"
IFS=$oIFS
fi
SFILES=${SFILES:-$STAGED_FILES_CMD}

echo "Checking PHP Lint..."
for FILE in $SFILES
do
php -l -d display_errors=0 $PROJECT/$FILE
if [ $? != 0 ]
then
echo "Fix the error before commit."
exit 1
fi
FILES="$FILES $PROJECT/$FILE"
done

if [ "$FILES" != "" ]
then
# --------------------------------------------------
# this is where magic happens,
# and you can add your own rules here:

bin/phpcs --standard=PSR2 src -n
bin/php-cs-fixer fix --config=.php_cs.php --dry-run --stop-on-violation --using-cache=no -vv

# --------------------------------------------------
if [ $? != 0 ]
then
echo "Fix the error before commit."
exit 1
fi
fi

exit $?
16 changes: 10 additions & 6 deletions src/IsoCodes/Abn.php
Expand Up @@ -3,17 +3,20 @@
namespace IsoCodes;

/**
* Class Abn, Australian Business Number
* Class Abn, Australian Business Number.
*
* @link https://en.wikipedia.org/wiki/Australian_Business_Number
* @link https://abr.business.gov.au/
* @see https://en.wikipedia.org/wiki/Australian_Business_Number
* @see https://abr.business.gov.au/
*/
class Abn implements IsoCodeInterface
{
/**
* Validate an Australian Business Number (ABN)
* Validate an Australian Business Number (ABN).
*
* @author Paul Ferrett, 2009 (http://www.paulferrett.com)
*
* @param string $abn
*
* @return bool
*/
public static function validate($abn)
Expand All @@ -22,16 +25,17 @@ public static function validate($abn)
$sum = 0;
$abn = preg_replace('/[^0-9]/', '', $abn);
$abn = Utils::unDecorate($abn, [' ']);
if (mb_strlen($abn) !== 11) {
if (11 !== mb_strlen($abn)) {
return false;
}
$abn[0] = ((int)$abn[0] - 1); // Subtract one from first digit
$abn[0] = ((int) $abn[0] - 1); // Subtract one from first digit
foreach (str_split($abn) as $key => $digit) {
$sum += ($digit * $weights[$key]);
}
if (($sum % 89) != 0) {
return false;
}

return true;
}
}
6 changes: 3 additions & 3 deletions src/IsoCodes/Bban.php
Expand Up @@ -15,8 +15,8 @@ class Bban implements IsoCodeInterface
* @author petitchevalroux
* @licence originale http://creativecommons.org/licenses/by-sa/2.0/fr/
*
* @link http://dev.petitchevalroux.net/php/valider-bban-php.359.html
* @link http://fr.wikipedia.org/wiki/Relev%C3%A9_d%27identit%C3%A9_bancaire
* @see http://dev.petitchevalroux.net/php/valider-bban-php.359.html
* @see http://fr.wikipedia.org/wiki/Relev%C3%A9_d%27identit%C3%A9_bancaire
*
* @return bool
*/
Expand All @@ -26,7 +26,7 @@ public static function validate($bban)
throw new \RuntimeException(__METHOD__.' needs the bcmath extension.');
}

if (mb_strlen($bban) !== 23) {
if (23 !== mb_strlen($bban)) {
return false;
}
$key = substr($bban, -2);
Expand Down
14 changes: 7 additions & 7 deletions src/IsoCodes/Bsn.php
Expand Up @@ -6,10 +6,10 @@
* In the Netherlands, the citizen service number (BSN) is a unique personal number
* allocated to everyone registered in the Municipal Personal Records Database.
*
* @link https://www.government.nl/topics/identification-documents/contents/the-citizen-service-number
* @link https://nl.wikipedia.org/wiki/Elfproef (dutch)
* @link https://nl.wikipedia.org/wiki/Burgerservicenummer (dutch)
* @link http://datavaluetalk.com/data-quality/remarkable-facts-on-dutch-national-personal-identification-number-burgerservicenummer-bsn/
* @see https://www.government.nl/topics/identification-documents/contents/the-citizen-service-number
* @see https://nl.wikipedia.org/wiki/Elfproef (dutch)
* @see https://nl.wikipedia.org/wiki/Burgerservicenummer (dutch)
* @see http://datavaluetalk.com/data-quality/remarkable-facts-on-dutch-national-personal-identification-number-burgerservicenummer-bsn/
*
* @author Albert Bakker <hello@abbert.nl>
*/
Expand All @@ -28,20 +28,20 @@ public static function validate($value)

$stringLength = strlen($value);

if ($stringLength !== 9 && $stringLength !== 8) {
if (9 !== $stringLength && 8 !== $stringLength) {
return false;
}

$sum = 0;
$multiplier = $stringLength;
for ($counter = 0; $counter < $stringLength; $counter++, $multiplier--) {
if ($multiplier == 1) {
if (1 == $multiplier) {
$multiplier = -1;
}

$sum += substr($value, $counter, 1) * $multiplier;
}

return $sum % 11 === 0;
return 0 === $sum % 11;
}
}
6 changes: 3 additions & 3 deletions src/IsoCodes/Cif.php
Expand Up @@ -11,7 +11,7 @@
*
* @source https://github.com/alrik11es/spanish-utils
*
* @link http://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal
* @see http://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal
*/
class Cif implements IsoCodeInterface
{
Expand All @@ -35,10 +35,10 @@ public static function validate($cif)
$n = (10 - substr($sum, -1)) % 10;

if (preg_match('/^[ABCDEFGHJKNPQRSUVW]{1}/', $cif)) {
if (in_array($cif[0], array('A', 'B', 'E', 'H'))) {
if (in_array($cif[0], ['A', 'B', 'E', 'H'])) {
// Numerico
return $cif[8] == $n;
} elseif (in_array($cif[0], array('K', 'P', 'Q', 'S'))) {
} elseif (in_array($cif[0], ['K', 'P', 'Q', 'S'])) {
// Letras
return $cif[8] == $cifCodes[$n];
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/IsoCodes/CreditCard.php
Expand Up @@ -16,7 +16,7 @@ class CreditCard implements IsoCodeInterface
*/
public static function validate($creditCard)
{
if (trim($creditCard) === '') {
if ('' === trim($creditCard)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/IsoCodes/Dun14.php
Expand Up @@ -6,7 +6,7 @@
* Class Dun14 for former Distribution Unit Number, 14 digits long codes.
* This is a symlink, for convenience purposes only.
*
* @link https://en.wikipedia.org/wiki/Global_Trade_Item_Number
* @see https://en.wikipedia.org/wiki/Global_Trade_Item_Number
*/
class Dun14 extends Gtin14 implements IsoCodeInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/IsoCodes/Ean13.php
Expand Up @@ -6,8 +6,8 @@
* Class Ean13 for former EAN/UCC-13 European/International Article Number, 13 digits long codes.
* This is a symlink, for convenience purposes only.
*
* @link https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @link https://en.wikipedia.org/wiki/Global_Trade_Item_Number
* @see https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @see https://en.wikipedia.org/wiki/Global_Trade_Item_Number
*/
class Ean13 extends Gtin13 implements IsoCodeInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/IsoCodes/Ean8.php
Expand Up @@ -6,8 +6,8 @@
* Class Ean8 for former EAN/UCC-8 European/International Article Number, 8 digits long codes.
* This is a symlink, for convenience purposes only.
*
* @link https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @link https://en.wikipedia.org/wiki/Global_Trade_Item_Number
* @see https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @see https://en.wikipedia.org/wiki/Global_Trade_Item_Number
*/
class Ean8 extends Gtin8 implements IsoCodeInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/IsoCodes/Gdti.php
Expand Up @@ -6,9 +6,9 @@
* Class Gdti for GS1 Global Document Type Identifier (GDTI)
* used by companies to identify documents, including the class or type of each document.
*
* @link http://www.gs1.org/global-document-type-identifier-gdti
* @link http://www.gs1.org/docs/idkeys/GS1_GDTI_Executive_Summary.pdf
* @link https://en.wikipedia.org/wiki/Global_Document_Type_Identifier
* @see http://www.gs1.org/global-document-type-identifier-gdti
* @see http://www.gs1.org/docs/idkeys/GS1_GDTI_Executive_Summary.pdf
* @see https://en.wikipedia.org/wiki/Global_Document_Type_Identifier
*/
class Gdti extends Gtin13 implements IsoCodeInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/IsoCodes/Gln.php
Expand Up @@ -7,8 +7,8 @@
* It is a simple tool used to identify a location and can identify locations uniquely where required.
* The mechanism for GLN is the same as GTIN-13.
*
* @link https://en.wikipedia.org/wiki/Global_Location_Number
* @link https://en.wikipedia.org/wiki/Global_Trade_Item_Number
* @see https://en.wikipedia.org/wiki/Global_Location_Number
* @see https://en.wikipedia.org/wiki/Global_Trade_Item_Number
*/
class Gln extends Gtin13 implements IsoCodeInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/IsoCodes/Grai.php
Expand Up @@ -6,9 +6,9 @@
* Class Grai for Global Returnable Asset Identifier, from GS1
* Used for the management of reusable transport items, transport equipment, and tools.
*
* @link http://www.gs1.org/grai
* @link http://www.gs1.org/docs/idkeys/GS1_GRAI_Executive_Summary.pdf
* @link https://en.wikipedia.org/wiki/Global_Returnable_Asset_Identifier
* @see http://www.gs1.org/grai
* @see http://www.gs1.org/docs/idkeys/GS1_GRAI_Executive_Summary.pdf
* @see https://en.wikipedia.org/wiki/Global_Returnable_Asset_Identifier
*/
class Grai extends Gtin13 implements IsoCodeInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/IsoCodes/Gsrn.php
Expand Up @@ -8,9 +8,9 @@
* (such as doctors who work for a hospital) and individual service clients
* (such as the metering points of an electricity company, or the loyalty account members of a retailer.).
*
* @link https://en.wikipedia.org/wiki/Global_Service_Relationship_Number
* @link http://www.gs1.org/global-service-relation-number-gsrn
* @link http://www.gs1.org/docs/idkeys/GS1_GSRN_Executive_Summary.pdf
* @see https://en.wikipedia.org/wiki/Global_Service_Relationship_Number
* @see http://www.gs1.org/global-service-relation-number-gsrn
* @see http://www.gs1.org/docs/idkeys/GS1_GSRN_Executive_Summary.pdf
*/
class Gsrn extends Gtin implements IsoCodeInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/IsoCodes/Gtin.php
Expand Up @@ -5,7 +5,7 @@
/**
* Abstract Class Gtin Global Trade Item Numbers.
*
* @link http://www.gs1.org/how-calculate-check-digit-manually
* @see http://www.gs1.org/how-calculate-check-digit-manually
*/
abstract class Gtin extends Luhn
{
Expand Down
2 changes: 1 addition & 1 deletion src/IsoCodes/Gtin12.php
Expand Up @@ -6,7 +6,7 @@
* Class Gtin12 for European/International Article Number, 12 digits long code.
* Formerly known as UPC-A, EAN-12.
*
* @link https://en.wikipedia.org/wiki/Global_Trade_Item_Number
* @see https://en.wikipedia.org/wiki/Global_Trade_Item_Number
*/
class Gtin12 extends Gtin implements IsoCodeInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/IsoCodes/Gtin13.php
Expand Up @@ -5,8 +5,8 @@
/**
* Class Gtin13 for former EAN/UCC-13 European/International Article Number, 13 digits long codes.
*
* @link https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @link https://en.wikipedia.org/wiki/Global_Trade_Item_Number
* @see https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @see https://en.wikipedia.org/wiki/Global_Trade_Item_Number
*/
class Gtin13 extends Gtin implements IsoCodeInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/IsoCodes/Gtin14.php
Expand Up @@ -5,7 +5,7 @@
/**
* Class Gtin14 for European/International Article Number, 14 digits long code.
*
* @link https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @see https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
*/
class Gtin14 extends Gtin implements IsoCodeInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/IsoCodes/Gtin8.php
Expand Up @@ -8,9 +8,9 @@
* GTIN-8 (formerly EAN-8) is derived from EAN-13, introduced for use on small packages where an EAN-13 barcode would be too large;
* for example on cigarettes, pencils, and chewing gum packets.
*
* @link https://en.wikipedia.org/wiki/EAN-8
* @link https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @link https://en.wikipedia.org/wiki/Global_Trade_Item_Number
* @see https://en.wikipedia.org/wiki/EAN-8
* @see https://en.wikipedia.org/wiki/International_Article_Number_(EAN)
* @see https://en.wikipedia.org/wiki/Global_Trade_Item_Number
*/
class Gtin8 extends Gtin implements IsoCodeInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/IsoCodes/Hetu.php
Expand Up @@ -5,8 +5,8 @@
/**
* Class Hetu, Finnish personal identity code (HETU, Henkilötunnus).
*
* @link https://en.wikipedia.org/wiki/National_identification_number#Finland
* @link http://vrk.fi/en/personal-identity-code1
* @see https://en.wikipedia.org/wiki/National_identification_number#Finland
* @see http://vrk.fi/en/personal-identity-code1
*/
class Hetu implements IsoCodeInterface
{
Expand All @@ -33,7 +33,7 @@ class Hetu implements IsoCodeInterface
*/
public static function validate($hetu)
{
if (!is_string($hetu) || strlen($hetu) != 11) {
if (!is_string($hetu) || 11 != strlen($hetu)) {
return false;
}

Expand Down

0 comments on commit 1328946

Please sign in to comment.