PHP code example of php-standard-library / psalm-plugin

1. Go to this page and download the library: Download php-standard-library/psalm-plugin 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/ */

    

php-standard-library / psalm-plugin example snippets


use Psl\Type;

$specification = Type\shape([
  'name' => Type\string(),
  'age' => Type\int(),
  'location' => Type\optional(Type\shape([
    'city' => Type\string(),
    'state' => Type\string(),
    'country' => Type\string(),
  ]))
]);

$input = $specification->coerce($_GET['user']);

/** @psalm-trace $input */
shell
php vendor/bin/psalm-plugin enable php-standard-library/psalm-plugin