Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-04 Thread Josh Bruce
> While I understand the proposed feature is opt-int it introduces more magic > that can be solved using more verbose and IMO cleaner solutions. Understood and appreciate the position. > This is somehow confusing, why is the $response storing object ref is ok > while inclining the new object crea

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-03 Thread Michał Marcin Brzuchalski
> > if ($response->getStatusCode() > 199 and $response->getStatusCode() < 300) > { > // do something with “true” - which has a range of 100 possibilities at > a granular level, which we could respond to differently - possible to > interact with $response > > } > // do something with “false” - whi

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-03 Thread Josh Bruce
> while declaring an object falsifiable changes the semantics of `if ($obj)`. Got me thinking, appreciate that. In PHP: false == empty == null (Originally the RFC was geared toward data objects being able to natively express emptiness when passed to empty() - might be beneficial for the S

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-03 Thread Claude Pache
> Le 3 nov. 2022 à 02:51, Josh Bruce a écrit : > > Similar to: > > function x(?SomeType $arg): ?SomeOtherType > > Instead of: > > function x(SomeType|null $arg): SomeType|null > > Both are the same thing under the hood. The big difference between `?SomeType` shortcut and falsifiable object

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-02 Thread Josh Bruce
Thank you all for the engagement so far. (Note: All scalar types and one compound type can be cast as true or false natively - of the scalar and compound types, callable and object are the only two with no, native false representation.) > Have you tried not initializing invalid objects? This co

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-02 Thread Jordan LeDoux
On Wed, Nov 2, 2022 at 1:12 AM Michał Marcin Brzuchalski < michal.brzuchal...@gmail.com> wrote: > Hi Josh, > > Have you tried not initializing invalid objects? This could help you. > Also that sounds more logical to me as I don't see any reasons to > initialize invalid objects if it's a matter of

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-02 Thread Marco Pivetta
On Wed, 2 Nov 2022 at 18:51, Claude Pache wrote: > > > > Le 2 nov. 2022 à 09:12, Michał Marcin Brzuchalski < > michal.brzuchal...@gmail.com> a écrit : > > > > P.S. I don't see it feasible to have objects that evaluate false in > > logical expressions. > > For better or for worse (IMHO, for worse)

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-02 Thread Claude Pache
> Le 2 nov. 2022 à 09:12, Michał Marcin Brzuchalski > a écrit : > > P.S. I don't see it feasible to have objects that evaluate false in > logical expressions. For better or for worse (IMHO, for worse), `SimpleXMLElement` instances representing attributeless empty elements are already falsy,

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-11-02 Thread Michał Marcin Brzuchalski
Hi Josh, pon., 31 paź 2022 o 20:38 Josh Bruce napisał(a): > Hello Interntals, > > Someone reached out to me outside of internals regarding the RFC I > submitted on being able to declare objects falsifiable, so, I decided to > update and re-enter the fray. > > I’ve updated the references section

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-10-31 Thread Marco Pivetta
Since this topic fits like a glove, just dropping the "why I don't use `__toString()`" argument here: https://github.com/ShittySoft/symfony-live-berlin-2018-doctrine-tutorial/pull/3#issuecomment-460085493 A falsifiable object is worse than `__toString()` in this context, IMO. Marco Pivetta https

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2022-10-31 Thread Josh Bruce
Hello Interntals, Someone reached out to me outside of internals regarding the RFC I submitted on being able to declare objects falsifiable, so, I decided to update and re-enter the fray. I’ve updated the references section as many of the RFCs that were under discussion at the time have since

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-09-26 Thread Josh Bruce
Hey Internals, So, I received a message that said of the mail I should have received from internals bounced; so, this is part test and part update. I’ve started mapping out call paths in the project that brought this concept to light. The project, Shoop, never uses is_bool() - instead it alway

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-08-30 Thread Josh Bruce
Hey Tyson, This is great! Thank you so much, sincerely. Still slow goings, which is fine, we have at least a year. lol Static analyzers seem to be the biggest concern to date. Haven’t been able to get one running locally - though I’ve only spent a few minutes here and there; definitely on the

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-08-09 Thread tyson andre
Hi Josh, I'd recommend looking at https://github.com/php/php-src/pull/5156 (linked to in your RFC's reference) when implementing this PR. Additionally, I didn't see if this was brought up - PHP already has a class which is falsifiable - SimpleXMLElement. You can see the source of ext/simplexml/

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-08-09 Thread Josh Bruce
Trying not to drown the list while some RFCs are getting worked out and preparing for 8.0. Quick update: 1. Walking through Nikita’s instructions - writing about it here: https://joshbruce.dev/essays/software-development/php-falsifiable-objects

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-16 Thread Josh Bruce
> On Jul 16, 2020, at 10:28 AM, Josh Bruce wrote: > > https://wiki.php.net/rfc/objects-can-be-falsifiable > > > Updates: > > - Open issues (outstanding questions/concerns) updated > - Future scope > - References now have links to original

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-16 Thread Josh Bruce
https://wiki.php.net/rfc/objects-can-be-falsifiable Updates: - Open issues (outstanding questions/concerns) updated - Future scope - References now have links to original copies on GitHub (still updating 0002) - will be removed if accepted a

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Marcio Almada
Hi, Implement an interface and magic method to allow objects to represent false > (or empty) while still be valid instances of the custom object (type). > > https://wiki.php.net/rfc/objects-can-be-falsifiable < > https://wiki.php.net/rfc/objects-can-be-falsifiable> > > If you saw the latest from t

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Marcio Almada
Hi! Hey Larry, > > wrote: > > > 1) return null, which is a non-type, and thus you need to make the return > > type ?User or User|null, which means the caller *must* always check it's > > nullness. > > > > Allowing an object to falsify itself is a 4th, more type-safe option. > It > > lets you retu

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Levi Morrison via internals
On Wed, Jul 15, 2020 at 10:43 AM Marco Pivetta wrote: > > Hey Larry, > > On Wed, Jul 15, 2020 at 5:32 PM Larry Garfield > wrote: > > > 1) return null, which is a non-type, and thus you need to make the return > > type ?User or User|null, which means the caller *must* always check it's > > nullnes

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Marco Pivetta
Hey Larry, On Wed, Jul 15, 2020 at 7:15 PM Larry Garfield wrote: > On Wed, Jul 15, 2020, at 11:59 AM, Marco Pivetta wrote: > > Hey Larry, > > > > > > > > On Wed, Jul 15, 2020 at 6:55 PM Larry Garfield > > wrote: > > > > > I disagree e

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Larry Garfield
On Wed, Jul 15, 2020, at 11:59 AM, Marco Pivetta wrote: > Hey Larry, > > > > On Wed, Jul 15, 2020 at 6:55 PM Larry Garfield > wrote: > > > I disagree entirely. The value of a Maybe over just null is > > > > 1) You can bind to it even if the result is empty; the "i

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Marco Pivetta
Hey Larry, On Wed, Jul 15, 2020 at 6:55 PM Larry Garfield wrote: > I disagree entirely. The value of a Maybe over just null is > > 1) You can bind to it even if the result is empty; the "if is null" check > gets abstracted away from the main code. > That's correc

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Larry Garfield
On Wed, Jul 15, 2020, at 11:43 AM, Marco Pivetta wrote: > Hey Larry, > > On Wed, Jul 15, 2020 at 5:32 PM Larry Garfield > wrote: > > > 1) return null, which is a non-type, and thus you need to make the return > > type ?User or User|null, which means the caller *must* always check it's > > nullne

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Marco Pivetta
Hey Larry, On Wed, Jul 15, 2020 at 5:32 PM Larry Garfield wrote: > 1) return null, which is a non-type, and thus you need to make the return > type ?User or User|null, which means the caller *must* always check it's > nullness. > > Allowing an object to falsify itself is a 4th, more type-safe o

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Matthew Brown
> > > I don't see how that would happen. What non-pathological case would allow > for $foo && !$foo == true? > > I suppose something a little less pathological would be `$collection && $collection->pop() && !$collection` which is still pretty icky (to me at least). The other implication is that

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Larry Garfield
On Wed, Jul 15, 2020, at 9:24 AM, David Rodrigues wrote: > I really appreciate any effort that can make PHP a more powerful language. > However, for this item, I believe it will generate much greater cognitive > complexity for new users (and I hate to assume that this is a problem, but > we have to

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread David Rodrigues
I really appreciate any effort that can make PHP a more powerful language. However, for this item, I believe it will generate much greater cognitive complexity for new users (and I hate to assume that this is a problem, but we have to remember our roots). Why, for now a variable $x will be truth,

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-15 Thread Larry Garfield
On Tue, Jul 14, 2020, at 11:48 PM, Matthew Brown wrote: > On Tue, 14 Jul 2020 at 19:59, Josh Bruce wrote: > > > Implement an interface and magic method to allow objects to represent > > false (or empty) while still be valid instances of the custom object (type). > > > > https://wiki.php.net/rfc/o

Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-14 Thread Matthew Brown
On Tue, 14 Jul 2020 at 19:59, Josh Bruce wrote: > Implement an interface and magic method to allow objects to represent > false (or empty) while still be valid instances of the custom object (type). > > https://wiki.php.net/rfc/objects-can-be-falsifiable < > https://wiki.php.net/rfc/objects-can-b

[PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable

2020-07-14 Thread Josh Bruce
Implement an interface and magic method to allow objects to represent false (or empty) while still be valid instances of the custom object (type). https://wiki.php.net/rfc/objects-can-be-falsifiable If you saw the latest from this morning, n