Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/tests/display_error_function_args.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Warning: unlink('/'): %s in %s on line %d

Warning: password_hash(Object(SensitiveParameterValue), '2y', Array): The "salt" option has been ignored, since providing a custom salt is no longer supported in %s on line %d

Warning: unlink(/): %s in %s on line %d
Warning: unlink(): %s in %s on line %d

Warning: password_hash(): The "salt" option has been ignored, since providing a custom salt is no longer supported in %s on line %d
26 changes: 26 additions & 0 deletions Zend/tests/partial_application/bound_arg_strict_types.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Partial application checks bound arguments with the creating scope's strict_types
--FILE--
<?php
declare(strict_types=1);

function f(int $a, $b) { return $a; }

try {
f("3", ?);
} catch (\TypeError $e) {
echo $e::class, ": ", $e->getMessage(), "\n";
}

function make() {
try {
f("3", ?);
} catch (\TypeError $e) {
echo $e::class, ": ", $e->getMessage(), "\n";
}
}
make();
?>
--EXPECT--
TypeError: f(): Argument #1 ($a) must be of type int, string given
TypeError: f(): Argument #1 ($a) must be of type int, string given
32 changes: 25 additions & 7 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,9 +1151,9 @@ static bool zend_check_intersection_type_from_list(
return true;
}

static zend_always_inline bool zend_check_type_slow(
static zend_always_inline bool zend_check_type_slow_ex(
const zend_type *type, zval *arg, const zend_reference *ref,
bool is_return_type, bool is_internal)
bool is_return_type, bool is_internal, bool strict)
{
if (ZEND_TYPE_IS_COMPLEX(*type) && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
zend_class_entry *ce;
Expand Down Expand Up @@ -1206,14 +1206,20 @@ static zend_always_inline bool zend_check_type_slow(
return 0;
}

return zend_verify_scalar_type_hint(type_mask, arg,
is_return_type ? ZEND_RET_USES_STRICT_TYPES() : ZEND_ARG_USES_STRICT_TYPES(),
is_internal);
return zend_verify_scalar_type_hint(type_mask, arg, strict, is_internal);

/* Special handling for IS_VOID is not necessary (for return types),
* because this case is already checked at compile-time. */
}

static zend_always_inline bool zend_check_type_slow(
const zend_type *type, zval *arg, const zend_reference *ref,
bool is_return_type, bool is_internal)
{
return zend_check_type_slow_ex(type, arg, ref, is_return_type, is_internal,
is_return_type ? ZEND_RET_USES_STRICT_TYPES() : ZEND_ARG_USES_STRICT_TYPES());
}

static zend_always_inline bool zend_check_type(
const zend_type *type, zval *arg, bool is_return_type, bool is_internal)
{
Expand All @@ -1234,9 +1240,21 @@ static zend_always_inline bool zend_check_type(

/* We can not expose zend_check_type() directly because it's inline and uses static functions */
ZEND_API bool zend_check_type_ex(
const zend_type *type, zval *arg, bool is_return_type, bool is_internal)
const zend_type *type, zval *arg, bool is_return_type, bool is_internal, bool strict)
{
return zend_check_type(type, arg, is_return_type, is_internal);
const zend_reference *ref = NULL;
ZEND_ASSERT(ZEND_TYPE_IS_SET(*type));

if (UNEXPECTED(Z_ISREF_P(arg))) {
ref = Z_REF_P(arg);
arg = Z_REFVAL_P(arg);
}

if (EXPECTED(ZEND_TYPE_CONTAINS_CODE(*type, Z_TYPE_P(arg)))) {
return 1;
}

return zend_check_type_slow_ex(type, arg, ref, is_return_type, is_internal, strict);
}

ZEND_API bool zend_check_user_type_slow(
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ZEND_API bool zend_verify_ref_array_assignable(zend_reference *ref);
ZEND_API bool zend_check_user_type_slow(
const zend_type *type, zval *arg, const zend_reference *ref, bool is_return_type);
ZEND_API bool zend_check_type_ex(
const zend_type *type, zval *arg, bool is_return_type, bool is_internal);
const zend_type *type, zval *arg, bool is_return_type, bool is_internal, bool strict);

#if ZEND_DEBUG
ZEND_API bool zend_internal_call_should_throw(const zend_function *fbc, zend_execute_data *call);
Expand Down
10 changes: 8 additions & 2 deletions Zend/zend_partial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,14 @@ static void zp_bind(zval *result, zend_function *function, uint32_t argc, zval *
arg_info = NULL;
}
if (arg_info && ZEND_TYPE_IS_SET(arg_info->type)
&& UNEXPECTED(!zend_check_type_ex(&arg_info->type, var, 0, 0))) {
zend_verify_arg_error(function, arg_info, offset+1, var);
&& UNEXPECTED(!zend_check_type_ex(&arg_info->type, var, 0, 0,
ZEND_FLF_ARG_USES_STRICT_TYPES()))) {
zend_string *need_msg = zend_type_to_string_resolved(arg_info->type,
function->common.scope);
zend_argument_type_error_ex(function, offset + 1,
"must be of type %s, %s given",
ZSTR_VAL(need_msg), zend_zval_value_name(var));
zend_string_release(need_msg);
zval_ptr_dtor(result);
ZVAL_NULL(result);
return;
Expand Down
14 changes: 10 additions & 4 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,11 @@ PHP_MSHUTDOWN_FUNCTION(curl)
/* {{{ curl_write */
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *) ctx;
php_curl_write *write_handler = ch->handlers.write;
size_t length = size * nmemb;
size_t length = nmemb;

#if PHP_CURL_DEBUG
fprintf(stderr, "curl_write() called\n");
Expand Down Expand Up @@ -786,6 +788,8 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key,
/* {{{ curl_read */
static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *)ctx;
php_curl_read *read_handler = ch->handlers.read;
size_t length = 0;
Expand All @@ -808,15 +812,15 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
} else {
ZVAL_NULL(&argv[1]);
}
ZVAL_LONG(&argv[2], (int)size * nmemb);
ZVAL_LONG(&argv[2], (zend_long) nmemb);

