1
0
mirror of https://github.com/php/php-src.git synced 2026-04-21 15:08:16 +02:00
Commit Graph

2582 Commits

Author SHA1 Message Date
Kamil Tekiela 6b1337b736 Fix typo [no-ci] 2021-07-30 13:58:28 +01:00
Andrii Dembitskyi d7b77a40e6 Fix SplFileObject::fseek() method description (#7321) 2021-07-30 13:50:43 +01:00
Nikita Popov 6d505d4445 Add RETURN/RETVAL_COPY_DEREF() macros
These were missing from the set...

I think quite a few of these usages don't actually need the DEREF,
but I've just kept things as is for now.
2021-07-22 09:44:19 +02:00
Máté Kocsis 23b1c4a982 Migrate to PHP-Parser 4.12.0 and regenerate some arginfos 2021-07-22 09:40:16 +02:00
Máté Kocsis 7a9a37d909 Actually, abstract methods don't have a body 2021-07-20 01:00:10 +02:00
Máté Kocsis fc0d8983d3 Fix some smaller formatting inconsistencies in stubs 2021-07-20 00:52:26 +02:00
Nikita Popov 814a932734 Add ZEND_ACC_NOT_SERIALIZABLE flag
This prevents serialization and unserialization of a class and its
children in a way that does not depend on the zend_class_serialize_deny
and zend_class_unserialize_deny handlers that will be going away
in PHP 9 together with the Serializable interface.

In stubs, `@not-serializable` can be used to set this flag.

This patch only uses the new flag for a handful of Zend classes,
converting the remainder is left for later.

Closes GH-7249.
Fixes bug #81111.
2021-07-19 15:59:11 +02:00
Máté Kocsis 75a678a7e3 Declare tentative return types for Zend (#7251)
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 13:44:20 +02:00
Máté Kocsis b3e0888129 Declare tentative return types in ext/spl - part 3 (#7239) 2021-07-16 12:09:05 +02:00
Máté Kocsis fae7cec6fb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix some more ext/spl return types
2021-07-15 16:41:52 +02:00
Máté Kocsis fc6656e0ac Fix some more ext/spl return types
Closes GH-7242
2021-07-15 16:40:29 +02:00
Nikita Popov c2b29308ff Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix RecursiveIteratorIterator segfault for invalid aggregate
2021-07-15 13:11:39 +02:00
Nikita Popov b9ae73eee9 Fix RecursiveIteratorIterator segfault for invalid aggregate
The code was assuming that the returned value is an object.
Reuse the logic from IteratorIterator.
2021-07-15 13:11:28 +02:00
Nikita Popov f556a30b92 Narrow ArrayIterator::key() return type
This can only return string|int|null, not any key type.
2021-07-15 11:03:50 +02:00
Nikita Popov 11f62c989e Revert "IteratorIterator::getInnerIterator() can't return null"
This reverts commit c252420d08.

This (currently) does not hold for invalid AppendIterators,
revert for now.
2021-07-15 11:01:28 +02:00
Nikita Popov c252420d08 IteratorIterator::getInnerIterator() can't return null
If ther IteratorIterator is initialized (which we check), then
zobject cannot be undef and the return value cannot be null.
2021-07-15 10:42:34 +02:00
Máté Kocsis 6d805ed275 Declare tentative return types for ext/spl - part 2
Closes GH-7235
2021-07-14 15:19:51 +02:00
Nikita Popov 42cb5b5fa8 Throw from MultipleIterator::key/current() for invalid iterator
Calling current()/key() on an invalid iterator is an error
condition. Throw instead of returning false.
2021-07-14 12:40:45 +02:00
Máté Kocsis 1bd779c231 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix some return types in ext/spl
2021-07-14 12:38:17 +02:00
Nikita Popov 58f3f751ca Throw from SplObjectStorage::current() for invalid iterator
Accessing key()/current() on an invalid iterator is an error
condition. Throw instead of returning null.
2021-07-14 12:34:39 +02:00
Máté Kocsis d618ed0a2d Fix some return types in ext/spl
Closes GH-7237
2021-07-14 12:33:14 +02:00
Máté Kocsis c6357b804e Declare tentative return types for ext/spl - part 1 (#7115) 2021-07-13 13:04:45 +02:00
Máté Kocsis 0192fd20cc Merge branch 'PHP-8.0' 2021-07-12 10:32:07 +02:00
Máté Kocsis 80e5ad5a29 Various ext/spl stub fixes
Closes GH-7215
2021-07-12 10:27:05 +02:00
Nikita Popov 8a67dfd16b Ensure correct return type from SplFileObject::getCurrentLine()
This is necessary to maintain return type consistency once
tentative return types are added.
2021-07-06 14:32:39 +02:00
Nikita Popov 188b1d4c7c SplFileObject::fgetcsv(): Consistently return false on failure
Both the documentation and the stubs state that this method is
supposed to return false on failure. However, if the line read
(rather than the getcsv operation) fails, it would incorrectly
return null instead.
2021-07-06 14:24:26 +02:00
Nikita Popov ac7a28189a Add initialization checks to DirectoryIterator methods 2021-07-06 13:08:53 +02:00
Nikita Popov 1a81251dbb Use some early returns in spl_directory 2021-07-06 12:37:22 +02:00
Nikita Popov bb97c947e3 Slightly clarify current_zval handling in spl_directory
This used COPY_DEREF in some places where references can't occur.
2021-07-06 11:37:42 +02:00
Nikita Popov 54c4c7d747 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ArrayObject::exchangeArray() return type
2021-07-06 10:52:46 +02:00
Nikita Popov bcefc31e4e Fix ArrayObject::exchangeArray() return type
This method cannot return null.
2021-07-06 10:52:08 +02:00
Nikita Popov f7b1238f13 Handle out of order destruction of RecursiveIteratorIterator 2021-07-02 17:14:00 +02:00
Nikita Popov c2a8934b86 Fix typo in RecursiveIteratorIterator get_gc handler 2021-07-02 16:11:48 +02:00
Nikita Popov b65380286a Avoid null pointer arithmetic in SplFixedArray
Fixes bug62904.phpt under clang ubsan.
2021-07-02 15:39:22 +02:00
Patrick Allaert aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
George Peter Banyard e9e06279c1 Refactor SplFixedArray (#7168)
* Move spl_offset_convert_to_long() to spl_fixedarray.c

It is only used there, which explains its weird offset semantics

* Refactor SplFixedArray offset handling
- Implement warning for resource type
- Throw a proper TypeError instead of a RuntimeException

* Use a proper Error to signal that [] cannot be used with SplFixedArray

* Refactor SplFixedArray has_dimension helper

* Drop some ZPP tests
2021-06-18 15:22:52 +01:00
George Peter Banyard ff1145943f Refactor spl_array_has_dimension_ex()
Use early returns instead of else blocks
Add comments, especially to explain why we need a check_empty == 2 check
2021-06-18 00:47:04 +01:00
Nikita Popov 71fb83567f Fix bug #80945: Don't throw undefined array key warning in ArrayObject unset()
This makes the behavior of ArrayObject the same as far plain
arrays, which don't throw a warning when unsetting a key that
already doesn't exit.
2021-06-14 10:14:38 +02:00
Nikita Popov 805471e86b Fix bug #81112: Implement JsonSerializable for SplFixedArray
This returns an array for SplFixedArray JSON encoding, which
is more appropriate than an object with integer string keys.

Closes GH-7117.
2021-06-14 10:07:45 +02:00
Nikita Popov 39131219e8 Migrate more SKIPIF -> EXTENSIONS (#7139)
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
2021-06-11 12:58:44 +02:00
Nikita Popov 9d2a466c4b Remove explicit assignments of zend_objects_destroy_object
This is the default handler, no need to set it explicitly. This
makes it easier to see which objects really have a custom dtor_obj.
2021-06-09 11:29:50 +02:00
Nikita Popov 9c18138a71 Support GC for RecursiveIteratorIterator
And move its dtor_obj handler into free_obj, so that cycle leaks
get automatically detected.
2021-06-09 11:25:50 +02:00
Nikita Popov 0643301c75 Don't perform recursive get_gc call
On further consideration, we should be making use of the fact
that zend_object_iterator is also a zend_object here, and let
GC handle the get_gc call on it. Calling get_gc recursively like
this is generally not safe, because there is only one gc_buffer.

This also happens to be much simpler...
2021-06-09 11:15:59 +02:00
Nikita Popov 67440dd695 Null out member after releasing
Missed this when changing from zval -> zend_string.
2021-06-09 10:52:27 +02:00
Nikita Popov b2cf198733 Use zend_string* for RecursiveTreeIterator prefixes
We don't perform any append operations on these strings, they
are fixed. Use zend_string* rather than smart_str for them.
2021-06-09 10:49:59 +02:00
Nikita Popov 6b9ffaff56 Simplify string management in RecursiveTreeIterator
Make use of zend_string rather than zval to clean up the
implementation.
2021-06-09 10:38:58 +02:00
Nikita Popov d7eea8e1be Store cached string as zend_string
This makes the code a bit simpler.
2021-06-09 10:15:36 +02:00
Nikita Popov 88c57df53d Remove dual_it dtor, add more GC roots
Move the dual_it_free call from the dtor_obj into the free_obj
handler, allowing us to drop the dtor_obj handler entirely. This
exposes another leak in bug65387.phpt, which is addressed by
adding more GC roots in the get_gc handler.
2021-06-09 10:04:43 +02:00
Nikita Popov 15fafcd664 Expose inner dual_it iterator to GC
Moving the zend_iterator_dtor from dual_it_dtor to dual_it_free_storage
exposed this GC leak in an existing test. Forward the result of the
iterator get_gc to the dual_it get_gc.
2021-06-08 16:55:22 +02:00
Ayesh Karunaratne b8e380ab09 Update deprecation message for incompatible float to int conversion
Updates the deprecation message for implicit incompatible float to int conversion from:

```
Implicit conversion from non-compatible float %.*H to int in %s on line %d
```

to

```
Implicit conversion from float %.*H to int loses precision in %s on line %d
```

Related: #6661
2021-06-07 14:36:11 +02:00