Skip to content

3.x update stan #682

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 1 commit into from
Nov 17, 2024
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
4 changes: 2 additions & 2 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.11.9" installed="1.11.9" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.25.0" installed="5.25.0" location="./tools/psalm" copy="false"/>
<phar name="phpstan" version="2.0.1" installed="2.0.1" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
</phive>
3 changes: 2 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
parameters:
ignoreErrors:
-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
message: '#^Strict comparison using \=\=\= between string and false will always evaluate to false\.$#'
identifier: identical.alwaysFalse
count: 1
path: src/Authenticator/HttpDigestAuthenticator.php
64 changes: 1 addition & 63 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,64 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.20.0@3f284e96c9d9be6fe6b15c79416e1d1903dcfef4">
<file src="src/AuthenticationService.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($parsed['host'])]]></code>
<code><![CDATA[empty($parsed['scheme'])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Authenticator/CookieAuthenticator.php">
<RiskyTruthyFalsyComparison>
<code>empty($identity)</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Authenticator/EnvironmentAuthenticator.php">
<RiskyTruthyFalsyComparison>
<code>empty($data)</code>
<code>empty($user)</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Authenticator/FormAuthenticator.php">
<RiskyTruthyFalsyComparison>
<code>empty($user)</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Authenticator/HttpDigestAuthenticator.php">
<RiskyTruthyFalsyComparison>
<code>empty($digest)</code>
<code>empty($user)</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Authenticator/JwtAuthenticator.php">
<RiskyTruthyFalsyComparison>
<code>empty($user)</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Authenticator/Result.php">
<RiskyTruthyFalsyComparison>
<code>empty($data)</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Authenticator/SessionAuthenticator.php">
<RiskyTruthyFalsyComparison>
<code>empty($user)</code>
<code>empty($user)</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Authenticator/TokenAuthenticator.php">
<RiskyTruthyFalsyComparison>
<code>empty($headerLine)</code>
<code>empty($queryParam)</code>
<code>empty($user)</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Identifier/IdentifierCollection.php">
<RiskyTruthyFalsyComparison>
<code>$result</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Middleware/AuthenticationMiddleware.php">
<RiskyTruthyFalsyComparison>
<code>$url</code>
</RiskyTruthyFalsyComparison>
</file>
</files>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0"/>
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@

<InvalidStringClass errorLevel="info" />
<MissingClassConstType errorLevel="info" />
<RiskyTruthyFalsyComparison errorLevel="info" />
</issueHandlers>
</psalm>
4 changes: 3 additions & 1 deletion src/AuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,10 @@
*/
protected function getImpersonationProvider(): ImpersonationInterface
{
/** @var \Authentication\Authenticator\ImpersonationInterface $provider */
$provider = $this->getAuthenticationProvider();
if ($provider === null) {
throw new InvalidArgumentException('No AuthenticationProvider present.');

Check warning on line 497 in src/AuthenticationService.php

View check run for this annotation

Codecov / codecov/patch

src/AuthenticationService.php#L497

Added line #L497 was not covered by tests
}
if (!($provider instanceof ImpersonationInterface)) {
$className = get_class($provider);
throw new InvalidArgumentException(
Expand Down
4 changes: 2 additions & 2 deletions src/Authenticator/CookieAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ protected function _createPlainToken(ArrayAccess|array $identity): string
*
* @param \ArrayAccess|array $identity Identity data.
* @return string
* @throws \JsonException
*/
protected function _createToken(ArrayAccess|array $identity): string
{
Expand All @@ -192,8 +193,7 @@ protected function _createToken(ArrayAccess|array $identity): string

$usernameField = $this->getConfig('fields.username');

/** @var string */
return json_encode([$identity[$usernameField], $hash]);
return json_encode([$identity[$usernameField], $hash], JSON_THROW_ON_ERROR);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Identity implements IdentityInterface
*
* @param \ArrayAccess|array $data Identity data
* @param array $config Config options
* @throws \InvalidArgumentException When invalid identity data is passed.
*/
public function __construct(ArrayAccess|array $data, array $config = [])
{
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/AuthenticationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class AuthenticationMiddleware implements MiddlewareInterface
*
* @param \Authentication\AuthenticationServiceInterface|\Authentication\AuthenticationServiceProviderInterface $subject Authentication service or application instance.
* @param \Cake\Core\ContainerInterface|null $container The container instance from the application.
* @throws \InvalidArgumentException When invalid subject has been passed.
*/
public function __construct(
AuthenticationServiceInterface|AuthenticationServiceProviderInterface $subject,
Expand Down