Magento – strict_types declaration must be the very first statement in magento 2.3.1

magento2setup-di-compilexml

I have Magento 2.3.1. I am facing below error when I run command setup:di:compile.

Fatal error: strict_types declaration must be the very first
statement in the script in
vendor/magento/module-quote/Model/ChangeQuoteControl.php on line 8

Best Answer

src/Framework/Error/Deprecated.php

<?php declare(strict_types=1);
<?php
/*
 * This file is part of PHPUnit.
 *

src/Framework/Error/Error.php

<?php declare(strict_types=1);
<?php
/*
 * This file is part of PHPUnit.
 *

src/Framework/Error/Notice.php

<?php declare(strict_types=1);
<?php
/*
 * This file is part of PHPUnit.
 *

src/Framework/Error/Warning.php

<?php declare(strict_types=1);
<?php
/*
 * This file is part of PHPUnit.
 *

For more details refer: https://github.com/sebastianbergmann/phpunit/issues/2791

https://github.com/sebastianbergmann/phpunit/commit/70ccf0370f0b99c22819d3730167a7d448911b9e