PHPackages                             nish/phpstan-safestring-rule - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. nish/phpstan-safestring-rule

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

nish/phpstan-safestring-rule
============================

Extension of PHPStan: Warn about unsafe strings

v0.2.5(2mo ago)4571MITPHPPHP ~7.1 || ~8.0

Since Jan 9Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/nishphp/phpstan-safestring-rule)[ Packagist](https://packagist.org/packages/nish/phpstan-safestring-rule)[ RSS](/packages/nish-phpstan-safestring-rule/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (18)Used By (0)

PHPStan SafeString Rule Extension
=================================

[](#phpstan-safestring-rule-extension)

This package is a PHPStan extension for checking unsafe string, e.g. Check calling echo without calling htmlspecialchars, check calling database query without using prepared statement.

Notice
------

[](#notice)

This package does not meet the "backward compatibility promise". Because it extends the basic processing of the core, it is not guaranteed to work with version differences.

Install
-------

[](#install)

```
composer require --dev nish/phpstan-safestring-rule

```

How to use
----------

[](#how-to-use)

Add to `phpstan.neon`

```
includes:
  - vendor/nish/phpstan-safestring-rule/extension.neon

services:
  -
    class: Nish\PHPStan\Rules\EchoHtmlRule
    tags: [phpstan.rules.rule]
  -
    factory: Nish\PHPStan\Type\SafeHtmlStringReturnTypeExtension([htmlspecialchars, h, raw])
    tags: [nish.phpstan.broker.dynamicFunctionReturnTypeExtension]
```

`composer.json` is:

```
    "autoload": {
        "psr-4": { "App\\": "src" },
        "files": [
            "src/functions.php"
        ]
    },
```

Value Object class `src/ProductDto.php`:

```
