8000 [PhpUnitBridge] vendor weak mode fails · Issue #21980 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PhpUnitBridge] vendor weak mode fails #21980

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
theofidry opened this issue Mar 12, 2017 · 11 comments
Closed

[PhpUnitBridge] vendor weak mode fails #21980

theofidry opened this issue Mar 12, 2017 · 11 comments

Comments

@theofidry
Copy link
Contributor
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.0 (master — 40d133c)

#21539 results in an error on my end after upgrading symfony/symfony to ^3.3.@dev.

PHP Fatal error:  Uncaught uasort() expects parameter 1 to be array, null given

/path/to/project/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:109
/path/to/project/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:219

  thrown in /path/to/project/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php on line 219

Fatal error: Uncaught uasort() expects parameter 1 to be array, null given

From what I see the error seems to come from https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php#L88 where it should be:

$deprecations = array(
            'unsilencedCount' => 0,
            'remainingCount' => 0,
            'remaining vendorCount' => 0,  // this one is missing although doesn't cause an error
            'legacyCount' => 0,
            'otherCount' => 0,
            'unsilenced' => array(),
            'remaining' => array(),
            'remaining vendor' => array(), // this is the missing bit causing an error
            'legacy' => array(),
            'other' => array(),
        );

PhpUnit config:

<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.6/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="app/autoload.php"
         stopOnFailure="true"
         verbose="true"
>
    <php>
        <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors" />
    </php>

   <!-- ... -->
</phpunit>

/cc @greg0ire

@greg0ire
Copy link
Contributor

Both entries are supposed to be added just below : https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php#L100 Can you please debug that part ?

@theofidry
Copy link
Contributor Author
theofidry commented Mar 12, 2017

Indeed I didn't see it.

There is two things:

  • the mode is not resolved yet when you are doing that check. The mode is resolved by $getMode which will be used there
  • DeprecationErrorHandler::register() is called, SYMFONY_DEPRECATIONS_HELPER is not set yet (but $getMode returns 'weak_vendors' later when a deprecation is fired)

@greg0ire
Copy link
Contributor

Not sure why, but I don't reproduce this bug… what do you reckon should be done ?

  1. add the 2 entries unconditionally?
  2. add them conditionally, but somewhere else?
  3. resolve the mode earlier?

@greg0ire
Copy link
Contributor

To be honest, I don't even understand what you mean by resolved… when I try the function, it does add the two entries in my case. $mode is set as expected.

@greg0ire
Copy link
Contributor

You said you are upgrading symfony/symfony, but the error is thrown in symfony/phpunit-bridge… could it be that you have both package, and some twisted autoloading problem is happening here? If yes, how is it even possible to install both packages together?

EDIT: I see that the symfony package on packagist does not replace symfony/phpunit-bridge. Is that normal?

@theofidry
Copy link
Contributor Author

Not sure why, but I don't reproduce this bug… what do you reckon should be done ?

add the 2 entries unconditionally?
add them conditionally, but somewhere else?
resolve the mode earlier?

Add the 2 entries unconditionally, we don't really care.

To be honest, I don't even understand what you mean by resolved

I mean that the $mode passed during DeprecationErrorHandler::register() is false in my case, but the mode returned by $getMode is weak_vendors.

@theofidry
Copy link
Contributor Author

demo here

@greg0ire
Copy link
Contributor
greg0ire commented Mar 13, 2017

You have both symfony/symfony and symfony/phpunit-bridge… does it make sense? Shouldn't matter though, since you picked master for both packages. I don't reproduce the issue though :

<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="app/autoload.php"
>
    <php>
        <ini name="error_reporting" value="-1" />
        <server name="KERNEL_DIR" value="app/" />
        <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors" />
    </php>

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory>src</directory>
            <exclude>
                <directory>src/*Bundle/Resources</directory>
                <directory>src/*/*Bundle/Resources</directory>
                <d
8000
irectory>src/*/Bundle/*Bundle/Resources</directory>
            </exclude>
        </whitelist>
    </filter>
</phpunit>

EDIT: I do reproduce the issue when using simple-phpunit. I get false too.

@greg0ire
Copy link
Contributor
greg0ire commented Mar 13, 2017

The issue goes away when using a "real" environment variable : SYMFONY_DEPRECATIONS_HELPER=weak_vendors vendor/bin/simple-phpunit.

@theofidry
Copy link
Contributor Author
theofidry commented Mar 13, 2017 via email

@greg0ire
Copy link
Contributor

So… you found a bug in simple-phpunit?

nicolas-grekas added a commit that referenced this issue Mar 14, 2017
This PR was merged into the 3.3-dev branch.

Discussion
----------

Stop relying on the $mode argument

When registering the error handler, simple-phpunit might be used, and in
that case, the bootstrap process will not have environment variables
defined inside phpunit.xml.dist . This means `$mode` might differ when
registering the error handler, and when an error is triggered.
This raises a question: should the $mode argument be removed to avoid
similar errors in the future?

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | yes/no
| Deprecations? | yes/no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes/no
| Fixed tickets | #21980
| License       | MIT
| Doc PR        | n/a

<!--
- Bug fixes must be submitted against the lowest branch where they apply
  (lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->

Commits
-------

0d180d5 Stop relying on the $mode argument
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

5 participants
0