Skip to content

Commit 9d17bc6

Browse files
authored
Merge pull request #11 from CorpusPHP/phpstan
Add phpstan
2 parents 8978231 + a89db11 commit 9d17bc6

File tree

7 files changed

+38
-23
lines changed

7 files changed

+38
-23
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
operating-system: [ubuntu-latest]
14-
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
14+
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
1515

1616
runs-on: ${{ matrix.operating-system }}
1717

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/vendor/
2-
composer.lock
2+
composer.lock
3+
*.cache

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fix: cbf
88
vendor/bin/php-cs-fixer fix
99

1010
.PHONY: test
11-
test: cs
11+
test: cs phpstan
1212
vendor/bin/phpunit
1313

1414
.PHONY: cs
@@ -17,4 +17,8 @@ cs:
1717

1818
.PHONY: cbf
1919
cbf:
20-
vendor/bin/phpcbf
20+
vendor/bin/phpcbf
21+
22+
.PHONY: phpstan
23+
phpstan:
24+
vendor/bin/phpstan analyse

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ HTTP Status Codes and Exceptions
99

1010
## Requirements
1111

12-
- **php**: ^7.1 | ^8.0
12+
- **php**: ^7.2 | ^8.0
1313

1414
## Installing
1515

@@ -21,7 +21,7 @@ composer require 'corpus/http'
2121

2222
## Documentation
2323

24-
### Class: \Corpus\Http\Exceptions\AbstractHttpException
24+
### Class: Corpus\Http\Exceptions\AbstractHttpException
2525

2626
Base Exception class all HTTP Exception Classes Extend
2727

@@ -39,43 +39,43 @@ Use the HTTP Status code as the base exceptions code.
3939

4040
- ***string*** `$message`
4141

42-
### Class: \Corpus\Http\Exceptions\ClientError\AbstractClientErrorException
42+
### Class: Corpus\Http\Exceptions\ClientError\AbstractClientErrorException
4343

4444
Base of Exceptions Representing The 4xx Class
4545

46-
### Class: \Corpus\Http\Exceptions\ClientError\BadRequestException
46+
### Class: Corpus\Http\Exceptions\ClientError\BadRequestException
4747

4848
#### Method: BadRequestException->getHttpStatusCode
4949

5050
```php
5151
function getHttpStatusCode() : int
5252
```
5353

54-
### Class: \Corpus\Http\Exceptions\ClientError\ForbiddenException
54+
### Class: Corpus\Http\Exceptions\ClientError\ForbiddenException
5555

5656
#### Method: ForbiddenException->getHttpStatusCode
5757

5858
```php
5959
function getHttpStatusCode() : int
6060
```
6161

62-
### Class: \Corpus\Http\Exceptions\ClientError\NotFoundException
62+
### Class: Corpus\Http\Exceptions\ClientError\NotFoundException
6363

6464
#### Method: NotFoundException->getHttpStatusCode
6565

6666
```php
6767
function getHttpStatusCode() : int
6868
```
6969

70-
### Class: \Corpus\Http\Exceptions\ClientError\UnauthorizedException
70+
### Class: Corpus\Http\Exceptions\ClientError\UnauthorizedException
7171

7272
#### Method: UnauthorizedException->getHttpStatusCode
7373

7474
```php
7575
function getHttpStatusCode() : int
7676
```
7777

78-
### Class: \Corpus\Http\Exceptions\Redirection\AbstractLocationRedirectionHttpException
78+
### Class: Corpus\Http\Exceptions\Redirection\AbstractLocationRedirectionHttpException
7979

8080
Base of 3xx Exceptions which include a "Location" header.
8181

@@ -96,51 +96,51 @@ AbstractRedirectionHttpException constructor.
9696

9797
#### Undocumented Method: `AbstractLocationRedirectionHttpException->getLocation()`
9898

99-
### Class: \Corpus\Http\Exceptions\Redirection\AbstractRedirectionHttpException
99+
### Class: Corpus\Http\Exceptions\Redirection\AbstractRedirectionHttpException
100100

101101
Base of Exceptions Representing The 3xx Class
102102

103-
### Class: \Corpus\Http\Exceptions\Redirection\FoundException
103+
### Class: Corpus\Http\Exceptions\Redirection\FoundException
104104

105105
#### Method: FoundException->getHttpStatusCode
106106

107107
```php
108108
function getHttpStatusCode() : int
109109
```
110110

111-
### Class: \Corpus\Http\Exceptions\Redirection\SeeOtherException
111+
### Class: Corpus\Http\Exceptions\Redirection\SeeOtherException
112112

113113
#### Method: SeeOtherException->getHttpStatusCode
114114

115115
```php
116116
function getHttpStatusCode() : int
117117
```
118118

119-
### Class: \Corpus\Http\Exceptions\ServerError\AbstractServerErrorException
119+
### Class: Corpus\Http\Exceptions\ServerError\AbstractServerErrorException
120120

121121
Base of Exceptions Representing The 5xx Class
122122

123-
### Class: \Corpus\Http\Exceptions\ServerError\InternalServerErrorException
123+
### Class: Corpus\Http\Exceptions\ServerError\InternalServerErrorException
124124

125125
#### Method: InternalServerErrorException->getHttpStatusCode
126126

127127
```php
128128
function getHttpStatusCode() : int
129129
```
130130

