Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] Notice: Only variable references should be returned by reference #39089

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

Closed
greg0ire opened this issue Nov 16, 2020 · 8 comments

Comments

@greg0ire
Copy link
Contributor

greg0ire commented Nov 16, 2020

Symfony version(s) affected: 5.1.8

Description
I'm getting the notice in the title. The code that causes it looks like this:

$accessor = function & () use ($targetObject, $name, $value) {
    return $targetObject->$name = $value;
};

How to reproduce

I don't know how to reproduce the generation of this piece of code yet, but reproducing the notice is easy enough:

https://3v4l.org/dE26T

I suspect it is related to this service definition (which looks quite simple):

    #Config amqp_lib
    PhpAmqpLib\Connection\AMQPStreamConnection:
        lazy: true
        class: PhpAmqpLib\Connection\AMQPStreamConnection
        arguments:
            - "%swarrot.host%"
            - "%swarrot.port%"
            - "%swarrot.login%"
            - "%swarrot.password%"
            - "%swarrot.vhost%"

Possible solution

Do it in 2 steps: https://3v4l.org/j501X ?

Stack trace:


/var/www/var/cache/prod/ContainerMifQx3V/AMQPStreamConnection_99651dd.php:251,
--
/var/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php:643,
/var/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php:234,
/var/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php:351,
/var/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AMQPChannel.php:287,
/var/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AMQPChannel.php:117,
/var/www/var/cache/prod/ContainerMifQx3V/getAMQPChannelService.php:35,
/var/www/var/cache/prod/ContainerMifQx3V/getAMQPChannelService.php:23,
/var/www/var/cache/prod/ContainerMifQx3V/AMQPChannel_f219a5d.php:116,
/var/www/var/cache/prod/ContainerMifQx3V/AMQPChannel_f219a5d.php:116,
/var/www/src/Index/Prepare/PrepareProductToIndex.php:173,
/var/www/src/Index/Prepare/PrepareProductToIndex.php:114,
/var/www/src/Index/Prepare/PrepareProductToIndex.php:70,
/var/www/src/Command/AlgoliaPrepareReindexFullCommand.php:107,
/var/www/vendor/symfony/console/Command/Command.php:258,
/var/www/vendor/symfony/console/Application.php:938,
/var/www/vendor/symfony/framework-bundle/Console/Application.php:96,
/var/www/vendor/symfony/console/Application.php:266,
/var/www/vendor/symfony/framework-bundle/Console/Application.php:82,
/var/www/vendor/symfony/console/Application.php:142,
/var/www/bin/console:49

@stof
Copy link
Member

stof commented Nov 16, 2020

Can you share some stack trace about where this code happens ?

@greg0ire
Copy link
Contributor Author

@stof addressed, I also added the service definition for that service.

@stof
Copy link
Member

stof commented Nov 16, 2020

@nicolas-grekas could this be a bug in the proxy generated by ocramius/proxy-manager ?

@nicolas-grekas
Copy link
Member

It could, or it could be an issue with the monkey-patching logic we have in the bridge, we should first check that. @greg0ire can you share the content of the AMQPStreamConnection_99651dd.php file?

@greg0ire
Copy link
Contributor Author

Here you go: https://hastebin.net/wuzirolega.php

@nicolas-grekas
Copy link
Member

What's your exact version of proxy-manager?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Nov 16, 2020

OK, that's an issue with proxy-manager:
https://github.com/Ocramius/ProxyManager/blob/f65ae0f9dcbdd9d6ad3abb721a9e09c3d7d868a4/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php#L78-L80

We'll have to fix this in the bridge also with some monkey-patching for 4.4 (since proxy-manager is not maintained for PHP version 7.1.)

@greg0ire
Copy link
Contributor Author

Thanks for finding the root cause, I reported this upstream

nicolas-grekas added a commit that referenced this issue Dec 23, 2020
…hp/proxy-manager-lts" (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[ProxyManagerBridge] fix PHP notice, switch to "friendsofphp/proxy-manager-lts"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39089
| License       | MIT
| Doc PR        | -

I submitted the fix for #39089 on the origin library at Ocramius/ProxyManager#646.

Because of the [versioning policy](https://github.com/Ocramius/.github/blob/6d4561515513f6d59fb144d838971d4a7715e3e4/version-support.md#dependency-upgrades) in use at the origin library, this fix won't be available for PHP < 7.4.

We usually resort to monkey-patching to workaround the policy and still ship the fix for 4.4 (which supports PHP >= 7.1).

This time, and as explained in Ocramius/ProxyManager#630, I propose to delegate the fix to [friendsofphp/proxy-manager-lts](https://github.com/FriendsOfPHP/proxy-manager-lts/). It already embeds the fix and a few others that allow us to remove most of the monkey-patching we had to accumulate over time.

Commits
-------

389f530 [ProxyManagerBridge] fix PHP notice, switch to "friendsofphp/proxy-manager-lts"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants