2016-12-09 18:07:47 +01:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2017-04-25 05:45:02 +02:00
|
|
|
class ArgTest extends TestCase
|
2016-12-09 18:07:47 +01:00
|
|
|
{
|
2017-04-25 05:45:02 +02:00
|
|
|
use Traits\FileCheckerInvalidCodeParseTestTrait;
|
|
|
|
use Traits\FileCheckerValidCodeParseTestTrait;
|
2017-01-02 21:31:18 +01:00
|
|
|
|
2017-01-13 20:07:23 +01:00
|
|
|
/**
|
2017-04-25 05:45:02 +02:00
|
|
|
* @return array
|
2017-01-13 20:07:23 +01:00
|
|
|
*/
|
2017-04-25 05:45:02 +02:00
|
|
|
public function providerFileCheckerValidCodeParse()
|
2016-12-09 18:07:47 +01:00
|
|
|
{
|
2017-04-25 05:45:02 +02:00
|
|
|
return [
|
|
|
|
'callMapClassOptionalArg' => [
|
|
|
|
'<?php
|
|
|
|
$m = new ReflectionMethod("hello", "goodbye");
|
2017-05-27 02:05:57 +02:00
|
|
|
$m->invoke("cool");',
|
|
|
|
],
|
2017-04-25 05:45:02 +02:00
|
|
|
];
|
2016-12-09 18:07:47 +01:00
|
|
|
}
|
2017-04-08 15:28:02 +02:00
|
|
|
|
|
|
|
/**
|
2017-04-25 05:45:02 +02:00
|
|
|
* @return array
|
2017-04-08 15:28:02 +02:00
|
|
|
*/
|
2017-04-25 05:45:02 +02:00
|
|
|
public function providerFileCheckerInvalidCodeParse()
|
2017-04-08 15:28:02 +02:00
|
|
|
{
|
2017-04-25 05:45:02 +02:00
|
|
|
return [
|
|
|
|
'possiblyInvalidArgument' => [
|
|
|
|
'<?php
|
|
|
|
$foo = [
|
|
|
|
"a",
|
|
|
|
["b"],
|
|
|
|
];
|
|
|
|
|
|
|
|
$a = array_map(
|
|
|
|
function (string $uuid) : string {
|
|
|
|
return $uuid;
|
|
|
|
},
|
|
|
|
$foo[rand(0, 1)]
|
|
|
|
);',
|
2017-05-27 02:05:57 +02:00
|
|
|
'error_message' => 'PossiblyInvalidArgument',
|
|
|
|
],
|
2017-04-08 15:28:02 +02:00
|
|
|
];
|
|
|
|
}
|
2016-12-09 18:07:47 +01:00
|
|
|
}
|