-
Notifications
You must be signed in to change notification settings - Fork 129
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
Lack of comment in the doubled class causes "ParseError: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST)" #185
Comments
Downgrade to older version of |
Hi @dudapiotr , Thanks for the suggestion. I did the downgrade (from 2.3.4) in two different projects and it worked 50%.
So, I'm guessing it's a combination between goaop/framework version and some other package that's not working right. But I'm really not capable of going though the composer.lock and trying to figure it out. There must be a better way than going line by line. I'll stick with the comments in the second project for now |
It turns out that whatever the bug is, it is causing way more problems than I initially thought. So I finally decided to remove AspectMock from the project and do my test doubles by extending the base classes and overwriting the methods that were calling in other dependencies. That was pretty easy, in my current project at least. Thanks! |
I'm seeing the same error and have been able to track it down a bit further, but don't know how to fix it. AspectMock overrides methods by adding an public function hasSignatureFile(): bool
{ if (($__am_res = __amock_before($this, __CLASS__, __FUNCTION__, array(), false)) !== __AM_CONTINUE__) { return $__am_res; }
switch ($this->getRedcapPid()) { if (($__am_res = __amock_before($this, __CLASS__, __FUNCTION__, array(), false)) !== __AM_CONTINUE__) { return $__am_res; }
case self::REDCAP_LC_HRPP:
case self::REDCAP_LC_HRPP_CC:
case self::REDCAP_LC_PI:
case self::REDCAP_LC_PI_CC:
return true;
default:
return false;
}
} |
This issue seems to be related to the |
THANK YOU @sollidsnake - this has been plaguing us for months now...
which, in turn, holds us back to phpunit v8. But after days of trying to sort this out (for a newer, focal-based version of our monolith) finally getting non-corruptions for once! |
I found linked issue: goaop/parser-reflection#104 |
I've done fix, but it is on review now. If somebody want to test or use it on different environments before pull-request will be approved and new version will be released with this patch, I've made forks of 3 repositories, you just need to specify it like this in your composer file: ...
"repositories": [
{
"type": "vcs",
"url": "https://github.com/xfuturomax/framework"
},
{
"type": "vcs",
"url": "https://github.com/xfuturomax/parser-reflection"
},
{
"type": "vcs",
"url": "https://github.com/xfuturomax/AspectMock"
}
],
...
"require-dev": {
"codeception/aspect-mock": "dev-fix/support-of-new-php-parser-composer"
},
... |
will try to give that a shot now @xfuturomax - thanks! |
so far, i keep getting...
|
@traceypooh Did you specify repositories like in my example above? |
i did. but looks like (i'm a bit of a clowncar w/ keyboard keys salad over here with more than basic composer.json...) but looks like finally got my setup to install like this:
|
TESTS WORKING! 🎉 🙏 🙇♀️ |
Hello, is there an E.T.A. for a release that contains this solution? Thank you. |
1 similar comment
Hello, is there an E.T.A. for a release that contains this solution? Thank you. |
@Naktibalda it would be very much appreciated if these changes get released |
Looks like this package has been abandoned. Unless somebody forks it, I think this is it, but it would be nice to get a confirmation by the owner and maybe encourage new maintainers. |
@xfuturomax patch to goaop/framework was released in goaop/framework 3.0.0 version on 5th of April. It only supports PHP 7.4. AspectMock v3 is not compatible with goaop/framework 3.0.0, I will make necessary changes and release AspectMock 4.0.0 supporting goaop/framework v3 only. |
This issue happens in AspectMock's own tests on Github Actions and it happened on Travis last year. On Github Actions, error happens with PHP 7.0, 7.3 and 7.4, but it doesn't happen with 7.1 and 7.2 Does anyone know what the issue is and how to fix it? Would adding version constraint for some dependency really help to avoid it? |
the only fix i've figured out and we're currently using is (above) at we have 2 composer.json files -- one for xenial/php v7.0; one for focal/php v7.4
|
(and xxx is not my password ;) ) |
the (best i can tell) character-by-character |
I created goaop-framework-v3 branch, could you test it on PHP 7.4? |
This issue happened on PHP 7.4 with goaop/framework v2: https://github.com/Codeception/AspectMock/runs/2314193689?check_suite_focus=true but it doesn't happen with goaop/framework v3, so I consider it fixed. https://github.com/Codeception/AspectMock/pull/193/checks?check_run_id=2364951832 |
I released it as 4.0.0 version, please upgrade. https://github.com/Codeception/AspectMock/releases/tag/4.0.0 |
working beautifully so far for us over here, so many thanks! 🙏 |
Hi,
Love AspectMock! I finally managed to start testing stuff which I've previously found untestable.
However, I'm getting a very weird and annoying issue with it, though. I'm getting "ParseError: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST)" without any apparent reason.
I've done a bunch of tests to figure out what it could be. I've even went so far as to try to double a completely blank class, just it's definition.
Actually, I've now reproduced it:
Here's the test:
Here's the Class
And here's the Result::
There's absolutely no 'if' in that class. It's as clean as it can be.
At first I thought it was the bootstrap.php file, but it's all correct there:
The $kernel is initialized correctly.
After a lot work trying to figure it out, I did find a quite easy fix, but which makes no sense.
Just by adding a simple comment "//"after opening the class, makes the test pass. Like this:
This is the result:
It makes absolutely no sense to me why that fixes it.
I'm ok with that fix for now, as it allows me to focus on the rest of the project. It's not pretty having to add useless comments throughtout the code, but it does the job for now.
It would be nice to know what actually causes this issue and if there's anything more robust I can do, or can be added to AspectMock to avoid this in the future.
Thanks!
The text was updated successfully, but these errors were encountered: