@@ -46,7 +46,7 @@ PHONGO_API zend_class_entry *php_phongo_regex_ce;
46
46
47
47
zend_object_handlers php_phongo_handler_regex ;
48
48
49
- /* Initialize the object from a string and return whether it was successful. */
49
+ /* Initialize the object and return whether it was successful. */
50
50
static bool php_phongo_regex_init (php_phongo_regex_t * intern , const char * pattern , phongo_zpp_char_len pattern_len , const char * flags , phongo_zpp_char_len flags_len )
51
51
{
52
52
intern -> pattern = estrndup (pattern , pattern_len );
@@ -57,8 +57,9 @@ static bool php_phongo_regex_init(php_phongo_regex_t *intern, const char *patter
57
57
return true;
58
58
}
59
59
60
- /* Initialize the object from a HashTable and return whether it was successful. */
61
- static bool php_phongo_regex_init_from_hash (php_phongo_regex_t * intern , HashTable * props )
60
+ /* Initialize the object from a HashTable and return whether it was successful.
61
+ * An exception will be thrown on error. */
62
+ static bool php_phongo_regex_init_from_hash (php_phongo_regex_t * intern , HashTable * props TSRMLS_DC )
62
63
{
63
64
#if PHP_VERSION_ID >= 70000
64
65
zval * pattern , * flags ;
@@ -75,6 +76,8 @@ static bool php_phongo_regex_init_from_hash(php_phongo_regex_t *intern, HashTabl
75
76
return php_phongo_regex_init (intern , Z_STRVAL_PP (pattern ), Z_STRLEN_PP (pattern ), Z_STRVAL_PP (flags ), Z_STRLEN_PP (flags ));
76
77
}
77
78
#endif
79
+
80
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "%s initialization requires \"pattern\" and \"flags\" string fields" , ZSTR_VAL (php_phongo_regex_ce -> name ));
78
81
return false;
79
82
}
80
83
@@ -154,9 +157,7 @@ PHP_METHOD(Regex, __set_state)
154
157
intern = Z_REGEX_OBJ_P (return_value );
155
158
props = Z_ARRVAL_P (array );
156
159
157
- if (!php_phongo_regex_init_from_hash (intern , props )) {
158
- php_error (E_ERROR , "Invalid serialization data for Regex object" );
159
- }
160
+ php_phongo_regex_init_from_hash (intern , props TSRMLS_CC );
160
161
}
161
162
/* }}} */
162
163
@@ -196,9 +197,7 @@ PHP_METHOD(Regex, __wakeup)
196
197
intern = Z_REGEX_OBJ_P (getThis ());
197
198
props = zend_std_get_properties (getThis () TSRMLS_CC );
198
199
199
- if (!php_phongo_regex_init_from_hash (intern , props )) {
200
- php_error (E_ERROR , "Invalid serialization data for Regex object" );
201
- }
200
+ php_phongo_regex_init_from_hash (intern , props TSRMLS_CC );
202
201
}
203
202
/* }}} */
204
203
0 commit comments