Skip to content

Commit 086b56c

Browse files
authored
Improve vendor isolation 2 (#39)
* Enhance vendor path exclusion logic in FileFilter and StreamWrapper, add tests for relative vendor paths and strict src directory matching * Implement PathMatcher utility for path normalization and vendor isolation; refactor FileFilter and StreamWrapper to utilize PathMatcher; add comprehensive tests for PathMatcher functionality. * Update CONTRIBUTING.md, composer.json, mago.toml, and psalm.xml for enhanced development standards and tooling integration * Add Rector integration and enhance strictness in type checks across the codebase * Fix formatting issues by adding newlines at the end of several files and ensuring consistent code style in tests. * Enhance project configuration by updating .gitignore, adding php-cs-fixer to composer.json, and creating .php-cs-fixer.dist.php for code style enforcement; refactor StreamWrapper and bootstrap logic for improved tooling integration. * Fix php stan errors * Update CONTRIBUTING.md to clarify linting and static analysis authorities, enhancing tooling interoperability guidelines * Set Codecov action to not fail CI on error for improved workflow stability * Add initial Codecov configuration for coverage reporting * Update .gitattributes to include additional files for export-ignore
1 parent e1599a4 commit 086b56c

37 files changed

Lines changed: 772 additions & 316 deletions

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@
77
/phpunit.xml export-ignore
88
/pint.json export-ignore
99
/typephp.php export-ignore
10+
/mago.toml export-ignore
11+
/psalm.xml export-ignore
12+
/.php-cs-fixer.dist.php export-ignore
13+
/codecov.yml export-ignore
14+
/rector.php export-ignore
15+
/typephp.php export-ignore

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
token: ${{ secrets.CODECOV_TOKEN }}
5454
files: clover.xml
55-
fail_ci_if_error: true
55+
fail_ci_if_error: false
5656

5757
- name: Run Test Suite (Pest)
5858
run: ./vendor/bin/pest --compact

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/var
44
/manual-tests
55
composer.lock
6-
index.php
6+
index.php
7+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
use PhpCsFixer\Config;
3+
use PhpCsFixer\Finder;
4+
5+
$finder = Finder::create()
6+
->in(__DIR__ . '/src')
7+
->exclude('vendor');
8+
9+
return (new Config())
10+
->setRules([
11+
'@PSR12' => true,
12+
'array_syntax' => ['syntax' => 'short'],
13+
'ordered_imports' => true,
14+
])
15+
->setFinder($finder)
16+
->setRiskyAllowed(true);

CONTRIBUTING.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,47 @@
11
# Contributing to TypePHP
22

3-
Thank you for showing interest in contributing to this TypePHP library! Contributions are essential for building a robust type-safe ecosystem for the PHP community.
3+
Thank you for showing interest in contributing to TypePHP! Contributions are essential for building a robust, type-safe ecosystem for the PHP community.
44

5-
This library is designed to be a reliable foundation for high-performance applications. To achieve this, it maintains rigorous standards for code quality and developer experience.
5+
This library is designed to be a reliable foundation for high-performance applications. To achieve this, it maintains rigorous standards for code quality, developer experience, and static analysis compatibility.
6+
7+
---
68

79
## Development Workflow
810

9-
To ensure consistency across the ecosystem, this repository requires the following workflow:
11+
To ensure consistency across the codebase, this repository requires the following workflow:
1012

1113
1. **Fork and Branch**: Fork the repository and create a feature branch from `main`.
1214
2. **Dependencies**: Install development tools using `composer install`.
13-
3. **Coding Standards**: This project follows strict PSR-12 standards. Use Laravel Pint to format code: `./vendor/bin/pint`.
14-
4. **Static Analysis**: Code must be predictable and type-safe. It must pass PHPStan at the maximum level: `./vendor/bin/phpstan analyse`.
15-
5. **Testing**: This project uses Pest. Ensure the test suite passes completely: `./vendor/bin/pest`.
15+
3. **Linting & Code Formatting Authority (Laravel Pint)**: This project follows strict PSR-12 standards. Laravel Pint is the **sole authoritative linter and formatter** for the entire codebase:
16+
```bash
17+
./vendor/bin/pint
18+
```
19+
4. **Static Analysis Authority (PHPStan)**: Code must pass **PHPStan at Level MAX** (`treatPhpDocTypesAsCertain: false`):
20+
```bash
21+
./vendor/bin/phpstan analyse
22+
```
23+
5. **Testing**: This project uses Pest. Ensure all tests pass completely:
24+
```bash
25+
./vendor/bin/pest
26+
```
1627
6. **Strict Typing**: Every PHP file must begin with `declare(strict_types=1);`.
1728

29+
---
30+
31+
## Tooling Authority & Interoperability Policy
32+
33+
* **Laravel Pint is the Authoritative Linter & Formatter**: All code styling and linting rules are defined strictly in `pint.json`. No external style linter overrides Pint.
34+
* **PHPStan is the Authoritative Static Analyzer**: PHPStan configured at Level MAX is the official gatekeeper for type safety and code quality in TypePHP. All contributions must pass PHPStan checks without errors.
35+
* **Tooling Interoperability (Psalm, Mago, Rector, PHP-CS-Fixer, etc.)**: Secondary analyzers and tools (such as Psalm, Mago, Rector, and PHP-CS-Fixer) are integrated into the test environment solely for **interoperability verification** and ensuring that TypePHP's runtime stream wrapper and AST transformations stand down properly and do not deadlock or conflict with external static analysis engines.
36+
37+
---
1838

1939
## Pull Request Process
2040

21-
1. **Start with an Issue**: Before writing code, please open an issue to discuss the bug or the proposed feature.
22-
2. **Tests are Required**: Every Pull Request must include automated tests that cover the new logic or prevent the bug from recurring.
41+
1. **Start with an Issue**: Before writing code, please open an issue to discuss the bug or proposed feature.
42+
2. **Tests are Required**: Every Pull Request must include automated Pest tests that cover the new logic and prevent regressions.
43+
3. **Keep Code Clean**: Run `./vendor/bin/pint`, `./vendor/bin/phpstan analyse`, and `./vendor/bin/pest` before submitting your PR.
2344

2445
---
2546

26-
The Hibla ecosystem thanks you for your time and effort!
47+
The TypePHP ecosystem thanks you for your time and effort!

codecov.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
enabled: false
6+
patch:
7+
default:
8+
enabled: false
9+
10+
comment:
11+
layout: "reach,diff,flags,files,footer"
12+
behavior: default

composer.json

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
"pestphp/pest": "^2.0 || ^3.0 || ^4.0",
3535
"phpstan/phpstan": "^2.1",
3636
"phpstan/phpstan-strict-rules": "^2.0",
37-
"phpstan/extension-installer": "^1.4"
37+
"phpstan/extension-installer": "^1.4",
38+
"vimeo/psalm": "^6.16",
39+
"carthage-software/mago": "^1.47",
40+
"rector/rector": "^2.6",
41+
"friendsofphp/php-cs-fixer": "^3.95"
3842
},
3943
"bin": [
4044
"bin/typephp"
@@ -62,8 +66,20 @@
6266
"test": [
6367
"./vendor/bin/pest --colors"
6468
],
65-
"analyse": [
66-
"./vendor/bin/phpstan analyse"
69+
"analyze": [
70+
"./vendor/bin/phpstan analyze"
71+
],
72+
"psalm": [
73+
"./vendor/bin/psalm"
74+
],
75+
"mago": [
76+
"./vendor/bin/mago analyze"
77+
],
78+
"rector": [
79+
"./vendor/bin/rector process"
80+
],
81+
"rector:dry": [
82+
"./vendor/bin/rector process --dry-run"
6783
]
6884
},
6985
"minimum-stability": "dev",
@@ -74,4 +90,4 @@
7490
"phpstan/extension-installer": true
7591
}
7692
}
77-
}
93+
}

