3131#include "zend_smart_str.h"
3232
3333ZEND_API zend_class_entry * zend_ce_throwable ;
34- ZEND_API zend_class_entry * zend_exception_ce ;
35- ZEND_API zend_class_entry * zend_error_exception_ce ;
36- ZEND_API zend_class_entry * zend_error_ce ;
37- ZEND_API zend_class_entry * zend_parse_error_ce ;
38- ZEND_API zend_class_entry * zend_type_error_ce ;
34+ ZEND_API zend_class_entry * zend_ce_exception ;
35+ ZEND_API zend_class_entry * zend_ce_error_exception ;
36+ ZEND_API zend_class_entry * zend_ce_error ;
37+ ZEND_API zend_class_entry * zend_ce_parse_error ;
38+ ZEND_API zend_class_entry * zend_ce_type_error ;
3939ZEND_API zend_class_entry * zend_ce_arithmetic_error ;
4040ZEND_API zend_class_entry * zend_ce_division_by_zero_error ;
4141
@@ -46,21 +46,21 @@ static zend_object_handlers default_exception_handlers;
4646/* {{{ zend_implement_throwable */
4747static int zend_implement_throwable (zend_class_entry * interface , zend_class_entry * class_type )
4848{
49- if (instanceof_function (class_type , zend_exception_ce ) || instanceof_function (class_type , zend_error_ce )) {
49+ if (instanceof_function (class_type , zend_ce_exception ) || instanceof_function (class_type , zend_ce_error )) {
5050 return SUCCESS ;
5151 }
5252 zend_error_noreturn (E_ERROR , "Class %s cannot implement interface %s, extend %s or %s instead" ,
5353 ZSTR_VAL (class_type -> name ),
5454 ZSTR_VAL (interface -> name ),
55- ZSTR_VAL (zend_exception_ce -> name ),
56- ZSTR_VAL (zend_error_ce -> name ));
55+ ZSTR_VAL (zend_ce_exception -> name ),
56+ ZSTR_VAL (zend_ce_error -> name ));
5757 return FAILURE ;
5858}
5959/* }}} */
6060
6161static inline zend_class_entry * i_get_exception_base (zval * object )
6262{
63- return instanceof_function (Z_OBJCE_P (object ), zend_exception_ce ) ? zend_exception_ce : zend_error_ce ;
63+ return instanceof_function (Z_OBJCE_P (object ), zend_ce_exception ) ? zend_ce_exception : zend_ce_error ;
6464}
6565
6666ZEND_API zend_class_entry * zend_get_exception_base (zval * object )
@@ -141,7 +141,7 @@ ZEND_API void zend_throw_exception_internal(zval *exception) /* {{{ */
141141 }
142142 }
143143 if (!EG (current_execute_data )) {
144- if (exception && Z_OBJCE_P (exception ) == zend_parse_error_ce ) {
144+ if (exception && Z_OBJCE_P (exception ) == zend_ce_parse_error ) {
145145 return ;
146146 }
147147 if (EG (exception )) {
@@ -206,7 +206,7 @@ static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type,
206206
207207 base_ce = i_get_exception_base (& obj );
208208
209- if (EXPECTED (class_type != zend_parse_error_ce || !(filename = zend_get_compiled_filename ()))) {
209+ if (EXPECTED (class_type != zend_ce_parse_error || !(filename = zend_get_compiled_filename ()))) {
210210 zend_update_property_string (base_ce , & obj , "file" , sizeof ("file" )- 1 , zend_get_executed_filename ());
211211 zend_update_property_long (base_ce , & obj , "line" , sizeof ("line" )- 1 , zend_get_executed_lineno ());
212212 } else {
@@ -295,7 +295,7 @@ ZEND_METHOD(error_exception, __construct)
295295 if (execute_data -> called_scope ) {
296296 ce = execute_data -> called_scope ;
297297 } else {
298- ce = zend_error_exception_ce ;
298+ ce = zend_ce_error_exception ;
299299 }
300300 zend_error (E_EXCEPTION | E_ERROR , "Wrong parameters for %s([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]])" , ZSTR_VAL (ce -> name ));
301301 return ;
@@ -304,25 +304,25 @@ ZEND_METHOD(error_exception, __construct)
304304 object = getThis ();
305305
306306 if (message ) {
307- zend_update_property_string (zend_exception_ce , object , "message" , sizeof ("message" )- 1 , message );
307+ zend_update_property_string (zend_ce_exception , object , "message" , sizeof ("message" )- 1 , message );
308308 }
309309
310310 if (code ) {
311- zend_update_property_long (zend_exception_ce , object , "code" , sizeof ("code" )- 1 , code );
311+ zend_update_property_long (zend_ce_exception , object , "code" , sizeof ("code" )- 1 , code );
312312 }
313313
314314 if (previous ) {
315- zend_update_property (zend_exception_ce , object , "previous" , sizeof ("previous" )- 1 , previous );
315+ zend_update_property (zend_ce_exception , object , "previous" , sizeof ("previous" )- 1 , previous );
316316 }
317317
318- zend_update_property_long (zend_error_exception_ce , object , "severity" , sizeof ("severity" )- 1 , severity );
318+ zend_update_property_long (zend_ce_error_exception , object , "severity" , sizeof ("severity" )- 1 , severity );
319319
320320 if (argc >= 4 ) {
321- zend_update_property_string (zend_exception_ce , object , "file" , sizeof ("file" )- 1 , filename );
321+ zend_update_property_string (zend_ce_exception , object , "file" , sizeof ("file" )- 1 , filename );
322322 if (argc < 5 ) {
323323 lineno = 0 ; /* invalidate lineno */
324324 }
325- zend_update_property_long (zend_exception_ce , object , "line" , sizeof ("line" )- 1 , lineno );
325+ zend_update_property_long (zend_ce_exception , object , "line" , sizeof ("line" )- 1 , lineno );
326326 }
327327}
328328/* }}} */
@@ -709,7 +709,7 @@ ZEND_METHOD(exception, __toString)
709709 ZVAL_UNDEF (& trace );
710710 }
711711
712- if (Z_OBJCE_P (exception ) == zend_type_error_ce && strstr (ZSTR_VAL (message ), ", called in " )) {
712+ if (Z_OBJCE_P (exception ) == zend_ce_type_error && strstr (ZSTR_VAL (message ), ", called in " )) {
713713 zend_string * real_message = zend_strpprintf (0 , "%s and defined" , ZSTR_VAL (message ));
714714 zend_string_release (message );
715715 message = real_message ;
@@ -819,46 +819,46 @@ void zend_register_default_exception(void) /* {{{ */
819819 default_exception_handlers .clone_obj = NULL ;
820820
821821 INIT_CLASS_ENTRY (ce , "Exception" , default_exception_functions );
822- zend_exception_ce = zend_register_internal_class_ex (& ce , NULL );
823- zend_exception_ce -> create_object = zend_default_exception_new ;
824- zend_class_implements (zend_exception_ce , 1 , zend_ce_throwable );
825-
826- zend_declare_property_string (zend_exception_ce , "message" , sizeof ("message" )- 1 , "" , ZEND_ACC_PROTECTED );
827- zend_declare_property_string (zend_exception_ce , "string" , sizeof ("string" )- 1 , "" , ZEND_ACC_PRIVATE );
828- zend_declare_property_long (zend_exception_ce , "code" , sizeof ("code" )- 1 , 0 , ZEND_ACC_PROTECTED );
829- zend_declare_property_null (zend_exception_ce , "file" , sizeof ("file" )- 1 , ZEND_ACC_PROTECTED );
830- zend_declare_property_null (zend_exception_ce , "line" , sizeof ("line" )- 1 , ZEND_ACC_PROTECTED );
831- zend_declare_property_null (zend_exception_ce , "trace" , sizeof ("trace" )- 1 , ZEND_ACC_PRIVATE );
832- zend_declare_property_null (zend_exception_ce , "previous" , sizeof ("previous" )- 1 , ZEND_ACC_PRIVATE );
822+ zend_ce_exception = zend_register_internal_class_ex (& ce , NULL );
823+ zend_ce_exception -> create_object = zend_default_exception_new ;
824+ zend_class_implements (zend_ce_exception , 1 , zend_ce_throwable );
825+
826+ zend_declare_property_string (zend_ce_exception , "message" , sizeof ("message" )- 1 , "" , ZEND_ACC_PROTECTED );
827+ zend_declare_property_string (zend_ce_exception , "string" , sizeof ("string" )- 1 , "" , ZEND_ACC_PRIVATE );
828+ zend_declare_property_long (zend_ce_exception , "code" , sizeof ("code" )- 1 , 0 , ZEND_ACC_PROTECTED );
829+ zend_declare_property_null (zend_ce_exception , "file" , sizeof ("file" )- 1 , ZEND_ACC_PROTECTED );
830+ zend_declare_property_null (zend_ce_exception , "line" , sizeof ("line" )- 1 , ZEND_ACC_PROTECTED );
831+ zend_declare_property_null (zend_ce_exception , "trace" , sizeof ("trace" )- 1 , ZEND_ACC_PRIVATE );
832+ zend_declare_property_null (zend_ce_exception , "previous" , sizeof ("previous" )- 1 , ZEND_ACC_PRIVATE );
833833
834834 INIT_CLASS_ENTRY (ce , "ErrorException" , error_exception_functions );
835- zend_error_exception_ce = zend_register_internal_class_ex (& ce , zend_exception_ce );
836- zend_error_exception_ce -> create_object = zend_error_exception_new ;
837- zend_declare_property_long (zend_error_exception_ce , "severity" , sizeof ("severity" )- 1 , E_ERROR , ZEND_ACC_PROTECTED );
835+ zend_ce_error_exception = zend_register_internal_class_ex (& ce , zend_ce_exception );
836+ zend_ce_error_exception -> create_object = zend_error_exception_new ;
837+ zend_declare_property_long (zend_ce_error_exception , "severity" , sizeof ("severity" )- 1 , E_ERROR , ZEND_ACC_PROTECTED );
838838
839839 INIT_CLASS_ENTRY (ce , "Error" , default_exception_functions );
840- zend_error_ce = zend_register_internal_class_ex (& ce , NULL );
841- zend_error_ce -> create_object = zend_default_exception_new ;
842- zend_class_implements (zend_error_ce , 1 , zend_ce_throwable );
843-
844- zend_declare_property_string (zend_error_ce , "message" , sizeof ("message" )- 1 , "" , ZEND_ACC_PROTECTED );
845- zend_declare_property_string (zend_error_ce , "string" , sizeof ("string" )- 1 , "" , ZEND_ACC_PRIVATE );
846- zend_declare_property_long (zend_error_ce , "code" , sizeof ("code" )- 1 , 0 , ZEND_ACC_PROTECTED );
847- zend_declare_property_null (zend_error_ce , "file" , sizeof ("file" )- 1 , ZEND_ACC_PROTECTED );
848- zend_declare_property_null (zend_error_ce , "line" , sizeof ("line" )- 1 , ZEND_ACC_PROTECTED );
849- zend_declare_property_null (zend_error_ce , "trace" , sizeof ("trace" )- 1 , ZEND_ACC_PRIVATE );
850- zend_declare_property_null (zend_error_ce , "previous" , sizeof ("previous" )- 1 , ZEND_ACC_PRIVATE );
840+ zend_ce_error = zend_register_internal_class_ex (& ce , NULL );
841+ zend_ce_error -> create_object = zend_default_exception_new ;
842+ zend_class_implements (zend_ce_error , 1 , zend_ce_throwable );
843+
844+ zend_declare_property_string (zend_ce_error , "message" , sizeof ("message" )- 1 , "" , ZEND_ACC_PROTECTED );
845+ zend_declare_property_string (zend_ce_error , "string" , sizeof ("string" )- 1 , "" , ZEND_ACC_PRIVATE );
846+ zend_declare_property_long (zend_ce_error , "code" , sizeof ("code" )- 1 , 0 , ZEND_ACC_PROTECTED );
847+ zend_declare_property_null (zend_ce_error , "file" , sizeof ("file" )- 1 , ZEND_ACC_PROTECTED );
848+ zend_declare_property_null (zend_ce_error , "line" , sizeof ("line" )- 1 , ZEND_ACC_PROTECTED );
849+ zend_declare_property_null (zend_ce_error , "trace" , sizeof ("trace" )- 1 , ZEND_ACC_PRIVATE );
850+ zend_declare_property_null (zend_ce_error , "previous" , sizeof ("previous" )- 1 , ZEND_ACC_PRIVATE );
851851
852852 INIT_CLASS_ENTRY (ce , "ParseError" , NULL );
853- zend_parse_error_ce = zend_register_internal_class_ex (& ce , zend_error_ce );
854- zend_parse_error_ce -> create_object = zend_default_exception_new ;
853+ zend_ce_parse_error = zend_register_internal_class_ex (& ce , zend_ce_error );
854+ zend_ce_parse_error -> create_object = zend_default_exception_new ;
855855
856856 INIT_CLASS_ENTRY (ce , "TypeError" , NULL );
857- zend_type_error_ce = zend_register_internal_class_ex (& ce , zend_error_ce );
858- zend_type_error_ce -> create_object = zend_default_exception_new ;
857+ zend_ce_type_error = zend_register_internal_class_ex (& ce , zend_ce_error );
858+ zend_ce_type_error -> create_object = zend_default_exception_new ;
859859
860860 INIT_CLASS_ENTRY (ce , "ArithmeticError" , NULL );
861- zend_ce_arithmetic_error = zend_register_internal_class_ex (& ce , zend_error_ce );
861+ zend_ce_arithmetic_error = zend_register_internal_class_ex (& ce , zend_ce_error );
862862 zend_ce_arithmetic_error -> create_object = zend_default_exception_new ;
863863
864864 INIT_CLASS_ENTRY (ce , "DivisionByZeroError" , NULL );
@@ -867,17 +867,17 @@ void zend_register_default_exception(void) /* {{{ */
867867}
868868/* }}} */
869869
870- /* {{{ Deprecated - Use zend_exception_ce directly instead */
870+ /* {{{ Deprecated - Use zend_ce_exception directly instead */
871871ZEND_API zend_class_entry * zend_exception_get_default (void )
872872{
873- return zend_exception_ce ;
873+ return zend_ce_exception ;
874874}
875875/* }}} */
876876
877- /* {{{ Deprecated - Use zend_error_exception_ce directly instead */
877+ /* {{{ Deprecated - Use zend_ce_error_exception directly instead */
878878ZEND_API zend_class_entry * zend_get_error_exception (void )
879879{
880- return zend_error_exception_ce ;
880+ return zend_ce_error_exception ;
881881}
882882/* }}} */
883883
@@ -888,10 +888,10 @@ ZEND_API zend_object *zend_throw_exception(zend_class_entry *exception_ce, const
888888 if (exception_ce ) {
889889 if (!instanceof_function (exception_ce , zend_ce_throwable )) {
890890 zend_error (E_NOTICE , "Exceptions must implement Throwable" );
891- exception_ce = zend_exception_ce ;
891+ exception_ce = zend_ce_exception ;
892892 }
893893 } else {
894- exception_ce = zend_exception_ce ;
894+ exception_ce = zend_ce_exception ;
895895 }
896896 object_init_ex (& ex , exception_ce );
897897
@@ -928,7 +928,7 @@ ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce,
928928 zval ex ;
929929 zend_object * obj = zend_throw_exception (exception_ce , message , code );
930930 ZVAL_OBJ (& ex , obj );
931- zend_update_property_long (zend_error_exception_ce , & ex , "severity" , sizeof ("severity" )- 1 , severity );
931+ zend_update_property_long (zend_ce_error_exception , & ex , "severity" , sizeof ("severity" )- 1 , severity );
932932 return obj ;
933933}
934934/* }}} */
@@ -961,7 +961,7 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
961961 ZVAL_OBJ (& exception , ex );
962962 ce_exception = Z_OBJCE (exception );
963963 EG (exception ) = NULL ;
964- if (ce_exception == zend_parse_error_ce ) {
964+ if (ce_exception == zend_ce_parse_error ) {
965965 zend_string * message = zval_get_string (GET_PROPERTY (& exception , "message" ));
966966 zend_string * file = zval_get_string (GET_PROPERTY_SILENT (& exception , "file" ));
967967 zend_long line = zval_get_long (GET_PROPERTY_SILENT (& exception , "line" ));
@@ -991,7 +991,7 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
991991
992992 ZVAL_OBJ (& zv , EG (exception ));
993993 /* do the best we can to inform about the inner exception */
994- if (instanceof_function (ce_exception , zend_exception_ce ) || instanceof_function (ce_exception , zend_error_ce )) {
994+ if (instanceof_function (ce_exception , zend_ce_exception ) || instanceof_function (ce_exception , zend_ce_error )) {
995995 file = zval_get_string (GET_PROPERTY_SILENT (& zv , "file" ));
996996 line = zval_get_long (GET_PROPERTY_SILENT (& zv , "line" ));
997997 }
0 commit comments