Complex classes like SMTP often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SMTP, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
31 | class SMTP |
||
32 | { |
||
33 | /** |
||
34 | * The PHPMailer SMTP version number. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | const VERSION = '6.2.0'; |
||
39 | |||
40 | /** |
||
41 | * SMTP line break constant. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | const LE = "\r\n"; |
||
46 | |||
47 | /** |
||
48 | * The SMTP port to use if one is not specified. |
||
49 | * |
||
50 | * @var int |
||
51 | */ |
||
52 | const DEFAULT_PORT = 25; |
||
53 | |||
54 | /** |
||
55 | * The maximum line length allowed by RFC 5321 section 4.5.3.1.6, |
||
56 | * *excluding* a trailing CRLF break. |
||
57 | * |
||
58 | * @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.6 |
||
59 | * |
||
60 | * @var int |
||
61 | */ |
||
62 | const MAX_LINE_LENGTH = 998; |
||
63 | |||
64 | /** |
||
65 | * The maximum line length allowed for replies in RFC 5321 section 4.5.3.1.5, |
||
66 | * *including* a trailing CRLF line break. |
||
67 | * |
||
68 | * @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.5 |
||
69 | * |
||
70 | * @var int |
||
71 | */ |
||
72 | const MAX_REPLY_LENGTH = 512; |
||
73 | |||
74 | /** |
||
75 | * Debug level for no output. |
||
76 | * |
||
77 | * @var int |
||
78 | */ |
||
79 | const DEBUG_OFF = 0; |
||
80 | |||
81 | /** |
||
82 | * Debug level to show client -> server messages. |
||
83 | * |
||
84 | * @var int |
||
85 | */ |
||
86 | const DEBUG_CLIENT = 1; |
||
87 | |||
88 | /** |
||
89 | * Debug level to show client -> server and server -> client messages. |
||
90 | * |
||
91 | * @var int |
||
92 | */ |
||
93 | const DEBUG_SERVER = 2; |
||
94 | |||
95 | /** |
||
96 | * Debug level to show connection status, client -> server and server -> client messages. |
||
97 | * |
||
98 | * @var int |
||
99 | */ |
||
100 | const DEBUG_CONNECTION = 3; |
||
101 | |||
102 | /** |
||
103 | * Debug level to show all messages. |
||
104 | * |
||
105 | * @var int |
||
106 | */ |
||
107 | const DEBUG_LOWLEVEL = 4; |
||
108 | |||
109 | /** |
||
110 | * Debug output level. |
||
111 | * Options: |
||
112 | * * self::DEBUG_OFF (`0`) No debug output, default |
||
113 | * * self::DEBUG_CLIENT (`1`) Client commands |
||
114 | * * self::DEBUG_SERVER (`2`) Client commands and server responses |
||
115 | * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status |
||
116 | * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages. |
||
117 | * |
||
118 | * @var int |
||
119 | */ |
||
120 | public $do_debug = self::DEBUG_OFF; |
||
121 | |||
122 | /** |
||
123 | * How to handle debug output. |
||
124 | * Options: |
||
125 | * * `echo` Output plain-text as-is, appropriate for CLI |
||
126 | * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output |
||
127 | * * `error_log` Output to error log as configured in php.ini |
||
128 | * Alternatively, you can provide a callable expecting two params: a message string and the debug level: |
||
129 | * |
||
130 | * ```php |
||
131 | * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; |
||
132 | * ``` |
||
133 | * |
||
134 | * Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only `debug` |
||
135 | * level output is used: |
||
136 | * |
||
137 | * ```php |
||
138 | * $mail->Debugoutput = new myPsr3Logger; |
||
139 | * ``` |
||
140 | * |
||
141 | * @var string|callable|\Psr\Log\LoggerInterface |
||
142 | */ |
||
143 | public $Debugoutput = 'echo'; |
||
144 | |||
145 | /** |
||
146 | * Whether to use VERP. |
||
147 | * |
||
148 | * @see http://en.wikipedia.org/wiki/Variable_envelope_return_path |
||
149 | * @see http://www.postfix.org/VERP_README.html Info on VERP |
||
150 | * |
||
151 | * @var bool |
||
152 | */ |
||
153 | public $do_verp = false; |
||
154 | |||
155 | /** |
||
156 | * The timeout value for connection, in seconds. |
||
157 | * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2. |
||
158 | * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure. |
||
159 | * |
||
160 | * @see http://tools.ietf.org/html/rfc2821#section-4.5.3.2 |
||
161 | * |
||
162 | * @var int |
||
163 | */ |
||
164 | public $Timeout = 300; |
||
165 | |||
166 | /** |
||
167 | * How long to wait for commands to complete, in seconds. |
||
168 | * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2. |
||
169 | * |
||
170 | * @var int |
||
171 | */ |
||
172 | public $Timelimit = 300; |
||
173 | |||
174 | /** |
||
175 | * Patterns to extract an SMTP transaction id from reply to a DATA command. |
||
176 | * The first capture group in each regex will be used as the ID. |
||
177 | * MS ESMTP returns the message ID, which may not be correct for internal tracking. |
||
178 | * |
||
179 | * @var string[] |
||
180 | */ |
||
181 | protected $smtp_transaction_id_patterns = [ |
||
182 | 'exim' => '/[\d]{3} OK id=(.*)/', |
||
183 | 'sendmail' => '/[\d]{3} 2.0.0 (.*) Message/', |
||
184 | 'postfix' => '/[\d]{3} 2.0.0 Ok: queued as (.*)/', |
||
185 | 'Microsoft_ESMTP' => '/[0-9]{3} 2.[\d].0 (.*)@(?:.*) Queued mail for delivery/', |
||
186 | 'Amazon_SES' => '/[\d]{3} Ok (.*)/', |
||
187 | 'SendGrid' => '/[\d]{3} Ok: queued as (.*)/', |
||
188 | 'CampaignMonitor' => '/[\d]{3} 2.0.0 OK:([a-zA-Z\d]{48})/', |
||
189 | ]; |
||
190 | |||
191 | /** |
||
192 | * The last transaction ID issued in response to a DATA command, |
||
193 | * if one was detected. |
||
194 | * |
||
195 | * @var string|bool|null |
||
196 | */ |
||
197 | protected $last_smtp_transaction_id; |
||
198 | |||
199 | /** |
||
200 | * The socket for the server connection. |
||
201 | * |
||
202 | * @var ?resource |
||
203 | */ |
||
204 | protected $smtp_conn; |
||
205 | |||
206 | /** |
||
207 | * Error information, if any, for the last SMTP command. |
||
208 | * |
||
209 | * @var array |
||
210 | */ |
||
211 | protected $error = [ |
||
212 | 'error' => '', |
||
213 | 'detail' => '', |
||
214 | 'smtp_code' => '', |
||
215 | 'smtp_code_ex' => '', |
||
216 | ]; |
||
217 | |||
218 | /** |
||
219 | * The reply the server sent to us for HELO. |
||
220 | * If null, no HELO string has yet been received. |
||
221 | * |
||
222 | * @var string|null |
||
223 | */ |
||
224 | protected $helo_rply; |
||
225 | |||
226 | /** |
||
227 | * The set of SMTP extensions sent in reply to EHLO command. |
||
228 | * Indexes of the array are extension names. |
||
229 | * Value at index 'HELO' or 'EHLO' (according to command that was sent) |
||
230 | * represents the server name. In case of HELO it is the only element of the array. |
||
231 | * Other values can be boolean TRUE or an array containing extension options. |
||
232 | * If null, no HELO/EHLO string has yet been received. |
||
233 | * |
||
234 | * @var array|null |
||
235 | */ |
||
236 | protected $server_caps; |
||
237 | |||
238 | /** |
||
239 | * The most recent reply received from the server. |
||
240 | * |
||
241 | * @var string |
||
242 | */ |
||
243 | protected $last_reply = ''; |
||
244 | |||
245 | /** |
||
246 | * Output debugging info via a user-selected method. |
||
247 | * |
||
248 | * @param string $str Debug string to output |
||
249 | * @param int $level The debug level of this message; see DEBUG_* constants |
||
250 | * |
||
251 | * @see SMTP::$Debugoutput |
||
252 | * @see SMTP::$do_debug |
||
253 | */ |
||
254 | protected function edebug($str, $level = 0) |
||
302 | |||
303 | /** |
||
304 | * Connect to an SMTP server. |
||
305 | * |
||
306 | * @param string $host SMTP server IP or host name |
||
307 | * @param int $port The port number to connect to |
||
308 | * @param int $timeout How long to wait for the connection to open |
||
309 | * @param array $options An array of options for stream_context_create() |
||
310 | * |
||
311 | * @return bool |
||
312 | */ |
||
313 | public function connect($host, $port = null, $timeout = 30, $options = []) |
||
361 | |||
362 | /** |
||
363 | * Create connection to the SMTP server. |
||
364 | * |
||
365 | * @param string $host SMTP server IP or host name |
||
366 | * @param int $port The port number to connect to |
||
367 | * @param int $timeout How long to wait for the connection to open |
||
368 | * @param array $options An array of options for stream_context_create() |
||
369 | * |
||
370 | * @return false|resource |
||
371 | */ |
||
372 | protected function getSMTPConnection($host, $port = null, $timeout = 30, $options = []) |
||
442 | |||
443 | /** |
||
444 | * Initiate a TLS (encrypted) session. |
||
445 | * |
||
446 | * @return bool |
||
447 | */ |
||
448 | public function startTLS() |
||
475 | |||
476 | /** |
||
477 | * Perform SMTP authentication. |
||
478 | * Must be run after hello(). |
||
479 | * |
||
480 | * @see hello() |
||
481 | * |
||
482 | * @param string $username The user name |
||
483 | * @param string $password The password |
||
484 | * @param string $authtype The auth type (CRAM-MD5, PLAIN, LOGIN, XOAUTH2) |
||
485 | * @param OAuth $OAuth An optional OAuth instance for XOAUTH2 authentication |
||
486 | * |
||
487 | * @return bool True if successfully authenticated |
||
488 | */ |
||
489 | public function authenticate( |
||
610 | |||
611 | /** |
||
612 | * Calculate an MD5 HMAC hash. |
||
613 | * Works like hash_hmac('md5', $data, $key) |
||
614 | * in case that function is not available. |
||
615 | * |
||
616 | * @param string $data The data to hash |
||
617 | * @param string $key The key to hash with |
||
618 | * |
||
619 | * @return string |
||
620 | */ |
||
621 | protected function hmac($data, $key) |
||
647 | |||
648 | /** |
||
649 | * Check connection state. |
||
650 | * |
||
651 | * @return bool True if connected |
||
652 | */ |
||
653 | public function connected() |
||
673 | |||
674 | /** |
||
675 | * Close the socket and clean up the state of the class. |
||
676 | * Don't use this function without first trying to use QUIT. |
||
677 | * |
||
678 | * @see quit() |
||
679 | */ |
||
680 | public function close() |
||
692 | |||
693 | /** |
||
694 | * Send an SMTP DATA command. |
||
695 | * Issues a data command and sends the msg_data to the server, |
||
696 | * finializing the mail transaction. $msg_data is the message |
||
697 | * that is to be send with the headers. Each header needs to be |
||
698 | * on a single line followed by a <CRLF> with the message headers |
||
699 | * and the message body being separated by an additional <CRLF>. |
||
700 | * Implements RFC 821: DATA <CRLF>. |
||
701 | * |
||
702 | * @param string $msg_data Message data to send |
||
703 | * |
||
704 | * @return bool |
||
705 | */ |
||
706 | public function data($msg_data) |
||
786 | |||
787 | /** |
||
788 | * Send an SMTP HELO or EHLO command. |
||
789 | * Used to identify the sending server to the receiving server. |
||
790 | * This makes sure that client and server are in a known state. |
||
791 | * Implements RFC 821: HELO <SP> <domain> <CRLF> |
||
792 | * and RFC 2821 EHLO. |
||
793 | * |
||
794 | * @param string $host The host name or IP to connect to |
||
795 | * |
||
796 | * @return bool |
||
797 | */ |
||
798 | public function hello($host = '') |
||
803 | |||
804 | /** |
||
805 | * Send an SMTP HELO or EHLO command. |
||
806 | * Low-level implementation used by hello(). |
||
807 | * |
||
808 | * @param string $hello The HELO string |
||
809 | * @param string $host The hostname to say we are |
||
810 | * |
||
811 | * @return bool |
||
812 | * |
||
813 | * @see hello() |
||
814 | */ |
||
815 | protected function sendHello($hello, $host) |
||
827 | |||
828 | /** |
||
829 | * Parse a reply to HELO/EHLO command to discover server extensions. |
||
830 | * In case of HELO, the only parameter that can be discovered is a server name. |
||
831 | * |
||
832 | * @param string $type `HELO` or `EHLO` |
||
833 | */ |
||
834 | protected function parseHelloFields($type) |
||
869 | |||
870 | /** |
||
871 | * Send an SMTP MAIL command. |
||
872 | * Starts a mail transaction from the email address specified in |
||
873 | * $from. Returns true if successful or false otherwise. If True |
||
874 | * the mail transaction is started and then one or more recipient |
||
875 | * commands may be called followed by a data command. |
||
876 | * Implements RFC 821: MAIL <SP> FROM:<reverse-path> <CRLF>. |
||
877 | * |
||
878 | * @param string $from Source address of this message |
||
879 | * |
||
880 | * @return bool |
||
881 | */ |
||
882 | public function mail($from) |
||
892 | |||
893 | /** |
||
894 | * Send an SMTP QUIT command. |
||
895 | * Closes the socket if there is no error or the $close_on_error argument is true. |
||
896 | * Implements from RFC 821: QUIT <CRLF>. |
||
897 | * |
||
898 | * @param bool $close_on_error Should the connection close if an error occurs? |
||
899 | * |
||
900 | * @return bool |
||
901 | */ |
||
902 | public function quit($close_on_error = true) |
||
913 | |||
914 | /** |
||
915 | * Send an SMTP RCPT command. |
||
916 | * Sets the TO argument to $toaddr. |
||
917 | * Returns true if the recipient was accepted false if it was rejected. |
||
918 | * Implements from RFC 821: RCPT <SP> TO:<forward-path> <CRLF>. |
||
919 | * |
||
920 | * @param string $address The address the message is being sent to |
||
921 | * @param string $dsn Comma separated list of DSN notifications. NEVER, SUCCESS, FAILURE |
||
922 | * or DELAY. If you specify NEVER all other notifications are ignored. |
||
923 | * |
||
924 | * @return bool |
||
925 | */ |
||
926 | public function recipient($address, $dsn = '') |
||
953 | |||
954 | /** |
||
955 | * Send an SMTP RSET command. |
||
956 | * Abort any transaction that is currently in progress. |
||
957 | * Implements RFC 821: RSET <CRLF>. |
||
958 | * |
||
959 | * @return bool True on success |
||
960 | */ |
||
961 | public function reset() |
||
965 | |||
966 | /** |
||
967 | * Send a command to an SMTP server and check its return code. |
||
968 | * |
||
969 | * @param string $command The command name - not sent to the server |
||
970 | * @param string $commandstring The actual command to send |
||
971 | * @param int|array $expect One or more expected integer success codes |
||
972 | * |
||
973 | * @return bool True on success |
||
974 | */ |
||
975 | protected function sendCommand($command, $commandstring, $expect) |
||
1031 | |||
1032 | /** |
||
1033 | * Send an SMTP SAML command. |
||
1034 | * Starts a mail transaction from the email address specified in $from. |
||
1035 | * Returns true if successful or false otherwise. If True |
||
1036 | * the mail transaction is started and then one or more recipient |
||
1037 | * commands may be called followed by a data command. This command |
||
1038 | * will send the message to the users terminal if they are logged |
||
1039 | * in and send them an email. |
||
1040 | * Implements RFC 821: SAML <SP> FROM:<reverse-path> <CRLF>. |
||
1041 | * |
||
1042 | * @param string $from The address the message is from |
||
1043 | * |
||
1044 | * @return bool |
||
1045 | */ |
||
1046 | public function sendAndMail($from) |
||
1050 | |||
1051 | /** |
||
1052 | * Send an SMTP VRFY command. |
||
1053 | * |
||
1054 | * @param string $name The name to verify |
||
1055 | * |
||
1056 | * @return bool |
||
1057 | */ |
||
1058 | public function verify($name) |
||
1062 | |||
1063 | /** |
||
1064 | * Send an SMTP NOOP command. |
||
1065 | * Used to keep keep-alives alive, doesn't actually do anything. |
||
1066 | * |
||
1067 | * @return bool |
||
1068 | */ |
||
1069 | public function noop() |
||
1073 | |||
1074 | /** |
||
1075 | * Send an SMTP TURN command. |
||
1076 | * This is an optional command for SMTP that this class does not support. |
||
1077 | * This method is here to make the RFC821 Definition complete for this class |
||
1078 | * and _may_ be implemented in future. |
||
1079 | * Implements from RFC 821: TURN <CRLF>. |
||
1080 | * |
||
1081 | * @return bool |
||
1082 | */ |
||
1083 | public function turn() |
||
1090 | |||
1091 | /** |
||
1092 | * Send raw data to the server. |
||
1093 | * |
||
1094 | * @param string $data The data to send |
||
1095 | * @param string $command Optionally, the command this is part of, used only for controlling debug output |
||
1096 | * |
||
1097 | * @return int|bool The number of bytes sent to the server or false on error |
||
1098 | */ |
||
1099 | public function client_send($data, $command = '') |
||
1117 | |||
1118 | /** |
||
1119 | * Get the latest error. |
||
1120 | * |
||
1121 | * @return array |
||
1122 | */ |
||
1123 | public function getError() |
||
1127 | |||
1128 | /** |
||
1129 | * Get SMTP extensions available on the server. |
||
1130 | * |
||
1131 | * @return array|null |
||
1132 | */ |
||
1133 | public function getServerExtList() |
||
1137 | |||
1138 | /** |
||
1139 | * Get metadata about the SMTP server from its HELO/EHLO response. |
||
1140 | * The method works in three ways, dependent on argument value and current state: |
||
1141 | * 1. HELO/EHLO has not been sent - returns null and populates $this->error. |
||
1142 | * 2. HELO has been sent - |
||
1143 | * $name == 'HELO': returns server name |
||
1144 | * $name == 'EHLO': returns boolean false |
||
1145 | * $name == any other string: returns null and populates $this->error |
||
1146 | * 3. EHLO has been sent - |
||
1147 | * $name == 'HELO'|'EHLO': returns the server name |
||
1148 | * $name == any other string: if extension $name exists, returns True |
||
1149 | * or its options (e.g. AUTH mechanisms supported). Otherwise returns False. |
||
1150 | * |
||
1151 | * @param string $name Name of SMTP extension or 'HELO'|'EHLO' |
||
1152 | * |
||
1153 | * @return string|bool|null |
||
1154 | */ |
||
1155 | public function getServerExt($name) |
||
1177 | |||
1178 | /** |
||
1179 | * Get the last reply from the server. |
||
1180 | * |
||
1181 | * @return string |
||
1182 | */ |
||
1183 | public function getLastReply() |
||
1187 | |||
1188 | /** |
||
1189 | * Read the SMTP server's response. |
||
1190 | * Either before eof or socket timeout occurs on the operation. |
||
1191 | * With SMTP we can tell if we have more lines to read if the |
||
1192 | * 4th character is '-' symbol. If it is a space then we don't |
||
1193 | * need to read anything else. |
||
1194 | * |
||
1195 | * @return string |
||
1196 | */ |
||
1197 | protected function get_lines() |
||
1280 | |||
1281 | /** |
||
1282 | * Enable or disable VERP address generation. |
||
1283 | * |
||
1284 | * @param bool $enabled |
||
1285 | */ |
||
1286 | public function setVerp($enabled = false) |
||
1290 | |||
1291 | /** |
||
1292 | * Get VERP address generation mode. |
||
1293 | * |
||
1294 | * @return bool |
||
1295 | */ |
||
1296 | public function getVerp() |
||
1300 | |||
1301 | /** |
||
1302 | * Set error messages and codes. |
||
1303 | * |
||
1304 | * @param string $message The error message |
||
1305 | * @param string $detail Further detail on the error |
||
1306 | * @param string $smtp_code An associated SMTP error code |
||
1307 | * @param string $smtp_code_ex Extended SMTP code |
||
1308 | */ |
||
1309 | protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '') |
||
1318 | |||
1319 | /** |
||
1320 | * Set debug output method. |
||
1321 | * |
||
1322 | * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it |
||
1323 | */ |
||
1324 | public function setDebugOutput($method = 'echo') |
||
1328 | |||
1329 | /** |
||
1330 | * Get debug output method. |
||
1331 | * |
||
1332 | * @return string |
||
1333 | */ |
||
1334 | public function getDebugOutput() |
||
1338 | |||
1339 | /** |
||
1340 | * Set debug output level. |
||
1341 | * |
||
1342 | * @param int $level |
||
1343 | */ |
||
1344 | public function setDebugLevel($level = 0) |
||
1348 | |||
1349 | /** |
||
1350 | * Get debug output level. |
||
1351 | * |
||
1352 | * @return int |
||
1353 | */ |
||
1354 | public function getDebugLevel() |
||
1358 | |||
1359 | /** |
||
1360 | * Set SMTP timeout. |
||
1361 | * |
||
1362 | * @param int $timeout The timeout duration in seconds |
||
1363 | */ |
||
1364 | public function setTimeout($timeout = 0) |
||
1368 | |||
1369 | /** |
||
1370 | * Get SMTP timeout. |
||
1371 | * |
||
1372 | * @return int |
||
1373 | */ |
||
1374 | public function getTimeout() |
||
1378 | |||
1379 | /** |
||
1380 | * Reports an error number and string. |
||
1381 | * |
||
1382 | * @param int $errno The error number returned by PHP |
||
1383 | * @param string $errmsg The error message returned by PHP |
||
1384 | * @param string $errfile The file the error occurred in |
||
1385 | * @param int $errline The line number the error occurred on |
||
1386 | */ |
||
1387 | protected function errorHandler($errno, $errmsg, $errfile = '', $errline = 0) |
||
1400 | |||
1401 | /** |
||
1402 | * Extract and return the ID of the last SMTP transaction based on |
||
1403 | * a list of patterns provided in SMTP::$smtp_transaction_id_patterns. |
||
1404 | * Relies on the host providing the ID in response to a DATA command. |
||
1405 | * If no reply has been received yet, it will return null. |
||
1406 | * If no pattern was matched, it will return false. |
||
1407 | * |
||
1408 | * @return bool|string|null |
||
1409 | */ |
||
1410 | protected function recordLastTransactionID() |
||
1429 | |||
1430 | /** |
||
1431 | * Get the queue/transaction ID of the last SMTP transaction |
||
1432 | * If no reply has been received yet, it will return null. |
||
1433 | * If no pattern was matched, it will return false. |
||
1434 | * |
||
1435 | * @return bool|string|null |
||
1436 | * |
||
1437 | * @see recordLastTransactionID() |
||
1438 | */ |
||
1439 | public function getLastTransactionID() |
||
1443 | } |
||
1444 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.