mago.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
php-version = "8.1.0"
2+
3+
[source]
4+
paths = ["src"]
5+
includes = []
6+
excludes = ["tests/**", "vendor/**", "storage/**", "var/**", "cache/**"]
7+

psalm.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<psalm errorLevel="8" resolveFromConfigFile="true"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" findUnusedBaselineEntry="false" findUnusedCode="false">
5+
<projectFiles>
6+
<directory name="src" />
7+
<ignoreFiles>
8+
<directory name="vendor" />
9+
</ignoreFiles>
10+
</projectFiles>
11+
12+
<issueHandlers>
13+
<!-- #[Override] is a PHP 8.3+ feature; TypePHP supports PHP 8.1+ -->
14+
<MissingOverrideAttribute errorLevel="suppress" />
15+
<UndefinedVariable errorLevel="suppress" />
16+
</issueHandlers>
17+
</psalm>

rector.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\CallLike\AddNameToBooleanArgumentRector;
6+
use Rector\Config\RectorConfig;
7+
8+
return RectorConfig::configure()
9+
->withPaths([
10+
__DIR__ . '/src',
11+
])
12+
->withoutParallel()
13+
->withRules([
14+
AddNameToBooleanArgumentRector::class,
15+
])
16+
;

0 commit comments

Comments
 (0)