Closed heregiam closed 7 years ago
Well the namespaces for sure need to be updated after everything has been moved to one repository due to multi-repo, while also keeping the PSR-4 namespace in-tact.
With PSR-4 the folder structure and namespaces should really match so I believe we should be using RMiller\BehatSpec\Extension\<EXTENSIONNAME>
namespaces so they are compatible with folder structure.
Additionally, there is a problem with PSR-4
autoload setting in composer.json as some parts over-ride each-others and that will slow down the loading.
Just to explain the current problem with the namespaces:
copmoser.json
we set PSR-4
for RMiller\BehatSpec
to point to different directories. This makes composer scan all of these directories when looking for files. Multiple declarations of same namespace also negate the purpose of using PSR-4 (which defines that namespace and directory should match).RMiller\BehatSpec
namespace in all the sub-extensions. When extensions were copied, the class files still use old namespaces (i.e. RMiller\PhpSpecExtension
).The #26 PR standardizes the namespaces to match the dir structure (like PSR-4
defined). However, this results in longer namespaces and there are ways to clean them up a bit:
What can be done to clean up the namespaces further is:
Extension
directory\namespace (you would have to adjust subtreesplit directories accordingly). I can adjust PR #25 to match this. So the new namespaces would be in format of RMiller\BehatSpec\<EXTENSIONNAME>\...
(instead of RMiller\BehatSpec\Extension\<EXTENSIONNAME>\...
).BehatSpec\
vendor if there would be a desire to move extensions under a BehatSpec
organization namespace. Combined with the above solution we could then have BehatSpec\<ExtensionName>
namespace (instead of RMiller\BehatSpec\Extension\<ExtensionName>\
).I would consider applying at least Solution 1. to this. The namespaces of the extensions need to be adjusted anyway to match the base RMiller\BehatSpec
, so we could aswell remove the extra \Extension
. Unless there is a plan to have non-extension stuff provided by this module, I believe this folder might not be necessary.
Regarding the move to just BehatSpec
, I think it would require a bit more changes on how the projects are setup and perhaps is a bit too much to do at this point after we just had subtreesplit migration. However, it's an option that might be worth considering so I mentioned it.
I can quickly adjust #25 so we can have this fixed the way you like, please let me know.
The class definitions for
behat.yml
andphpspec.yml
in the Configuration section ofREADME.md
both result in class not found errors running behat and phpspec.I believe instead of:
RMiller\BehatSpec\BehatExtension
andRMiller\BehatSpec\PhpSpecExtension
they should be:RMiller\BehatSpecExtension\BehatExtension
andRMiller\BehatSpecExtension\PhpSpecExtension