Download the PHP package lychee-org/phpstan-sensitive-parameter-values without Composer

On this page you can find all versions of the php package lychee-org/phpstan-sensitive-parameter-values. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpstan-sensitive-parameter-values

PHPStan SensitiveParameter Detector

CI

License OpenSSF Scorecard

A PHPStan extension that detects parameters that might contain sensitive information and should be marked with the #[\SensitiveParameter] attribute (added in PHP 8.2+).

About SensitiveParameter

The #[\SensitiveParameter] attribute was introduced in PHP 8.2 to mark sensitive data that should be hidden from stack traces and debugging output. This extension helps you identify parameters that should use this attribute for better security.

Learn more: PHP RFC: Redact parameters in back traces

Requirements

Installation

Usage

The extension will be automatically registered if you use PHPStan's extension installer.

Alternatively, include the extension in your PHPStan configuration:

Typed SensitiveParameterValue

PHP's built-in \SensitiveParameterValue::getValue() is natively typed as mixed, so calling it normally loses type information. This extension ships a PHPStan stub that declares SensitiveParameterValue as generic over the type of the value passed to its constructor, so PHPStan can narrow the return type of getValue() accordingly:

This is most useful when inspecting exception traces, where PHP replaces sensitive arguments with SensitiveParameterValue instances:

Propagating sensitivity through the call graph

Marking a parameter #[\SensitiveParameter] only protects that one call frame. If the value is then forwarded unchanged into a callee whose corresponding parameter is not marked sensitive, protection stops there: an exception thrown from inside the callee will still expose the value in plaintext.

SensitiveParameterPropagationRule flags login()'s $password in this example, with:

This is detected across method calls, static calls, constructors, and plain function calls. Only simple, unmodified pass-through arguments (a bare $variable matching a sensitive parameter of the enclosing function/method) are tracked — values that are transformed, wrapped, or reassigned before being passed on are not.

Cryptographic callees are never flagged

Passing a sensitive value directly into a hashing or encryption function is the intended usage — there is nothing to propagate. The rule ships with a built-in allowlist of well-known cryptographic functions and methods that will never trigger a propagation warning:

The built-in allowlist covers:

See Configuring the cryptographic callee allowlist for how to add your own entries.

Storing sensitive values safely

Marking a parameter sensitive prevents it from leaking through stack traces, but that protection is undone if the raw value is then saved into a property — anything that inspects, dumps, or serializes the object exposes it again. SensitiveParameterStorageRule requires sensitive values to be wrapped in \SensitiveParameterValue before being stored:

Constructor property promotion is also checked, since promotion assigns the raw value directly with no place to wrap it:

A value that's already wrapped is also checked: unwrapping it via ->getValue() right before storing defeats the point of wrapping it in the first place, so it's flagged too:

Only direct, unmodified assignments of a bare $variable (or a bare ->getValue() call on one) into a property are detected; values transformed before being stored are not tracked.

What it detects

The rule detects parameters with names containing common sensitive keywords:

Note: Due to substring matching, secret catches apisecret/clientsecret and token catches refreshtoken/accesstoken.

It works with:

Examples

❌ Will trigger warnings:

✅ Properly protected:

Advanced Configuration

Configuring sensitive keywords

To use custom sensitive keywords instead of the defaults, set sensitiveParameter.keywords in your phpstan.neon:

Providing a non-empty list completely replaces the default keyword list.

Configuring the cryptographic callee allowlist

If your project uses a custom hashing or encryption wrapper that should not trigger a propagation warning, add it to sensitiveParameter.cryptoCallees:

Entries are matched as:

Providing a non-empty list completely replaces the built-in allowlist, so include any built-in entries you still want to keep:

Suppressing Warnings

You can suppress warnings using PHPStan's ignore comments:

Constructor Parameters

Due to a PHPStan limitation, ignore comments for constructor parameters must be placed before the constructor:

Note: This ignores ALL parameter warnings for that constructor. For functions with multiple parameters where only some are false positives, consider renaming the problematic parameter to avoid the sensitive keyword match.

Common Issues

False Positives

The rule uses substring matching, which can occasionally trigger false positives:

For these cases, use ignore comments as shown above or consider renaming parameters to be more specific (e.g., $applicationToInstall, $authService, $verificationMethod).

Reporting Issues

Found a bug or have a feature request? Please report it on GitHub.

When reporting issues, please include:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development setup:

Running tests:

License

MIT License - see LICENSE for details.


All versions of phpstan-sensitive-parameter-values with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
phpstan/phpstan Version ^2.1.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lychee-org/phpstan-sensitive-parameter-values contains the following files

Loading the files please wait ...