Repository navigation
Shadow the object, array, callable and composite types natively - #6503
Merged
Merged
Conversation
…e, ObjectShapeType and NonexistentParentClassType natively StaticType (TypeWithClassName + SubtractableType, delegating to its ObjectType through the object's class entry so the GenericStaticType and ThisType overrides hold), its two children, ObjectWithoutClassType, ObjectShapeType and NonexistentParentClassType. Four more trait registrars; the twins' closures become Closures over internal holder classes. The type-family differential gains the object-ish subjects over real reflections (68k observations). The Windows source list in config.w32, duplicated by the previous merge, is regenerated from src/. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FSCEwuXjDzsNw2wSNsDW6D
ArrayType (implements Type: key/item types, every array operation, template inference) and the five array accessories NonEmptyArrayType, AccessoryArrayListType, OversizedArrayType, HasOffsetType and HasOffsetValueType (CompoundType + AccessoryType). Six more trait registrars; a union-typed property builder; the closures the twins hand to TypeTraverser::map() become an internal NativeCallback holder running a C body. The type-family differential gains 44 subjects (246k observations). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FSCEwuXjDzsNw2wSNsDW6D
…natively AccessoryNumericStringType, AccessoryNonEmptyStringType, AccessoryNonFalsyStringType, AccessoryLiteralStringType, AccessoryLowercaseStringType, AccessoryUppercaseStringType, AccessoryDecimalIntegerStringType, HasMethodType and HasPropertyType (CompoundType + AccessoryType). The ports that created them through the class-reference table instantiate them directly now. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FSCEwuXjDzsNw2wSNsDW6D
The core object family: ObjectType (TypeWithClassName + SubtractableType, with its per-instance memo slots and the bounded static caches declared as real static properties, since ObjectTypeTest reflects into them), and its native children GenericObjectType and EnumCaseObjectType. Every $this-> call dispatches through the object's class entry so the PHP TemplateObjectType/TemplateGenericObjectType overrides keep holding. The type-family differential gains 90k observations over real reflections. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FSCEwuXjDzsNw2wSNsDW6D
The callable family: IterableType (CompoundType), CallableType (CompoundType + CallableParametersAcceptor) and ClosureType (TypeWithClassName + CallableParametersAcceptor) with the twins' full state in declared slots. The bodies the two callable types share verbatim live once in TypeTraits.cpp; the type-family differential gains 46 subjects (110k observations). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FSCEwuXjDzsNw2wSNsDW6D
The array-shape type: key/value/optional-key/next-auto-index bookkeeping, every array operation with shape precision, isSuperTypeOf/accepts over optional keys, list handling, unsealed shapes, describe in all forms, generalize, template inference and toPhpDocNode, mirrored method by method (the largest single port). The native class declares the twin's twelve properties in its order, the $optionalKeySet memo included, so its slots are the generated ones. The type-family differential gains 48 subjects (439k observations). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FSCEwuXjDzsNw2wSNsDW6D
The composite types: UnionType (CompoundType, with its member operations, normalization, sorted description and finite-set memo), its native child BenevolentUnionType, and IntersectionType (CompoundType with the accessory-aware description and array-shape handling). The member operations the twins express as closures are native ops; PHP subclasses overriding them (TemplateUnionType, anonymous test subclasses) are honoured through the object's class entry. The type-family differential gains 48 subjects (482k observations). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FSCEwuXjDzsNw2wSNsDW6D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the object, array, callable and composite half of the Type kernel into the native extension.
What goes native
StaticType,ThisType,GenericStaticType,ObjectWithoutClassType,ObjectShapeType,NonexistentParentClassType.StaticTypedelegates to itsObjectTypethrough the object's class entry, so theThisTypeandGenericStaticTypeoverrides hold.ArrayTypeand the array accessoriesNonEmptyArrayType,AccessoryArrayListType,OversizedArrayType,HasOffsetType,HasOffsetValueType. This covers every array operation and template inference. The closures the twins hand toTypeTraverser::map()become a native callback holder running a C body.HasMethodTypeandHasPropertyType.ObjectType,GenericObjectType,EnumCaseObjectType. The per-instance memo slots are included, and the bounded static caches are declared as real static properties, becauseObjectTypeTestreflects into them. Every$this->call dispatches through the object's class entry, so the PHPTemplateObjectTypeandTemplateGenericObjectTypeoverrides keep holding.IterableType,CallableType,ClosureType. The twins' full state lives in declared slots, and the bodies the two callable types share verbatim live once inTypeTraits.cpp.ConstantArrayType, the largest single port, mirrored method by method. It covers shape bookkeeping, optional keys, lists, unsealed shapes, every description form, generalization andtoPhpDocNode(). It declares the twin's twelve properties in order, the$optionalKeySetmemo included, so its slots are the generated ones.UnionType,BenevolentUnionType,IntersectionType. This covers member operations, normalization, the sorted description, the finite-set memo, and the accessory-aware intersection description. PHP subclasses that override member operations (TemplateUnionType, anonymous test subclasses) are honoured through the object's class entry.Each family adds its trait registrars to
turbo-ext/src/TypeTraits.cpp, one per PHP trait, declared by the twin's signatures.Tests
turbo-ext/tests/type-family.phpgains the subjects of every family, including the PHP subclasses over the native parents and real class reflections. That's about 1.5M observations, compared between the PHP twins and the activated extension bysmoke.php.Verification
On this commit, with the extension loaded and active:
side-by-side.php,signature-parity.phpandsmoke.phppass.make tests,make phpstan,make csandmake lintare clean.-Wall -Wextra -Werror) both pass.🤖 Generated with Claude Code
https://claude.ai/code/session_017MvPby652L7wUqGAHEiEcN