@@ -127,34 +127,55 @@ public static function register($mode = false)
127
127
return $ b ['count ' ] - $ a ['count ' ];
128
128
};
129
129
130
- foreach (array ('unsilenced ' , 'remaining ' , 'legacy ' , 'other ' ) as $ group ) {
131
- if ($ deprecations [$ group .'Count ' ]) {
132
- echo "\n" , $ colorize (sprintf ('%s deprecation notices (%d) ' , ucfirst ($ group ), $ deprecations [$ group .'Count ' ]), 'legacy ' !== $ group ), "\n" ;
130
+ $ displayDeprecations = function ($ deprecations ) use ($ colorize , $ cmp ) {
131
+ foreach (array ('unsilenced ' , 'remaining ' , 'legacy ' , 'other ' ) as $ group ) {
132
+ if ($ deprecations [$ group .'Count ' ]) {
133
+ echo "\n" , $ colorize (sprintf ('%s deprecation notices (%d) ' , ucfirst ($ group ), $ deprecations [$ group .'Count ' ]), 'legacy ' !== $ group ), "\n" ;
133
134
134
- uasort ($ deprecations [$ group ], $ cmp );
135
+ uasort ($ deprecations [$ group ], $ cmp );
135
136
136
- foreach ($ deprecations [$ group ] as $ msg => $ notices ) {
137
- echo "\n " , $ notices ['count ' ], 'x: ' , $ msg , "\n" ;
137
+ foreach ($ deprecations [$ group ] as $ msg => $ notices ) {
138
+ echo "\n " , $ notices ['count ' ], 'x: ' , $ msg , "\n" ;
138
139
139
- arsort ($ notices );
140
+ arsort ($ notices );
140
141
141
- foreach ($ notices as $ method => $ count ) {
142
- if ('count ' !== $ method ) {
143
- echo ' ' , $ count , 'x in ' , preg_replace ('/(.*) \\\\(.*?::.*?)$/ ' , '$2 from $1 ' , $ method ), "\n" ;
142
+ foreach ($ notices as $ method => $ count ) {
143
+ if ('count ' !== $ method ) {
144
+ echo ' ' , $ count , 'x in ' , preg_replace ('/(.*) \\\\(.*?::.*?)$/ ' , '$2 from $1 ' , $ method ), "\n" ;
145
+ }
144
146
}
145
147
}
146
148
}
147
149
}
150
+ if (!empty ($ notices )) {
151
+ echo "\n" ;
152
+ }
153
+ };
154
+
155
+ $ displayDeprecations ($ deprecations );
156
+
157
+ // store failing status
158
+ $ isFailing = 'weak ' !== $ mode && ($ deprecations ['unsilenced ' ] || $ deprecations ['remaining ' ] || $ deprecations ['other ' ]);
159
+
160
+ // reset deprecations array
161
+ foreach ($ deprecations as $ key => $ arrayOrInt ) {
162
+ if (is_int ($ arrayOrInt )) {
163
+ $ deprecations [$ key ] = 0 ;
164
+ } else {
165
+ $ deprecations [$ key ] = array ();
166
+ }
148
167
}
149
- if (!empty ($ notices )) {
150
- echo "\n" ;
151
- }
152
168
153
- if ('weak ' !== $ mode && ($ deprecations ['unsilenced ' ] || $ deprecations ['remaining ' ] || $ deprecations ['other ' ])) {
154
- register_shutdown_function (function () {
169
+ register_shutdown_function (function () use (&$ deprecations , $ isFailing , $ displayDeprecations , $ mode ) {
170
+
171
+ if (array_sum (array_filter ($ deprecations , function ($ key ) { return false !== strpos ($ key , 'Count ' ); }, ARRAY_FILTER_USE_KEY )) > 0 ) {
172
+ echo "Deprecations during shutdown \n" ;
173
+ }
174
+ $ displayDeprecations ($ deprecations );
175
+ if ($ isFailing || 'weak ' !== $ mode && ($ deprecations ['unsilenced ' ] || $ deprecations ['remaining ' ] || $ deprecations ['other ' ])) {
155
176
exit (1 );
156
- });
157
- }
177
+ }
178
+ });
158
179
});
159
180
}
160
181
}
0 commit comments