Page MenuHomePhabricator

phpcs doesn't work with mediawiki/vendor repo, while phpunit fails with composer-managed vendor.
Open, Needs TriagePublic


If I use the mediwiki/vendor repo to supply dependencies, I get the following:

$ phpcs 
PHP Fatal error:  Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff "vendor/mediawiki/mediawiki-codesniffer/MediaWiki" does not exist' in /usr/share/php/PHP/CodeSniffer.php:1092
Stack trace:
#0 /usr/share/php/PHP/CodeSniffer.php(733): PHP_CodeSniffer->_expandRulesetReference(Object(SimpleXMLElement), '/usr/local/src/...', 0)
#1 /usr/share/php/PHP/CodeSniffer.php(551): PHP_CodeSniffer->processRuleset('/usr/local/src/...')
#2 /usr/share/php/PHP/CodeSniffer/CLI.php(818): PHP_CodeSniffer->initStandard(Array, Array)
#3 /usr/share/php/PHP/CodeSniffer/CLI.php(95): PHP_CodeSniffer_CLI->process()
#4 /usr/bin/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()
#5 {main}
  thrown in /usr/share/php/PHP/CodeSniffer.php on line 1092

Apparently mediawiki/vendor doesn't include whatever dependencies are needed to run phpcs. Now that phpcs is voting, it's a pain not to be able to run it locally.

If instead I use composer to install dependencies, phpcs works but phpunit fails some tests! For example:

$ php tests/phpunit/phpunit.php --configuration tests/phpunit/suite.xml tests/phpunit/includes/exception/ErrorPageErrorTest.php 
PHPUnit already present
PHPUnit 3.7.37 by Sebastian Bergmann.

Configuration read from /usr/local/src/MediaWiki/core/tests/phpunit/suite.xml


Time: 124 ms, Memory: 13.25Mb

There were 2 errors:

1) ErrorPageErrorTest::testConstruction
Erroneous data format for unserializing 'Mock_Message_e3de1385'


2) ErrorPageErrorTest::testReport
Erroneous data format for unserializing 'Mock_Message_e3de1385'


Tests: 3, Assertions: 1, Errors: 2.

With composer-managed vendor, it uses the ancient version of phpunit we have composer install. Which apparently has the issue described in, phpunit-mock-objects 1.2.3 doesn't work with PHP 5.6.

Event Timeline

Anomie raised the priority of this task from to Needs Triage.
Anomie updated the task description. (Show Details)
Anomie added projects: Composer, MediaWiki-Vendor.
Anomie added a subscriber: Anomie.

Yet another reason to find a fix for T112895: Support installing composer require-dev packages together with mediawiki/vendor so we can bump that PHPUnit version in core and run something modern.

$ phpcs

This isn't from mediawiki/vendor, it's probably from a system package.

$ phpcs

This isn't from mediawiki/vendor, it's probably from a system package.

So? It works with composer-managed dependencies, and doesn't with mediawiki/vendor.

What's your preferred way to run phpcs tests when using mediawiki/vendor, instead of having to submit it and then read the Jenkins/Zuul output?

I propose to Decline this; it's trivial to run composer update --dev and composer test locally.