You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced/how-it-works.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,11 +93,13 @@ TypePHP solves this using `TypePHPPrinter` and regex post-processing. Injected g
93
93
94
94
### Disk Caching
95
95
96
-
Once transformed, TypePHP saves the resulting code to disk in `sys_get_temp_dir() . '/typephp-cache/'`. On all subsequent requests:
96
+
Once transformed, TypePHP saves the resulting code to disk in your configured `cache_dir` (which defaults to `sys_get_temp_dir() . '/typephp-cache/'`). On all subsequent requests:
97
97
* AST parsing runs **0 times**.
98
98
* PHP's **OPCache** compiles the cached file once into bytecode in RAM.
*(TypePHP's stream wrapper automatically detects and skips intercepting files inside your configured `cache_dir` to prevent infinite loops and double-transformation overhead).*
102
+
101
103
---
102
104
103
105
## Typed Arrays and Array Shapes
@@ -182,10 +184,6 @@ For function-level templates (`@template T`), TypePHP pushes a temporary call fr
182
184
183
185
---
184
186
185
-
Here is the updated, brief **Validation Error Messages and Trace Attribution** section for `docs/architecture/how-it-works.md`:
186
-
187
-
---
188
-
189
187
## Validation Error Messages and Trace Attribution
190
188
191
189
When a type contract fails, TypePHP constructs informative error messages through a 3-tier pipeline:
|**`'properties'`**| Class Property Writes |`$this->id = 1`, `UserProfile::$username = 'Alice'`|
148
+
---
149
+
150
+
### 2. `docs/advanced/how-it-works.md`
151
+
152
+
*(Find the "Zero Line-Drift Formatting and Caching" section and update the "Disk Caching" part to this:)*
148
153
149
-
### Important Notes on `inline_vars` Behavior
154
+
```markdown
155
+
### Disk Caching
150
156
151
-
***Inner Structural Types Are Always Validated:** Disabling `'scalars' => false` only turns off standalone scalar assignments (such as `/** @var positive-int $x */`). If `'arrays'` or `'generics'` is enabled, TypePHP **will still validate inner scalar constraints** inside array shapes (`array{id: positive-int}`), lists (`list<positive-int>`), or generic containers (`Collection<positive-int>`) to maintain structural type integrity.
152
-
***Active Generic Instance Prebinding:** Enabling `'generics' => true` allows inline `@var` annotations on object instantiations (such as `/** @var Collection<User> $users */ $users = new Collection();`) to **actively prebind generic template parameters (`T = User`)** directly to that object instance in `WeakMap` memory. Every subsequent method call on that instance (`$users->add()`, `$users->get()`) will enforce `T = User`!
157
+
Once transformed, TypePHP saves the resulting code to disk in your configured `cache_dir` (which defaults to `sys_get_temp_dir() . '/typephp-cache/'`). On all subsequent requests:
158
+
* AST parsing runs **0 times**.
159
+
* PHP's **OPCache** compiles the cached file once into bytecode in RAM.
*(TypePHP's stream wrapper automatically detects and skips intercepting files inside your configured `cache_dir` to prevent infinite loops and double-transformation overhead).*
163
+
```
153
164
154
165
---
155
166
156
-
## Pattern Specificity Rules
167
+
### 3. `docs/troubleshooting.md`
168
+
169
+
*(Find the "How do I know if TypePHP is actively transforming a file?" question and update the answer:)*
157
170
158
-
If a file matches both an `include` rule and an `exclude` rule, TypePHP compares pattern lengths:
***Tie-Breaker:** If pattern lengths are equal, `exclude` takes precedence to ensure application safety.
173
+
```
174
+
175
+
---
176
+
All docs are updated! What's our next target? Should we start refactoring validators, expanding the Extension System, or write a quick web-framework mock test?
Copy file name to clipboardExpand all lines: docs/troubleshooting.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,15 @@ If TypePHP is not enforcing contracts on a specific file or method, check the fo
22
22
You can verify that a file is being intercepted and transformed in two ways:
23
23
24
24
1.**Intentionally Trigger an Error:** Pass an invalid argument (such as a negative integer to a `positive-int` parameter). If a `TypePHP\Exception\TypeError` is thrown, TypePHP is active.
25
-
2.**Inspect the Cache Directory:** Look inside your system temporary directory (`sys_get_temp_dir() . '/typephp-cache/'`). You will see transformed PHP files containing injected `RuntimeTypeChecker` calls.
25
+
2.**Inspect the Cache Directory:** Look inside your configured `cache_dir` (if undefined, this defaults to your system temporary directory: `sys_get_temp_dir() . '/typephp-cache/'`). You will see transformed PHP files containing injected `RuntimeTypeChecker` calls.
26
+
27
+
---
28
+
29
+
### Why are files inside my custom `cache_dir` not being intercepted?
30
+
31
+
If you configured a custom `cache_dir` inside your project directory (e.g., `__DIR__ . '/storage/typephp'`) and set your include paths to `['**']`, you might wonder why the cache files aren't being transformed.
32
+
33
+
**This is a built-in safety mechanism.** TypePHP automatically detects your `cache_dir` and unconditionally excludes it from its internal `StreamWrapper` and `FileFilter`. This prevents catastrophic infinite loops and double-parsing overhead that would occur if TypePHP tried to intercept and transform its own cached files.
0 commit comments