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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Enh #22: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw)
- Bug #23: Update Rector command in `composer.json` to remove unnecessary 'src' argument (@terabytesoftw)
- Enh #24: Add enums for backed integer, backed string, and unit values in the `Stub` namespace (@terabytesoftw)

## 0.3.1 January 20, 2026

Expand Down
2 changes: 0 additions & 2 deletions src/ReflectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*/
final class ReflectionHelper
{
private function __construct() {}

/**
* Retrieves a property value from a specified class context.
*
Expand Down
21 changes: 21 additions & 0 deletions src/Stub/BackedInteger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace PHPForge\Support\Stub;

/**
* Stub enum for backed integer values.
*
* Provides deterministic values required by the test suite.
*
* @copyright Copyright (C) 2026 Terabytesoftw.
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
*/
enum BackedInteger: int
{
/**
* Type representing a value.
*/
case VALUE = 1;
}
21 changes: 21 additions & 0 deletions src/Stub/BackedString.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace PHPForge\Support\Stub;

/**
* Stub enum for backed string values.
*
* Provides deterministic values required by the test suite.
*
* @copyright Copyright (C) 2026 Terabytesoftw.
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
*/
enum BackedString: string
{
/**
* Type representing a value.
*/
case VALUE = 'value';
}
21 changes: 21 additions & 0 deletions src/Stub/Unit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace PHPForge\Support\Stub;

/**
* Stub enum for unit values.
*
* Provides deterministic values required by the test suite.
*
* @copyright Copyright (C) 2026 Terabytesoftw.
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
*/
enum Unit
{
/**
* Type representing a value.
*/
case value;
}
14 changes: 5 additions & 9 deletions tests/EnumDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PHPForge\Support\Tests;

use PHPForge\Support\EnumDataProvider;
use PHPForge\Support\Tests\Stub\TestEnum;
use PHPForge\Support\Stub\BackedInteger;
use PHPForge\Support\Tests\Support\Provider\EnumDataProviderProvider;
use PHPUnit\Framework\Attributes\{DataProviderExternal, Group};
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -76,21 +76,17 @@ public function testCasesGenerateExpectedStructure(

public function testTagCasesGenerateExpectedStructure(): void
{
$data = EnumDataProvider::tagCases(TestEnum::class, 'element');
$data = EnumDataProvider::tagCases(BackedInteger::class, 'element');

self::assertNotEmpty(
$data,
'Should return at least one data set.',
);
self::assertSame(
[
'BAR element tag' => [
TestEnum::BAR,
'BAR',
],
'FOO element tag' => [
TestEnum::FOO,
'FOO',
'1 element tag' => [
BackedInteger::VALUE,
1 => '1',
],
],
$data,
Expand Down
19 changes: 0 additions & 19 deletions tests/Stub/TestBackedEnum.php

This file was deleted.

18 changes: 0 additions & 18 deletions tests/Stub/TestEnum.php

This file was deleted.

19 changes: 0 additions & 19 deletions tests/Stub/TestIntBackedEnum.php

This file was deleted.

43 changes: 22 additions & 21 deletions tests/Support/Provider/EnumDataProviderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace PHPForge\Support\Tests\Support\Provider;

use PHPForge\Support\Tests\Stub\TestEnum;
use PHPForge\Support\Stub\{BackedInteger, BackedString, Unit};
use UnitEnum;

/**
* Data provider for {@see \PHPForge\Support\Tests\EnumDataProviderTest} test cases.
Expand All @@ -17,34 +18,34 @@
final class EnumDataProviderProvider
{
/**
* @return array<string, array{string, string|\UnitEnum, bool, string, string, string}>
* @return array<string, array{string, string|UnitEnum, bool, string, string, string}>
*/
public static function casesParameters(): array
{
return [
'as enum instance' => [
TestEnum::class,
'data-test',
false,
'enum: FOO',
' data-test="FOO"',
"Should return the 'data-test' attribute value for enum case: FOO.",
'enum backed integer instance' => [
BackedInteger::class,
BackedInteger::VALUE,
true,
'enum: 1',
' 1="1"',
"Should return the '1' attribute value for enum case: 1.",
],
'as html' => [
TestEnum::class,
'enum backed string instance' => [
BackedString::class,
'data-test',
true,
'enum: BAR',
' data-test="BAR"',
"Should return the 'data-test' attribute value for enum case: BAR.",
'enum: value',
' data-test="value"',
"Should return the 'data-test' attribute value for enum case: value.",
],
'attribute as enum instance' => [
TestEnum::class,
TestEnum::FOO,
true,
'enum: FOO',
' FOO="FOO"',
"Should return the 'FOO' attribute value for enum case: FOO.",
'enum unit instance' => [
Unit::class,
'data-test',
false,
'enum: value',
' data-test="value"',
"Should return the 'data-test' attribute value for enum case: value.",
],
];
}
Expand Down
Loading