Skip to content

Commit ef014bd

Browse files
committed
fix(support): Refactor project structure and update dependencies.
1 parent 48d173a commit ef014bd

File tree

17 files changed

+672
-253
lines changed

17 files changed

+672
-253
lines changed

.gitattributes

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@
2121
*.gif binary
2222
*.ttf binary
2323

24+
# Ignore some meta files when creating an archive of this repository
25+
/.github export-ignore
26+
/.editorconfig export-ignore
27+
/.gitattributes export-ignore
28+
/.gitignore export-ignore
29+
/.phpunit-watcher.yml export-ignore
30+
/.scrutinizer.yml export-ignore
31+
/.styleci.yml export-ignore
32+
/infection.json.dist export-ignore
33+
/phpunit.xml.dist export-ignore
34+
/psalm.xml export-ignore
35+
/tests export-ignore
36+
/docs export-ignore
37+
2438
# Avoid merge conflicts in CHANGELOG
2539
# https://about.gitlab.com/2015/02/10/gitlab-reduced-merge-conflicts-by-90-percent-with-changelog-placeholders/
2640
/CHANGELOG.md merge=union
27-
28-
# Exclude files from the archive
29-
/.gitattributes export-ignore
30-
/.github export-ignore
31-
/.gitignore export-ignore
32-
/.styleci.yml export-ignore
33-
/codeception.yml export-ignore
34-
/composer-require-checker.json export-ignore
35-
/docs export-ignore
36-
/phpunit.xml.dist export-ignore
37-
/psalm.xml export-ignore
38-
/rector.php export-ignore
39-
/tests export-ignore

.gitignore

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
#code coverage
2-
/code_coverage
1+
# phpstorm project files
2+
.idea
3+
4+
# netbeans project files
5+
nbproject
6+
7+
# zend studio for eclipse project files
8+
.buildpath
9+
.project
10+
.settings
11+
12+
# windows thumbnail cache
13+
Thumbs.db
14+
15+
# Mac DS_Store Files
16+
.DS_Store
317

418
# composer vendor dir
519
/vendor
6-
/composer.lock
720

8-
#node_modules
9-
/node_modules
21+
# composer lock file
22+
/composer.lock
1023

11-
# phpstorm project files
12-
.idea
24+
# composer itself is not needed
25+
composer.phar
1326

14-
# phpunit
15-
.phpunit.cache
16-
.phpunit.result.cache
17-
phpunit.xml
27+
# phpunit itself is not needed
1828
phpunit.phar
1929

20-
#yii3 config packages
21-
/config/packages
30+
# local phpunit config
31+
/phpunit.xml
2232

23-
# windows thumbnail cache
24-
Thumbs.db
33+
# phpunit cache
34+
.phpunit.result.cache

LICENSE

Lines changed: 0 additions & 16 deletions
This file was deleted.

