Re: [PHP-DEV] Feedback for nullc Idea

2025-03-24 Thread Aimeos | Norbert Sendetzky
On 23.03.25 19:37, Rowan Tommins [IMSoP] wrote: I'm sympathetic to the problem you're trying to solve - the precedence of ?? isn't always helpful - but I'm not sure I like the proposed solution, for 3 reasons. 1) The name "nullc" is over-shortened and cryptic. The "c" looks almost like an acc

Re: [PHP-DEV] Two new functions array_first() and array_last()

2023-10-17 Thread Aimeos | Norbert Sendetzky
On 17.10.23 17:16, Ken Guest wrote: Having array_value_first and array_value_last to match the existing array_key_first and array_key_last functions make sense, and would seem to me to be more intuitive than function names that would not match that scheme. Please don't make things more complica

[PHP-DEV] Re: Pass file handle in XMLReader

2020-12-04 Thread Aimeos | Norbert Sendetzky
Am 04.12.20 um 13:23 schrieb Christoph M. Becker: > For clarity, it might be preferable to introduce a new static creation > method for this. The implementation could probably use > xmlReaderForIO()[1], instead of xmlReaderForFile(). Wouldn't xmlReaderForFd() be more suitable or is this only for

[PHP-DEV] Pass file handle in XMLReader

2020-12-02 Thread Aimeos | Norbert Sendetzky
Hi internals The XMLReader object only allows a file name in the constructor and the open() method. While this is OK most of the time, files stored at cloud services not accessible via an URL must be downloaded first. For big files (e.g 100MB to 1GB and more), this requires a lot of time and resou

[PHP-DEV] Re: PHP 8 is_file/is_dir and imagecreatefromstring()

2020-12-02 Thread Aimeos | Norbert Sendetzky
Am 01.12.20 um 18:24 schrieb Christoph M. Becker: > On 01.12.2020 at 18:18, Aimeos | Norbert Sendetzky wrote: > >> PHP 8 is stricter in checking input data then PHP 7. This is good but >> has some side effects for is_file(), is_dir() and similar functions when >> inva

Re: [PHP-DEV] Re: PHP 8 is_file/is_dir input handling

2020-12-01 Thread Aimeos | Norbert Sendetzky
Am 01.12.20 um 19:23 schrieb G. P. B.: > So why having is_file()/is_dir() throw a warning for the past 8 years > (since PHP 5.4) a non-issue? Because by that logic it shouldn't > have been emitting warnings either. > Would it have been fine if this would have been a TypeError as it was > originally

Re: [PHP-DEV] Re: PHP 8 is_file/is_dir input handling

2020-12-01 Thread Aimeos | Norbert Sendetzky
Am 01.12.20 um 18:47 schrieb G. P. B.: >>> Or is_file could check for it, handle it gracefully, and be a safe >>> function to call without worrying about this undocumented edge case. >> > Apologize my email client sent by mistake: > But this has always generated a warning see: > https://3v4l.org/7E

[PHP-DEV] Re: PHP 8 is_file/is_dir input handling

2020-12-01 Thread Aimeos | Norbert Sendetzky
Am 01.12.20 um 18:24 schrieb Christoph M. Becker: >> In PHP 7, this returns FALSE: >> >> php -r 'var_dump(is_file("ab\0c"));' >> >> In PHP 8, the same code throws a ValueException. Problem is now that >> it's not possible to check upfront if the passed argument is a valid >> path to avoid the excep

[PHP-DEV] PHP 8 is_file/is_dir input handling

2020-12-01 Thread Aimeos | Norbert Sendetzky
Hi internals PHP 8 is stricter in checking input data then PHP 7. This is good but has some side effects for is_file(), is_dir() and similar functions when invalid paths are passed for checking. In PHP 7, this returns FALSE: php -r 'var_dump(is_file("ab\0c"));' In PHP 8, the same code throws a

Re: [PHP-DEV] [RFC][DISCUSSION] Change var_export() array syntax to use short hand arrays

2020-03-30 Thread Aimeos | Norbert Sendetzky
Am 30.03.20 um 16:39 schrieb Sara Golemon: >> I don't see a reason not to follow with the short array syntax; the only >>> expectation of people using var_export(), AFAIK, is to get valid PHP code; >>> they don't care about the syntax, >> > If "they" don't care about syntax, then why do you? The o

Re: [PHP-DEV] [RFC] Adding a "Stringable" interface to PHP 8

