1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

238 Commits

Author SHA1 Message Date
Juan Morales
b80ffc5b2e Json last error msg/error message with location error (#20629)
This slightly extend error messages with locations taken from scanner / parser
2026-01-03 18:34:19 +01:00
Peter Kokot
c44834d8ad Trim trailing whitespace (#14721) 2024-06-29 18:41:45 +02:00
Arnaud Le Blanc
11accb5cdf Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Gina Peter Banyard
fd2d869642 Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Jakub Zelenka
53aa53f42f Introduce Zend guard recursion protection
This PR introduces a new way of recursion protection in JSON, var_dump
and friends. It fixes issue in master for __debugInfo and also improves
perf for jsonSerializable in some cases. More info can be found in
GH-10020.

Closes GH-11812
2023-08-24 13:03:14 +01:00
Jakub Zelenka
a225f6ab6b Merge branch 'PHP-8.2' 2023-05-13 18:54:16 +01:00
Jakub Zelenka
90553af15c Merge branch 'PHP-8.1' into PHP-8.2 2023-05-13 18:53:35 +01:00
Jakub Zelenka
e8a836eb39 Expose JSON internal function to escape string 2023-05-13 18:41:33 +01:00
Juan Morales
2e8699f6f2 RFC - json_validate() (#9399)
* Add `json_validate(string $json, int $depth = 512, int $flags = 0): bool` from https://wiki.php.net/rfc/json_validate
* In json_validate, use a different set of C no-op functions for creating/updating
   arrays/objects when validating while reusing the unmodified parser/scanner code
* Forbid unsupported flags in json_validate()
* Remove test of passing NULL as parameter (normal behavior of https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg for internal functions)

Co-authored-by: jcm <juan.carlos.morales@tradebyte.com>
2022-10-08 09:21:59 -04:00
Arnaud Le Blanc
4df3dd7679 Reduce memory allocated by var_export, json_encode, serialize, and other (#8902)
smart_str uses an over-allocated string to optimize for append operations. Functions that use smart_str tend to return the over-allocated string directly. This results in unnecessary memory usage, especially for small strings.

The overhead can be up to 231 bytes for strings smaller than that, and 4095 for other strings. This can be avoided for strings smaller than `4096 - zend_string header size - 1` by reallocating the string.

This change introduces `smart_str_trim_to_size()`, and calls it in `smart_str_extract()`. Functions that use `smart_str` are updated to use `smart_str_extract()`.

Fixes GH-8896
2022-07-08 14:47:46 +02:00
Máté Kocsis
c5ffa0a1a7 Declare ext/json constants in stubs (#8716) 2022-06-06 12:13:12 +02:00
Ilija Tovilo
54440fa6eb Merge branch 'PHP-8.1'
* PHP-8.1:
  Register JSON_ERROR_NON_BACKED_ENUM constant (#8285)
2022-03-31 14:31:43 +02:00
Ilija Tovilo
2145f80d4b Register JSON_ERROR_NON_BACKED_ENUM constant (#8285)
Fixes GH-8238
2022-03-31 14:31:17 +02:00
George Peter Banyard
ec53e17adf Use more appropriate types in JSON extension (#8194)
Mainly zend_result
2022-03-16 22:53:41 +00:00
KsaR
01b3fc03c3 Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +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
Máté Kocsis
98fb565c74 Generate class entries from stubs for another batch of extensions
Closes GH-6669
2021-02-08 19:53:55 +01: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
1b2aba285d Remove Z_PARAM separate params where they don't make sense
Separation can only possibly make sense for array parameters
(or something that can contain arrays, like zval parameters). It
never makes sense to separate a bool.

The deref parameters are also of dubious utility, but leaving them
for now.
2021-01-14 11:58:08 +01:00
Nikita Popov
aa0d886cbc Don't leak json error_code across requests 2020-10-22 12:42:09 +02:00
Max Semenik
2b5de6f839 Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
twosee
88355dd338 Constify char * arguments of APIs
Closes GH-5676.
2020-06-08 10:38:45 +02:00
Máté Kocsis
3fe49d81f8 Generate method entries from stubs for a couple of extensions
Closes GH-5368
2020-04-11 13:28:53 +02:00
Máté Kocsis
50765075db Improve some ValueError messages
Closes GH-5340
2020-04-06 10:41:01 +02:00
Máté Kocsis
5322de1ba8 Generate functions entries from stubs for another set of extensions
Closes GH-5351
2020-04-05 00:59:44 +02:00
Máté Kocsis
8f4f1dea34 Convert zend_parse_parameters_none() to fast ZPP
I've done the conversion in those extensions where fast ZPP is predominant.
2020-01-03 13:23:37 +01:00
Máté Kocsis
01a50778d1 Use RETURN_THROWS() after zend_throw_exception() in most of the extensions 2020-01-02 10:56:18 +01:00
Máté Kocsis
12ce73a5bb Use RETURN_THROWS() after zend_value_error() 2019-12-31 16:58:15 +01:00
Máté Kocsis
345703724c Use RETURN_THROWS() during ZPP in most of the extensions
Except for some bigger ones: reflection, sodium, spl
2019-12-31 11:46:11 +01:00
George Peter Banyard
734932ecbb Convert warnings to ValueError 2019-12-08 21:03:14 +01:00
Christoph M. Becker
49b98b4d5c Add arginfo stub for JsonSerializable 2019-10-05 11:10:30 +02:00
Gabriel Caruso
5d6e923d46 Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Craig Duncan
7e7eaa0eb2 Convert json functions arginfo to php stubs
Closes GH-4500
2019-08-10 16:04:30 +01:00
Peter Kokot
dee243d475 Bump PHP_JSON_VERSION to PHP_VERSION
Closes GH-4459
2019-07-24 22:19:33 +02:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Gabriel Caruso
1314f0fb3a Use int instead of long in protos 2018-02-23 11:06:20 +01:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Andrea Faulds
e823770515 Merge JSON_THROW_ON_ERROR 2017-10-22 19:41:23 +01:00
Jakub Zelenka
0f047f60f0 [ci skip] Remove CSV leftovers from json code - $Id$ 2017-07-16 15:51:39 +01:00
Jakub Zelenka
9c58822653 Introduce internal php_json_encode_ex to allow extensions setting depth 2017-07-16 15:47:23 +01:00
Jakub Zelenka
0d0f7cde8c Add JSON_INVALID_UTF8_SUBSTITUTE and JSON_INVALID_UTF8_IGNORE
It implements request #65082 and adds options for replacing resp.
ignoring invalid UTF-8 sequences for json_encode and json_decode.
2017-07-16 12:35:24 +01:00
Dmitry Stogov
9c2a1f52a5 Avoid useless dereferences and separations during paramter passing. 2017-06-19 12:55:59 +03:00
Sara Golemon
aa2282df21 Allow JSON_OBJECT_AS_ARRAY option to actually have meaning
Options can only be passed if $assoc is passed, but passing
assoc clobbers any attempt to pass JSON_OBJECT_AS_ARRAY as an
option.

Allow the option to occur in the options field by handling
"null" as default/use-options.
2017-03-17 15:36:24 -07:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Sara Golemon
6007eb7584 Use new param API in json 2016-12-31 08:35:07 -08:00
Anatol Belski
d61db8d602 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  remove TSRMLS_*
2016-11-22 00:32:42 +01:00
Anatol Belski
5e9b4c26a5 remove TSRMLS_* 2016-11-21 23:53:37 +01:00
Jakub Zelenka
f284479734 Merge branch 'PHP-7.0' into PHP-7.1 2016-11-20 20:38:34 +00:00
Jakub Zelenka
60574ea1ac Fix bug #73526 (php_json_encode depth issue) 2016-11-20 20:36:03 +00:00