-
Notifications
You must be signed in to change notification settings - Fork 550
Add comprehensive PHPDoc documentation to Type interface #4866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ondrejmirtes
wants to merge
6
commits into
2.1.x
Choose a base branch
from
claude/document-type-interface-qtagP
base: 2.1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,092
−190
Conversation
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
Document every method on the Type interface with descriptions of purpose, behavior, parameters, return values, and usage guidance. Key additions: - Interface-level doc explaining the central role of Type and the critical rule to never use instanceof for type checks - Core methods: isSuperTypeOf, accepts, equals, describe with examples - Class identification: getReferencedClasses vs getObjectClassNames vs getObjectClassReflections, getClassStringObjectType - Member access: canAccessProperties/canCallMethods/canAccessConstants and has*/get*/getUnresolved* patterns - Array operations: all 13 array transformation methods (chunk, flip, pop, shift, slice, splice, reverse, search, shuffle, etc.) - Offset access: isOffsetAccessible vs isOffsetAccessLegal, setOffsetValueType vs setExistingOffsetValueType - Type checking: all is* methods for scalars, strings, and arrays - Type conversion: all to* methods (toBoolean through toCoercedArgumentType) - Comparison: looseCompare, isSmallerThan, getSmallerType family - Templates: inferTemplateTypes, getReferencedTemplateTypes, traverse - Other: generalize, tryRemove, getFiniteTypes, hasTemplateOrLateResolvableType https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
Document every method on the Scope interface, ClassMemberAccessAnswerer interface, and NamespaceAnswerer interface with descriptions of purpose, behavior, parameters, return values, and usage guidance. Scope interface: - Interface-level doc explaining Scope as the analysis state at an AST position, listing all extension types that receive it as a parameter - File/context methods: getFile vs getFileDescription (trait handling), isDeclareStrictTypes, isInTrait/getTraitReflection - Function context: getFunction, getFunctionName, getParentScope - Variable tracking: hasVariableType, getVariableType, canAnyVariableExist (extract() handling), getDefinedVariables vs getMaybeDefinedVariables - Type resolution: getType (the core method), getNativeType (PHPDoc-free), getKeepVoidType (preserves void), getScopeType vs getType (deferred evaluation), getScopeNativeType - Name resolution: resolveName (self/static/parent handling), resolveTypeByName (preserves LSB via StaticType/ThisType) - Reflection helpers: getInstancePropertyReflection, getStaticPropertyReflection, getMethodReflection, getConstantReflection - Scope filtering: filterByTruthyValue/filterByFalseyValue for type narrowing in conditional branches - Context queries: isInClassExists, isInFunctionExists, isInClosureBind, isInAnonymousFunction, isInExpressionAssign, isUndefinedExpressionAllowed, isInFirstLevelStatement, getFunctionCallStack ClassMemberAccessAnswerer interface: - Interface-level doc explaining its role as visibility checker passed to Type methods for enforcing public/protected/private access - canReadProperty vs canWriteProperty (PHP 8.4 asymmetric visibility) - canCallMethod, canAccessConstant NamespaceAnswerer interface: - Interface-level doc explaining namespace resolution context https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
…pe and Scope interfaces Document all interfaces and classes reachable through parameter types and return types of the previously documented Type and Scope interfaces. This covers 31 files across the type system, reflection layer, and supporting infrastructure: - Core result types: TrinaryLogic, AcceptsResult, IsSuperTypeOfResult - Type system: VerbosityLevel, GeneralizePrecision, ConstantScalarType, TypeWithClassName - Reflection: ClassMemberReflection, PropertyReflection, ExtendedPropertyReflection, MethodReflection, ExtendedMethodReflection, FunctionReflection, ParameterReflection, ClassConstantReflection, ConstantReflection, ParametersAcceptor, ExtendedParametersAcceptor, PassedByReference, Assertions, AttributeReflection - Callables: CallableParametersAcceptor, SimpleThrowPoint, SimpleImpurePoint - Generics: TemplateTypeMap, TemplateTypeReference, TemplateTypeVariance - Prototype resolution: UnresolvedPropertyPrototypeReflection, UnresolvedMethodPrototypeReflection - PHP version: PhpVersion, PhpVersions https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
Based on git blame analysis of Type.php, document the recurring pattern of adding new methods to the Type interface as a bug fix strategy instead of scattering instanceof checks or utility calls across the codebase. https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
…ype interfaces CompoundType: Document the double-dispatch protocol for bidirectional type comparison, explaining why instanceof CompoundType is the correct pattern (unlike instanceof SomeSpecificType which is discouraged). Document all four methods with their decomposition semantics. AccessoryType: Document the marker interface's role as a refinement type that always lives inside an IntersectionType alongside a base type. Include a complete mapping table of all 13 implementations to their corresponding query methods on the Type interface. https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
…es, tags, or common knowledge https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
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.
Document every method on the Type interface with descriptions of purpose,
behavior, parameters, return values, and usage guidance. Key additions:
critical rule to never use instanceof for type checks
getObjectClassReflections, getClassStringObjectType
and has*/get*/getUnresolved* patterns
pop, shift, slice, splice, reverse, search, shuffle, etc.)
setOffsetValueType vs setExistingOffsetValueType
https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437