PHP code example of fromholdio / phpstan-non-nullable-sink-rules

1. Go to this page and download the library: Download fromholdio/phpstan-non-nullable-sink-rules library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fromholdio / phpstan-non-nullable-sink-rules example snippets


$items[$key] = 'value';
$value = $items[$key];
isset($items[$key]);
array_key_exists($key, $items);

function example(mixed $key, array $items): void
{
    $items[$key] = 'value';
}

function example(mixed $value, ?string $nullable): void
{
    trim($value);
    strlen($nullable);
}

filter_input(...)
get_option(...)
$_GET
json_decode(...)
text
Do not treat mixed as bad everywhere.
At known non-nullable/narrow PHP-owned sinks, mixed is not good enough.
bash
composer analyse