bvanhoekelen/performance

Improve usability by replacing private with protected

Closed this issue · 4 comments

dorxy commented

I'm trying to use this library to run some performance tests of our own by integrating it in a symfony console.

There is however no pretty way to create (and set) your own presenter, or even extend one of the current ones, as almost everything required to do so is either a private function or property.

I think this is also one of the reasons this library is forked a lot, even though there are some configuration options, if you for example only wish to not clear the console screen in the presenter, you have to pretty much fork the entire library otherwise it cannot be done.

My suggestion:

  • Do a global replace of private to protected
  • Do a global replace of self:: to static::

This already resolves a lot of issues with making minor adjustments to the library and extending on it without having to fork.

Hi,

I am trying to understand the reason why i have to replace self:: with static::.
Can you show an example where you experiencing problems with this library? Or can you create a fork with the adjustments you make to resolves a lot of issues?

In the case of 'not clear the console screen', it's possible to add this to the config. Pleas make a new issue for this.

Thanks for your feedback!

dorxy commented

Hi! :)

Thanks for taking this on so quickly, I already have 2.4.0 in use and the clear screen option works perfectly!

The use of static vs self is partially explained here: https://stackoverflow.com/questions/11710099/what-is-the-difference-between-selfbar-and-staticbar-in-php

So that also has to do with making something extendible while still being able to use the original classes code.

One thing I noticed most while trying to extend (besides all private functions/properties) is that there is no way to create your own presenter, even though there is an abstract class. It would be convenient to for example set the class of the presenter by using MyPresenterClass::class within the config instead of using the web and console constants.

I also notice a lot of docblocks start with /* instead of /** and most class properties have no var type docblock which prevents some autocompletion, which can be very convenient when extending.

Verder hele coole library! :) Als ik nog meer dingen tegenkom tijdens ons gebruik ervan zal ik nog wel issues aanmaken, wellicht als ik in mijn vrije tijd een plekje kan maken dat ik een PR kan doen :)

Hi,

I create a new branch feat/issues-12 with changes you prefer. The purpose of this branch is te test the impact. The branch is also accessible to packagist.

Het was een druk weekend dus kon ik dit wat later maken. Ik ben benieuwd of dit je verder helpt.

See version v2.5.0