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.
This commit is contained in:
parent
fa785cdd46
commit
2aa2219f28
1 changed files with 12 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue