Re: [PHP-DEV] New functions: string_starts_with(), string_ends_with()

2017-07-31 Thread Michał Brzuchalski
Hi Andreas, 2017-08-01 6:57 GMT+02:00 Andreas Hennings : > Hello list, > a quite common use case is that one needs to find out if a string > $haystack begins or ends with another string $needle. > Or in other words, if $needle is a prefix or a suffix of $haystack. > > One prominent example would

[PHP-DEV] New functions: string_starts_with(), string_ends_with()

2017-07-31 Thread Andreas Hennings
Hello list, a quite common use case is that one needs to find out if a string $haystack begins or ends with another string $needle. Or in other words, if $needle is a prefix or a suffix of $haystack. One prominent example would be in PSR-4 or PSR-0 class loaders. Maybe the use case also occurs whe

Re: [PHP-DEV] json_encode() / json_decode() warnings

2017-07-31 Thread Andrea Faulds
Jakub Zelenka wrote: On Sat, Jul 29, 2017 at 7:10 PM, Niklas Keller wrote: Andrea Faulds schrieb am Sa., 29. Juli 2017, 18:55: Hi Craig, Craig Duncan wrote: On 29 July 2017 at 15:16, Andrea Faulds wrote: Could we not simply make it a flag? e.g. $bar = json_encode($foo, JSON_THROW_

[PHP-DEV] NEUTRAL Benchmark Results for PHP Master 2017-07-30

2017-07-31 Thread lp_benchmark_robot
Results for project PHP master, build date 2017-07-30 19:22:35-07:00 commit: e6bfbb6 previous commit:f9c3ee9 revision date: 2017-07-30 22:01:31+02:00 environment:Haswell-EP cpu:Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB

Re: [PHP-DEV] [Request][Discussion] Introduce interfaces PDOInterface and PDOStatementInterface

2017-07-31 Thread Andrew Nester
> On Jul 31, 2017, at 5:54 PM, Johannes Schlüter wrote: > > On Mo, 2017-07-31 at 14:49 +0300, Andrew Nester wrote: >> That’s actually the thing that you can’t use >> PDO::ATTR_STATEMENT_CLASS with persistent PDO. > > The actually question is: Why not? - From a quick glance on the code I > see n

Re: [PHP-DEV] [Request][Discussion] Introduce interfaces PDOInterface and PDOStatementInterface

2017-07-31 Thread Johannes Schlüter
On Mo, 2017-07-31 at 14:49 +0300, Andrew Nester wrote: > That’s actually the thing that you can’t use > PDO::ATTR_STATEMENT_CLASS with persistent PDO. The actually question is: Why not? - From a quick glance on the code I see no obvious reason. In speculation I assume the implementor thought "Well

Re: [PHP-DEV] [Request][Discussion] Introduce interfaces PDOInterface and PDOStatementInterface

2017-07-31 Thread Andrew Nester
> On Jul 31, 2017, at 2:59 PM, Dan Ackroyd wrote: > > On 31 July 2017 at 12:49, Andrew Nester wrote: >> >> To make it possible to have persistent PDO with custom PDOStatement you >> should have: >> >> 1) custom `CustomPDO implements PDOInterface` which will be somewhat proxy >> to PDO insta

Re: [PHP-DEV] [Request][Discussion] Introduce interfaces PDOInterface and PDOStatementInterface

2017-07-31 Thread Dan Ackroyd
On 31 July 2017 at 12:49, Andrew Nester wrote: > > To make it possible to have persistent PDO with custom PDOStatement you > should have: > > 1) custom `CustomPDO implements PDOInterface` which will be somewhat proxy to > PDO instance > 2) custom `CustomPDOStatement implements PDOStatementInterfa

Re: [PHP-DEV] [Request][Discussion] Introduce interfaces PDOInterface and PDOStatementInterface

2017-07-31 Thread Andrew Nester
> On Jul 31, 2017, at 2:17 PM, Dan Ackroyd wrote: > > On 31 July 2017 at 08:21, Andrew Nester wrote: >> >> when we are using persistent PDO we can’t use PDO::ATTR_STATEMENT_CLASS and >> return our custom PDOStatement class >> >> But just implementing PDOInterface and PDOStatementInterface wi

Re: [PHP-DEV] [Request][Discussion] Introduce interfaces PDOInterface and PDOStatementInterface

2017-07-31 Thread Andrew Nester
That’s actually the thing that you can’t use PDO::ATTR_STATEMENT_CLASS with persistent PDO. To make it possible to have persistent PDO with custom PDOStatement you should have: 1) custom `CustomPDO implements PDOInterface` which will be somewhat proxy to PDO instance 2) custom `CustomPDOStatem

Re: [PHP-DEV] [Request][Discussion] Introduce interfaces PDOInterface and PDOStatementInterface

2017-07-31 Thread Dan Ackroyd
On 31 July 2017 at 08:21, Andrew Nester wrote: > > when we are using persistent PDO we can’t use PDO::ATTR_STATEMENT_CLASS and > return our custom PDOStatement class > > But just implementing PDOInterface and PDOStatementInterface will allow us to > implement > this and have proper type hints in

Re: [PHP-DEV] [Request][Discussion] Introduce interfaces PDOInterface and PDOStatementInterface

2017-07-31 Thread Andrew Nester
Yes, sure. Good example has been provided in related issue in bug tracker. Assume we are using persistent PDO and want to handle long running processes and add some logic when executing queries / connections (for instance logging). It would require your custom classes deriving from PDO and PDOS