@@ -63,14 +63,12 @@ public static function getSubscribedEvents(): array
63
63
*/
64
64
public function onConsoleStart (ConsoleCommandEvent $ event ): void
65
65
{
66
- $ command = $ event ->getCommand ();
66
+ $ commandName = $ event ->getCommand ()?->getName ();
67
67
68
- if (null === $ command || $ this ->isIgnored ($ command )) {
68
+ if (null === $ commandName || $ this ->isIgnored ($ commandName )) {
69
69
return ;
70
70
}
71
71
72
- $ commandName = $ command ->getName ();
73
-
74
72
if ($ this ->inspector ->needTransaction ()) {
75
73
$ this ->inspector ->startTransaction ($ commandName )
76
74
->setType ('command ' )
@@ -90,9 +88,9 @@ public function onConsoleStart(ConsoleCommandEvent $event): void
90
88
*/
91
89
public function onConsoleError (ConsoleErrorEvent $ event ): void
92
90
{
93
- $ command = $ event ->getCommand ();
91
+ $ commandName = $ event ->getCommand ()?->getName ();
94
92
95
- if (null === $ command || $ this ->isIgnored ($ command ) || ! $ this ->inspector ->isRecording ()) {
93
+ if (null === $ commandName || $ this ->isIgnored ($ commandName ) || ! $ this ->inspector ->isRecording ()) {
96
94
return ;
97
95
}
98
96
@@ -101,14 +99,12 @@ public function onConsoleError(ConsoleErrorEvent $event): void
101
99
102
100
public function onConsoleTerminate (ConsoleTerminateEvent $ event ): void
103
101
{
104
- $ command = $ event ->getCommand ();
102
+ $ commandName = $ event ->getCommand ()?->getName ();
105
103
106
- if (null === $ command || $ this ->isIgnored ($ command )) {
104
+ if (null === $ commandName || $ this ->isIgnored ($ commandName )) {
107
105
return ;
108
106
}
109
107
110
- $ commandName = $ command ->getName ();
111
-
112
108
if ($ this ->inspector ->hasTransaction () && $ this ->inspector ->transaction ()->name === $ commandName ) {
113
109
$ this ->inspector ->transaction ()->setResult ($ event ->getExitCode () === 0 ? 'success ' : 'error ' );
114
110
} elseif (\array_key_exists ($ commandName , $ this ->segments )) {
@@ -122,9 +118,9 @@ public function onConsoleTerminate(ConsoleTerminateEvent $event): void
122
118
123
119
public function onConsoleSignal (ConsoleSignalEvent $ event ): void
124
120
{
125
- $ command = $ event ->getCommand ();
121
+ $ commandName = $ event ->getCommand ()?->getName ();
126
122
127
- if (null === $ command || $ this ->isIgnored ($ command )) {
123
+ if (null === $ commandName || $ this ->isIgnored ($ commandName )) {
128
124
return ;
129
125
}
130
126
@@ -133,10 +129,10 @@ public function onConsoleSignal(ConsoleSignalEvent $event): void
133
129
}
134
130
}
135
131
136
- protected function isIgnored (Command $ command ): bool
132
+ protected function isIgnored (string $ command ): bool
137
133
{
138
134
foreach ($ this ->ignoredCommands as $ pattern ) {
139
- if (Filters::matchWithWildcard ($ pattern , $ command-> getName () )) {
135
+ if (Filters::matchWithWildcard ($ pattern , $ command )) {
140
136
return true ;
141
137
}
142
138
}
0 commit comments