From f5b868f5f402f9673da76c6318e2f284e627a448 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Thu, 15 Aug 2024 03:58:10 +0300 Subject: [PATCH] feat: phpcs, psr12 rules and fixes --- composer.json | 3 + composer.lock | 85 +++++++++++++++++++- example.php | 6 +- phpcs.xml | 8 ++ src/Exceptions/ApiResponseErrorException.php | 4 +- src/Exceptions/UnexpectedValueException.php | 4 +- 6 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 phpcs.xml diff --git a/composer.json b/composer.json index 3484377..75f8a8b 100644 --- a/composer.json +++ b/composer.json @@ -12,5 +12,8 @@ "psr-4": { "Ivuorinen\\BusinessDataFetcher\\": "src/" } + }, + "require-dev": { + "squizlabs/php_codesniffer": "^3.10" } } diff --git a/composer.lock b/composer.lock index bac4c48..6274968 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1651a96cd6f414d8650851a68e3cf096", + "content-hash": "db4a711b51fc33460388a38b09cee0ad", "packages": [ { "name": "guzzlehttp/guzzle", @@ -667,7 +667,88 @@ "time": "2024-04-18T09:32:20+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "squizlabs/php_codesniffer", + "version": "3.10.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/86e5f5dd9a840c46810ebe5ff1885581c42a3017", + "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-07-21T23:26:44+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/example.php b/example.php index 28938a8..433ef17 100644 --- a/example.php +++ b/example.php @@ -1,10 +1,10 @@ getBusinessInformation('1639413-9'); + $results = $client->getBusinessInformation("1639413-9"); print_r($results); } catch (\GuzzleHttp\Exception\GuzzleException $e) { var_dump($e); diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..66173cf --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,8 @@ + + + PSR12 + + + + + diff --git a/src/Exceptions/ApiResponseErrorException.php b/src/Exceptions/ApiResponseErrorException.php index 7799919..3a57a10 100644 --- a/src/Exceptions/ApiResponseErrorException.php +++ b/src/Exceptions/ApiResponseErrorException.php @@ -2,4 +2,6 @@ namespace Ivuorinen\BusinessDataFetcher\Exceptions; -class ApiResponseErrorException extends \Exception {} +class ApiResponseErrorException extends \Exception +{ +} diff --git a/src/Exceptions/UnexpectedValueException.php b/src/Exceptions/UnexpectedValueException.php index ea94f4e..c87c057 100644 --- a/src/Exceptions/UnexpectedValueException.php +++ b/src/Exceptions/UnexpectedValueException.php @@ -2,4 +2,6 @@ namespace Ivuorinen\BusinessDataFetcher\Exceptions; -class UnexpectedValueException extends \Exception {} +class UnexpectedValueException extends \Exception +{ +}