Skip to content

Wrong types for assertIsNotNumeric #124

@ZebulanStanphill

Description

@ZebulanStanphill

The following TestCase will cause PHPStan to report a false positive.

<?php declare(strict_types=1);

use PHPUnit\Framework\TestCase;

/**
 * @phpstan-return non-empty-string
 */
function someFunction(): string {
	return '10';
}

final class MyTest extends TestCase {
	public function testGeneration(): void {
		self::assertIsNotNumeric(
			someFunction(),
			'This expectation message is misinterpreted as the "actual" param.'
		);
	}
}

The false positive:

Call to static method PHPUnit\Framework\Assert::assertIsNotNumeric() with non-empty-string and 'This expectation…' will always evaluate to true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions