mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
5cd8b3cccd
Fixes #570
56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
namespace Psalm\Tests;
|
|
|
|
class ForbiddenCodeTest extends TestCase
|
|
{
|
|
use Traits\FileCheckerInvalidCodeParseTestTrait;
|
|
use Traits\FileCheckerValidCodeParseTestTrait;
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function providerFileCheckerInvalidCodeParse()
|
|
{
|
|
return [
|
|
'varDump' => [
|
|
'<?php
|
|
var_dump("hello");',
|
|
'error_message' => 'ForbiddenCode',
|
|
],
|
|
'execTicks' => [
|
|
'<?php
|
|
`rm -rf`;',
|
|
'error_message' => 'ForbiddenCode',
|
|
],
|
|
'exec' => [
|
|
'<?php
|
|
shell_exec("rm -rf");',
|
|
'error_message' => 'ForbiddenCode',
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function providerFileCheckerValidCodeParse()
|
|
{
|
|
return [
|
|
'execWithSuppression' => [
|
|
'<?php
|
|
@exec("pwd 2>&1", $output, $returnValue);
|
|
if ($returnValue === 0) {
|
|
echo "success";
|
|
}',
|
|
],
|
|
'execWithoutSuppression' => [
|
|
'<?php
|
|
exec("pwd 2>&1", $output, $returnValue);
|
|
if ($returnValue === 0) {
|
|
echo "success";
|
|
}',
|
|
],
|
|
];
|
|
}
|
|
}
|