Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error w/ assert #32

Open
SignpostMarv opened this issue Jun 15, 2019 · 1 comment
Open

fatal error w/ assert #32

SignpostMarv opened this issue Jun 15, 2019 · 1 comment
Labels
more info needed There's no enough information provided to address the issue

Comments

@SignpostMarv
Copy link
Contributor

using:

  • 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 added a commit to daft-framework/daft-markup that referenced this issue Jun 15, 2019
…salm/psalm-plugin-phpunit#32, `ERROR: InvalidDocblockParamName - Tests\ValidatorTest.php:284:20`
@weirdan
Copy link
Member

weirdan commented Jun 30, 2019

@SignpostMarv can you provide a failing scenario, ideally as a Gherkin test (see here)? Your code can be a little overwhelming at times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed There's no enough information provided to address the issue
Projects
None yet
Development

No branches or pull requests

2 participants