I'm getting this error when I try to call a function before referencing another class the exists in the same file as the function I'm trying to call.
This error don't occur if the line // new ICMS; is uncommented.
Composer json
"autoload": {
"psr-4": {
"Gbbs\\NfeCalculos\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Gbbs\\NfeCalculos\\Tests\\": "tests"
}
},
Folder structure
nfe-calculos/
├── src/
│ └── ICMS.php
└── tests/
└── ICMSTest.php
ICMS.php
<?php
declare(strict_types=1);
namespace Gbbs\NfeCalculos;
use Exception;
class ICMS
{}
function pICMSFromUFs(string $ufOrigem, string $ufDestino): float
{
throw new Exception('UF inexistente: ' . $ufOrigem . ' - ' . $ufDestino);
}
ICMSTest.php
<?php
declare(strict_types=1);
namespace Gbbs\NfeCalculos\Tests;
use Gbbs\NfeCalculos\ICMS;
use PHPUnit\Framework\TestCase;
use function Gbbs\NfeCalculos\pICMSFromUFs;
class ICMSTest extends TestCase
{
/**
* Test invalid UFs
*/
public function testInvalidUFsInpICMSFromUFs()
{
// new ICMS;
$this->expectException('\Exception');
pICMSFromUFs('1', '1');
}
}