Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace Doctrine\Common;
6
 
7
/**
8
 * EventArgs is the base class for classes containing event data.
9
 *
10
 * This class contains no event data. It is used by events that do not pass state
11
 * information to an event handler when an event is raised. The single empty EventArgs
12
 * instance can be obtained through {@link getEmptyInstance}.
13
 */
14
class EventArgs
15
{
16
    /**
17
     * Single instance of EventArgs.
18
     */
19
    private static EventArgs|null $emptyEventArgsInstance = null;
20
 
21
    /**
22
     * Gets the single, empty and immutable EventArgs instance.
23
     *
24
     * This instance will be used when events are dispatched without any parameter,
25
     * like this: EventManager::dispatchEvent('eventname');
26
     *
27
     * The benefit from this is that only one empty instance is instantiated and shared
28
     * (otherwise there would be instances for every dispatched in the abovementioned form).
29
     *
30
     * @link https://msdn.microsoft.com/en-us/library/system.eventargs.aspx
31
     * @see EventManager::dispatchEvent
32
     */
33
    public static function getEmptyInstance(): EventArgs
34
    {
35
        return self::$emptyEventArgsInstance ??= new EventArgs();
36
    }
37
}