1. Go to this page and download the library: Download phpyh/psalm-tester 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/ */
phpyh / psalm-tester example snippets
t
--FILE--
/** @psalm-trace $_list */
$_list = array_values(['a' => 1, 'b' => 2]);
--EXPECT--
Trace on line 9: $_list: non-empty-list<1|2>
t
--EXPECTF--
Trace on line %d: $_list: non-empty-list<%s>
use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use PHPyh\PsalmTester\PsalmTester;
use PHPyh\PsalmTester\StaticAnalysisTest;
final class PsalmTest extends TestCase
{
private ?PsalmTester $psalmTester = null;
#[TestWith([__DIR__ . '/array_values.phpt'])]
public function testPhptFiles(string $phptFile): void
{
$this->psalmTester ??= PsalmTester::create();
$this->psalmTester->test(StaticAnalysisTest::fromPhptFile($phptFile));
}
}
use PHPyh\PsalmTester\PsalmTester;
PsalmTester::create(
defaultArguments: '--no-progress --no-cache --config=my_default_config.xml',
);
t
--ARGS--
--no-progress --config=my_special_config.xml
--FILE--
...
--EXPECT--
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.