summaryrefslogtreecommitdiff
path: root/ext/spl
Commit message (Collapse)AuthorAgeFilesLines
* Change Zend Stream API to use zend_string* instead of char*.Dmitry Stogov2021-03-161-11/+11
| | | | | This allows to eliminate re-calculation of string lenght and hash value. See the detailed list of changes in UPGRADING.INTERNALS.
* Use spl_filesystem_object.file_name for SPL_FS_DIR as a cache and prevent ↵Dmitry Stogov2021-03-091-9/+14
| | | | multiple file name reconstruction.
* Cache haschildren/getchildren methods of recursive iterators.Dmitry Stogov2021-03-041-9/+26
|
* Switch to new ZPPDmitry Stogov2021-03-041-3/+5
|
* Merge branch 'PHP-8.0'Dmitry Stogov2021-03-021-1/+1
|\ | | | | | | | | * PHP-8.0: Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT)
| * Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT)Dmitry Stogov2021-03-011-1/+1
| |
* | Optimize out zend_strpprintf() usage for simple concationatonDmitry Stogov2021-02-261-6/+18
| |
* | Improve SPL directory and stat() cache using zend_srting* instead of char*Dmitry Stogov2021-02-262-196/+172
| |
* | Switch few functions useful in Symphony apps to new ZPP API.Dmitry Stogov2021-02-241-3/+3
| |
* | Fixed error messageDmitry Stogov2021-02-244-12/+12
| |
* | Fixed bug #80724Cameron Porter2021-02-234-4/+85
| | | | | | | | | | | | | | | | | | FilesystemIterator::FOLLOW_SYMLINKS is currently treated as a directory key mode flag, even though it does not change the way that the key during iteration is set. To address this, FOLLOW_SYMLINKS has been converted into an OTHER flag. Closes GH-6695.
* | Generate ext/spl class entries from stubsMáté Kocsis2021-02-1829-233/+843
| | | | | | | | Closes GH-6709
* | Merge branch 'PHP-8.0'Nikita Popov2021-02-152-19/+15
|\ \ | |/ | | | | | | | | * PHP-8.0: Fix leak when breaking out of FilesystemIterator Fixed bug #80600
| * Merge branch 'PHP-7.4' into PHP-8.0Nikita Popov2021-02-152-19/+15
| |\ | | | | | | | | | | | | * PHP-7.4: Fix leak when breaking out of FilesystemIterator
| | * Fix leak when breaking out of FilesystemIteratorNikita Popov2021-02-152-19/+15
| | | | | | | | | | | | | | | | | | | | | | | | We need to always destroy current, not just when iter.data is not set. Take this opportunity to clean up the iterator destructor code a bit, to remove redundant checks and incorrect comments.
* | | Deprecate passing null to non-nullable arg of internal functionNikita Popov2021-02-1111-26/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This deprecates passing null to non-nullable scale arguments of internal functions, with the eventual goal of making the behavior consistent with userland functions, where null is never accepted for non-nullable arguments. This change is expected to cause quite a lot of fallout. In most cases, calling code should be adjusted to avoid passing null. In some cases, PHP should be adjusted to make some function arguments nullable. I have already fixed a number of functions before landing this, but feel free to file a bug if you encounter a function that doesn't accept null, but probably should. (The rule of thumb for this to be applicable is that the function must have special behavior for 0 or "", which is distinct from the natural behavior of the parameter.) RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg Closes GH-6475.
* | | Merge branch 'PHP-8.0'Nikita Popov2021-02-114-8/+27
|\ \ \ | |/ / | | | | | | | | | * PHP-8.0: Fixed bug #80719
| * | Merge branch 'PHP-7.4' into PHP-8.0Nikita Popov2021-02-114-8/+27
| |\ \ | | |/ | | | | | | | | | * PHP-7.4: Fixed bug #80719
| | * Fixed bug #80719Nikita Popov2021-02-114-8/+23
| | |
* | | Sort some decls in spl_iterators.hLevi Morrison2021-02-111-21/+21
| | | | | | | | | | | | There are enough of them that sorting makes it a bit nicer.
* | | Remove useless zend_update_class_constants() callsDmitry Stogov2021-01-281-10/+0
| | |
* | | Fix proptable canonicalization bypass in ArrayObjectNikita Popov2021-01-262-174/+179
| | | | | | | | | | | | | | | | | | When an ArrayObject wraps an object, we should be using the proptable canonicalilzation rules, which require all keys to be strings.
* | | Add support for generating class entries from stubsMáté Kocsis2021-01-262-1/+4
| | | | | | | | | | | | | | | | | | Closes GH-6289 Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
* | | gen_stub: Also verify implementation-aliasNikita Popov2021-01-192-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | This makes --verify also check @implementation-alias. Failures are ignored using @no-verify instead. Some mistakes have been made that would have been caught by this... Closes GH-6615.
* | | Merge branch 'PHP-8.0'Nikita Popov2021-01-183-4/+4
|\ \ \ | |/ / | | | | | | | | | * PHP-8.0: SplFileObject::fgets() cannot return false
| * | SplFileObject::fgets() cannot return falseNikita Popov2021-01-183-4/+4
| | | | | | | | | | | | | | | spl_filesystem_file_read() is called with silent=0, so it will throw on failure.
* | | Replace zend_bool uses with boolNikita Popov2021-01-157-20/+20
| | | | | | | | | | | | | | | | | | | | | 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.
* | | Remove SEPARATE_ARG_IF_REF macroNikita Popov2021-01-142-22/+0
| | | | | | | | | | | | | | | | | | | | | The name doesn't correspond to what it does at all, and all the existing usages appear to be unnecessary. Usage of this macro can be replaced by ZVAL_DEREF + Z_TRY_ADDREF_P.
* | | Fix INDIRECT elements leaked by SPL __serialize implementationsNikita Popov2021-01-124-6/+6
| | |
* | | Remove some unnecessary zend_delete_global_variable usesNikita Popov2021-01-081-6/+2
| | |
* | | Fix use-after-scope in SplObjectStorage::unserialize()Nikita Popov2021-01-051-18/+8
| | | | | | | | | | | | | | | | | | | | | Introduced by the recent switch to a zend_object. Unserialize the object into a tmp_var to avoid leaving behind a stack reference. Fixes oss-fuzz #29271.
* | | Reduce memory usage of SplObjectStorageTyson Andre2021-01-043-72/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Track an 8-byte pointer as the key instead of 16-byte zval. (4 byte on 32-bit builds) The memory used for a set of 1 million objects decreased from 114 MiB to 106 MiB. Use the new `Z_PARAM_*` APIs to parse the `zend_object*` pointer directly Closes GH-6566
* | | Optimize SplFixedArray when magic methods aren't overriddenTyson Andre2021-01-041-29/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This decreases the memory usage of SplFixedArrays by 32 bytes per object on 64-bit systems (use 1 null pointer instead of 5 null pointers) If allocating a lot of arrays of size 1, memory usage was 19.44MiB before this change, and 16.24MiB after the change. Existing tests continue to pass. Subclassing SplFixedArray is already inefficient and rarely done. It checks for the existence of 5 methods every time a subclass is instantiated. (and has to switch back from C to the php vm to call those methods) Closes GH-6552
* | | Use Z_PARAM_OBJ macros when zval isn't neededTyson Andre2021-01-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some cases, like spl_object_id, the code is simpler but equally efficient after optimizations. In other cases, like get_mangled_object_vars(), the compiler can't infer that the object in the zval won't change. Closes GH-6567
* | | Remove superfluous return statement.George Peter Banyard2020-12-291-1/+0
| | |
* | | Remove redundant check in SplObjectStorage->countTyson Andre2020-12-291-9/+1
| | |
* | | Flesh out HashTable insertion APIsSara Golemon2020-12-011-6/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fills out the array/object-property insert helpers for zend_array, zend_object, and zend_reference. This adds the following matrix of 18 APIs add_next_index_T() add_index_T() add_assoc_T() add_assoc_T_ex() add_property_T() add_property_T_ex() Where T in array, object, reference Converted internal callsites currently doing an explicit object wrap.
* | Fix #62004: SplFileObject: fgets after seek returns wrong lineChristoph M. Becker2020-11-308-7/+51
| | | | | | | | | | | | | | | | | | | | | | | | As it is, `::seek(0)` sets the file pointer to the beginning of the file, but `::seek($n)` where `$n > 0` sets the file pointer to the beginning of the following line, having line `$n` already read into the line buffer. This is pretty inconsistent; we fix it by always seeking to the beginning of the line. We also add a test case for the duplicate bug #46569. Closes GH-6434.
* | Use separate directory in dit_004.phptNikita Popov2020-10-261-1/+15
| | | | | | | | | | Make sure the directory is not modified while we're iterating it, which may give unstable results.
* | Properly validate ArrayObject::asort() argumentNikita Popov2020-10-223-14/+13
| |
* | Add additional initialization checks to SplFileInfoNikita Popov2020-10-192-0/+34
| |
* | Update ext/spl parameter namesNikita Popov2020-10-0741-174/+176
| | | | | | | | Closes GH-6284.
* | Support GC for AppendIteratorNikita Popov2020-10-013-6/+10
| | | | | | | | | | This also requires adding GC support for ArrayIterator internal iterators.
* | Fix bug #65387Nikita Popov2020-10-012-0/+101
| | | | | | | | | | Add GC support to dual_it. This is still missing AppendIterator support.
* | Clean up spl_fixedarray.cLevi Morrison2020-09-271-138/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove inline. Remove old folding blocks. Convert an int usage to bool. Convert some uses of int and size_t into zend_long. This is incomplete because get_gc requires `int *n`, which should probably become zend_long or size_t eventually. Adds spl_fixedarray_empty to help enforce invariants. Adds spl_fixedarray_default_ctor. Documents some functions. Reworks spl_fixedarray_copy into two functions: - spl_fixedarray_copy_ctor - spl_fixedarray_copy_range I'm hoping to eventually export SplFixedArray for extensions to use directly, which is the motivation here.
* | Add option to print parameter name stats to gen_stubNikita Popov2020-09-241-1/+1
| |
* | Consistent error handling for fgetcsv/fputcsvNikita Popov2020-09-239-52/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Normalize the behavior between the file functions and those on SplFileObject. Be consistent about throwing regardless of whether the delimiter etc is empty or has too many characters. I don't think it's worthwhile to distinguish these cases. Back when we looked into this originally, there was some hope that we might want to add support for multiple-character delimiter etc, but after a cursory look, I really don't think this is going to happen (for fputcsv maybe, but for fgetcsv this just makes an already broken function much more complicated.) Closes GH-6188.
* | SplFixedArray is Aggregate, not IterableAlex Dowad2020-09-239-364/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One strange feature of SplFixedArray was that it could not be used in nested foreach loops. If one did so, the inner loop would overwrite the iteration state of the outer loop. To illustrate: $spl = SplFixedArray::fromArray([0, 1]); foreach ($spl as $a) { foreach ($spl as $b) { echo "$a $b"; } } Would only print two lines: 0 0 0 1 Use the new InternalIterator feature which was introduced in ff19ec2df3 to convert SplFixedArray to an Aggregate rather than Iterable. As a bonus, we get to trim down some ugly code! Yay!
* | Throw warning for failed object to int/float conversionNikita Popov2020-09-211-1/+1
| | | | | | | | | | | | We previously couldn't increase the error level here because it was coupled to comparison handling. This is no longer the case in PHP 8.
* | Fix a few Iterator signaturesMáté Kocsis2020-09-213-13/+16
| | | | | | | | Closes GH-6176