@@ -73,7 +73,7 @@ composer update
7373
7474## Basic Usage
7575
76- ### Cross-platform string equality
76+ ### Accessing private properties
7777
7878``` php
7979<?php
@@ -82,15 +82,17 @@ declare(strict_types=1);
8282
8383use PHPForge\Support\Assert;
8484
85- // Normalize line endings for consistent comparisons
86- Assert::equalsWithoutLE(
87- "Foo\r\nBar",
88- "Foo\nBar",
89- "Should match regardless of line ending style"
90- );
85+ $object = new class () {
86+ private string $secretValue = 'hidden';
87+ };
88+
89+ // access private properties for testing
90+ $value = Assert::inaccessibleProperty($object, 'secretValue');
91+
92+ self::assertSame('hidden', $value);
9193```
9294
93- ### Accessing private properties
95+ ### Equals without line ending
9496
9597``` php
9698<?php
@@ -99,13 +101,12 @@ declare(strict_types=1);
99101
100102use PHPForge\Support\Assert;
101103
102- $object = new class () {
103- private string $secretValue = 'hidden';
104- };
105-
106- // Access private properties for testing
107- $value = Assert::inaccessibleProperty($object, 'secretValue');
108- $this->assertSame('hidden', $value);
104+ // normalize line endings for consistent comparisons
105+ Assert::equalsWithoutLE(
106+ "Foo\r\nBar",
107+ "Foo\nBar",
108+ "Should match regardless of line ending style"
109+ );
109110```
110111
111112### Invoking protected methods
@@ -124,12 +125,13 @@ $object = new class () {
124125 }
125126};
126127
127- // Test protected method behavior
128+ // test protected method behavior
128129$result = Assert::invokeMethod($object, 'calculate', [5, 3]);
129- $this->assertSame(8, $result);
130+
131+ self::assertSame(8, $result);
130132```
131133
132- ### Modifying inaccessible properties
134+ ### Remove files from directory
133135
134136``` php
135137<?php
@@ -138,18 +140,13 @@ declare(strict_types=1);
138140
139141use PHPForge\Support\Assert;
140142
141- $object = new class () {
142- private string $config = 'default';
143- };
144-
145- // Set private property for testing scenarios
146- Assert::setInaccessibleProperty($object, 'config', 'test-mode');
143+ $testDir = dirname(__DIR__) . '/runtime';
147144
148- $newValue = Assert::inaccessibleProperty($object, 'config');
149- $this->assertSame('test-mode', $newValue );
145+ // clean up test artifacts (preserves '.gitignore' and '.gitkeep')
146+ Assert::removeFilesFromDirectory($testDir );
150147```
151148
152- ### Test environment cleanup
149+ ### Set inaccessible property
153150
154151``` php
155152<?php
@@ -158,18 +155,16 @@ declare(strict_types=1);
158155
159156use PHPForge\Support\Assert;
160157
161- $testDir = __DIR__ . '/runtime';
158+ $object = new class () {
159+ private string $config = 'default';
160+ };
162161
163- // Create test files and directories
164- mkdir($testDir . '/subdir', 0755, true);
165- touch($testDir . '/test.txt');
166- touch($testDir . '/subdir/nested.txt');
162+ // set private property for testing scenarios
163+ Assert::setInaccessibleProperty($object, 'config', 'test-mode');
167164
168- // Clean up test artifacts (preserves .gitignore and .gitkeep)
169- Assert::removeFilesFromDirectory($testDir);
165+ $newValue = Assert::inaccessibleProperty($object, 'config');
170166
171- $this->assertFileDoesNotExist($testDir . '/test.txt');
172- $this->assertDirectoryDoesNotExist($testDir . '/subdir');
167+ self::assertSame('test-mode', $newValue);
173168```
174169
175170## Documentation
0 commit comments