Skip to content
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

Class Proxy contains syntax errors in PHP 7 #312

Closed
jgiacobbi opened this issue Jan 13, 2017 · 1 comment
Closed

Class Proxy contains syntax errors in PHP 7 #312

jgiacobbi opened this issue Jan 13, 2017 · 1 comment

Comments

@jgiacobbi
Copy link

Hello, My project has been working until just recently. We started dependency injecting some things into a particular class and the typehints cause the proxy to have syntax errors.

Here is the constructor declaration:

public function __construct(ClassOne $classOne, Logger $logger = null, System $system = null)
{
	...
}

Here is the proxied version:

public function __construct(\Company\Namespace\ClassOne $classOne, ?\Company\Namespace\Logging\Logger $logger = NULL, ?\Company\Namespace\System $system = NULL)
{
    return self::$__joinPoints['method:__construct']->__invoke($this, \array_slice([$classOne, $logger, $system], 0, \func_num_args()));
}

And this is the error:

PHP Parse error:  syntax error, unexpected '?', expecting variable (T_VARIABLE) in /var/log/company/project/cache/_proxies/src/API.php on line 30

The workaround is just to remove the typehints. Without typehints it works fine.

@lisachenko
Copy link
Member

Yes, confirmed as a bug in the master branch. I will apply a patch tomorrow.

In case of emergency, you can lock any stable tag (2.0.0) for now instead of dev-version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants