Skip to content

Commit 952826a

Browse files
authored
chore(tests): add phpstan static analysis
1 parent 894f672 commit 952826a

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

.github/workflows/tests.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,22 @@ jobs:
5353
command: composer install
5454
- name: Run PHPUnit
5555
run: vendor/bin/phpunit -v
56+
phpstan:
57+
name: "PHPStan"
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v2
61+
- name: Setup PHP
62+
uses: shivammathur/setup-php@v2
63+
with:
64+
php-version: 8.1
65+
- name: Install composer dependencies
66+
uses: nick-invision/retry@v1
67+
with:
68+
timeout_minutes: 10
69+
max_attempts: 3
70+
command: composer install
71+
- name: Run PHPStan
72+
run: |
73+
composer require phpstan/phpstan
74+
vendor/bin/phpstan analyse --level=0 src/

src/OAuth2/Autoloader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function register($dir = null)
3939
* Handles autoloading of classes.
4040
*
4141
* @param string $class - A class name.
42-
* @return boolean - Returns true if the class has been loaded
42+
* @return void
4343
*/
4444
public function autoload($class)
4545
{

src/OAuth2/GrantType/JwtBearer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public function __construct(JwtBearerInterface $storage, $audience, EncryptionIn
4646
$jwtUtil = new Jwt();
4747
}
4848

49-
$this->config = array_merge(array(
49+
$config = array_merge(array(
5050
'allowed_algorithms' => array('RS256', 'RS384', 'RS512')
5151
), $config);
5252

5353
$this->jwtUtil = $jwtUtil;
5454

55-
$this->allowedAlgorithms = $this->config['allowed_algorithms'];
55+
$this->allowedAlgorithms = $config['allowed_algorithms'];
5656
}
5757

5858
/**

src/OAuth2/Storage/CouchbaseDB.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace OAuth2\Storage;
44

5+
use Couchbase;
56
use OAuth2\OpenID\Storage\AuthorizationCodeInterface as OpenIDAuthorizationCodeInterface;
67

78
/**
@@ -27,14 +28,18 @@ class CouchbaseDB implements AuthorizationCodeInterface,
2728

2829
public function __construct($connection, $config = array())
2930
{
30-
if ($connection instanceof \Couchbase) {
31+
if (! class_exists(Couchbase::class)) {
32+
throw new \RuntimeException('Missing Couchbase');
33+
}
34+
35+
if ($connection instanceof Couchbase) {
3136
$this->db = $connection;
3237
} else {
3338
if (!is_array($connection) || !is_array($connection['servers'])) {
3439
throw new \InvalidArgumentException('First argument to OAuth2\Storage\CouchbaseDB must be an instance of Couchbase or a configuration array containing a server array');
3540
}
3641

37-
$this->db = new \Couchbase($connection['servers'], (!isset($connection['username'])) ? '' : $connection['username'], (!isset($connection['password'])) ? '' : $connection['password'], $connection['bucket'], false);
42+
$this->db = new Couchbase($connection['servers'], (!isset($connection['username'])) ? '' : $connection['username'], (!isset($connection['password'])) ? '' : $connection['password'], $connection['bucket'], false);
3843
}
3944

4045
$this->config = array_merge(array(
@@ -332,4 +337,4 @@ public function setJti($client_id, $subject, $audience, $expiration, $jti)
332337
//TODO: Needs couchbase implementation.
333338
throw new \Exception('setJti() for the Couchbase driver is currently unimplemented.');
334339
}
335-
}
340+
}

0 commit comments

Comments
 (0)