1. Go to this page and download the library: Download efabrica/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/ */
efabrica / phpstan-rules example snippets
use GuzzleHttp\Client;
$guzzleClient = new Client();
$guzzleClient->request('GET', 'https://example.com/api/url');
use GuzzleHttp\Client;
$guzzleClient = new Client();
$guzzleClient->request('GET', 'https://example.com/api/url', ['timeout' => 3, 'connect_timeout' => 1]);
use Tomaj\NetteApi\Handlers\BaseHandler;
final class SomeHandler extends BaseHandler
{
public function params(): array
{
return [
new GetInputParam('my-name')
];
}
}
use Tomaj\NetteApi\Handlers\BaseHandler;
final class SomeHandler extends BaseHandler
{
public function params(): array
{
return [
new GetInputParam('my_name')
];
}
}
/**
* @context MyInterface
*/
trait MyTrait
{
}
final class SomeClass
{
use MyTrait;
}
/**
* @context MyInterface
*/
trait MyTrait
{
}
final class SomeClass implements MyInterface
{
use MyTrait;
}
class ClassWithDisabledMethod implements WithDisabledMethodInterface
{
public function disabledMethod() {} // this method shouldn't be called in WithCallInterface::checkedMethod
}
final class SomeClass implements WithCallInterface
{
public function checkedMethod(): array
{
return [(new ClassWithDisabledMethod)->disabledMethod()]
}
}
final class SomeClass implements WithCallInterface
{
public function checkedMethod(): array
{
return [(new ClassWithDisabledMethod)]
}
}
class SomeClass
{
public function someMethod(?string $someParameter = null): void
{
// this method should be called with string value of $someParameter
}
}
class Foo
{
public function bar(SomeClass $someClass)
{
$someClass->someMethod();
}
}
class Foo
{
public function bar(SomeClass $someClass)
{
$someClass->someMethod('baz');
}
}