inpsyde / wp-app-container

DI Container and related tools to be used at website level.
GNU General Public License v2.0
38 stars 2 forks source link

Expose more information for App::debugInfo #1

Closed Chrico closed 4 years ago

Chrico commented 4 years ago

I've enhanced the App::debugInfo to provide more information about the Container::context and Container::config.

Also i've removed the string casting on AppLogger::dump on ProviderStatus. This will still work when just printing the ProviderStatus due the __toString()-method. But also now allows to access more in detail via ProviderStatus::status and ProviderStatus::appStatuses the actual stored values.


The pull contains following:

AppLogger // dump method does not cast string on ProviderStatus. ProviderStatus // add new methods status and appStatuses to expose more information to outside. App::debugInfo new contains context and config from container.

gmazzap commented 4 years ago

The problem with exposing inner objects is that (besides breaking encapsulation) consumers can access ProviderStatus objects from the debug info and act on them, breaking things in non-predictable ways: debug info method becomes at any effect a getter of encapsulated objects.

This was also the reason why there was a cast to string: anyone obtaining a string can't do anything on that besides printing, obtaing objects consumers can call methods on those object breaking expectations.

The same apply for exposing Context.

Regarding SiteConfig it will likely contain secrets, and adding secrets to method designed for debug does not look a good idea to me.

If we need more debug info, we could do that without breaking encapsulation and risking of exposing secrets:

gmazzap commented 4 years ago

@Chrico I implemented the things I described in febd9ec (I also needed to fix tests). Please review.

Then I also pushed 88522b0 to upgrade and fix PHPCS and fix Psalm. I also added testing.yml to enable GitHub actions.

Chrico commented 4 years ago

Thanks! Originally i wanted start working on that today..but seem's i now only need to review ;)