Closed gmazzap closed 3 years ago
Thanks for your feedback 👍 The raised issues and solutions are sounding reasonable for us. If you want you can go ahead and..
a) Update the Package::addModule()
to check if actually services/extension/factories are returned.
b) Introduce a new class constant for registered factories to be more clear.
Maybe we could even extend Package::moduleProgress()
by a thrid argument to contain the id's of the services registered for the current Module. What do you think?
Maybe we could even extend Package::moduleProgress() by a thrid argument to contain the id's of the services registered for the current Module.
It makes sense, but my fear is that when we'll have many packages and a total of hundreds of services the memory footprint will raise too much. Even because each service ID will be a pretty long string.
Maybe we could store services IDs only if debug is true?
Maybe we could store services IDs only if debug is true?
Would make sense, we have access to the Properties and therfor access to Properties::isDebug()
. 👍
Fixed via #11
Describe the bug
Assume this module class:
and assume the following code:
What do you expect the
print_r
outputs?I would have expected nothing, because the module does literally nothing.
But its actual output is:
The two issues
This to me means there are two issues:
ServiceModule
andFactoryModule
will be added as "registered" twice. And that both in theregistered
key and in the*
key.First issue
the reason is that
Package
class callsmoduleProgress()
two times with the same parameters (see here and here).This could be solved in two ways:
MODULE_*
constant, e.g.MODULE_REGISTERED_FACTORIES
moduleProgress()
when registering factories if it was already called when registering regular services.Which do you prefer?
Second issue
this might be misleading for debug.
Imagine a method like:
No matter if
some_condition()
will be true or false,$package->modulesStatus()
will show the module as "registered" so one might think that services where registered, but maybe they were not.To solve this,
moduleProgress()
should be called only if some services / factories / extensions are actually returned.E.g. the current code:
could become:
and the same for
FactoryModule
andExecutableModule
.What's next
If you agree, I'll be happy to send a PR, but I would need to know what to do about the duplicated "registered" entry (de-duplicate or introduce
MODULE_REGISTERED_FACTORIES
)To Reproduce
Execute the code I posted above :)
System
Unrelated.
Additional context
None.