Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

ScopePointer ::__construct and ::getObject not aligning #182

Open
DannyvdSluijs opened this issue Oct 5, 2016 · 3 comments
Open

ScopePointer ::__construct and ::getObject not aligning #182

DannyvdSluijs opened this issue Oct 5, 2016 · 3 comments

Comments

@DannyvdSluijs
Copy link

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.

@ovr
Copy link
Owner

ovr commented Oct 5, 2016

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

  1. Check in __construct
  2. is null
  3. is object
  4. is method

If not, lets throw an InvalidArgumentException

@Lexty
Copy link
Contributor

Lexty commented Oct 11, 2016

@ddmler
Copy link
Collaborator

ddmler commented Oct 12, 2016

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants