PHP code example of lipemat / phpstan-wordpress

1. Go to this page and download the library: Download lipemat/phpstan-wordpress 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/ */

    

lipemat / phpstan-wordpress example snippets


/**
 * @phpstan-var \AtLeast<array{a?: string, b?: string}, 'a'> $array
 *   // results: array{a: string, b?: string}
 */

/**
 * @phpstan-var \Exclude<array{a: string, b: string}, 'a'> $array
 *   // results: array{b: string}
 */

/**
 * @phpstan-var \Optional<array{a: string, b: string}> $array
 *   // results: array{a?: string, b?: string}
 * 
 * @phpstan-var \Optional<array{a: string, b: string}, 'b'> $array
 *   // results: array{a: string, b?: string}
 */

/**
 * @phpstan-var \Pick<array{a: string, b: string}, 'a'> $array
 *   // results: array{a: string}
 */

/**
 * @phpstan-var \Required<array{a?: string, b?: string}> $array
 *   // results: array{a: string, b: string}
 *                                                            
 * @phpstan-var \Required<array{a?: string, b?: string}, 'b'> $array
 *   // results: array{a?: string, b: string}                                                  
 */

/**
 * @phpstan-var \Sarcastic<string> $string
 *   // results: anyone's guess
 */

/**
 * @phpstan-var \Union<array{a: string}, array{b: string}> $array
 *   // results: array{a: string, b: string}
 */
yml
scanFiles:
  - %rootDir%/../../../stubs/cmb2/cmb2-3.10.php
  - %rootDir%/../../../stubs/genesis/genesis-3.4.php
  - %rootDir%/../../../stubs/wp-cli/php-cli-tools-0.11.php
  - %rootDir%/../../../stubs/vip.php
  - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-stubs.php
  - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-commands-stubs.php
  - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-i18n-stubs.php
yml
scanFiles:
  - %rootDir%/../../lipemat/phpstan-wordpress/stubs/cmb2/cmb2-3.10.php
  - %rootDir%/../../lipemat/phpstan-wordpress/stubs/genesis/genesis-3.4.php
  - %rootDir%/../../lipemat/phpstan-wordpress/stubs/wp-cli/php-cli-tools-0.11.php
  - %rootDir%/../../lipemat/phpstan-wordpress/stubs/vip.php
  - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-stubs.php
  - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-commands-stubs.php
  - %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-i18n-stubs.php