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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ jobs:
runs-on: "ubuntu-24.04"

strategy:
fail-fast: false
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
dependencies:
- "highest"
include:
- dependencies: "lowest"
php-version: "8.2"
php-version: "8.3"

steps:
- name: "Checkout"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.2"
php-version: "8.3"
coverage: "none"
tools: "cs2pr, pecl"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/infection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.2"
php-version: "8.3"
coverage: "pcov"

- name: "Install dependencies with Composer"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.2"
php-version: "8.3"
coverage: "none"
tools: "cs2pr, pecl"

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
}
},
"require": {
"php": "^8.2",
"php": "^8.3",
"league/construct-finder": "^1.4",
"phpunit/phpunit": "^11 || ^12"
"phpunit/phpunit": "^12 || ^13"
},
"require-dev": {
"cdn77/coding-standard": "^7.0",
Expand Down
2 changes: 0 additions & 2 deletions src/Stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
throw new ReflectionException(sprintf('Property "%s" not found', $property));
}

$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($stub, $value);
}

Expand All @@ -59,7 +58,6 @@
/** @var array<string, mixed> $properties */
$properties = [];
foreach (self::getAllProperties($reflection) as $property) {
$property->setAccessible(true);
if (! $property->isInitialized($stub)) {
continue;
}
Expand Down Expand Up @@ -112,7 +110,7 @@
* @phpstan-var ReflectionClass<T>|false $parentClass
*/
$parentClass = $reflection->getParentClass();
if ($parentClass === false) {

Check warning on line 113 in src/Stub.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "Identical": @@ @@ * @phpstan-var ReflectionClass<T>|false $parentClass */ $parentClass = $reflection->getParentClass(); - if ($parentClass === false) { + if ($parentClass !== false) { return $properties; }
return $properties;
}

Expand Down
11 changes: 10 additions & 1 deletion tests/StubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Error;
use ReflectionException;

use const PHP_VERSION_ID;

final class StubTest extends BaseTestCase
{
public function testValueIsDefaultWhenNotSet(): void
Expand Down Expand Up @@ -67,9 +69,16 @@ public function testPrivateReadonlyPropertyIsSetBypassingConstructor(): void
self::assertSame('value', $stub->parentReadonlyProperty());
}

/** PHP does not allow setting protected or public readonly properties from different scopes */
/** PHP < 8.4 does not allow setting public readonly properties from different scopes */
public function testPublicReadonlyPropertyCannotBeSet(): void
{
if (PHP_VERSION_ID >= 80400) {
$stub = Stub::create(ClassWithReadonlyProperty::class, ['parentPublicReadonlyProperty' => 'value']);
self::assertSame('value', $stub->parentPublicReadonlyProperty);

return;
}

try {
Stub::create(ClassWithReadonlyProperty::class, ['parentPublicReadonlyProperty' => 'value']);
} catch (Error $e) {
Expand Down
Loading