Skip to content

Commit 8444917

Browse files
Add PSR-12 enforcement via PHP_CodeSniffer
1 parent 91f4792 commit 8444917

6 files changed

Lines changed: 130 additions & 77 deletions

File tree

.phpcs.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="openapi-php-sdk">
3+
<description>PSR-12 coding standard</description>
4+
5+
<file>src/</file>
6+
7+
<arg name="basepath" value="."/>
8+
<arg name="colors"/>
9+
<arg value="p"/>
10+
11+
<rule ref="PSR12"/>
12+
</ruleset>

composer.json

Lines changed: 105 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,112 @@
11
{
2-
"name": "openapi/openapi-sdk",
3-
"description": "Minimal and agnostic PHP SDK for Openapi® (https://openapi.com)",
4-
"license": "MIT",
5-
"authors": [
6-
{
7-
"name": "Altravia",
8-
"email": "info@altravia.com",
9-
"homepage": "https://www.altravia.com",
10-
"role": "Maintainer"
11-
},
12-
{
13-
"name": "Lorenzo Paderi",
14-
"email": "l.paderi@altravia.com",
15-
"homepage": "https://github.com/lpaderiAltravia",
16-
"role": "Developer"
17-
},
18-
{
19-
"name": "Mario Ugurcu",
20-
"email": "mario.ugurcu@wum-studios.de",
21-
"homepage": "https://github.com/Seraphim200001",
22-
"role": "Contributor"
23-
},
24-
{
25-
"name": "Francesco Bianco",
26-
"email": "bianco@javanile.org",
27-
"homepage": "https://github.com/francescobianco",
28-
"role": "Contributor"
29-
},
30-
{
31-
"name": "Claude Code (Anthropic)",
32-
"email": "noreply@anthropic.com",
33-
"homepage": "https://claude.ai/code",
34-
"role": "AI Contributor"
35-
}
36-
],
37-
"keywords": [
38-
"api", "rest", "http", "client", "sdk", "oauth", "oauth2", "token",
39-
"sms", "pec", "email", "geocoding", "company", "business-registry",
40-
"italy", "italian", "imprese", "visure", "catasto",
41-
"laravel", "symfony", "codeigniter", "yii", "slim", "lumen",
42-
"cakephp", "phalcon", "laminas", "zend", "october", "wordpress",
43-
"php", "php8", "curl", "psr-18", "http-client", "guzzle"
44-
],
45-
"minimum-stability": "stable",
46-
"require": {
47-
"php": ">=8.0.0",
48-
"ext-curl": "*",
49-
"ext-json": "*",
50-
"psr/http-client": "^1.0"
2+
"name": "openapi/openapi-sdk",
3+
"description": "Minimal and agnostic PHP SDK for Openapi® (https://openapi.com)",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Altravia",
8+
"email": "info@altravia.com",
9+
"homepage": "https://www.altravia.com",
10+
"role": "Maintainer"
5111
},
52-
"require-dev": {
53-
"symfony/dotenv": "^5.3",
54-
"phpunit/phpunit": "^9.5",
55-
"phpstan/phpstan": "^2.1"
12+
{
13+
"name": "Lorenzo Paderi",
14+
"email": "l.paderi@altravia.com",
15+
"homepage": "https://github.com/lpaderiAltravia",
16+
"role": "Developer"
5617
},
57-
"autoload": {
58-
"psr-4": {
59-
"Openapi\\": "src"
60-
},
61-
"files": [
62-
"src/Bootstrap.php"
63-
]
18+
{
19+
"name": "Mario Ugurcu",
20+
"email": "mario.ugurcu@wum-studios.de",
21+
"homepage": "https://github.com/Seraphim200001",
22+
"role": "Contributor"
6423
},
65-
"autoload-dev": {
66-
"psr-4": {
67-
"Tests\\": "tests"
68-
}
24+
{
25+
"name": "Francesco Bianco",
26+
"email": "bianco@javanile.org",
27+
"homepage": "https://github.com/francescobianco",
28+
"role": "Contributor"
6929
},
70-
"scripts": {
71-
"analyse": "vendor/bin/phpstan analyse -c phpstan.neon",
72-
"test": "phpunit tests/",
73-
"test:unit": "phpunit tests/ --testsuite=unit",
74-
"example:token": "php examples/token_generation.php",
75-
"example:api": "php examples/api_calls.php",
76-
"example:complete": "php examples/complete_workflow.php"
30+
{
31+
"name": "Claude Code (Anthropic)",
32+
"email": "noreply@anthropic.com",
33+
"homepage": "https://claude.ai/code",
34+
"role": "AI Contributor"
7735
}
36+
],
37+
"keywords": [
38+
"api",
39+
"rest",
40+
"http",
41+
"client",
42+
"sdk",
43+
"oauth",
44+
"oauth2",
45+
"token",
46+
"sms",
47+
"pec",
48+
"email",
49+
"geocoding",
50+
"company",
51+
"business-registry",
52+
"italy",
53+
"italian",
54+
"imprese",
55+
"visure",
56+
"catasto",
57+
"laravel",
58+
"symfony",
59+
"codeigniter",
60+
"yii",
61+
"slim",
62+
"lumen",
63+
"cakephp",
64+
"phalcon",
65+
"laminas",
66+
"zend",
67+
"october",
68+
"wordpress",
69+
"php",
70+
"php8",
71+
"curl",
72+
"psr-18",
73+
"http-client",
74+
"guzzle"
75+
],
76+
"minimum-stability": "stable",
77+
"require": {
78+
"php": ">=8.0.0",
79+
"ext-curl": "*",
80+
"ext-json": "*",
81+
"psr/http-client": "^1.0"
82+
},
83+
"require-dev": {
84+
"symfony/dotenv": "^5.3",
85+
"phpunit/phpunit": "^9.5",
86+
"phpstan/phpstan": "^2.1",
87+
"squizlabs/php_codesniffer": "^4.0"
88+
},
89+
"autoload": {
90+
"psr-4": {
91+
"Openapi\\": "src"
92+
},
93+
"files": [
94+
"src/Bootstrap.php"
95+
]
96+
},
97+
"autoload-dev": {
98+
"psr-4": {
99+
"Tests\\": "tests"
100+
}
101+
},
102+
"scripts": {
103+
"analyse": "vendor/bin/phpstan analyse -c phpstan.neon",
104+
"test": "phpunit tests/",
105+
"test:unit": "phpunit tests/ --testsuite=unit",
106+
"example:token": "php examples/token_generation.php",
107+
"example:api": "php examples/api_calls.php",
108+
"example:complete": "php examples/complete_workflow.php",
109+
"cs": "phpcs",
110+
"cs-fix": "phpcbf"
111+
}
78112
}

src/ApiException.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ class ApiException extends \Exception
1212
/**
1313
* TODO: Utilize this method in Client and OauthClient to provide structured error context
1414
*/
15-
public function setServerResponse(mixed $response, mixed $headers = null, mixed $rawResponse = null, ?int $httpCode = null): void
16-
{
15+
public function setServerResponse(
16+
mixed $response,
17+
mixed $headers = null,
18+
mixed $rawResponse = null,
19+
?int $httpCode = null
20+
): void {
1721
$this->serverResponse = $response;
1822
$this->headers = $headers;
1923
$this->rawResponse = $rawResponse;

src/Bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
4+
35
declare(strict_types=1);
46

57
use Openapi\Environment\DotEnv;

src/OauthClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class OauthClient
88
private string $username;
99
private string $apikey;
1010

11-
const OAUTH_BASE_URL = 'https://oauth.openapi.it';
12-
const TEST_OAUTH_BASE_URL = 'https://test.oauth.openapi.it';
11+
public const OAUTH_BASE_URL = 'https://oauth.openapi.it';
12+
public const TEST_OAUTH_BASE_URL = 'https://test.oauth.openapi.it';
1313

1414
public function __construct(?string $username = null, ?string $apikey = null, bool $test = false)
1515
{
@@ -59,7 +59,7 @@ public function getCounters(string $period, string $date): string
5959
return $this->request('GET', $this->url . '/counters/' . $period . '/' . $date);
6060
}
6161

62-
62+
6363
/**
6464
* @param array<string, mixed>|null $body
6565
*/

src/Transports/CurlTransport.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ final class CurlTransport implements HttpTransportInterface
88
{
99
public function __construct(
1010
private ?string $token = null
11-
) {}
11+
) {
12+
}
1213

1314
public function request(
1415
string $method,

0 commit comments

Comments
 (0)