Skip to content

Commit d5aa43a

Browse files
ondrejmirtesclaude
andcommitted
Register ConstantArrayTypeBuilder's, TypeCombinatorCache's and ObjectType's hand-spelled methods by signature
ConstantArrayTypeBuilder's mutators, TypeCombinatorCache's methods and ObjectType::resetCaches() still spelled their arginfo by hand, without the twins' `void` / `Type` return types, although generated sig:: declarations exist for them. They register by those now. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Fdg8n3eEi4ZoXa4dA2k4A
1 parent b486c0e commit d5aa43a

4 files changed

Lines changed: 14 additions & 17 deletions

File tree

‎turbo-ext/src/ConstantArrayTypeBuilder.cpp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,39 +1220,39 @@ void pt_register_constant_array_type_builder()
12201220
PT_RETURN_VAL(pt_constant_array_type_builder_create_from_constant_array(startArrayType));
12211221
});
12221222

1223-
cls.method("makeUnsealed", reg::Public, 2, { reg::obj("keyType", ptcls::type), reg::obj("valueType", ptcls::type) }, [](INTERNAL_FUNCTION_PARAMETERS) {
1223+
cls.method(sigs::makeUnsealed, [](INTERNAL_FUNCTION_PARAMETERS) {
12241224
zval *keyType, *valueType;
12251225
if (!zp::parse<zp::Obj, zp::Obj>(execute_data, keyType, valueType)) RETURN_THROWS();
12261226
if (UNEXPECTED(!pt_catb_check_type(keyType, 1) || !pt_catb_check_type(valueType, 2))) RETURN_THROWS();
12271227
PT_THIS.makeUnsealed(keyType, valueType);
12281228
});
12291229

1230-
cls.method("mergeUnsealed", reg::Public, 2, { reg::obj("keyType", ptcls::type), reg::obj("valueType", ptcls::type) }, [](INTERNAL_FUNCTION_PARAMETERS) {
1230+
cls.method(sigs::mergeUnsealed, [](INTERNAL_FUNCTION_PARAMETERS) {
12311231
zval *keyType, *valueType;
12321232
if (!zp::parse<zp::Obj, zp::Obj>(execute_data, keyType, valueType)) RETURN_THROWS();
12331233
if (UNEXPECTED(!pt_catb_check_type(keyType, 1) || !pt_catb_check_type(valueType, 2))) RETURN_THROWS();
12341234
if (UNEXPECTED(!PT_THIS.mergeUnsealed(keyType, valueType))) RETURN_THROWS();
12351235
});
12361236

1237-
cls.method("setOffsetValueType", reg::Public, 2, { reg::obj("offsetType", ptcls::type, true), reg::obj("valueType", ptcls::type), reg::withDefault(reg::boolArg("optional"), "false") }, [](INTERNAL_FUNCTION_PARAMETERS) {
1237+
cls.method(sigs::setOffsetValueType, [](INTERNAL_FUNCTION_PARAMETERS) {
12381238
zval *offsetType, *valueType;
12391239
bool optional = false;
12401240
if (!zp::parse<zp::ObjOrNull, zp::Obj, zp::Opt<zp::Bool>>(execute_data, offsetType, valueType, optional)) RETURN_THROWS();
12411241
if (UNEXPECTED(!pt_catb_check_type(offsetType, 1) || !pt_catb_check_type(valueType, 2))) RETURN_THROWS();
12421242
if (UNEXPECTED(!PT_THIS.setOffsetValueType(offsetType, valueType, optional))) RETURN_THROWS();
12431243
});
12441244

1245-
cls.method<&ConstantArrayTypeBuilder::markNonListKey, zp::Bool>("markNonListKey", reg::Private, { reg::boolArg("optional") });
1245+
cls.method<&ConstantArrayTypeBuilder::markNonListKey, zp::Bool>(sigs::markNonListKey);
12461246

1247-
cls.method("degradeToGeneralArray", reg::Public, 0, { reg::withDefault(reg::boolArg("oversized"), "false") }, [](INTERNAL_FUNCTION_PARAMETERS) {
1247+
cls.method(sigs::degradeToGeneralArray, [](INTERNAL_FUNCTION_PARAMETERS) {
12481248
bool oversized = false;
12491249
if (!zp::parse<zp::Opt<zp::Bool>>(execute_data, oversized)) RETURN_THROWS();
12501250
if (UNEXPECTED(!PT_THIS.degradeToGeneralArray(oversized))) RETURN_THROWS();
12511251
});
12521252

1253-
cls.method<&ConstantArrayTypeBuilder::disableClosureDegradation>("disableClosureDegradation", reg::Public, {});
1253+
cls.method<&ConstantArrayTypeBuilder::disableClosureDegradation>(sigs::disableClosureDegradation);
12541254

1255-
cls.method<&ConstantArrayTypeBuilder::disableArrayDegradation>("disableArrayDegradation", reg::Public, {});
1255+
cls.method<&ConstantArrayTypeBuilder::disableArrayDegradation>(sigs::disableArrayDegradation);
12561256

12571257
cls.method<&ConstantArrayTypeBuilder::getArray>(sigs::getArray);
12581258

‎turbo-ext/src/ObjectType.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3638,7 +3638,7 @@ void pt_register_object_type()
36383638
PT_THIS.construct(className, subtractedType, classReflection);
36393639
});
36403640

3641-
cls.method("resetCaches", reg::PublicStatic, 0, {}, [](INTERNAL_FUNCTION_PARAMETERS) {
3641+
cls.method(sigs::resetCaches, [](INTERNAL_FUNCTION_PARAMETERS) {
36423642
ZEND_PARSE_PARAMETERS_NONE();
36433643
ObjectType::resetCaches();
36443644
});

‎turbo-ext/src/TypeCombinatorCache.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
#include "generated/IntersectionType.h"
7474
#include "generated/TypeCombinatorCache.h"
7575
#include "generated/UnionType.h"
76+
77+
namespace sigs = ptdecl::TypeCombinatorCache::sig;
7678
#include "zv.h"
7779

7880
#include <Zend/zend_weakrefs.h>
@@ -886,13 +888,11 @@ void pt_type_combinator_cache_clear()
886888

887889
void pt_register_type_combinator_cache()
888890
{
889-
static const char *TYPE_CLASS = "PHPStan\\Type\\Type";
890-
891891
reg::Class cls("PHPStan\\Type\\TypeCombinatorCache");
892892
ptdecl::TypeCombinatorCache::declareClass(cls);
893893
ptdecl::TypeCombinatorCache::declareProperties(cls);
894894

895-
cls.method("union", reg::PublicStatic, 0, { reg::variadicObj("types", TYPE_CLASS) }, [](INTERNAL_FUNCTION_PARAMETERS) {
895+
cls.method(sigs::union_, [](INTERNAL_FUNCTION_PARAMETERS) {
896896
zval *types;
897897
uint32_t count;
898898
ZEND_PARSE_PARAMETERS_START(0, -1)
@@ -901,7 +901,7 @@ void pt_register_type_combinator_cache()
901901
PT_RETURN_VAL(pt_type_combinator_cache_union(count, types));
902902
});
903903

904-
cls.method("intersect", reg::PublicStatic, 0, { reg::variadicObj("types", TYPE_CLASS) }, [](INTERNAL_FUNCTION_PARAMETERS) {
904+
cls.method(sigs::intersect, [](INTERNAL_FUNCTION_PARAMETERS) {
905905
zval *types;
906906
uint32_t count;
907907
ZEND_PARSE_PARAMETERS_START(0, -1)
@@ -910,13 +910,13 @@ void pt_register_type_combinator_cache()
910910
PT_RETURN_VAL(pt_type_combinator_cache_intersect(count, types));
911911
});
912912

913-
cls.method("remove", reg::PublicStatic, 2, { reg::obj("fromType", TYPE_CLASS), reg::obj("typeToRemove", TYPE_CLASS) }, [](INTERNAL_FUNCTION_PARAMETERS) {
913+
cls.method(sigs::remove, [](INTERNAL_FUNCTION_PARAMETERS) {
914914
zval *fromType, *typeToRemove;
915915
if (!zp::parse<zp::Obj, zp::Obj>(execute_data, fromType, typeToRemove)) RETURN_THROWS();
916916
PT_RETURN_VAL(pt_type_combinator_cache_remove(fromType, typeToRemove));
917917
});
918918

919-
cls.method("clearCache", reg::PublicStatic, 0, {}, [](INTERNAL_FUNCTION_PARAMETERS) {
919+
cls.method(sigs::clearCache, [](INTERNAL_FUNCTION_PARAMETERS) {
920920
ZEND_PARSE_PARAMETERS_NONE();
921921
TypeCombinatorCache::clear();
922922
});

‎turbo-ext/tests/signature-parity.php‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
'PHPStan\\Reflection\\BetterReflection\\SourceLocator\\PhpFileCleaner' => 'pending',
4242
'PHPStan\\Reflection\\BetterReflection\\SourceLocator\\SymbolFinderInFiles' => 'pending',
4343
'PHPStan\\Reflection\\Php\\PhpClassReflectionExtension' => 'pending',
44-
'PHPStan\\Type\\Constant\\ConstantArrayTypeBuilder' => 'pending',
45-
'PHPStan\\Type\\ObjectType' => 'pending',
46-
'PHPStan\\Type\\TypeCombinatorCache' => 'pending',
4744
];
4845

4946
/**

0 commit comments

Comments
 (0)