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 2c6c726
Browse filesBrowse the repository at this point in the historyBrowse files
Throw the twin's error where native paths reported a failure with nothing pending
Several native paths returned their "exception pending" value without an
exception, so the glue returned with nothing thrown (a caller then got
null): IfHandler after warning about a foreign elseif or else,
SwitchHandler and TryCatchHandler after warning about a non-array case,
catch or catch-type list, TryCatchHandler after warning about a foreign
finally, SimpleImpurePoint on a non-object scope, TypeSpecifier on a
non-object nullsafe result, and PhpClassReflectionExtension on a
non-array result of a call declared to return an array.
Each now does what the twin does: warns and iterates nothing over a
non-array list, throws the TypeError of the call the twin makes next
(processExprNode(), processStmtNodesInternal(), callNodeCallback()),
the "Call to a member function" Error, or the engine's return-type
TypeError for a callee that broke its signature. SwitchHandler reads a
foreign case's properties with the engine's warning instead of crashing,
and IfHandler prints the undefined array key with ZEND_LONG_FMT.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Fdg8n3eEi4ZoXa4dA2k4A
if (UNEXPECTED(elseNode == NULL)) returnzv::Val();
271
275
elseHold = zv::Val::copyOf(zv::Ref(elseNode));
272
276
if (UNEXPECTED(Z_TYPE_P(elseHold.raw()) != IS_OBJECT)) {
277
+
/* the twin reads null stmts with a warning and hands the
278
+
* non-node on as the parent */
273
279
zend_error(E_WARNING, "Attempt to read property \"stmts\" on %s", zend_zval_value_name(elseHold.raw()));
280
+
if (!EG(exception)) {
281
+
zend_type_error("PHPStan\\Analyser\\NodeScopeResolver::processStmtNodesInternal(): Argument #1 ($parentNode) must be of type PhpParser\\Node, %s given", zend_zval_value_name(elseHold.raw()));
returnzv::Str::adopt(zend_strpprintf(0, "Internal error: Expected to find an ancestor with class name %s on %s, but none was found.", ZSTR_VAL(declaringClassName), ZSTR_VAL(className)));
170
170
}
171
171
172
+
/* the result of a call declared `: array`; false (an exception pending) when
173
+
* the call threw or when the callee broke its signature — the engine's
174
+
* return-type TypeError, which a PHP callee would have thrown itself */
/* the twin's processStmtNodesInternal() parameter types, for a
248
+
* hand-built case list's foreign element */
249
+
{
250
+
bool error = false;
251
+
if (UNEXPECTED(!ptsh::isInstanceOf(caseNode, PT_CLASS_NODE, error))) {
252
+
if (!error) {
253
+
zend_type_error("PHPStan\\Analyser\\NodeScopeResolver::processStmtNodesInternal(): Argument #1 ($parentNode) must be of type PhpParser\\Node, %s given", zend_zval_value_name(caseNode));
254
+
}
255
+
returnzv::Val();
256
+
}
257
+
if (UNEXPECTED(Z_TYPE_P(caseStmtsHold.raw()) != IS_ARRAY)) {
258
+
zend_type_error("PHPStan\\Analyser\\NodeScopeResolver::processStmtNodesInternal(): Argument #2 ($stmts) must be of type array, %s given", zend_zval_value_name(caseStmtsHold.raw()));
/* the twin's callNodeCallback() parameter type, for a hand-built
209
+
* catch list's foreign element */
210
+
{
211
+
bool error = false;
212
+
if (UNEXPECTED(!ptsh::isInstanceOf(catchNode, PT_CLASS_NODE, error))) {
213
+
if (!error) {
214
+
zend_type_error("PHPStan\\Analyser\\NodeScopeResolver::callNodeCallback(): Argument #2 ($node) must be of type PhpParser\\Node, %s given", zend_zval_value_name(catchNode));
215
+
}
216
+
returnzv::Val();
217
+
}
218
+
}
205
219
if (UNEXPECTED(!pt_node_scope_resolver_call_node_callback(nodeScopeResolver, nodeCallback, catchNode, scope, storage))) returnzv::Val();
if (UNEXPECTED(Z_TYPE_P(finallyHold.raw()) != IS_OBJECT)) {
586
+
/* the twin reads null stmts with a warning and hands the
587
+
* non-node on as the parent */
571
588
zend_error(E_WARNING, "Attempt to read property \"stmts\" on %s", zend_zval_value_name(finallyHold.raw()));
589
+
if (!EG(exception)) {
590
+
zend_type_error("PHPStan\\Analyser\\NodeScopeResolver::processStmtNodesInternal(): Argument #1 ($parentNode) must be of type PhpParser\\Node, %s given", zend_zval_value_name(finallyHold.raw()));
0 commit comments