From 84449177290e12e565dcada6f19237a1e932ed65 Mon Sep 17 00:00:00 2001 From: muhammadshaharyaraulakh Date: Sun, 7 Jun 2026 12:26:59 +0500 Subject: [PATCH] Add PSR-12 enforcement via PHP_CodeSniffer --- .phpcs.xml | 12 +++ composer.json | 176 ++++++++++++++++++------------- src/ApiException.php | 8 +- src/Bootstrap.php | 2 + src/OauthClient.php | 6 +- src/Transports/CurlTransport.php | 3 +- 6 files changed, 130 insertions(+), 77 deletions(-) create mode 100644 .phpcs.xml diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000..67e59ab --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,12 @@ + + + PSR-12 coding standard + + src/ + + + + + + + \ No newline at end of file diff --git a/composer.json b/composer.json index a10fc35..88cffec 100644 --- a/composer.json +++ b/composer.json @@ -1,78 +1,112 @@ { - "name": "openapi/openapi-sdk", - "description": "Minimal and agnostic PHP SDK for OpenapiĀ® (https://openapi.com)", - "license": "MIT", - "authors": [ - { - "name": "Altravia", - "email": "info@altravia.com", - "homepage": "https://www.altravia.com", - "role": "Maintainer" - }, - { - "name": "Lorenzo Paderi", - "email": "l.paderi@altravia.com", - "homepage": "https://github.com/lpaderiAltravia", - "role": "Developer" - }, - { - "name": "Mario Ugurcu", - "email": "mario.ugurcu@wum-studios.de", - "homepage": "https://github.com/Seraphim200001", - "role": "Contributor" - }, - { - "name": "Francesco Bianco", - "email": "bianco@javanile.org", - "homepage": "https://github.com/francescobianco", - "role": "Contributor" - }, - { - "name": "Claude Code (Anthropic)", - "email": "noreply@anthropic.com", - "homepage": "https://claude.ai/code", - "role": "AI Contributor" - } - ], - "keywords": [ - "api", "rest", "http", "client", "sdk", "oauth", "oauth2", "token", - "sms", "pec", "email", "geocoding", "company", "business-registry", - "italy", "italian", "imprese", "visure", "catasto", - "laravel", "symfony", "codeigniter", "yii", "slim", "lumen", - "cakephp", "phalcon", "laminas", "zend", "october", "wordpress", - "php", "php8", "curl", "psr-18", "http-client", "guzzle" - ], - "minimum-stability": "stable", - "require": { - "php": ">=8.0.0", - "ext-curl": "*", - "ext-json": "*", - "psr/http-client": "^1.0" + "name": "openapi/openapi-sdk", + "description": "Minimal and agnostic PHP SDK for OpenapiĀ® (https://openapi.com)", + "license": "MIT", + "authors": [ + { + "name": "Altravia", + "email": "info@altravia.com", + "homepage": "https://www.altravia.com", + "role": "Maintainer" }, - "require-dev": { - "symfony/dotenv": "^5.3", - "phpunit/phpunit": "^9.5", - "phpstan/phpstan": "^2.1" + { + "name": "Lorenzo Paderi", + "email": "l.paderi@altravia.com", + "homepage": "https://github.com/lpaderiAltravia", + "role": "Developer" }, - "autoload": { - "psr-4": { - "Openapi\\": "src" - }, - "files": [ - "src/Bootstrap.php" - ] + { + "name": "Mario Ugurcu", + "email": "mario.ugurcu@wum-studios.de", + "homepage": "https://github.com/Seraphim200001", + "role": "Contributor" }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests" - } + { + "name": "Francesco Bianco", + "email": "bianco@javanile.org", + "homepage": "https://github.com/francescobianco", + "role": "Contributor" }, - "scripts": { - "analyse": "vendor/bin/phpstan analyse -c phpstan.neon", - "test": "phpunit tests/", - "test:unit": "phpunit tests/ --testsuite=unit", - "example:token": "php examples/token_generation.php", - "example:api": "php examples/api_calls.php", - "example:complete": "php examples/complete_workflow.php" + { + "name": "Claude Code (Anthropic)", + "email": "noreply@anthropic.com", + "homepage": "https://claude.ai/code", + "role": "AI Contributor" } + ], + "keywords": [ + "api", + "rest", + "http", + "client", + "sdk", + "oauth", + "oauth2", + "token", + "sms", + "pec", + "email", + "geocoding", + "company", + "business-registry", + "italy", + "italian", + "imprese", + "visure", + "catasto", + "laravel", + "symfony", + "codeigniter", + "yii", + "slim", + "lumen", + "cakephp", + "phalcon", + "laminas", + "zend", + "october", + "wordpress", + "php", + "php8", + "curl", + "psr-18", + "http-client", + "guzzle" + ], + "minimum-stability": "stable", + "require": { + "php": ">=8.0.0", + "ext-curl": "*", + "ext-json": "*", + "psr/http-client": "^1.0" + }, + "require-dev": { + "symfony/dotenv": "^5.3", + "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^2.1", + "squizlabs/php_codesniffer": "^4.0" + }, + "autoload": { + "psr-4": { + "Openapi\\": "src" + }, + "files": [ + "src/Bootstrap.php" + ] + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests" + } + }, + "scripts": { + "analyse": "vendor/bin/phpstan analyse -c phpstan.neon", + "test": "phpunit tests/", + "test:unit": "phpunit tests/ --testsuite=unit", + "example:token": "php examples/token_generation.php", + "example:api": "php examples/api_calls.php", + "example:complete": "php examples/complete_workflow.php", + "cs": "phpcs", + "cs-fix": "phpcbf" + } } diff --git a/src/ApiException.php b/src/ApiException.php index f73a35e..2cb0ab4 100644 --- a/src/ApiException.php +++ b/src/ApiException.php @@ -12,8 +12,12 @@ class ApiException extends \Exception /** * TODO: Utilize this method in Client and OauthClient to provide structured error context */ - public function setServerResponse(mixed $response, mixed $headers = null, mixed $rawResponse = null, ?int $httpCode = null): void - { + public function setServerResponse( + mixed $response, + mixed $headers = null, + mixed $rawResponse = null, + ?int $httpCode = null + ): void { $this->serverResponse = $response; $this->headers = $headers; $this->rawResponse = $rawResponse; diff --git a/src/Bootstrap.php b/src/Bootstrap.php index c5ce834..1884a51 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -1,5 +1,7 @@ request('GET', $this->url . '/counters/' . $period . '/' . $date); } - + /** * @param array|null $body */ diff --git a/src/Transports/CurlTransport.php b/src/Transports/CurlTransport.php index 8a662be..002b74d 100644 --- a/src/Transports/CurlTransport.php +++ b/src/Transports/CurlTransport.php @@ -8,7 +8,8 @@ final class CurlTransport implements HttpTransportInterface { public function __construct( private ?string $token = null - ) {} + ) { + } public function request( string $method,