<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.4.2</td>
</tr>
</tbody>
</table>

<p dir="auto">Got an exception</p>
<p dir="auto">When I run <code class="notranslate">php my-script.php</code>.<br>
Seems like a bug to me because no matter how I order the arguments the problem still occurs.</p>
<p dir="auto">Expected:</p>
<blockquote>
<p dir="auto">Not enough arguments (missing: "invoice-id, customer").</p>
</blockquote>
<p dir="auto">Actual:</p>
<blockquote>
<p dir="auto">Cannot add a required argument after an optional one.</p>
</blockquote>
<p dir="auto">Caused by <code class="notranslate">Symfony\Component\Console\Input\InputDefinition::addArgument</code>.</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php


namespace Mite\Console;


use Mite\Mite;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class PdfCommand extends Command {
    protected static $defaultName = 'mite:pdf';

    protected function configure() {
        // $this-&gt;addOption( 'month', 'm', InputOption::VALUE_OPTIONAL, 'Month which shall be invoiced', date( 'm' ) );

        $this-&gt;addArgument( 'invoice-id', InputArgument::REQUIRED, 'ID of the invoice' );
        $this-&gt;addArgument( 'customer', InputArgument::REQUIRED, 'Name of the customer as stored in mite' );

        $this-&gt;addOption( 'month', 'm', InputOption::VALUE_OPTIONAL, 'Month which shall be invoiced', date( 'm' ) );
    }

    protected function execute( InputInterface $input, OutputInterface $output ) {

    }
}
"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>


<span class="pl-k">namespace</span> <span class="pl-v">Mite</span>\<span class="pl-v">Console</span>;


<span class="pl-k">use</span> <span class="pl-v">Mite</span>\<span class="pl-v">Mite</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Command</span>\<span class="pl-v">Command</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Input</span>\<span class="pl-v">InputArgument</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Input</span>\<span class="pl-v">InputInterface</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Input</span>\<span class="pl-v">InputOption</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Output</span>\<span class="pl-v">OutputInterface</span>;

<span class="pl-k">class</span> <span class="pl-v">PdfCommand</span> <span class="pl-k">extends</span> <span class="pl-v">Command</span> {
    <span class="pl-k">protected</span> <span class="pl-k">static</span> <span class="pl-c1"><span class="pl-c1">$</span>defaultName</span> = <span class="pl-s">'mite:pdf'</span>;

    <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">configure</span>() {
        <span class="pl-c">// $this-&gt;addOption( 'month', 'm', InputOption::VALUE_OPTIONAL, 'Month which shall be invoiced', date( 'm' ) );</span>

        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">addArgument</span>( <span class="pl-s">'invoice-id'</span>, <span class="pl-v">InputArgument</span>::<span class="pl-c1">REQUIRED</span>, <span class="pl-s">'ID of the invoice'</span> );
        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">addArgument</span>( <span class="pl-s">'customer'</span>, <span class="pl-v">InputArgument</span>::<span class="pl-c1">REQUIRED</span>, <span class="pl-s">'Name of the customer as stored in mite'</span> );

        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">addOption</span>( <span class="pl-s">'month'</span>, <span class="pl-s">'m'</span>, <span class="pl-v">InputOption</span>::<span class="pl-c1">VALUE_OPTIONAL</span>, <span class="pl-s">'Month which shall be invoiced'</span>, date( <span class="pl-s">'m'</span> ) );
    }

    <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">execute</span>( <span class="pl-smi"><span class="pl-smi">InputInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>input</span>, <span class="pl-smi"><span class="pl-smi">OutputInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>output</span> ) {

    }
}</pre></div>
<p dir="auto">app.php</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php

require_once __DIR__ . '/../vendor/autoload.php';

$app = new \Symfony\Component\Console\Application( 'mite-pdf' );

$app-&gt;addCommands( [
	new \Mite\Console\PdfCommand(),
] );

$app-&gt;setDefaultCommand('mite:pdf');

$app-&gt;run();"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>

<span class="pl-k">require_once</span> __DIR__ . <span class="pl-s">'/../vendor/autoload.php'</span>;

<span class="pl-s1"><span class="pl-c1">$</span>app</span> = <span class="pl-k">new</span> \<span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Application</span>( <span class="pl-s">'mite-pdf'</span> );

<span class="pl-s1"><span class="pl-c1">$</span>app</span>-&gt;<span class="pl-en">addCommands</span>( [
	<span class="pl-k">new</span> \<span class="pl-v">Mite</span>\<span class="pl-v">Console</span>\<span class="pl-v">PdfCommand</span>(),
] );

<span class="pl-s1"><span class="pl-c1">$</span>app</span>-&gt;<span class="pl-en">setDefaultCommand</span>(<span class="pl-s">'mite:pdf'</span>);

<span class="pl-s1"><span class="pl-c1">$</span>app</span>-&gt;<span class="pl-en">run</span>();</pre></div>
<p dir="auto"><strong>Symfony version(s) affected</strong>: 4.2.x (but probably all <code class="notranslate">PHP&lt;7.0</code> compatible versions too)</p>
<p dir="auto"><strong>Description</strong><br>
Using the <code class="notranslate">symfony/testpack</code>, <code class="notranslate">symfony/phpunit-bridge</code> and setting the <code class="notranslate">phpunit</code> version on <code class="notranslate">8.0</code>. When creating a test which extends <code class="notranslate">Symfony\Bundle\FrameworkBundle\Test\KernelTestCase</code> it will throw the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PHP Fatal error:  Declaration of Symfony\Bundle\FrameworkBundle\Test\KernelTestCase::tearDown() must be compatible with PHPUnit\Framework\TestCase::tearDown(): void in /projects/phpunit-8/vendor/symfony/framework-bundle/Test/KernelTestCase.php on line 24"><pre class="notranslate"><code class="notranslate">PHP Fatal error:  Declaration of Symfony\Bundle\FrameworkBundle\Test\KernelTestCase::tearDown() must be compatible with PHPUnit\Framework\TestCase::tearDown(): void in /projects/phpunit-8/vendor/symfony/framework-bundle/Test/KernelTestCase.php on line 24
</code></pre></div>
<p dir="auto"><strong>How to reproduce</strong></p>

<p dir="auto"><a href="https://github.com/evertharmeling/symfony-phpunit-8">https://github.com/evertharmeling/symfony-phpunit-8</a></p>
<p dir="auto">Using the 'reproducer' project:</p>
<ul dir="auto">
<li>Run <code class="notranslate">composer install</code> in project root.</li>
<li>Run <code class="notranslate">vendor/bin/simple-phpunit</code> in project root.</li>
</ul>
<p dir="auto"><strong>Possible Solution</strong></p>

<ul dir="auto">
<li>Restricting the <code class="notranslate">phpunit/phpunit</code> version to <code class="notranslate">&lt;8.0</code></li>
</ul>
<p dir="auto"><strong>Additional context</strong></p>

<p dir="auto">Somewhat related <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="80190168" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/14736" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/14736/hovercard" href="https://github.com/symfony/symfony/issues/14736">#14736</a>. Because this could solve for support on <code class="notranslate">phpunit &gt;=8.0</code></p>