2020-02-11 Thread Aimeos | Norbert Sendetzky
Am 11.02.20 um 14:11 schrieb Michał Brzuchalski: >>> Traversable, Serializable, Countable, Throwable, JsonSerializable >>> all are related to some special engine behavior, which this ones also is. >> >> But one could argue that "string" is not a verb like "traverse", >> "serialize", "count", "throw

Re: [PHP-DEV] [RFC] Adding a "Stringable" interface to PHP 8

2020-02-11 Thread Aimeos | Norbert Sendetzky
Am 11.02.20 um 12:58 schrieb Nikita Popov: > Just so someone has mentioned it... is "Stringable" really the best name > for this interface? Reddit really didn't like it ;) Some possible > alternatives: ToString, HasToString, CastsToString. I would vote for "Stringable" because PHP already has inte

Re: [PHP-DEV] Re: [RFC] "arrayable" pseudo type hint

2020-02-04 Thread Aimeos | Norbert Sendetzky
Am 04.02.20 um 19:17 schrieb Rowan Tommins: > I think Larry's point was that the flexibility of PHP's array type makes it > really hard to pin down whether a given object is "array-like" or not, and > which attributes a particular function actually cares about. What else besides array access, coun

Re: [PHP-DEV] Re: [RFC] "arrayable" pseudo type hint

2020-02-04 Thread Aimeos | Norbert Sendetzky
Am 04.02.20 um 18:18 schrieb Larry Garfield: >> interface Arrayable extends ArrayAccess, Countable, Traversable >> { >> public function toArray() : array; >> } >> >> Then, methods signatures can support array and Array-like objects: >> >> function useArrayable( array|Arrayable $arg ) : array|Ar

Re: [PHP-DEV] [RFC - discussion] __toArray()

2020-02-04 Thread Aimeos | Norbert Sendetzky
Am 04.02.20 um 14:43 schrieb Marco Pivetta: >> I think we can't classify it as BC break, because no existing code >> implements __toArray at the moment, and hence it will not fail when this >> feature is introduced and code gets upgraded to newer versions. > > It is a BC break because it changes t

[PHP-DEV] Re: [RFC] "arrayable" pseudo type hint

2020-02-04 Thread Aimeos | Norbert Sendetzky
a magic __toArray() method, even if this would be easier for developers in this case. If union data types are available and "iterable" is implemented as alias, an alias "arrayable" for "array|Arrayable" may be added as well. Am 19.11.19 um 23:21 schrieb Aimeos | No

Re: [PHP-DEV] [RFC] "arrayable" pseudo type hint

2019-11-24 Thread Aimeos | Norbert Sendetzky
> Since PHP 7.1, there's the "iterable" pseudo type hint that matches > "array" or "Traversable". > > PHP frameworks would profit from support of an "arrayable" pseudo type > hint that matches "array" and all objects that can be used like arrays. > > For that, "arrayable" objects have to implemen

[PHP-DEV] Extend ArrayObject class

2019-11-24 Thread Aimeos | Norbert Sendetzky
The ArrayObject class is only rarely used at the moment due to a lack for almost all array_* functions beside the sort functions. Currently implemented by ArrayObject: https://www.php.net/manual/en/class.arrayobject.php Missing methods that would be most useful: array_​chunk array_​column array_​

[PHP-DEV] [RFC] "arrayable" pseudo type hint

2019-11-19 Thread Aimeos | Norbert Sendetzky
Since PHP 7.1, there's the "iterable" pseudo type hint that matches "array" or "Traversable". PHP frameworks would profit from support of an "arrayable" pseudo type hint that matches "array" and all objects that can be used like arrays. For that, "arrayable" objects have to implement these interf

Re: [PHP-DEV] Concept: "arrayable" pseudo type and \Arrayable interface

2019-11-17 Thread Aimeos | Norbert Sendetzky
>>> And if necessary, we can convert them to native arrays: >>> >>> if( $arrayable instanceof \Arrayable ) { >>>$arrayable = $arrayable->toArray(); >>> } >> >> Also the toArray() should be called when an Arrayable is cast to an array: >> (array)$arrayable. >> >> And shouldn’t the toArray match

[PHP-DEV] Concept: "arrayable" pseudo type and \Arrayable interface

2019-11-17 Thread Aimeos | Norbert Sendetzky
Since PHP 7.1 there's the "iterable" pseudo type hint that matches "array" and "Traversable". PHP frameworks would profit from support of an "arrayable" pseudo type hint that matches "array" and all objects that implements "Traversable", "ArrayAccess" and "Countable". Thus, we could pass arrays o