@@ -6247,34 +6247,38 @@ PHP_FUNCTION(array_map)
62476247 Checks if the given key or index exists in the array */
62486248PHP_FUNCTION (array_key_exists )
62496249{
6250- zval * key ; /* key to check for */
6251- HashTable * array ; /* array to check in */
6250+ zval * key ;
6251+ zval * array ;
6252+ HashTable * ht ;
62526253
62536254 ZEND_PARSE_PARAMETERS_START (2 , 2 )
62546255 Z_PARAM_ZVAL (key )
6255- Z_PARAM_ARRAY_OR_OBJECT_HT (array )
6256+ Z_PARAM_ARRAY_OR_OBJECT (array )
62566257 ZEND_PARSE_PARAMETERS_END ();
62576258
6259+ if (EXPECTED (Z_TYPE_P (array ) == IS_ARRAY )) {
6260+ ht = Z_ARRVAL_P (array );
6261+ } else {
6262+ ht = zend_get_properties_for (array , ZEND_PROP_PURPOSE_ARRAY_CAST );
6263+ }
6264+
62586265 switch (Z_TYPE_P (key )) {
62596266 case IS_STRING :
6260- if (zend_symtable_exists_ind (array , Z_STR_P (key ))) {
6261- RETURN_TRUE ;
6262- }
6263- RETURN_FALSE ;
6267+ RETVAL_BOOL (zend_symtable_exists_ind (ht , Z_STR_P (key )));
6268+ break ;
62646269 case IS_LONG :
6265- if (zend_hash_index_exists (array , Z_LVAL_P (key ))) {
6266- RETURN_TRUE ;
6267- }
6268- RETURN_FALSE ;
6270+ RETVAL_BOOL (zend_hash_index_exists (ht , Z_LVAL_P (key )));
6271+ break ;
62696272 case IS_NULL :
6270- if (zend_hash_exists_ind (array , ZSTR_EMPTY_ALLOC ())) {
6271- RETURN_TRUE ;
6272- }
6273- RETURN_FALSE ;
6274-
6273+ RETVAL_BOOL (zend_hash_exists_ind (ht , ZSTR_EMPTY_ALLOC ()));
6274+ break ;
62756275 default :
62766276 php_error_docref (NULL , E_WARNING , "The first argument should be either a string or an integer" );
6277- RETURN_FALSE ;
6277+ RETVAL_FALSE ;
6278+ }
6279+
6280+ if (Z_TYPE_P (array ) != IS_ARRAY ) {
6281+ zend_release_properties (ht );
62786282 }
62796283}
62806284/* }}} */
0 commit comments