Skip to content

Commit a54cb40

Browse files
authored
Merge pull request #257 from neildaniels/reintroduce-phpstan
Reintroduce PHPStan
2 parents af52c60 + a84c9a4 commit a54cb40

File tree

122 files changed

+697
-698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+697
-698
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
strategy:
1414
matrix:
1515
php-version:
16-
- "7.3"
1716
- "7.4"
1817
- "8.0"
1918
- "8.1"
@@ -24,15 +23,6 @@ jobs:
2423
symfony-deprecations-helper:
2524
- ""
2625
include:
27-
- php-version: "7.3"
28-
deps: "normal"
29-
30-
- php-version: "7.3"
31-
deps: "low"
32-
33-
- php-version: "7.3"
34-
deps: "dev"
35-
3626
- php-version: "7.4"
3727
deps: "normal"
3828

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Static Analysis
2+
3+
on: ["pull_request", "push"]
4+
5+
jobs:
6+
static-analysis-phpstan:
7+
name: "PHPStan"
8+
runs-on: "ubuntu-latest"
9+
10+
strategy:
11+
matrix:
12+
php-version:
13+
- "7.4"
14+
- "8.0"
15+
- "8.1"
16+
17+
steps:
18+
- name: "Checkout code"
19+
uses: "actions/checkout@v3"
20+
21+
- name: "Install PHP"
22+
uses: "shivammathur/setup-php@v2"
23+
with:
24+
coverage: "none"
25+
php-version: "${{ matrix.php-version }}"
26+
tools: cs2pr
27+
28+
- name: "Install dependencies with Composer"
29+
uses: "ramsey/composer-install@v2"
30+
with:
31+
php_version: "${{ matrix.php-version }}"
32+
33+
- name: "Run PHPStan"
34+
run: "vendor/bin/phpstan analyse --error-format=checkstyle --no-progress | cs2pr"
35+
36+
# static-analysis-psalm:
37+
# name: "Psalm"
38+
# runs-on: "ubuntu-latest"
39+
#
40+
# strategy:
41+
# matrix:
42+
# php-version:
43+
# - "7.4"
44+
#
45+
# steps:
46+
# - name: "Checkout code"
47+
# uses: "actions/checkout@v2"
48+
#
49+
# - name: "Install PHP"
50+
# uses: "shivammathur/setup-php@v2"
51+
# with:
52+
# coverage: "none"
53+
# php-version: "${{ matrix.php-version }}"
54+
#
55+
# - name: "Install dependencies with Composer"
56+
# uses: "ramsey/composer-install@v1"
57+
#
58+
# - name: "Run a static analysis with vimeo/psalm"
59+
# run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)"

.github/workflows/static-analysis.yml.bak

Lines changed: 0 additions & 57 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ composer.lock
88
.phpunit.result.cache
99
examples/
1010
examples/var/
11+
phpstan.neon$

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"squizlabs/php_codesniffer": "^3.5.8",
5454
"symfony/cache": ">=4.4 || ^5 || ^6",
5555
"symfony/event-dispatcher": ">=4.4 || ^5 || ^6",
56-
"phpstan/phpstan": "^0.12.18",
56+
"phpstan/phpstan": "^1.8.1",
5757
"phpunit/phpunit": ">=8.5.23 || ^9.3",
5858
"php-http/guzzle7-adapter": "^0.1",
5959
"monolog/monolog": ">=1.11.0",
@@ -77,5 +77,10 @@
7777
"php-http/cache-plugin": "When making use of cache, you need to install this plugin.",
7878
"psr/simple-cache-implementation": "If you wish to enable caching features, provide an PSR-16 cache."
7979
},
80-
"type": "library"
80+
"type": "library",
81+
"config": {
82+
"allow-plugins": {
83+
"dealerdirect/phpcodesniffer-composer-installer": true
84+
}
85+
}
8186
}

lib/Tmdb/Api/Authentication.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public function validateRequestTokenWithLogin($requestToken, $username, $passwor
102102
if ($e->getCode() == 401) {
103103
throw new UnauthorizedRequestTokenException("The request token has not been validated yet.");
104104
}
105+
106+
return null;
105107
}
106108
//@codeCoverageIgnoreEnd
107109
}
@@ -128,6 +130,8 @@ public function getNewSession($requestToken)
128130
if ($e->getCode() == 401) {
129131
throw new UnauthorizedRequestTokenException("The request token has not been validated yet.");
130132
}
133+
134+
return null;
131135
//@codeCoverageIgnoreEnd
132136
}
133137
}

lib/Tmdb/Api/Tv.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,13 @@ public function rateTvShow($id, $rating)
289289
* Get the alternative titles for a specific show ID.
290290
*
291291
* @param integer $id
292+
* @param array $parameters
293+
* @param array $headers
292294
* @return mixed
293295
*/
294-
public function getAlternativeTitles($id)
296+
public function getAlternativeTitles($id, array $parameters = [], array $headers = [])
295297
{
296-
return $this->get('tv/' . $id . '/alternative_titles');
298+
return $this->get('tv/' . $id . '/alternative_titles', $parameters, $headers);
297299
}
298300

299301
/**

lib/Tmdb/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ public function getGuestSessionToken(): ?GuestSessionToken
264264

265265
/**
266266
* @param GuestSessionToken|null $guestSessionToken
267-
* @return $this
267+
* @return self
268268
*/
269-
public function setGuestSessionToken(GuestSessionToken $guestSessionToken): Client
269+
public function setGuestSessionToken(?GuestSessionToken $guestSessionToken): Client
270270
{
271271
$this->options['guest_session_token'] = $guestSessionToken;
272272

lib/Tmdb/Event/HydrationEvent.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getSubject(): AbstractModel
6363

6464
/**
6565
* @param AbstractModel $subject
66-
* @return $this
66+
* @return self
6767
*/
6868
public function setSubject(AbstractModel $subject): HydrationEvent
6969
{
@@ -82,7 +82,7 @@ public function getData(): array
8282

8383
/**
8484
* @param array $data
85-
* @return $this
85+
* @return self
8686
*/
8787
public function setData(array $data = []): HydrationEvent
8888
{
@@ -109,7 +109,7 @@ public function getLastRequest(): ?RequestInterface
109109

110110
/**
111111
* @param RequestInterface|null $lastRequest
112-
* @return $this
112+
* @return self
113113
*/
114114
public function setLastRequest(RequestInterface $lastRequest = null): HydrationEvent
115115
{
@@ -128,7 +128,7 @@ public function getLastResponse(): ?ResponseInterface
128128

129129
/**
130130
* @param ResponseInterface|null $lastResponse
131-
* @return $this
131+
* @return self
132132
*/
133133
public function setLastResponse(ResponseInterface $lastResponse = null): HydrationEvent
134134
{

lib/Tmdb/Event/Listener/Logger/LogHydrationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class LogHydrationListener
3232
private $logger;
3333

3434
/**
35-
* @var HttpMessageFormatterInterface
35+
* @var HydrationFormatterInterface
3636
*/
3737
private $formatter;
3838

0 commit comments

Comments
 (0)