Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ByPassfinalsStartedSubscriber
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 notify
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * This file is part of fast-forward/dev-tools.
7 *
8 * This source file is subject to the license bundled
9 * with this source code in the file LICENSE.
10 *
11 * @copyright Copyright (c) 2026 Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
12 * @license   https://opensource.org/licenses/MIT MIT License
13 *
14 * @see       https://github.com/php-fast-forward/dev-tools
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\DevTools\PhpUnit\Event\TestSuite;
20
21use DG\BypassFinals;
22use PHPUnit\Event\TestSuite\Started;
23use PHPUnit\Event\TestSuite\StartedSubscriber;
24
25/**
26 * Enables BypassFinals when the PHPUnit test suite starts.
27 *
28 * This subscriber MUST activate BypassFinals as soon as the test suite start
29 * event is emitted so that final classes, final methods, and readonly
30 * protections can be bypassed where the test environment requires that
31 * behavior.
32 *
33 * This subscriber SHALL perform only the activation side effect associated
34 * with the test suite start event.
35 */
36 class ByPassfinalsStartedSubscriber implements StartedSubscriber
37{
38    /**
39     * Handles the PHPUnit test suite started event.
40     *
41     * This method MUST enable BypassFinals for the current test execution
42     * context when the test suite starts.
43     *
44     * @param Started $event the emitted test suite started event
45     *
46     * @return void
47     */
48    public function notify(Started $event): void
49    {
50        BypassFinals::enable();
51    }
52}