diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index e1eb295fca3..90c665f38f4 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -1650,13 +1650,13 @@ cleanup_parallel: } if (!base_dn_str) { - zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP instance"); + zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance"); ret = 0; goto cleanup; } if (!filter_str) { - zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP instance"); + zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance"); ret = 0; goto cleanup; } @@ -1704,7 +1704,7 @@ cleanup_parallel: result->result = ldap_res; } } else { - zend_argument_type_error(1, "must be of type LDAP|array, %s given", zend_zval_value_name(link)); + zend_argument_type_error(1, "must be of type LDAP\\Connection|array, %s given", zend_zval_value_name(link)); } cleanup: diff --git a/ext/ldap/tests/ldap_list_read_search_programming_errors.phpt b/ext/ldap/tests/ldap_list_read_search_programming_errors.phpt index ee016bde99b..59e227d818e 100644 --- a/ext/ldap/tests/ldap_list_read_search_programming_errors.phpt +++ b/ext/ldap/tests/ldap_list_read_search_programming_errors.phpt @@ -11,6 +11,24 @@ $ldap = ldap_connect('ldap://127.0.0.1:3333'); $valid_dn = "cn=userA,something"; $valid_filter = ""; +try { + var_dump(ldap_list(42, $valid_dn, $valid_filter)); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump(ldap_list($ldap, [$valid_dn], $valid_filter)); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump(ldap_list($ldap, $valid_dn, [$valid_filter])); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + $not_list = [ "attrib1", "wat" => "attrib2", @@ -59,6 +77,9 @@ try { ?> --EXPECT-- +TypeError: ldap_list(): Argument #1 ($ldap) must be of type LDAP\Connection|array, int given +TypeError: ldap_list(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance +TypeError: ldap_list(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance ValueError: ldap_list(): Argument #4 ($attributes) must be a list TypeError: ldap_list(): Argument #4 ($attributes) must be a list of strings, int given ValueError: ldap_list(): Argument #4 ($attributes) must not contain strings with any null bytes diff --git a/ext/ldap/tests/ldap_search_error.phpt b/ext/ldap/tests/ldap_search_error.phpt index 13613ba9d5c..04d8af46f59 100644 --- a/ext/ldap/tests/ldap_search_error.phpt +++ b/ext/ldap/tests/ldap_search_error.phpt @@ -64,5 +64,5 @@ ldap_search(): Argument #4 ($attributes) must be a list ldap_search(): Argument #1 ($ldap) must not be empty ldap_search(): Argument #2 ($base) must be the same size as argument #1 ldap_search(): Argument #3 ($filter) must be the same size as argument #1 -ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP instance -ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP instance +ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance +ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance