Skip to content

Commit fb999d2

Browse files
committed
Update README.md to clarify CLI binary type-checking capabilities for standalone scripts
1 parent 0b73868 commit fb999d2

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎README.md‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Here is the updated `README.md` reflecting that the CLI binary automatically type-checks any specified script without needing to register it in `typephp.php`:
2+
3+
```markdown
14
<h1 align="center">TypePHP</h1>
25

36
<p align="center">
@@ -76,23 +79,27 @@ Simply run your tests or use your local development server (**Laravel**, **Symfo
7679

7780
## Executing Standalone Scripts (CLI Runner)
7881

79-
For standalone, single-execution PHP scripts that do not have an explicit autoloader entry point, run them directly with the TypePHP CLI binary:
82+
You can run any standalone PHP script directly with the TypePHP CLI binary:
8083

8184
```bash
8285
vendor/bin/typephp script.php
8386
```
8487

88+
Targeting a file directly with the CLI binary automatically type-checks that file—**even if it is not registered in `typephp.php` or falls outside your configured `include` paths**.
89+
90+
Any secondary files required or included by your script will continue to respect your project's configured `include` and `exclude` paths.
91+
8592
---
8693

8794
## Type-Checking Files Anywhere (`"*"` Wildcard Glob)
8895

89-
By default, TypePHP checks standard application folders (`src/**`, `app/**`, `tests/**`). To type-check PHP files anywhere in your project root while still respecting your excluded folders, set the `"*"` wildcard glob in `typephp.php`:
96+
By default, TypePHP checks standard application folders (`src/**`, `app/**`, `tests/**`). To type-check PHP files anywhere in your project root during regular application runs while still respecting your excluded folders, set the `"*"` wildcard glob in `typephp.php`:
9097

9198
```php
9299
// typephp.php
93100
return [
94101
'include' => [
95-
'*', // Intercepts and type-checks PHP files anywhere in the project
102+
'*',
96103
],
97104
'exclude' => [
98105
'vendor/**',
@@ -167,14 +174,14 @@ Define generic templates and TypePHP tracks their state per object instance in m
167174
class Collection
168175
{
169176
/** @param T $item */
170-
public function add(mixed $item): void { /* ... */ }
177+
public function add(mixed $item): void { }
171178
}
172179

173180
// Prebind T = User to this specific instance in WeakMap memory
174181
/** @var Collection<User> $users */
175182
$users = new Collection();
176183

177-
$users->add(new User('Alice')); // Valid
184+
$users->add(new User('Alice'));
178185

179186
$users->add(new Product('SKU-100'));
180187
// Throws TypeError: Argument $item (template T = User) must be of type User, Product given
@@ -207,7 +214,7 @@ class DatabaseService
207214

208215
$service = new DatabaseService();
209216

210-
$service->connect(['driver' => 'pdo_mysql']); // Valid
217+
$service->connect(['driver' => 'pdo_mysql']);
211218

212219
$service->connect(['driver' => 'pdo_invalid']);
213220
// Throws TypeError: Argument $params['driver'] must be a key of DriverManager::DRIVER_MAP

0 commit comments

Comments
 (0)