Skip to content
Merged
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
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ PHP NEWS
- Readline:
. Fixed class constant completion in the interactive shell. (Weilin Du)

- Zip:
. Fixed bug GH-23276 (ZipArchive subclass storing its own stream cannot be
garbage collected). (Weilin Du, ndossche)

- SAPI:
. Fixed fuzzer targets failing to build in isolation. (Mrmaxmeier)
. Fixed returns uninitialized value on LiteSpeed lsapi SAPI (Go Kudo)
Expand Down Expand Up @@ -110,6 +114,8 @@ PHP NEWS

- Standard:
. Fixed incorrect parameter name in convert_uudecode() warning. (lacatoire)
. Added support for the "<" and ">" endianness modifiers in pack() and
unpack() format codes. (alexandre-daubois)

- Zip:
. Fixed bug GH-17787 (ZipArchive stream stops reading early when the archive
Expand Down
8 changes: 8 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@ PHP 8.6 UPGRADE NOTES
SNMP::setStringOutputFormat() methods. (eskyuu)
RFC: https://wiki.php.net/rfc/snmp_improvements_2026#implement_more_mib_parsing_and_value_output_controls

- Standard:
. pack() and unpack() now accept the "<" and ">" endianness modifiers on
the signed and unsigned integer format codes.
RFC: https://wiki.php.net/rfc/pack-unpack-endianness-signed-integers-support
. pack() and unpack() now accept the "<" and ">" endianness modifiers on
the float and double format codes.
RFC: https://wiki.php.net/rfc/pack-unpack-float-endianness-modifier

- Streams:
. Added new stream errors API including new classes, enums, functions and
internal API. It is controlled using error_mode, error_store and
Expand Down
47 changes: 47 additions & 0 deletions Zend/tests/partial_application/default_arg_scope.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--TEST--
PFA default argument value scope
--ENV--
A=1
--FILE--
<?php

if (getenv('A')) {
/* Relative class references are never resolved at compile time on traits */
trait T {
static function f($a, $b = self::VAL) {
var_dump($b);
}
}
trait U {
static function g($a, $b = parent::VAL) {
var_dump($b);
}
}
}

class C {
const VAL = 'C';
use T;
}

class D extends C {
const VAL = 'D';
use U;
}

C::f(0);
D::f(0);
C::f(?, ...)(0);
D::f(?, ...)(0);

D::g(0);
D::g(?, ...)(0);

?>
--EXPECT--
string(1) "C"
string(1) "C"
string(1) "C"
string(1) "C"
string(1) "C"
string(1) "C"
2 changes: 1 addition & 1 deletion Zend/tests/partial_application/magic_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Closure [ <user> public method {closure:%s:%d} ] {
Parameter #0 [ <required> mixed $arguments0 ]
}
}
ArgumentCountError: Too few arguments to function Foo::{closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
ArgumentCountError: Too few arguments to function Closure::{closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
Foo::method
int(1)
Foo::method
Expand Down
6 changes: 3 additions & 3 deletions Zend/tests/partial_application/magic_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ echo (string) new ReflectionFunction($bar);
$bar(100);
?>
--EXPECTF--
Closure [ <user> static public method {closure:%s:%d} ] {
Closure [ <user> static function {closure:%s:%d} ] {
@@ %s 10 - 10

- Parameters [1] {
Expand All @@ -42,7 +42,7 @@ Foo::method
int(1)
Foo::method
int(1)
Closure [ <user> static public method {closure:%s:%d} ] {
Closure [ <user> static function {closure:%s:%d} ] {
@@ %s 17 - 17

- Parameters [2] {
Expand All @@ -55,7 +55,7 @@ int(10)
Foo::method
int(10)
int(20)
Closure [ <user> static public method {closure:%s:%d} ] {
Closure [ <user> static function {closure:%s:%d} ] {
@@ %s 24 - 24

- Bound Variables [1] {
Expand Down
49 changes: 49 additions & 0 deletions Zend/tests/partial_application/magic_scope.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--TEST--
Magic method scope
--CREDITS--
Ryan @ Calif.io
--FILE--
<?php

class InstanceTarget
{
private function secret(string $value): void
{
echo "PRIVATE-INSTANCE:$value\n";
}

public function __call(string $name, array $arguments): void
{
echo "MAGIC-INSTANCE:$name:" . implode(',', $arguments) . "\n";
}
}

class StaticTarget
{
private static function secret(string $value): void
{
echo "PRIVATE-STATIC:$value\n";
}

public static function __callStatic(string $name, array $arguments): void
{
echo "MAGIC-STATIC:$name:" . implode(',', $arguments) . "\n";
}
}

$instance = new InstanceTarget();

$instance->secret('direct');
StaticTarget::secret('direct');

$instancePartial = $instance->secret(?);
$staticPartial = StaticTarget::secret(?);
$instancePartial('controlled');
$staticPartial('controlled');

?>
--EXPECT--
MAGIC-INSTANCE:secret:direct
MAGIC-STATIC:secret:direct
MAGIC-INSTANCE:secret:controlled
MAGIC-STATIC:secret:controlled
2 changes: 1 addition & 1 deletion Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
if (uses_variadic_placeholder) {
flags |= ZEND_PARTIAL_USES_VARIADIC_PLACEHOLDER;
}
zend_partial_create(result, &frame->This, fptr,
zend_partial_create(result, scope, &frame->This, fptr,
ZEND_CALL_NUM_ARGS(frame), ZEND_CALL_ARG(frame, 1),
extra_named_params, named_positions,
fcc_ast->filename, &ast->lineno,
Expand Down
12 changes: 10 additions & 2 deletions Zend/zend_partial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ static void zp_bind(zval *result, zend_function *function, uint32_t argc, zval *
}
}

void zend_partial_create(zval *result, zval *this_ptr, zend_function *function,
void zend_partial_create(zval *result, zend_class_entry *scope, zval *this_ptr, zend_function *function,
uint32_t argc, zval *argv, zend_array *extra_named_params,
const zend_array *named_positions,
zend_string *declaring_filename,
Expand Down Expand Up @@ -1162,8 +1162,16 @@ void zend_partial_create(zval *result, zval *this_ptr, zend_function *function,
object = NULL;
}


/* We conveniently use the function's scope for the scope of the generated closure as this allows const exprs
* referencing self:: or parent:: to behave normally without rewriting them.
* This affects method resolution for magic methods, so use the actual scope for them. */
if (!(function->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
scope = function->common.scope;
}

zend_create_partial_closure(result, (zend_function*)op_array,
function->common.scope, called_scope, object,
scope, called_scope, object,
(function->common.fn_flags & ZEND_ACC_CLOSURE) != 0);

zp_bind(result, function, argc, argv, extra_named_params, const_args);
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_partial.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BEGIN_EXTERN_C()
* 'declaring_lineno_ptr' should be a pointer the zend_op.lineno or
* zend_ast.lineno that declares the PFA. The address is used to build a cache
* key. */
void zend_partial_create(zval *result, zval *this_ptr, zend_function *function,
void zend_partial_create(zval *result, zend_class_entry *scope, zval *this_ptr, zend_function *function,
uint32_t argc, zval *argv, zend_array *extra_named_params,
const zend_array *named_positions,
zend_string *declaring_filename,
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -9897,7 +9897,7 @@ ZEND_VM_HANDLER(212, ZEND_CALLABLE_CONVERT_PARTIAL, CONST, CONST|UNUSED, NUM)
}

zend_partial_create(EX_VAR(opline->result.var),
&call->This, call->func,
EX(func)->common.scope, &call->This, call->func,
ZEND_CALL_NUM_ARGS(call), ZEND_CALL_ARG(call, 1),
(ZEND_CALL_INFO(call) & ZEND_CALL_HAS_EXTRA_NAMED_PARAMS) ?
call->extra_named_params : NULL,
Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_vm_execute.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading