File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
src/aleksip/DataTransformPlugin Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace aleksip \DataTransformPlugin ;
4+
5+ trait ErrorHandlerTrait
6+ {
7+ protected static $ levels = [
8+ E_WARNING => 'E_WARNING ' ,
9+ E_NOTICE => 'E_NOTICE ' ,
10+ E_DEPRECATED => 'E_DEPRECATED ' ,
11+ E_USER_DEPRECATED => 'E_USER_DEPRECATED ' ,
12+ ];
13+
14+ protected $ errno ;
15+ protected $ errstr ;
16+
17+ protected function errorHandler ($ errno , $ errstr )
18+ {
19+ $ this ->errno = $ errno ;
20+ $ this ->errstr = $ errstr ;
21+
22+ return TRUE ;
23+ }
24+
25+ protected function setErrorHandler ()
26+ {
27+ $ this ->errno = null ;
28+ $ this ->errstr = null ;
29+ set_error_handler ([$ this , 'errorHandler ' ]);
30+ }
31+
32+ protected function restoreErrorHandler ($ errorMessage = null )
33+ {
34+ restore_error_handler ();
35+ if (isset ($ this ->errno )) {
36+ $ level = isset (self ::$ levels [$ this ->errno ]) ? self ::$ levels [$ this ->errno ] : $ this ->errno ;
37+ if (isset ($ errorMessage )) {
38+ DataTransformPlugin::writeWarning ($ errorMessage );
39+ }
40+ DataTransformPlugin::writeWarning ($ this ->errstr . ' ( ' . $ level . ') ' , isset ($ errorMessage ));
41+ }
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments