<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
built-fast / phpstan-sensitive-parameter example snippets
function login(string $username, string $password) {
// Parameter $password should use #[\SensitiveParameter]
}
class AuthService {
public function setCredentials(string $apikey, string $secret) {
// Both $apikey and $secret should be marked sensitive
}
}
// Function-level protection
#[\SensitiveParameter]
function login(string $username, string $password) {
// All parameters are protected
}
// Parameter-level protection
function authenticate(
string $username,
#[\SensitiveParameter] string $password
) {
// Only $password is protected
}
// Mixed protection
class AuthService {
public function verify(
#[\SensitiveParameter] string $token,
string $userId,
string $apikey // This will still trigger a warning
) {
// $token is protected, $apikey needs protection
}
}
// @phpstan-ignore-next-line sensitiveParameter.missing
function legacyFunction(string $password) {
// Legacy code that cannot be updated
}
// @phpstan-ignore-next-line sensitiveParameter.missing
function anotherLegacyFunction(string $secret) {
// Another legacy function
}
function modernFunction(string $password): void // @phpstan-ignore-line sensitiveParameter.missing
{
// Function with inline ignore comment
}
// @phpstan-ignore-next-line sensitiveParameter.missing
public function __construct(
private readonly SomeService $serviceWithSensitiveKeywordInName
) {}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.