131-
### Class: \Corpus\Http\Exceptions\Success\AbstractSuccessException
131+
### Class: Corpus\Http\Exceptions\Success\AbstractSuccessException
132132

133133
Base of Exceptions Representing The 2xx Class
134134

135-
### Class: \Corpus\Http\Exceptions\Success\NoContentException
135+
### Class: Corpus\Http\Exceptions\Success\NoContentException
136136

137137
#### Method: NoContentException->getHttpStatusCode
138138

139139
```php
140140
function getHttpStatusCode() : int
141141
```
142142

143-
### Class: \Corpus\Http\Status
143+
### Class: Corpus\Http\Status
144144

145145
```php
146146
<?php
@@ -209,6 +209,9 @@ class Status {
209209
public const LoopDetected = 508;
210210
public const NotExtended = 510;
211211
public const NetworkAuthenticationRequired = 511;
212+
/**
213+
* @var array<int,string>
214+
*/
212215
public static $statusText = [self::StatusContinue => 'Continue', self::SwitchingProtocols => 'Switching Protocols', self::Processing => 'Processing', self::EarlyHints => 'Early Hints', self::OK => 'OK', self::Created => 'Created', self::Accepted => 'Accepted', self::NonAuthoritativeInfo => 'Non-Authoritative Information', self::NoContent => 'No Content', self::ResetContent => 'Reset Content', self::PartialContent => 'Partial Content', self::MultiStatus => 'Multi-Status', self::AlreadyReported => 'Already Reported', self::IMUsed => 'IM Used', self::MultipleChoices => 'Multiple Choices', self::MovedPermanently => 'Moved Permanently', self::Found => 'Found', self::SeeOther => 'See Other', self::NotModified => 'Not Modified', self::UseProxy => 'Use Proxy', self::TemporaryRedirect => 'Temporary Redirect', self::PermanentRedirect => 'Permanent Redirect', self::BadRequest => 'Bad Request', self::Unauthorized => 'Unauthorized', self::PaymentRequired => 'Payment Required', self::Forbidden => 'Forbidden', self::NotFound => 'Not Found', self::MethodNotAllowed => 'Method Not Allowed', self::NotAcceptable => 'Not Acceptable', self::ProxyAuthRequired => 'Proxy Authentication Required', self::RequestTimeout => 'Request Timeout', self::Conflict => 'Conflict', self::Gone => 'Gone', self::LengthRequired => 'Length Required', self::PreconditionFailed => 'Precondition Failed', self::RequestEntityTooLarge => 'Request Entity Too Large', self::RequestURITooLong => 'Request URI Too Long', self::UnsupportedMediaType => 'Unsupported Media Type', self::RequestedRangeNotSatisfiable => 'Requested Range Not Satisfiable', self::ExpectationFailed => 'Expectation Failed', self::Teapot => 'I\'m a teapot', self::MisdirectedRequest => 'Misdirected Request', self::UnprocessableEntity => 'Unprocessable Entity', self::Locked => 'Locked', self::FailedDependency => 'Failed Dependency', self::TooEarly => 'Too Early', self::UpgradeRequired => 'Upgrade Required', self::PreconditionRequired => 'Precondition Required', self::TooManyRequests => 'Too Many Requests', self::RequestHeaderFieldsTooLarge => 'Request Header Fields Too Large', self::UnavailableForLegalReasons => 'Unavailable For Legal Reasons', self::InternalServerError => 'Internal Server Error', self::NotImplemented => 'Not Implemented', self::BadGateway => 'Bad Gateway', self::ServiceUnavailable => 'Service Unavailable', self::GatewayTimeout => 'Gateway Timeout', self::HTTPVersionNotSupported => 'HTTP Version Not Supported', self::VariantAlsoNegotiates => 'Variant Also Negotiates', self::InsufficientStorage => 'Insufficient Storage', self::LoopDetected => 'Loop Detected', self::NotExtended => 'Not Extended', self::NetworkAuthenticationRequired => 'Network Authentication Required'];
213216
}
214217
```
@@ -221,7 +224,7 @@ function statusText(int $code) : ?string
221224

222225
Return the text for an HTTP status code.
223226

224-
### Class: \Corpus\Http\StatusAwareInterface
227+
### Class: Corpus\Http\StatusAwareInterface
225228

226229
#### Method: StatusAwareInterface->getHttpStatusCode
227230

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.1 | ^8.0"
13+
"php": "^7.2 | ^8.0"
1414
},
1515
"autoload": {
1616
"psr-4": {
@@ -21,7 +21,8 @@
2121
"phpunit/phpunit": "~7.5 | ~9.0",
2222
"squizlabs/php_codesniffer": "^3.5",
2323
"corpus/coding-standard": "^0.6.0",
24-
"friendsofphp/php-cs-fixer": "^2.17"
24+
"friendsofphp/php-cs-fixer": "^2.17",
25+
"phpstan/phpstan": "^1.12"
2526
},
2627
"config": {
2728
"allow-plugins": {

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 9
3+
paths:
4+
- src
5+
phpVersion: 70200

src/Status.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ abstract class Status {
7272
public const NotExtended = 510; // RFC 2774, 7
7373
public const NetworkAuthenticationRequired = 511; // RFC 6585, 6
7474

75+
/** @var array<int,string> */
7576
public static $statusText = [
7677
self::StatusContinue => 'Continue',
7778
self::SwitchingProtocols => 'Switching Protocols',

0 commit comments

Comments
 (0)