DDC-359: Specified, but empty CLI Options --option= causes Notice undefined offset: 0 [Test case for CliController included] #446

Closed
opened 2026-01-22 12:38:38 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 21, 2010).

Originally assigned to: @jwage on GitHub.

Jira issue originally created by user naderman:

Specified, but empty CLI Options --option= cause a Notice (undefined offset: 0)

This problem also exists in trunk.

What I ran:

naderman@Chaumont:~/projects/doctrine/Doctrine-trunk/tools/sandbox$ ./doctrine Orm:generate-proxies --class-dir=

Expected output:

Doctrine Command Line Interface

No classes to process.

Actual output:

PHP Notice:  Undefined offset: 0 in /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php on line 230
PHP Stack trace:
PHP   1. {main}() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:0
PHP   2. include() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:4
PHP   3. Doctrine\Common\Cli\CliController->run() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine.php:12
PHP   4. Doctrine\Common\Cli\CliController->_processArguments() /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php:127
Doctrine Command Line Interface

Orm:generate-proxies => The supplied configuration uses the annotation metadata driver. The 'class-dir' argument is required for this driver.

I decided to write a patch and a test case for the issue but it turns out there aren't any tests for CliController, so I added some. You can find the result attached. Not sure if you can still call this "unit" test but it looks to me like the best you can currently do and should work quite well.

I also came across another problem in CliController where it incorrectly refers to AbstractPrinter, rather than Printers\AbstractPrinter which is now included in the patch for the original bug.

I'm not sure what your guideline on @author tags is, I added them to the test case and the TaskMock class now, but feel free to remove them if you like. Some of Doctrine's files seem to have them and some not.

Originally created by @doctrinebot on GitHub (Feb 21, 2010). Originally assigned to: @jwage on GitHub. Jira issue originally created by user naderman: Specified, but empty CLI Options --option= cause a Notice (undefined offset: 0) This problem also exists in trunk. What I ran: ``` naderman@Chaumont:~/projects/doctrine/Doctrine-trunk/tools/sandbox$ ./doctrine Orm:generate-proxies --class-dir= ``` Expected output: ``` Doctrine Command Line Interface No classes to process. ``` Actual output: ``` PHP Notice: Undefined offset: 0 in /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php on line 230 PHP Stack trace: PHP 1. {main}() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:0 PHP 2. include() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:4 PHP 3. Doctrine\Common\Cli\CliController->run() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine.php:12 PHP 4. Doctrine\Common\Cli\CliController->_processArguments() /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php:127 Doctrine Command Line Interface Orm:generate-proxies => The supplied configuration uses the annotation metadata driver. The 'class-dir' argument is required for this driver. ``` I decided to write a patch and a test case for the issue but it turns out there aren't any tests for CliController, so I added some. You can find the result attached. Not sure if you can still call this "unit" test but it looks to me like the best you can currently do and should work quite well. I also came across another problem in CliController where it incorrectly refers to AbstractPrinter, rather than Printers\AbstractPrinter which is now included in the patch for the original bug. I'm not sure what your guideline on @author tags is, I added them to the test case and the TaskMock class now, but feel free to remove them if you like. Some of Doctrine's files seem to have them and some not.
admin added the Bug label 2026-01-22 12:38:39 +01:00
admin closed this issue 2026-01-22 12:38:40 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 21, 2010):

@doctrinebot commented on GitHub (Feb 21, 2010): - relates to [DDC-222: Create unit tests for CLI components](http://www.doctrine-project.org/jira/browse/DDC-222)
Author
Owner

@doctrinebot commented on GitHub (Mar 18, 2010):

Comment created by @jwage:

Thanks for the bug report and awesome patch/test case!

@doctrinebot commented on GitHub (Mar 18, 2010): Comment created by @jwage: Thanks for the bug report and awesome patch/test case!
Author
Owner

@doctrinebot commented on GitHub (Mar 18, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 18, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 2 attachments from Jira into https://gist.github.com/27196a8ad68d10e999a5

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 2 attachments from Jira into https://gist.github.com/27196a8ad68d10e999a5 - [10381_empty_option_bug.diff](https://gist.github.com/27196a8ad68d10e999a5#file-10381_empty_option_bug-diff) - [10382_cli_controller_tests.diff](https://gist.github.com/27196a8ad68d10e999a5#file-10382_cli_controller_tests-diff)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#446