phpsa
                                
                                 phpsa copied to clipboard
                                
                                    phpsa copied to clipboard
                            
                            
                            
                        ScopePointer ::__construct and ::getObject not aligning
When doing the UT for #170 I cam across the ScopePointer which takes in any parameter into the constructor (string, int, object etc.) And based on the @return tag for the getObject it should return ClassMethod or FunctionDefinition
https://github.com/ovr/phpsa/blob/master/src/ScopePointer.php#L23 https://github.com/ovr/phpsa/blob/master/src/ScopePointer.php#L51
I guess some type of type checking needs to be added, and an exception should be thrown if not type not permitted.
Seems We are having 2 ways how to improve this
1.
So I suggest to build a new Interface called like ScopePointerInterface
Implement ClassMethod, FunctionDefinition with ScopePointerInterface
Add ScopePointerInterface strict
https://github.com/ovr/phpsa/blob/master/src/ScopePointer.php#L23
- Check in __construct
- is null
- is object
- is method
If not, lets throw an InvalidArgumentException
As we can see AbstractDefinition::getPointer, property ScopePointer::$object can be one of the following: ClassMethod, ClosureDefinition, FunctionDefinition, ReflectionClassMethod, RuntimeClassDefinition, TraitDefinition, ClassDefinition.
So what about this version of ScopePointer?
https://github.com/Lexty/phpsa/blob/182-scope-pointer-strict-type/src/ScopePointer.php
So what about this version of ScopePointer? https://github.com/Lexty/phpsa/blob/182-scope-pointer-strict-type/src/ScopePointer.php
ping @ovr @K-Phoen