ch->in_callback = true;
zend_call_known_fcc(&read_handler->fcc, &retval, /* param_count */ 3, argv, /* named_params */ NULL);
ch->in_callback = false;
if (!Z_ISUNDEF(retval)) {
_php_curl_verify_handlers(ch, /* reporterror */ true);
if (Z_TYPE(retval) == IS_STRING) {
length = MIN(size * nmemb, Z_STRLEN(retval));
length = MIN(nmemb, Z_STRLEN(retval));
memcpy(data, Z_STRVAL(retval), length);
} else if (Z_TYPE(retval) == IS_LONG) {
length = Z_LVAL_P(&retval);
Expand Down Expand Up @@ -884,9 +888,11 @@ static int curl_seek(void *clientp, curl_off_t offset, int origin)
/* {{{ curl_write_header */
static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *) ctx;
php_curl_write *write_handler = ch->handlers.write_header;
size_t length = size * nmemb;
size_t length = nmemb;

switch (write_handler->method) {
case PHP_CURL_STDOUT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ array(3) {
}
Destroy [%s,%s]

Warning: unlink(%s): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
Close [%s,PHPSESSID]
bool(true)
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ GC [0]
bool(true)
Destroy [%s,PHPT-%d]

Warning: unlink(%s): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
Close [%s,PHPSESSID]
bool(true)
8 changes: 4 additions & 4 deletions ext/standard/tests/file/copy_variation4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Destination file name => %s/
Size of source file => int(1500)
Size of destination file => int(%d)

Warning: unlink(%s): %s
Warning: unlink(): %s

-- Iteration 2 --
Existence of destination file before copy => bool(true)
Expand All @@ -103,7 +103,7 @@ Destination file name => %s/
Size of source file => int(1500)
Size of destination file => int(%d)

Warning: unlink(%s): %s
Warning: unlink(): %s

-- Iteration 3 --
Existence of destination file before copy => bool(true)
Expand All @@ -115,7 +115,7 @@ Destination file name => %s/
Size of source file => int(1500)
Size of destination file => int(%d)

Warning: unlink(%s): %s
Warning: unlink(): %s

-- Iteration 4 --
Existence of destination file before copy => bool(true)
Expand All @@ -127,7 +127,7 @@ Destination file name => %s/
Size of source file => int(1500)
Size of destination file => int(%d)

Warning: unlink(%s): %s
Warning: unlink(): %s

-- Iteration 5 --
Existence of destination file before copy => bool(false)
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/file/copy_variation5-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Destination file name => %s/CopY5.TMP
Size of source file => int(1500)
Size of destination file => int(1500)

Warning: unlink(%s/COPY5.TMP): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d

Warning: unlink(%s/CopY5.TMP): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
*** Done ***
2 changes: 1 addition & 1 deletion ext/standard/tests/file/mkdir_rmdir_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ echo "Done\n";
--EXPECTF--
*** Testing rmdir() on non-existent directory ***

Warning: rmdir(temp): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
bool(false)
Done
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ bool(true)
*** Testing rmdir() on a non-empty directory ***
bool(true)

Warning: rmdir(%s/mkdir私はガラスを食べられます/): Directory not empty in %s on line %d
Warning: rmdir(): Directory not empty in %s on line %d
bool(false)

*** Testing mkdir() and rmdir() for binary safe functionality ***
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/mkdir_rmdir_variation-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ bool(true)
*** Testing rmdir() on a non-empty directory ***
bool(true)

Warning: rmdir(%s/mkdir/): Directory not empty in %s on line %d
Warning: rmdir(): Directory not empty in %s on line %d
bool(false)

*** Testing mkdir() and rmdir() for binary safe functionality ***
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/mkdir_rmdir_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool(true)
*** Testing rmdir() on a non-empty directory ***
bool(true)

Warning: rmdir(%s/mkdir_variation2/): %s on line %d
Warning: rmdir(): %s on line %d
bool(false)

*** Testing mkdir() and rmdir() for binary safe functionality ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Warning: readlink(): readlink failed to read the symbolic link (%s), error %d in
bool(false)
bool(false)

Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d

-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --
bool(true)
Expand All @@ -94,5 +94,5 @@ Warning: readlink(): readlink failed to read the symbolic link (%s), error %d in
bool(false)
bool(false)

Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
Done
4 changes: 2 additions & 2 deletions ext/standard/tests/file/readlink_realpath_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Warning: readlink(): No such file or directory in %s on line %d
bool(false)
bool(false)

Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d

-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --
bool(true)
Expand All @@ -93,5 +93,5 @@ Warning: readlink(): No such file or directory in %s on line %d
bool(false)
bool(false)

Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
Done
2 changes: 1 addition & 1 deletion ext/standard/tests/file/rename_variation-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool(false)
bool(false)
bool(false)

Warning: unlink(%s/rename_variation2.tmp): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
-- Iteration 3 --
bool(true)
bool(false)
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/rename_variation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool(false)
bool(false)
bool(false)

Warning: unlink(%s): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
-- Iteration 3 --
bool(true)
bool(false)
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/tests/file/rmdir_variation3-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ Directory removed
Directory removed
-- removing rmdirVar3.tmp\..\BADDIR\aSubDir --

Warning: rmdir(rmdirVar3.tmp\..\BADDIR\aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing BADDIR\aSubDir --

Warning: rmdir(BADDIR\aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing %s\rmdirVar3.tmp\aSubDir --
Directory removed
-- removing %s\.\rmdirVar3.tmp\aSubDir --
Expand All @@ -87,7 +87,7 @@ Directory removed
Directory removed
-- removing %s\BADDIR\aSubDir --

Warning: rmdir(%s\BADDIR\aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing rmdirVar3.tmp\aSubDir\ --
Directory removed
-- removing %s\rmdirVar3.tmp\aSubDir\ --
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/tests/file/rmdir_variation3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ Directory removed
Directory removed
-- removing rmdirVar3.tmp/../BADDIR/aSubDir --

Warning: rmdir(rmdirVar3.tmp/../BADDIR/aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing BADDIR/aSubDir --

Warning: rmdir(BADDIR/aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing %s/rmdirVar3.tmp/aSubDir --
Directory removed
-- removing %s/./rmdirVar3.tmp/aSubDir --
Expand All @@ -77,7 +77,7 @@ Directory removed
Directory removed
-- removing %s/BADDIR/aSubDir --

Warning: rmdir(%s/BADDIR/aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing rmdirVar3.tmp/aSubDir/ --
Directory removed
-- removing %s/rmdirVar3.tmp/aSubDir/ --
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/file/unlink_error-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ bool(false)

-- Testing unlink() on non-existent file --

Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
bool(false)

-- Testing unlink() on directory --

Warning: unlink(%s/unlink_error): Is a directory in %s on line %d
Warning: unlink(): Is a directory in %s on line %d
bool(false)
Done
4 changes: 2 additions & 2 deletions ext/standard/tests/file/unlink_error-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ bool(false)

-- Testing unlink() on non-existent file --

Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
bool(false)

-- Testing unlink() on directory --

Warning: unlink(%s/unlink_error): Is a directory in %s on line %d
Warning: unlink(): Is a directory in %s on line %d
bool(false)
Done
Loading
Loading