Commit graph

168 commits

Author SHA1 Message Date
Gina Peter Banyard
1ad7743133
Zend: Resolve self and parent types at compile time (#17755)
This does not apply to traits.
2025-02-11 15:15:32 +00:00
DanielEScherzer
7a8b1f683b
Generated arginfo header files: use known strings for prop names when… (#15751)
Instead of allocating, using, and then releasing a zend_string for every
property name unconditionally, only do so when the minimum supported version of
PHP does not have that string in its known strings (ZEND_KNOWN_STRINGS). If the
string is already known, just use the known version directly. This is already
done for some non-generated class registrations, e.g. in
`zend_enum_register_props()`.
2024-09-30 13:22:34 +02:00
DanielEScherzer
db545767e5
Rename ZEND_STR_DEPRECATED to ZEND_STR_DEPRECATED_CAPITALIZED (#15831)
To match other capitalized strings like `ZEND_STR_UNKNOWN_CAPITALIZED` and
`ZEND_STR_ARRAY_CAPITALIZED`. Since this known string was only added in PHP
8.4, no backwards compatibility alias is needed.
2024-09-10 22:45:23 +01:00
Gina Peter Banyard
a79c70f574
[RFC] Convert exit (and die) from language constructs to functions (#13483)
RFC: https://wiki.php.net/rfc/exit-as-function
2024-08-14 12:44:12 +01:00
Ilija Tovilo
780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +02:00
Benjamin Eberlei
72c874691b
RFC: Add #[\Deprecated] Attribute (#11293)
see https://wiki.php.net/rfc/deprecated_attribute

Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2024-07-02 09:44:25 +02:00
Dmitry Stogov
ad16767d58
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix zend_string_starts_with_literal_ci (#14137)
2024-05-06 08:49:52 +03:00
twosee
f5e450d101
Fix zend_string_starts_with_literal_ci (#14137) 2024-05-06 08:49:33 +03:00
George Peter Banyard
5c3a6eaec9
Zend: Remove dependency on zend.h for certain headers (#12166) 2023-09-11 12:27:21 +01:00
George Peter Banyard
a342138e17
Revert "Use binary safe case compare in new zend_string API"
This reverts commit eb5cc1372c.

A) I'm using the function incorectly
B) Somehow the function is undefined although it's used in other zend_string APIs
2023-07-05 18:13:04 +01:00
George Peter Banyard
eb5cc1372c
Use binary safe case compare in new zend_string API 2023-07-05 18:04:45 +01:00
George Peter Banyard
b9af98092c
Add case insensitive versions of the zend_string_starts_with_* APIs (#11032) 2023-04-10 12:35:52 +01:00
Dmitry Stogov
61b19ba3f0 Revert "Zend/zend_types.h: move zend_uchar.h to zend_char.h"
This reverts commit 42577c6b6b.
2023-04-04 22:47:45 +03:00
Dmitry Stogov
ac3abe4579 Revert "Zend/zend_types.h: move zend_string to zend_string.h"
This reverts commit 02690fe3c0.
2023-04-04 22:47:45 +03:00
Ilija Tovilo
2ec0134ee2
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix NUL byte in exception string terminating Exception::__toString()
2023-03-19 10:51:05 +01:00
Ilija Tovilo
c0bb5b0b67
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix NUL byte in exception string terminating Exception::__toString()
2023-03-19 10:50:39 +01:00
Ilija Tovilo
b5726c2cb1
Fix NUL byte in exception string terminating Exception::__toString()
Fixes GH-10810
Closes GH-10873
2023-03-19 10:48:26 +01:00
Max Kellermann
02690fe3c0 Zend/zend_types.h: move zend_string to zend_string.h
It is now possible to include only `zend_string.h` without
`zend_types.h`.
2023-02-26 14:16:53 +00:00
Max Kellermann
42577c6b6b Zend/zend_types.h: move zend_uchar.h to zend_char.h
Prepare to fix the cyclic header dependency from `zend_string.h`.
2023-02-26 14:16:53 +00:00
Niels Dossche
99b86141ae Introduce convenience macros for copying flags that hold when concatenating two strings
This abstracts away, and cleans up, the flag handling for properties of
strings that hold when concatenating two strings if they both hold that
property. (These macros also work with simply copies of strings because
a copy of a string can be considered a concatenation with the empty
string.) This gets rid of some branches and some repetitive code, and
leaves room for adding more flags like these in the future.
2023-02-05 14:32:50 +00:00
Ilija Tovilo
9e097822e8
Fix lineno for all constant expressions
Fixes GH-8821
Closes GH-8855
2023-02-02 19:03:47 +01:00
George Peter Banyard
0b9fb636d1 Add macro to check zend_string is marked as valid UTF-8 2023-02-02 12:02:36 +00:00
Christoph M. Becker
2d3427c507
Revert "#include cleanup (#10216)"
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit e628c66f9d.
2023-01-16 12:29:41 +01:00
Levi Morrison
0f4d37d040
Enforce literals in certain macros (#10111)
These macros are designed only for literals. This is a
standards compliant trick to ensure they are literals.

For example, these are the same:

    "Hello" " world"
    "Hello world"
2023-01-04 08:47:33 -07:00
Max Kellermann
e628c66f9d
#include cleanup (#10216)
Shift header include

In the C file, include the header first so missing #includes are
detected by the compiler, and use lighter header dependencies in the
header, to speed up compile times.
2023-01-04 13:24:28 +00:00
Remi Collet
55a88f36b6
add SensitiveParameter as known string and use it in arginfo 2022-07-18 11:43:33 +02:00
George Peter Banyard
0ae6a67550
Add true as a type (#8326)
RFC: https://wiki.php.net/rfc/true-type
2022-06-12 23:28:19 +01:00
George Peter Banyard
b40ae80804
Convert iterable into an internal alias for Traversable|array (#7309)
This does a compile time transformation of ``iterable`` into ``Traversable|array`` which simplifies some of the LSP variance handling.

The arginfo generation script from stubs is updated to produce a union type when it encounters the type ``iterable``
Extension functions which do not regenerate the arginfo, or write them manually are still supported by mimicking the compile time transformation while registering the function.

Type Reflection is preserved for single ``iterable`` (and ``?iterable``) to produce a ReflectionNamedType with name ``iterable``, however usage of ``iterable`` in union types will be converted to ``array|Traversable``
2022-06-07 13:35:34 +01:00
George Peter Banyard
c2547ab7dc
Add some const qualifiers in zend_string/hash (#8304)
Co-authored-by: Levi Morrison <morrison.levi@gmail.com>
2022-04-20 15:56:51 +01:00
Max Kellermann
b9e895bca0
Replace memcmp() with zend_string functions (#8216)
* ext/oci8: use zend_string_equals()

Eliminate duplicate code.

* main/php_variables: use zend_string_equals_literal()

Eliminate duplicate code.

* Zend/zend_string: add zend_string_equals_cstr()

Allows eliminating duplicate code.

* Zend, ext/{opcache,standard}, main/output: use zend_string_equals_cstr()

Eliminate duplicate code.

* Zend/zend_string: add zend_string_starts_with()

* ext/{opcache,phar,spl,standard}: use zend_string_starts_with()

This adds missing length checks to several callers, e.g. in
cache_script_in_shared_memory().  This is important when the
zend_string is shorter than the string parameter, when memcmp()
happens to check backwards; this can result in an out-of-bounds memory
access.
2022-03-31 16:27:58 +02:00
Dmitry Stogov
f583c4dfd2 Use 64-bit multiplication on 64-bit systems 2021-12-14 17:09:59 +03:00
Tyson Andre
024d5f4b63 Cache method overrides of ArrayAccess in zend_class_entry
Previously, code such as subclasses of SplFixedArray would check for method
overrides when instantiating the objects.

This optimization was mentioned as a followup to GH-6552
2021-12-04 11:35:38 -05:00
Christoph M. Becker
c0d890e918
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #74604: Out of bounds in php_pcre_replace_impl
2021-11-29 19:17:49 +01:00
Christoph M. Becker
60717fcd34
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #74604: Out of bounds in php_pcre_replace_impl
2021-11-29 19:17:16 +01:00
Christoph M. Becker
816aa20391
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74604: Out of bounds in php_pcre_replace_impl
2021-11-29 19:15:20 +01:00
Christoph M. Becker
712fc54e85
Fix #74604: Out of bounds in php_pcre_replace_impl
Trying to allocate a `zend_string` with a length only slighty smaller
than `SIZE_MAX` causes an integer overflow; we make sure that this
doesn't happen by catering to the maximal overhead of a `zend_string`.

Closes GH-7597.
2021-11-29 19:12:55 +01:00
Tyson Andre
fbdded1ff1 Use interned string for calling count() in Zend VM
Similar to f0dd79a7e4

Copied from GH-7695
2021-11-28 14:09:54 -05:00
Nikita Popov
f0dd79a7e4 Optimize ArrayAccess method lookup
While these currently aren't cached in the class entry, we can
at least save us a lowercasing and hash calculation of the method
name.
2021-11-28 13:06:17 +01:00
Nikita Popov
4a4ae45a0b Fix bug #81142 by adding zend_string_init_existing_interned()
Add a new interned string handler that fetches an interned string
if it exists, but does not create one if it does not (and instead
returns a non-interned string).

This fixes bug #81142, by preventing the creating of new interned
strings for unserialized array keys.

Closes GH-7360.
2021-08-12 11:57:50 +02:00
Christoph M. Becker
9f18bff6b4
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #74960: Heap buffer overflow via str_repeat
2021-07-21 15:36:16 +02:00
Christoph M. Becker
f03e7c845e
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74960: Heap buffer overflow via str_repeat
2021-07-21 15:33:17 +02:00
Christoph M. Becker
760ff841a1
Fix #74960: Heap buffer overflow via str_repeat
Trying to allocate a `zend_string` with a length only slighty smaller
than `SIZE_MAX` causes an integer overflow, so callers may need to
check that explicitly.  To make that easy in a portable way, we
introduce `ZSTR_MAX_LEN`.

Closes GH-7294.
2021-07-21 15:31:37 +02:00
Nikita Popov
a1c6ee2164 Convert error filename to zend_string
Error handling functions/callbacks now accept the error filename
as a zend_string* instead of a const char*.
2021-04-23 11:05:14 +02:00
Matt Brown
6cd0b48cac Implement never return type
The never type can be used to indicate that a function never
returns, for example because it always unwinds.

RFC: https://wiki.php.net/rfc/noreturn_type

Closes GH-6761.
2021-04-19 11:27:29 +02:00
Nikita Popov
4ce5d2ea88 Add known strings for jit autoglobals
We always create interned strings for all autoglobals anyway, so
we might as well add known strings to make them more widely usable.
2021-04-09 15:37:59 +02:00
Ilija Tovilo
269c8dac1d
Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00
Dmitry Stogov
0f6c00200b Speed up __sleep() and __wakeup() calls 2021-02-25 12:16:22 +03:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
205d209de9 PDO MySQL: Use mysqlnd column names
mysqlnd already creates interned zend_strings for us, so let's
make use of them.

This also required updating the PDO case changing code to work
with potentially shared strings. For the lowercasing, use the
optimized zend_string_tolower() implementation.
2020-12-16 15:17:13 +01:00
Nikita Popov
daf222c9f8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Handle memory limit error during string reallocation correctly
2020-09-03 09:51:54 +02:00