After creating a simple interface in my new module. I typed in bin/magento setup:di:compile, and I get an error saying that the name is already in use.
Here is my code:
namespace Company\Test\Api;
/*
* @api
*/
interface XyzInterface {
public function getSomething();
}
Then I get this error:
Repositories code generation... 1/7 [====>-----------------------] 14% 2 secs 52.0 MiBPHP
Fatal error: Cannot declare interface Company\Test\Api\XyzInterface, because the name is already in use in .../app/code/Company/Test/Api/XyzInterface.php on line 13
The line is the "interface XyzInterface"
I am not sure what I am doing wrong.
Best Answer
Today I received the same-type error:
where the line 100 is end of the file.
Approximately after 4 hours of debugging I really find the reason: a misprint in the namespace declaration. Till the final moment I didn't believe that it is a typographical error in names declaration, but when I have rewritten all names anew - the mistake has disappeared. This article was very helpful:
Thank you, Alan Storm :)
UPDATE:
Another type of that error is incorrect Namespace declaration with missing part of the namespace, as in this example:
Error:
where the line 109 is end of the file.
In the file
vendor/magento/data-migration-tool/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php
we found the namespace asMigration\Step
when the correct namespace should beMigration\Step\UrlRewrite
because path to this class isMigration/Step/UrlRewrite
. After changing of the namespace toMigration/Step/UrlRewrite
the error is gone.