rezzza / TimeTraveler

Time traveling php library (pretty similar to ruby timecop)
103 stars 11 forks source link

[WIP] POC with GO-AOP instead of AOP PHP #22

Closed gmorel closed 8 years ago

gmorel commented 9 years ago

Rebund of https://github.com/rezzza/TimeTraveler/issues/21

Proof of Concept

As a fundation to allow us injecting time. We need to validate GO-AOP behaviour for:

As if the Pointcut @Around("execution(public DateTime->format(*))") were ignored (nothing built in the cache directory either)

Test

You can run the test via

bin/atoum tests/units/Rezzza/TimeTravelerAspect.php

gmorel commented 9 years ago

@adri In your comment you were using lapistano\ProxyObject\ProxyBuilder, and not GO-AOP, right ? Or I missed something ?

gmorel commented 9 years ago

Maybe my PointCut declaration is wrong ? https://github.com/rezzza/TimeTraveler/pull/22/files#diff-ec9fa2630df712d9e8ff0e06e7e768dbR63

adri commented 9 years ago

Could it be that the global namespace () is missing before Datetime in the pointcut description?

gmorel commented 9 years ago

Yes I thought so

@Around("execution(public \DateTime->format(*))")

but I get a

Error: Unexpected token \ in the execution(public \DateTime->format(*)) before Rezzza\TimeTravelerAspect->aroundNativeDateTimeFormatMethod, defined in TimeTraveler/src/TimeTravelerAspect.php:68. Expected one of: *, , namePart, |, public, protected, private, final

adri commented 9 years ago

Hmm maybe @lisachenko has a hint? :-)

lisachenko commented 9 years ago

Hello, guys! Unfortunately, it's impossible to intercept built-in classes as they already loaded into the memory of PHP. This is only possible via extension, but I have some thoughts, how this can be implemented, check https://github.com/goaop/framework/issues/238 answer

lisachenko commented 8 years ago

This PR can be closed as well, because of limitation of goaop framework for built-in classes. However, custom source transformer can do this job, as discussed in https://github.com/goaop/framework/issues/238

shouze commented 8 years ago

tagged wontfix