Skip to content

Revert bc breaks #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,26 @@ parameters:
count: 2
path: src/Client.php

-
message: '#^Instanceof between ArrayAccess and ArrayAccess will always evaluate to true\.$#'
identifier: instanceof.alwaysTrue
count: 1
path: src/Client.php

-
message: '#^Instanceof between Joomla\\Application\\WebApplicationInterface and Joomla\\Application\\WebApplicationInterface will always evaluate to true\.$#'
identifier: instanceof.alwaysTrue
count: 1
path: src/Client.php

-
message: '#^Method Joomla\\OAuth2\\Client\:\:query\(\) should return Joomla\\Http\\Response but returns false\.$#'
identifier: return.type
count: 1
path: src/Client.php

-
message: '#^Result of && is always false\.$#'
identifier: booleanAnd.alwaysFalse
count: 1
path: src/Client.php
16 changes: 13 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

declare(strict_types=1);

namespace Joomla\OAuth2;

use Joomla\Application\WebApplicationInterface;
Expand Down Expand Up @@ -67,8 +65,14 @@ class Client
*
* @since 1.0
*/
public function __construct(array|\ArrayAccess $options = [], ?Http $http = null, ?Input $input = null, ?WebApplicationInterface $application = null)
public function __construct($options = [], ?Http $http = null, ?Input $input = null, ?WebApplicationInterface $application = null)
{
if (!\is_array($options) && !($options instanceof \ArrayAccess)) {
throw new \InvalidArgumentException(
'The options param must be an array or implement the ArrayAccess interface.'
);
}

$this->options = $options;
$this->http = $http ?: (new HttpFactory())->getHttp($this->options);
$this->input = $input ?: ($application ? $application->getInput() : new Input());
Expand Down Expand Up @@ -123,6 +127,12 @@ public function authenticate()
}

if ($this->getOption('sendheaders')) {
if (!($this->application instanceof WebApplicationInterface)) {
throw new \RuntimeException(
\sprintf('A "%s" implementation is required to process authentication.', WebApplicationInterface::class)
);
}

$this->application->redirect($this->createUrl());
}

Expand Down