LICENSE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# BSD 3-Clause License
2+
3+
Copyright © 2008 by Terabytesoftw (<https://github.com/terabytesoftw/>)
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of PHP Forge (Terabytesoftw) nor the names of its
15+
contributors may be used to endorse or promote products derived from this
16+
software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 78 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -27,143 +27,169 @@
2727
</a>
2828
</p>
2929

30-
## Installation
30+
## Features
3131

32-
The preferred way to install this extension is through [composer](https://getcomposer.org/download/).
32+
**Advanced Reflection Utilities**
33+
- Access and modify private/protected properties via reflection.
34+
- Invoke inaccessible methods for comprehensive testing coverage.
3335

34-
Either run
36+
**Cross-Platform String Assertions**
37+
- Eliminate false negatives from Windows/Unix line ending differences.
38+
- Normalize line endings for consistent string comparisons across platforms.
3539

36-
```shell
40+
**File System Test Management**
41+
- Recursive file and directory cleanup for isolated test environments.
42+
- Safe removal operations preserving Git tracking files.
43+
44+
## Quick start
45+
46+
### System requirements
47+
48+
- [`PHP`](https://www.php.net/downloads) 8.1 or higher.
49+
- [`Composer`](https://getcomposer.org/download/) for dependency management.
50+
- [`PHPUnit`](https://phpunit.de/) for testing framework integration.
51+
52+
### Installation
53+
54+
#### Method 1: Using [Composer](https://getcomposer.org/download/) (recommended)
55+
56+
Install the extension.
57+
58+
```bash
3759
composer require --prefer-dist php-forge/support
3860
```
3961

40-
or add
62+
#### Method 2: Manual installation
63+
64+
Add to your `composer.json`.
4165

4266
```json
43-
"php-forge/support": "^0.1"
67+
{
68+
"require-dev": {
69+
"php-forge/support": "^0.1"
70+
}
71+
}
4472
```
4573

46-
to the require-dev section of your `composer.json` file.
74+
Then run.
4775

48-
## Usage
76+
```bash
77+
composer update
78+
```
4979

50-
### Equals without line ending
80+
## Basic Usage
81+
82+
### Cross-platform string equality
5183

5284
```php
5385
<?php
5486

5587
declare(strict_types=1);
5688

57-
namespace PHPForge\Support\Tests;
58-
5989
use PHPForge\Support\Assert;
6090

91+
// Normalize line endings for consistent comparisons
6192
Assert::equalsWithoutLE(
62-
<<<Text
63-
Foo
64-
Bar
65-
Text,
66-
"Foo\nBar"
93+
"Foo\r\nBar",
94+
"Foo\nBar",
95+
"Should match regardless of line ending style"
6796
);
6897
```
6998

70-
### Inaccessible property
99+
### Accessing private properties
71100

72101
```php
73102
<?php
74103

75104
declare(strict_types=1);
76105

77-
namespace PHPForge\Support\Tests;
78-
79106
use PHPForge\Support\Assert;
80107

81108
$object = new class () {
82-
private string $foo = 'bar';
109+
private string $secretValue = 'hidden';
83110
};
84111

85-
$this->assertSame('bar', Assert::inaccessibleProperty($object, 'foo'));
112+
// Access private properties for testing
113+
$value = Assert::inaccessibleProperty($object, 'secretValue');
114+
$this->assertSame('hidden', $value);
86115
```
87116

88-
### Invoke method
117+
### Invoking protected methods
89118

90119
```php
91120
<?php
92121

93122
declare(strict_types=1);
94123

95-
namespace PHPForge\Support\Tests;
96-
97124
use PHPForge\Support\Assert;
98125

99126
$object = new class () {
100-
protected function foo(): string
127+
protected function calculate(int $a, int $b): int
101128
{
102-
return 'foo';
129+
return $a + $b;
103130
}
104131
};
105132

106-
$this->assertSame('foo', Assert::invokeMethod($object, 'foo'));
133+
// Test protected method behavior
134+
$result = Assert::invokeMethod($object, 'calculate', [5, 3]);
135+
$this->assertSame(8, $result);
107136
```
108137

109-
### Set inaccessible property
138+
### Modifying inaccessible properties
110139

111140
```php
112141
<?php
113142

114143
declare(strict_types=1);
115144

116-
namespace PHPForge\Support\Tests;
117-
118145
use PHPForge\Support\Assert;
119146

120147
$object = new class () {
121-
private string $foo = 'bar';
148+
private string $config = 'default';
122149
};
123150

124-
Assert::setInaccessibleProperty($object, 'foo', 'baz');
151+
// Set private property for testing scenarios
152+
Assert::setInaccessibleProperty($object, 'config', 'test-mode');
125153

126-
$this->assertSame('baz', Assert::inaccessibleProperty($object, 'foo'));
154+
$newValue = Assert::inaccessibleProperty($object, 'config');
155+
$this->assertSame('test-mode', $newValue);
127156
```
128157

129-
### Remove files from directory
158+
### Test environment cleanup
130159

131160
```php
132161
<?php
133162

134163
declare(strict_types=1);
135164

136-
namespace PHPForge\Support\Tests;
137-
138165
use PHPForge\Support\Assert;
139166

140-
$dir = __DIR__ . '/runtime';
141-
142-
mkdir($dir);
143-
mkdir($dir . '/subdir');
144-
touch($dir . '/test.txt');
145-
touch($dir . '/subdir/test.txt');
167+
$testDir = __DIR__ . '/runtime';
146168

147-
Assert::removeFilesFromDirectory($dir);
169+
// Create test files and directories
170+
mkdir($testDir . '/subdir', 0755, true);
171+
touch($testDir . '/test.txt');
172+
touch($testDir . '/subdir/nested.txt');
148173

149-
$this->assertFileDoesNotExist($dir . '/test.txt');
174+
// Clean up test artifacts (preserves .gitignore and .gitkeep)
175+
Assert::removeFilesFromDirectory($testDir);
150176

151-
rmdir(__DIR__ . '/runtime');
177+
$this->assertFileDoesNotExist($testDir . '/test.txt');
178+
$this->assertDirectoryDoesNotExist($testDir . '/subdir');
152179
```
153180

154-
## Support versions
181+
## Documentation
155182

156-
[![PHP81](https://img.shields.io/badge/PHP-%3E%3D8.1-787CB5)](https://www.php.net/releases/8.1/en.php)
157-
[![Yii30](https://img.shields.io/badge/Yii%20version-3.0-blue)](https://yiiframework.com)
183+
For comprehensive testing guidance, see:
158184

159-
## Testing
160-
161-
[Check the documentation testing](/docs/testing.md) to learn about testing.
185+
- 🧪 [Testing Guide](docs/testing.md)
162186

163187
## Our social networks
164188

165-
[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555?style=flat)](https://twitter.com/Terabytesoftw)
189+
[![X](https://img.shields.io/badge/follow-@terabytesoftw-1DA1F2?logo=x&logoColor=1DA1F2&labelColor=555555&style=flat)](https://x.com/Terabytesoftw)
166190

167191
## License
168192

193+
[![License](https://img.shields.io/github/license/php-forge/support?cacheSeconds=0)](LICENSE.md)
194+
169195
The MIT License. Please see [License File](LICENSE.md) for more information.

0 commit comments

Comments
 (0)