Skip to content
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

Apply PHP 8.2's SensitiveParameter attribute to Uri::withUserInfo() #116

Merged
merged 1 commit into from
Aug 30, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@
<RedundantConditionGivenDocblockType occurrences="1">
<code>gettype($port)</code>
</RedundantConditionGivenDocblockType>
<UndefinedAttributeClass occurrences="1">
<code>SensitiveParameter</code>
</UndefinedAttributeClass>
</file>
<file src="src/functions/create_uploaded_file.legacy.php">
<MixedArgument occurrences="1">
Expand Down Expand Up @@ -467,9 +470,6 @@
</MoreSpecificReturnType>
</file>
<file src="test/CallbackStreamTest.php">
<MissingClosureReturnType occurrences="1">
<code>function () {</code>
</MissingClosureReturnType>
<MixedAssignment occurrences="2">
<code>$ret</code>
<code>$ret</code>
Expand Down
13 changes: 11 additions & 2 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Laminas\Diactoros;

use Psr\Http\Message\UriInterface;
use SensitiveParameter;

use function array_keys;
use function explode;
Expand Down Expand Up @@ -228,6 +229,9 @@ public function withScheme($scheme): UriInterface
return $new;
}

// The following rule is buggy for parameters attributes
// phpcs:disable SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing.NoSpaceBetweenTypeHintAndParameter

/**
* Create and return a new instance containing the provided user credentials.
*
Expand All @@ -236,8 +240,11 @@ public function withScheme($scheme): UriInterface
*
* {@inheritdoc}
*/
public function withUserInfo($user, $password = null): UriInterface
{
public function withUserInfo(
$user,
#[SensitiveParameter]
TimWolla marked this conversation as resolved.
Show resolved Hide resolved
$password = null
): UriInterface {
if (! is_string($user)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a string user argument; received %s',
Expand Down Expand Up @@ -269,6 +276,8 @@ public function withUserInfo($user, $password = null): UriInterface
return $new;
}

// phpcs:enable SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing.NoSpaceBetweenTypeHintAndParameter

/**
* {@inheritdoc}
*/
Expand Down