55namespace DragonCode \Benchmark ;
66
77use Closure ;
8+ use DragonCode \Benchmark \Contracts \ProgressBar ;
89use DragonCode \Benchmark \Exceptions \NoComparisonsException ;
910use DragonCode \Benchmark \Services \AssertService ;
1011use DragonCode \Benchmark \Services \CallbacksService ;
1415use DragonCode \Benchmark \Services \RunnerService ;
1516use DragonCode \Benchmark \Services \ViewService ;
1617use DragonCode \Benchmark \Transformers \ResultTransformer ;
17- use DragonCode \Benchmark \View \ProgressBarView ;
1818
1919use function abs ;
2020use function count ;
@@ -48,6 +48,7 @@ public static function make(): static
4848 * Sets a callback to be executed before all iterations for each comparison.
4949 *
5050 * @param Closure(int|string $name): mixed $callback
51+ *
5152 * @return $this
5253 */
5354 public function before (Closure $ callback ): static
@@ -61,6 +62,7 @@ public function before(Closure $callback): static
6162 * Sets a callback to be executed before each iteration.
6263 *
6364 * @param Closure(int|string $name, int<1, max> $iteration): mixed $callback
65+ *
6466 * @return $this
6567 */
6668 public function beforeEach (Closure $ callback ): static
@@ -74,6 +76,7 @@ public function beforeEach(Closure $callback): static
7476 * Sets a callback to be executed after all iterations for each comparison.
7577 *
7678 * @param Closure(int|string $name): mixed $callback
79+ *
7780 * @return $this
7881 */
7982 public function after (Closure $ callback ): static
@@ -87,6 +90,7 @@ public function after(Closure $callback): static
8790 * Sets a callback to be executed after each iteration.
8891 *
8992 * @param Closure(int|string $name, int<1, max> $iteration, float $time, float $memory): mixed $callback
93+ *
9094 * @return $this
9195 */
9296 public function afterEach (Closure $ callback ): static
@@ -100,6 +104,7 @@ public function afterEach(Closure $callback): static
100104 * Sets the number of iterations for each comparison.
101105 *
102106 * @param int<1, max> $count
107+ *
103108 * @return $this
104109 */
105110 public function iterations (int $ count ): static
@@ -113,6 +118,7 @@ public function iterations(int $count): static
113118 * Enables deviation calculation and sets the number of runs.
114119 *
115120 * @param int<2, max> $count
121+ *
116122 * @return $this
117123 */
118124 public function deviations (int $ count = 2 ): static
@@ -128,6 +134,7 @@ public function deviations(int $count = 2): static
128134 * Sets the rounding precision for time values.
129135 *
130136 * @param int<0, max>|null $precision The number of decimal places. Null means no rounding.
137+ *
131138 * @return $this
132139 */
133140 public function round (?int $ precision ): static
@@ -144,7 +151,7 @@ public function round(?int $precision): static
144151 */
145152 public function disableProgressBar (): static
146153 {
147- $ this ->view ->progressBar ()-> disable ();
154+ $ this ->view ->disable ();
148155
149156 return $ this ;
150157 }
@@ -153,6 +160,7 @@ public function disableProgressBar(): static
153160 * Registers callback functions for comparison.
154161 *
155162 * @param array|Closure ...$callbacks Callback functions or an array of callback functions for comparison.
163+ *
156164 * @return $this
157165 */
158166 public function compare (array |Closure ...$ callbacks ): static
@@ -234,7 +242,7 @@ protected function performCompare(): void
234242 $ callbacks = $ this ->callbacks ->compare ;
235243
236244 $ this ->withProgress (
237- callback: fn (ProgressBarView $ bar ) => $ this ->chunks ($ callbacks , $ bar ),
245+ callback: fn (ProgressBar $ bar ) => $ this ->chunks ($ callbacks , $ bar ),
238246 total : $ this ->steps ($ callbacks )
239247 );
240248 }
@@ -248,7 +256,7 @@ protected function performDeviation(): void
248256
249257 $ callbacks = $ this ->callbacks ->compare ;
250258
251- $ this ->withProgress (function (ProgressBarView $ bar ) use (&$ results , $ callbacks ) {
259+ $ this ->withProgress (function (ProgressBar $ bar ) use (&$ results , $ callbacks ) {
252260 for ($ i = 1 ; $ i <= $ this ->deviations ; $ i ++) {
253261 $ this ->clear ();
254262
@@ -298,9 +306,9 @@ protected function steps(array $callbacks, int $multiplier = 1): int
298306 * Executes all callback functions with before/after hooks.
299307 *
300308 * @param array $callbacks An array of callback functions.
301- * @param ProgressBarView $progressBar The progress bar.
309+ * @param ProgressBar $progressBar The progress bar.
302310 */
303- protected function chunks (array $ callbacks , ProgressBarView $ progressBar ): void
311+ protected function chunks (array $ callbacks , ProgressBar $ progressBar ): void
304312 {
305313 foreach ($ callbacks as $ name => $ callback ) {
306314 $ this ->callbacks ->performBefore ($ name );
@@ -316,9 +324,9 @@ protected function chunks(array $callbacks, ProgressBarView $progressBar): void
316324 *
317325 * @param mixed $name The callback name.
318326 * @param Closure $callback The callback function to execute.
319- * @param ProgressBarView $progressBar The progress bar.
327+ * @param ProgressBar $progressBar The progress bar.
320328 */
321- protected function run (mixed $ name , Closure $ callback , ProgressBarView $ progressBar ): void
329+ protected function run (mixed $ name , Closure $ callback , ProgressBar $ progressBar ): void
322330 {
323331 for ($ i = 1 ; $ i <= $ this ->iterations ; $ i ++) {
324332 $ result = $ this ->callbacks ->performBeforeEach ($ name , $ i );
@@ -338,6 +346,7 @@ protected function run(mixed $name, Closure $callback, ProgressBarView $progress
338346 *
339347 * @param Closure $callback The callback function to execute.
340348 * @param array $parameters Parameters to pass to the callback.
349+ *
341350 * @return array An array [time in milliseconds, memory in bytes].
342351 */
343352 protected function call (Closure $ callback , array $ parameters = []): array
0 commit comments