Open jc21 opened 9 years ago
How does line 12 in jc21/Api/Migrate.php look like?
12: use jc21\Model\Candidate;
Then you have to change one of your use statements. In the file Migrate.php you could refactor the use of Candidate
. Change to:
use jc21\Model\Candidate as ModelCandidate;
You also need to change all references from Candidate
to ModelCandidate
in the same file.
Would this be a possible solution for you?
Not really. Having unique class names across multiple files kind of defeats the purpose of scopes.
If it's too hard then don't worry :)
But I don't think that the name clashing has anything to do with this command line tool. It's your code in Migrate.php that uses both Api\Candidate and Model\Candidate which forces you to do import X as Y
so that the PHP-interpreter will be able to distinguish between the two Candidates .... However, I'm not sure this is the case so I will do some investigating.
btw, is it possible to get a stack trace?
Oh I may have not been clear. In Migrate.php there is only one reference to Candidate class, which is the one on line 12. The command line tool is failing because it's trying to "use" the Candidate scope but it's already got a Candidate scope from a previous class it has processed.
src/jc21/Api/Candidate.php
<?php
namespace jc21\Api;
class Candidate {
// ...
}
src/jc21/Model/Candidate.php
<?php
namespace jc21\Model;
class Candidate {
// ...
}
src/Console/Migrate.php
<?php
namespace Console;
use jc21\Model\Candidate;
class Migrate {
// ...
}
src/Console/Migrate2.php
<?php
namespace Console;
use jc21\Api\Candidate;
class Migrate2 {
// ...
}
I'll get you a trace tomorrow.
Ok I found another one when I was using it on a larger scale app, specifying the parent src directory to parse.
With namespaced classes like:
And then 2 more classes, each using one of the classes above, the generate throws the following error:
I assume it's because something weird is happening with reflection?
Let me know if this example isn't clear enough.