Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/phpDocumentor/Reflection/Php/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function generatePlaceholder(string $name): string
/** @param array<string, Fqsen|Type> $parts */
public function __construct(string $expression, array $parts = [])
{
Assert::notEmpty($expression);
Assert::stringNotEmpty($expression);
Assert::allIsInstanceOfAny($parts, [Fqsen::class, Type::class]);

$this->expression = $expression;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testEnumWithConstant(): void

$enum = $file->getEnums()['\MyNamespace\MyEnumWithConstant'];
self::assertInstanceOf(Enum_::class, $enum);
self::assertCount(1, $enum->getConstants());
self::assertCount(2, $enum->getConstants());
self::assertArrayHasKey('\MyNamespace\MyEnumWithConstant::MYCONST', $enum->getConstants());
self::assertSame("'MyConstValue'", $enum->getConstants()['\MyNamespace\MyEnumWithConstant::MYCONST']->getValue());
}
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/data/Enums/enumWithConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
enum MyEnumWithConstant
{
public const MYCONST = 'MyConstValue';

public const INT_CONST = 0;
}
19 changes: 19 additions & 0 deletions tests/unit/phpDocumentor/Reflection/Php/ExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

namespace phpDocumentor\Reflection\Php;

use Generator;
use InvalidArgumentException;
use phpDocumentor\Reflection\Fqsen;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

use function sprintf;
Expand Down Expand Up @@ -110,4 +112,21 @@ public function testOverridePartsWhenRenderingExpression(): void

self::assertSame(sprintf('This is an %s expression', $replacement), $result);
}

#[DataProvider('expressionValues')]
public function testExpressionTemplateCreation(string $expression): void
{
$actual = new Expression($expression, []);
self::assertSame($expression, $actual->getExpression());
}

/** @return Generator<string, array{expression: string} */
public static function expressionValues(): Generator
{
$values = ['0', 'null', 'false'];

foreach ($values as $value) {
yield $value => ['expression' => $value];
}
}
}