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
{{ message }}
Repository navigation
Commit f8758d6
Browse filesBrowse the repository at this point in the historyBrowse files
name: 'What is the difference between TypePHP (typephp/typephp) and Swoole TypePHP?',
125
+
acceptedAnswer: {
126
+
'@type': 'Answer',
127
+
text: 'TypePHP (typephp/typephp on Packagist, typephp.dev) is a 100% pure-PHP 8.1+ Composer library that enforces PHPDoc contracts, reified generics, array shapes, and typestates at runtime on standard PHP and frameworks like Laravel, Symfony, and Shopware. Swoole TypePHP is a separate Ahead-of-Time compiler that translates a PHP subset into C++ native binaries.',
128
+
},
129
+
},
130
+
{
131
+
'@type': 'Question',
132
+
name: 'Does TypePHP work with Laravel, Symfony, Pest, and PHPUnit?',
133
+
acceptedAnswer: {
134
+
'@type': 'Answer',
135
+
text: 'Yes. TypePHP hooks into Composer autoloading automatically and works as a drop-in across Laravel, Symfony, Shopware, WordPress, Pest, and PHPUnit with zero C-extensions or build steps.',
136
+
},
137
+
},
138
+
{
139
+
'@type': 'Question',
140
+
name: 'Can I run TypePHP alongside PHPStan or Psalm?',
141
+
acceptedAnswer: {
142
+
'@type': 'Answer',
143
+
text: 'Yes. PHPStan and Psalm verify static code structure at compile time, while TypePHP enforces those same PHPDoc contracts at runtime against live dynamic data, database rows, API payloads, and generic containers.',
Copy file name to clipboardExpand all lines: docs/advanced/compile-time-elimination.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: "Compile-Time AST Check Elimination"
3
+
description: "How TypePHP eliminates runtime assertion wrappers at load time for proven literals, folded arithmetic, $this returns, enums, shapes, and generators."
4
+
---
5
+
1
6
# Compile-Time Check Elimination
2
7
3
8
A common concern with runtime type enforcement is performance overhead. If every return statement, variable assignment, and property initialization were blindly wrapped in runtime assertions, high-frequency functions and tight loops would suffer from unnecessary Zend VM function-call overhead.
description: "Catch TypePHP\\Exception\\TypeError or native \\TypeError for call-site stack trace attribution and clean HTTP 422 API payload validation responses."
4
+
---
5
+
1
6
# Exception Handling
2
7
3
8
If you run TypePHP in live production applications especially for validating external HTTP API payloads, webhooks, or dynamic database records and catching `TypePHP\Exception\TypeError` gives you a clean way to intercept data validation failures gracefully without letting exceptions crash your application.
Copy file name to clipboardExpand all lines: docs/advanced/extensions.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: "Building TypePHP Extensions"
3
+
description: "Create reusable TypePHP extensions implementing ExtensionInterface to bundle vendor path whitelists and stub files with safe include-only isolation."
4
+
---
5
+
1
6
# Building Extensions
2
7
3
8
TypePHP provides an Extension System that allows third-party package authors and framework integrations to automatically register path whitelists and pre-verified stub files so end-users can benefit from type checking without writing manual include paths or stub configuration in `typephp.php`.
Copy file name to clipboardExpand all lines: docs/advanced/how-it-works.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: "How TypePHP Works (StreamWrapper & Load-Time Weaving)"
3
+
description: "Inside TypePHP's pure-PHP architecture: file:// StreamWrapper interception, compile-time AST elimination, callee-side contracts, zero line-drift, and WeakMap state."
4
+
---
5
+
1
6
# How It Works
2
7
3
8
TypePHP provides transparent, zero-overhead runtime type enforcement without custom C-extensions or modified PHP binaries. It operates entirely in PHP user-land by combining native stream interception, compile-time AST analysis, bytecode caching, and in-memory generic state tracking.
Copy file name to clipboardExpand all lines: docs/advanced/ignore-annotations.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: "Ignore Annotations (@typephp-ignore)"
3
+
description: "Selectively skip runtime type checking on legacy methods, properties, files, or downstream call stacks with @typephp-ignore and @typephp-ignore-file."
4
+
---
5
+
1
6
# Ignore Annotations (`@typephp-ignore`)
2
7
3
8
TypePHP provides docblock suppression tags to skip type enforcement on legacy code, un-refactored methods, performance-critical loops, or test callers without requiring you to remove PHPDoc annotations.
description: "Override or fix inaccurate PHPDoc contracts and generic variance in third-party Composer packages using .stub files without editing vendor/."
Copy file name to clipboardExpand all lines: docs/blog/index.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,6 @@
1
1
---
2
+
title: "TypePHP Engineering Blog & Release Notes"
3
+
description: "Deep dives, performance benchmarks, case studies, and release notes on pure-PHP runtime type checking, reified generics, typestates, and Zend Engine optimization."
Copy file name to clipboardExpand all lines: docs/core-concepts/by-reference-contracts.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: "By-Reference Contracts & Mutations"
3
+
description: "Guard PHP reference boundaries at runtime: &$param entry checks, @param-out exit contracts, variable and property aliasing, foreach loops, and array_walk."
4
+
---
5
+
1
6
# By-Reference Contracts & Mutations
2
7
3
8
In standard PHP, references (`&`) create Zend Engine `zval` aliases (`IS_REFERENCE`). Historically, references have been the single most common loophole in dynamic validation systems: once a reference is created, modifying the alias bypasses standard variable assignment interceptors.
0 commit comments