The arena allocator has no problem with zero-size allocations (and
will just return the same pointer for each in this case), so just
do that to avoid null pointers.
Detected by parsing the strings in zend_func_info.c, looping over them
and checking for inconsistencies with Reflection.
(new ReflectionFunction('str_shuffle')->getReturnType()) would be
a non-null 'string', for example.
- e.g. that change was made in 7393777da9
for php 8.0
Closes GH-4269.
To avoid duplicate type checks. In debug builds arginfo is still
checked and will generate an assertions if the function doesn't
subsequently throw an exception.
Some test results change due to differences in zpp and arginfo
error messages.
Also add PHP_TEST_EXTRA_ARGS environment variable, which allows
to pass on -c, -d etc flags provided by run-tests.php. Otherwise
we won't get the built-in server to run with opcache.
Also initialize the variable to 0 -- I don't think we really care
if this is not determine on some platform, but it should at least
not be uninitialized.
mysqli has an uncommon approach to 64-bit compatibility:
it will convert numbers that can't be represented on 32-bit
platforms to a string.
This is documented at
https://www.php.net/manual/en/mysqli-stmt.affected-rows.php#refsect1-mysqli-stmt.affected-rows-returnvalues
So if there's a query to a remote mysqli server that affects
more than 2.2 billion rows, then the opcache inference might be
incorrect.
(It's possible to add a MAY_BE_STRING_ON_32_BIT_PLATFORM bitflag macro to
account for this, but I don't think there's a need or want to?)
Patches 3162285b86
This is based on the list of php 7.4 functions using
MYSQLI_RETURN_LONG_INT in mysqli_api.c
https://www.php.net/manual/en/mysqli.get-charset.php
tests/mysqli_field_seek.phpt has a test of this returning an object.
Looking at the source in ext/mysqli/mysqli_nonapi.c,
this should be object|null, not array|null
This might actually cause bugs in opcache's inferences,
(no proof of this)
so it might make sense to pull this patch into an earlier minor version.
See https://php.net/pathinfo
This fixes a bug introduced in the cleanup for commit
0d79c70cf3
`pathinfo($str, PATHINFO_EXTENSION)` will always return a string
(if there is no extension, the function returns the empty string)
ext/gd/gd.c seems to return null for wrong parameter count, false for
error, and long otherwise. See https://php.net/imagecolorallocate
In php 8.0, the MAY_BE_NULL can probably be removed.
See UPGRADING for Mbstring.
All of these are aliases of corresponding `mb_*`
functions that existed in php 7 but were removed in php 8.
Other functions such as gzgetss were already removed.
This should only have one r.
http://php.net/get_parent_class mentions that it returns string|false
Also, I'm not 100% sure if this is right - should this include
MAY_BE_NULL to handle the case of too many parameters?
(then again, get_called_class() also returns null in the global scope)
```
php > var_export(get_parent_class(2,3));
Warning: get_parent_class() expects at most 1 parameter, 2 given in php
shell code on line 1
NULL
```
I'm not sure this one ever happens in practice (and we might want
to forbid NULL return from get_properties), but if it does, return
an empty array instead of false.
Now that set() is gone, there is little point in keeping get(), as
it is essentially just a different way of writing cast_object()
now.
Closes GH-4202.
Avoids a stack overflow in Zend/tests/runtime_compile_time_binary_operands.php
that happens in recursive RPO calculation. We could make that code
non-recursive, but I don't think it makes sense to JIT this kind of
function in the first place.
We are no longer constructing the local symbol table when calling
error handlers since 2f1f34952e,
which was the original motivation for having this information and
was used in an earlier version of the JIT.
In PHP 8 we always throw on zpp failure, so we can always return the
type for the valid argument case only. We'll want to also adjust the
return type listings based on that (and drop MAY_BE_NULL/MAY_BE_FALSE
where possible).
Even though we don't need it at runtime, add the BIND_IMPLICIT
flag to BIND_STATIC as well, so we can distinguish this case in
type inference.
This fixes a JIT miscompile in arrow_functions/002.phpt.
The num_args does not include variadics, so a "zero-arg" function
may accept additional arguments through that. No functions seem
to be affected right now, but they will be after #4175.
The num_args does not include variadics, so a "zero-arg" function
may accept additional arguments through that. No functions seem
to be affected right now, but they will be after #4175.
This is a minimal variance implementation: It does not support any
cyclic type dependencies. Additionally the preloading requirements
are much more restrictive than necessary. Hopefully we can relax
these in the future.
We need to check result_use rather than result_def for a null zval.
Previously we were later assuming that the null zval is really a
partial array, which does not go well.
Opcache stores `opline->handler`s in shared memory. These pointers are
invalid, if the main PHP DLL is loaded at another base address due to
ASLR. We therefore store the address of `execute_ex` in the mmap base
file, and check on startup whether it matches its current address. If
not, we fall back on the file cache if enabled, and bail out otherwise.
This still does not address cases where the opline handler is located
inside of another DLL (e.g. for some profilers, debuggers), but there
seems to be no general solution for now.
If opcache.log_verbosity_level is greater than 1, opcache will raise
warnings, which will be written to stderr in the default case. These
warnings are actually to be expected, but would break the test, so we
make sure that the log_verbosity_level is 1 when running this test.