PHP code example of sidz / phpstan-rules

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

    

sidz / phpstan-rules example snippets




some_function(10);



class Test
{
    private $prop1 = 10;

    private $prop2 = -5.5;
}



$var1 + 2;

$var2 - .3;

$var3 * 2.2;

$var4 / 2;

$var5 % 1000;

$var6 ** 2;

2 + $var1;

1.1 - $var2;

2 * $var3;

-2 / $var4;

1000 % $var5;



$a & 1;

$b | 2;

$c ^ 3;

$a << 4;

$b >> 5;

1 & $a;

2 | $b;

3 ^ $c;

4 << $a;

5 >> $b;

6 >> 7;



$var1 === 1;

$var2 !== 2;

$var3 !== 3;

$var4 === 4.4;

$var5 !== -5;

$var6 < 6;

$var7 <= 7;

$var8 > .8;

$var9 >= 9;

$var10 <=> 0.1;

$var11 === 11;



class Test
{
    public function testMethod($param = 3): string
    {
        return 'string';
    }
}



$a and 1;

1 and $a;

$b or 2;

2 or $b;

$c xor 3;

3 xor $c;



match (3) {
    1 => 'Hi',
    2, 4 => 'There',
    default => throw new LogicException(),
};



class Test
{

    public function getNegativeValue(): float
    {
        return -20.5;
    }
}



switch (100) {
    case 5:
        break;
}



$a = $b ? 2 : 'string';

$c = $b ?: -3.5;

$d = $b ? 'string' : 6;



$var1 = 4;

$var2 = -2;

function test_func($var4 = 3): void
{
    $var5 = 0;
}

$var6 = .1;

$var7 = 3.5;

$var8 = -2.3;