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

31 Commits

Author SHA1 Message Date
Calvin Buckley
76791e90b9 Use win32 glob implementation on all platforms (#18164)
* Move glob to main/ from win32/

In preparation to make the Win32 reimplementation the standard
cross-platform one. Currently, it doesn't do that and just passes
through the original glob implementation. We could consider also having
an option to use the standard glob for systems that have a sufficient
one.

* Enable building with win32 glob on non-windows

Kind of broken. We're namespacing the function and struct, but not yet
the GLOB_* defines. There are a lot of places callers check if i.e.
NOMATCH is defined that would likely become redundant.

Currently it also has php_glob and #defines glob php_glob (etc.) - I
suspect doing the opposite and changing the callers would make more
sense, just doing MVP to geet it to build (even if it fails tests).

* Massive first pass at conversion to internal glob

Have not tested yet. the big things are:

- Should be invisible to userland PHP code.
- A lot of :%s/GLOB_/PHP_GLOB_/g; the diff can be noisy as a result,
  especially in comments.
- Prefixes everything with PHP_ to avoid conflicts with system glob in
  case it gets included transitively.
- A lot of weird shared definitions that were sprawled out to other
  headers are now included in php_glob.h.
- A lot of (but not yet all cases) of HAVE_GLOB are removed, since we
  can always fall back to php_glob.
- Using the system glob is not wired up yet; it'll need more shim
  ifdefs for each flag type than just glob_t/glob/globfree defs.

* Fix inclusion of GLOB_ONLYDIR

This is a GNU extension, but we don't need to implement it, as the GNU
implementation is flawed enough that callers have to manually filter it
anyways; just provide a stub definition for the constant.

We could consideer implementing this properly later. For now, fixes the
basic glob constant tests.

* Remove HAVE_GLOBs

We now always have a glob implementation that works. HAVE_GLOB should
only be used to check if we have a system implementation, for if we
decide to wrap the system implementation instead.

* We don't need to care about being POSIXly correct for internal glob

* Check for reallocarray

Ideally temporary until GH-17433.

* Forgot to move this file from win32/ to main/

* Check for issetugid (BSD function)

* Allow using the system glob with --enable-system-glob

* Style fix after removing ifdef

* Remove empty case for system glob
2025-05-20 16:20:59 -03:00
Kamil Tekiela
bf5e6c5f2d SplFileObject::fwrite $length param nullable (#17242) 2024-12-23 00:54:24 +01:00
DanielEScherzer
2501cad25a Stubs and generated arginfo: remove tentative returns from final methods (#16213)
A tentative return type is used to allow userland code that overrides a method
to not include a typehint without a fatal error; this is inapplicable to final
methods (including all methods of final classes), which cannot be overridden.
Remove the tentative return declarations, and update the build script to
complain about future additions.
2024-10-04 07:43:59 +02:00
Tim Düsterhus
29f98e7485 Replace @deprecated by #[\Deprecated] for internal functions / class constants (#14750)
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-07-10 16:47:31 +02:00
Jorg Adam Sowa
f0757100a4 Typed constants in SPL extension (#12358) 2023-10-07 13:14:57 +01:00
George Peter Banyard
6e87485d3c Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-9883  SplFileObject::__toString() reads next line
2022-11-22 12:26:03 +00:00
George Peter Banyard
6fbf81c674 Fix GH-9883 SplFileObject::__toString() reads next line
We need to overwrite the __toString magic method for SplFileObject, similarly to how DirectoryIterator overwrites it
Moreover, the custom cast handler is useless as we define __toString methods, so use the standard one instead.

Closes GH-9912
2022-11-22 12:21:14 +00:00
Máté Kocsis
b73f139c70 Declare ext/spl constants in stubs (#9226) 2022-08-02 16:37:12 +02:00
George Peter Banyard
dbf1cafd77 Remove internal usage of SplFileInfo::_bad_state_ex() method (#8318)
* Use standard VM handling instead
 * Deprecate the method as it is now useless
2022-06-09 13:24:58 +01:00
George Peter Banyard
8dbfb15f7c Use more specific return types in SPL 2022-04-11 14:04:37 +01:00
Nikita Popov
d0a0518798 Make DirectoryIterator current() / key() return types tentative
Fixes GH-8192.
2022-03-12 17:32:44 +01: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
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
ac7a28189a Add initialization checks to DirectoryIterator methods 2021-07-06 13:08:53 +02:00
Cameron Hall
5b29eba7ca Fix #42357: fputcsv() has an optional parameter for line endings
fputcsv does not terminate lines correctly as per RFC 41801[1]. After adding a new parameter fputcsv may now use a user defined line ending,. In order to maintain backwards compatibility fputcsv() still terminates lines with "\n" by default.

Also fixes: #46367[2], #62770[3]
Ref: #42357[4]

[1] <https://tools.ietf.org/html/rfc4180>
[2] <https://bugs.php.net/bug.php?id=46367>
[3] <https://bugs.php.net/bug.php?id=62770>
[4] <https://bugs.php.net/bug.php?id=42357>
2021-03-29 13:34:38 +01:00
Máté Kocsis
4f4c031f62 Generate ext/spl class entries from stubs
Closes GH-6709
2021-02-18 13:01:51 +01:00
Nikita Popov
f2364f316d SplFileObject::fgets() cannot return false
spl_filesystem_file_read() is called with silent=0, so it will
throw on failure.
2021-01-18 16:47:21 +01:00
Nikita Popov
68195bd481 Update ext/spl parameter names
Closes GH-6284.
2020-10-07 12:26:46 +02:00
Máté Kocsis
64af12d13b Add support for @implementation-alias in stubs
Closes GH-6170
2020-09-21 10:08:45 +02:00
Máté Kocsis
de912821e0 Display string default values in stubs more uniformly
Settling on using quoted string
2020-09-16 21:27:01 +02:00
Máté Kocsis
c76910cd96 Display types in stubs more uniformly
In preparation for generating method signatures for the manual.

This change gets rid of bogus false|null return types, a few unnecessary trailing backslashes, and settles on using ? when possible for nullable types.
2020-09-16 21:19:36 +02:00
Máté Kocsis
628db3f3b5 Fix UNKNOWN default values in various extensions
Closes GH-6075
2020-09-07 19:02:02 +02:00
Nikita Popov
07539685b9 Return empty string from SplFileInfo::getPathname()
Instead of false. This is consistent with how other methods like
SplFileInfo::getPath() behave. It's also a requirement before
SplFileInfo::__toString() calls SplFileInfo::getPathname() and
needs to return a string.
2020-08-14 11:09:30 +02:00
Máté Kocsis
046cc5e4c2 Add another round of missing parameter types to stubs
Closes GH-5950
2020-08-07 16:48:45 +02:00
Máté Kocsis
d7f7080bb5 Generate methods entries from stubs for ext/spl
Closes GH-5458
2020-04-25 23:54:56 +02:00
Christoph M. Becker
9809713844 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #69264: __debugInfo() ignored while extending SPL classes
2020-04-06 12:04:12 +02:00
Nikita Popov
2bcc4ab8f4 Verify that all stubs have a return type 2020-04-03 17:59:30 +02:00
Máté Kocsis
66fc55642c Add stubs for SplFileInfo et al.
Closes GH-5287
2020-03-23 13:36:17 +01:00