Skip to content

Commit 0b73236

Browse files
rdeutzRobertDeutz
andauthored
Revert bc breaks (#34)
* revert * update baseline --------- Co-authored-by: Robert Deutz <rd@rdbs.de>
1 parent 45950bb commit 0b73236

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

phpstan-baseline.neon

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,26 @@ parameters:
66
count: 2
77
path: src/Client.php
88

9+
-
10+
message: '#^Instanceof between ArrayAccess and ArrayAccess will always evaluate to true\.$#'
11+
identifier: instanceof.alwaysTrue
12+
count: 1
13+
path: src/Client.php
14+
15+
-
16+
message: '#^Instanceof between Joomla\\Application\\WebApplicationInterface and Joomla\\Application\\WebApplicationInterface will always evaluate to true\.$#'
17+
identifier: instanceof.alwaysTrue
18+
count: 1
19+
path: src/Client.php
20+
921
-
1022
message: '#^Method Joomla\\OAuth2\\Client\:\:query\(\) should return Joomla\\Http\\Response but returns false\.$#'
1123
identifier: return.type
1224
count: 1
1325
path: src/Client.php
26+
27+
-
28+
message: '#^Result of && is always false\.$#'
29+
identifier: booleanAnd.alwaysFalse
30+
count: 1
31+
path: src/Client.php

src/Client.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* @license GNU General Public License version 2 or later; see LICENSE
88
*/
99

10-
declare(strict_types=1);
11-
1210
namespace Joomla\OAuth2;
1311

1412
use Joomla\Application\WebApplicationInterface;
@@ -67,8 +65,14 @@ class Client
6765
*
6866
* @since 1.0
6967
*/
70-
public function __construct(array|\ArrayAccess $options = [], ?Http $http = null, ?Input $input = null, ?WebApplicationInterface $application = null)
68+
public function __construct($options = [], ?Http $http = null, ?Input $input = null, ?WebApplicationInterface $application = null)
7169
{
70+
if (!\is_array($options) && !($options instanceof \ArrayAccess)) {
71+
throw new \InvalidArgumentException(
72+
'The options param must be an array or implement the ArrayAccess interface.'
73+
);
74+
}
75+
7276
$this->options = $options;
7377
$this->http = $http ?: (new HttpFactory())->getHttp($this->options);
7478
$this->input = $input ?: ($application ? $application->getInput() : new Input());
@@ -123,6 +127,12 @@ public function authenticate()
123127
}
124128

125129
if ($this->getOption('sendheaders')) {
130+
if (!($this->application instanceof WebApplicationInterface)) {
131+
throw new \RuntimeException(
132+
\sprintf('A "%s" implementation is required to process authentication.', WebApplicationInterface::class)
133+
);
134+
}
135+
126136
$this->application->redirect($this->createUrl());
127137
}
128138

0 commit comments

Comments
 (0)