From 2aa2219f286a91e2acd8c954d6f0edda4735e843 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 6 Dec 2016 11:01:55 +1300 Subject: [PATCH] Fix reference example under PHP 7.1 PHP 7.1 no longer supports calling methods with fewer parameters than declared, so we need to generate __construct() with default values for all but the first parameter. --- Source/Modules/php.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 213025d95..78f5dfb2a 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1478,6 +1478,9 @@ public: Replaceall(value, "$", "\\$"); } Printf(args, "$%s=%s", arg_names[i], value); + } else if (constructor && i >= 1 && i < min_num_of_arguments) { + // We need to be able to call __construct($resource). + Printf(args, "$%s=null", arg_names[i]); } else { Printf(args, "$%s", arg_names[i]); } @@ -1498,6 +1501,15 @@ public: Printf(invoke_args, ","); } Printf(invoke_args, "%s", args); + if (constructor && min_num_of_arguments > 1) { + // We need to be able to call __construct($resource). + Clear(args); + Printf(args, "$%s", arg_names[0]); + for (i = 1; i < min_num_of_arguments; ++i) { + Printf(args, ","); + Printf(args, "$%s=null", arg_names[i]); + } + } bool had_a_case = false; int last_handled_i = i - 1; for (; i < max_num_of_arguments; ++i) {