fatal error w/ assert
using:
- psalm/phpunit-psalm-plugin@93b6617829a973b26a6c7a5ddda2530434d6a78f
- vimeo/psalm@d1630863ad64e6beb915ac255c41c744b56f3b4a
daft-markup\Tests\ValidatorTest.php:295
daft-markup\Tests\ValidatorTest.php:297
PHP Warning: assert(): assert(null !== $param->type) failed in daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php on line 351
PHP Fatal error: Uncaught TypeError: Argument 2 passed to Psalm\PhpUnitPlugin\Hooks\TestCaseHandler::Psalm\PhpUn
Warning: assert(): assert(null !== $param->type) failed in daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php on line 351 itPlugin\Hooks{closure}() must be an instance of Psalm\Type\Union, null given, called in daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php on line 370 and defined in daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php:263
Stack trace:
- #0 daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php(370): Psalm\PhpUnitPlugin\Hooks\TestCaseHandler::Psalm\PhpUnitPlugin\Hooks{closure}(Object(Psalm\Type\Union), NULL, false, 0)
- #1 daft-markup\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\ClassAnalyzer.php(942): Psalm\PhpUnitPlugin\Hooks\TestCaseHandler::afterStatementAnalysis(Object(PhpParser\Node\Stmt\Class_), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Internal\Analyzer\NamespaceAnalyzer), Object(Psalm\Codebase), Array)
- #2 daft-markup\vendor\vimeo\psalm\src\Psal in daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php on line 263
Fatal error: Uncaught TypeError: Argument 2 passed to Psalm\PhpUnitPlugin\Hooks\TestCaseHandler::Psalm\PhpUnitPlugin\Hooks{closure}() must be an instance of Psalm\Type\Union, null given, called in daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php on line 370 and defined in daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php:263
Stack trace:
- #0 daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php(370): Psalm\PhpUnitPlugin\Hooks\TestCaseHandler::Psalm\PhpUnitPlugin\Hooks{closure}(Object(Psalm\Type\Union), NULL, false, 0)
- #1 daft-markup\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\ClassAnalyzer.php(942): Psalm\PhpUnitPlugin\Hooks\TestCaseHandler::afterStatementAnalysis(Object(PhpParser\Node\Stmt\Class_), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Internal\Analyzer\NamespaceAnalyzer), Object(Psalm\Codebase), Array)
- #2 daft-markup\vendor\vimeo\psalm\src\Psal in daft-markup\vendor\psalm\plugin-phpunit\hooks\TestCaseHandler.php on line 263
https://github.com/SignpostMarv/daft-markup/blob/02448009310e961520e5a50beadd8fc8b97c64be/Tests/ValidatorTest.php#L297
/**
* @param mixed $markupContent
* @param class-string<\Throwable> $expected_message
*
* @dataProvider dataProvider_ValidateContent_failure
*/
public function test_ValidateContent_failure(
$markup_content,
string $expected_exception,
string $expected_message
) : void {
static::expectException($expected_exception);
static::expectExceptionMessage($expected_message);
MarkupValidator::ValidateContent($markup_content);
}
https://github.com/SignpostMarv/daft-markup/blob/02448009310e961520e5a50beadd8fc8b97c64be/src/MarkupValidator.php#L125
/**
* @param mixed $markupContent
*/
final public static function ValidateContent($markupContent) : void
{
if ( ! is_array($markupContent)) {
throw new InvalidArgumentException('Element content must be specified as an array!');
}
/**
* @var array<int|string, mixed>
*/
$markupContent = $markupContent;
foreach (array_keys($markupContent) as $key) {
if ( ! is_scalar($markupContent[$key]) && ! is_array($markupContent[$key])) {
throw new InvalidArgumentException('Element content must be scalar or an array!');
}
}
}
@SignpostMarv can you provide a failing scenario, ideally as a Gherkin test (see here)? Your code can be a little overwhelming at times.