Page MenuHomePhabricator

PHP Fatal error: Cannot use 'Null' as class name as it is reserved
Closed, ResolvedPublic

Description

I'm using PHP 7.0.8-0ubuntu0.16.04.3. When I ran Flow extension, I got this error :

PHP Fatal error:  Cannot use 'Null' as class name as it is reserved in /home/simsu/Other/projects/Web/gci/mw/extensions/Flow/includes/Import/SourceStore/Null.php on line 8
PHP Stack trace:
PHP   1. {main}() /home/simsu/Other/projects/Web/gci/mw/tests/phpunit/phpunit.php:0
PHP   2. require() /home/simsu/Other/projects/Web/gci/mw/tests/phpunit/phpunit.php:163
PHP   3. PHPUnitMaintClass->execute() /home/simsu/Other/projects/Web/gci/mw/maintenance/doMaintenance.php:111
PHP   4. PHPUnit_TextUI_Command::main() /home/simsu/Other/projects/Web/gci/mw/tests/phpunit/phpunit.php:133
PHP   5. PHPUnit_TextUI_Command->run() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/TextUI/Command.php:118
PHP   6. PHPUnit_TextUI_TestRunner->doRun() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/TextUI/Command.php:188
PHP   7. PHPUnit_Framework_TestSuite->run() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:487
PHP   8. PHPUnit_Framework_TestSuite->run() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/Framework/TestSuite.php:728
PHP   9. MediaWikiTestCase->run() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/Framework/TestSuite.php:728
PHP  10. PHPUnit_Framework_TestCase->run() /home/simsu/Other/projects/Web/gci/mw/tests/phpunit/MediaWikiTestCase.php:399
PHP  11. PHPUnit_Framework_TestResult->run() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/Framework/TestCase.php:909
PHP  12. PHPUnit_Framework_TestCase->runBare() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/Framework/TestResult.php:701
PHP  13. PHPUnit_Framework_TestCase->runTest() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/Framework/TestCase.php:954
PHP  14. ReflectionMethod->invokeArgs() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/Framework/TestCase.php:1103
PHP  15. Flow\Tests\Import\LiquidThreadsApi\ConversionStrategyTest->testCanConstruct() /home/simsu/Other/projects/Web/gci/mw/vendor/phpunit/phpunit/src/Framework/TestCase.php:1103
PHP  16. Flow\Tests\Import\LiquidThreadsApi\ConversionStrategyTest->createStrategy() /home/simsu/Other/projects/Web/gci/mw/extensions/Flow/tests/phpunit/Import/LiquidThreadsApi/ConversionStrategyTest.php:31
PHP  17. spl_autoload_call() /home/simsu/Other/projects/Web/gci/mw/extensions/Flow/tests/phpunit/Import/LiquidThreadsApi/ConversionStrategyTest.php:161
PHP  18. AutoLoader::autoload() /home/simsu/Other/projects/Web/gci/mw/extensions/Flow/tests/phpunit/Import/LiquidThreadsApi/ConversionStrategyTest.php:161

As you can see the class name uses Null which is a reserved keyword in PHP. The obvious fix is to rename the class to something else.

Event Timeline

Restricted Application added a project: Collaboration-Team-Triage. · View Herald TranscriptDec 3 2016, 5:32 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Legoktm triaged this task as High priority.Dec 3 2016, 9:44 AM
Legoktm added a project: [DO NOT USE] NewPHP.
Legoktm added a subscriber: Legoktm.
km@km-tp ~/p/v/m/e/Flow> php -l includes/Import/SourceStore/Null.php 
PHP Fatal error:  Cannot use 'Null' as class name as it is reserved in includes/Import/SourceStore/Null.php on line 8
Errors parsing includes/Import/SourceStore/Null.php
km@km-tp ~/p/v/m/e/Flow> php -v
PHP 7.0.13 (cli) (built: Nov  9 2016 07:29:28) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
Reedy moved this task from Unsorted to PHP 7 on the [DO NOT USE] NewPHP board.Dec 3 2016, 11:56 AM
Catrope added a subscriber: Catrope.Dec 6 2016, 6:41 PM

This appears to be specific to PHP 7: https://3v4l.org/giYc4

Catrope claimed this task.Dec 6 2016, 6:41 PM

Change 325608 had a related patch set uploaded (by Catrope):
Rename Flow\Import\SourceStore\Null to NullImportSourceStore

https://gerrit.wikimedia.org/r/325608

Change 325608 merged by jenkins-bot:
Rename Flow\Import\SourceStore\Null to NullImportSourceStore

https://gerrit.wikimedia.org/r/325608

Legoktm closed this task as Resolved.Dec 6 2016, 9:26 PM