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 d015636
Browse filesBrowse the repository at this point in the historyBrowse files
Raise TypeErrors for non-Type arguments of native traverse callbacks
The native TypeTraverser::map() callbacks of TypeCombinator and of the
called-on-type member prototypes reported a non-object $type argument
as an ArgumentCountError, which the twins' `Type $type` closure
parameters raise as a TypeError; the argument count and the type are now
checked separately. countConstantArrayValueTypes() also checks each
element the way the twin's TypeTraverser::map(Type $type, ...) call does,
so a scalar or a non-Type object element is that TypeError instead of
reaching the callback (a scalar) or failing with an unrelated Error (an
object).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Fdg8n3eEi4ZoXa4dA2k4A
if (UNEXPECTED(argc < 1 || Z_TYPE(argv[0]) != IS_OBJECT)) {
161
+
if (UNEXPECTED(argc < 1)) {
162
162
zend_argument_count_error("Too few arguments to function %s::{closure}(), %u passed and exactly 1 expected", ZSTR_VAL(pt_ce_called_on_type_unresolved_method_prototype_reflection->name), argc);
163
163
return;
164
164
}
165
+
if (UNEXPECTED(Z_TYPE(argv[0]) != IS_OBJECT)) {
166
+
zend_type_error("%s::{closure}(): Argument #1 ($type) must be of type %s, %s given", ZSTR_VAL(pt_ce_called_on_type_unresolved_method_prototype_reflection->name), ptcls::type, zend_zval_value_name(&argv[0]));
167
+
return;
168
+
}
165
169
zv::Val result = transformStaticType(Z_OBJ_P(thisZv), &argv[0]);
166
170
if (UNEXPECTED(result.isUndef())) return;
167
171
result.intoReturnValue(return_value);
@@ -175,10 +179,14 @@ class CalledOnTypeUnresolvedMethodPrototypeReflection
if (UNEXPECTED(argc < 2 || Z_TYPE(argv[0]) != IS_OBJECT)) {
182
+
if (UNEXPECTED(argc < 2)) {
179
183
zend_argument_count_error("Too few arguments to function %s::{closure}(), %u passed and exactly 2 expected", ZSTR_VAL(pt_ce_called_on_type_unresolved_method_prototype_reflection->name), argc);
180
184
return;
181
185
}
186
+
if (UNEXPECTED(Z_TYPE(argv[0]) != IS_OBJECT)) {
187
+
zend_type_error("%s::{closure}(): Argument #1 ($type) must be of type %s, %s given", ZSTR_VAL(pt_ce_called_on_type_unresolved_method_prototype_reflection->name), ptcls::type, zend_zval_value_name(&argv[0]));
if (UNEXPECTED(argc < 2 || Z_TYPE(argv[0]) != IS_OBJECT)) {
152
+
if (UNEXPECTED(argc < 2)) {
153
153
zend_argument_count_error("Too few arguments to function %s::{closure}(), %u passed and exactly 2 expected", ZSTR_VAL(pt_ce_called_on_type_unresolved_property_prototype_reflection->name), argc);
154
154
return;
155
155
}
156
+
if (UNEXPECTED(Z_TYPE(argv[0]) != IS_OBJECT)) {
157
+
zend_type_error("%s::{closure}(): Argument #1 ($type) must be of type %s, %s given", ZSTR_VAL(pt_ce_called_on_type_unresolved_property_prototype_reflection->name), ptcls::type, zend_zval_value_name(&argv[0]));
zend_argument_count_error("Too few arguments to function %s::{closure}(), %u passed and exactly 2 expected", ZSTR_VAL(pt_ce_type_combinator->name), argc);
1954
+
returnfalse;
1955
+
}
1956
+
if (UNEXPECTED(Z_TYPE_P(&argv[0]) != IS_OBJECT)) {
1957
+
zend_type_error("%s::{closure}(): Argument #1 ($type) must be of type %s, %s given", ZSTR_VAL(pt_ce_type_combinator->name), ptcls::type, zend_zval_value_name(&argv[0]));
1958
+
returnfalse;
1959
+
}
1960
+
returntrue;
1961
+
}
1962
+
1946
1963
/* the body of optimizeConstantArrays()'s TypeTraverser::map() callback:
1947
1964
* a non-empty ConstantArrayType generalized to an oversized array over
1948
1965
* the union of its (generalized) keys and values, `use (&$isOversized)`
if (UNEXPECTED(!pt_type_instanceof(entry.value().raw(), PT_CLASS_TYPE, isType))) return -1;
2329
+
if (UNEXPECTED(!isType)) {
2330
+
zend_type_error("%s::map(): Argument #1 ($type) must be of type %s, %s given", ZSTR_VAL(pt_ce_type_traverser->name), ptcls::type, zend_zval_value_name(entry.value().raw()));
0 commit comments