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 Josh Bruce
laude Pache wrote: > > > >> Le 3 nov. 2022 à 02:51, Josh Bruce > <mailto:j...@joshbruce.dev>> a écrit : >> >> Similar to: >> >> function x(?SomeType $arg): ?SomeOtherType >> >> Instead of: >> >> function x(SomeType|null

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

[PHP-DEV] Change email address associated with account

2022-10-31 Thread Josh Bruce
Hey Internals! Apologies if this is the wrong space. I’d like to change my email address for internals but don’t want to lose ownership (??) of the falsifiable RFC: https://wiki.php.net/rfc/objects-can-be-falsifiable Is this possible? Should I be posting this somewhere else, if so, where? Che

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

2022-10-31 Thread Josh Bruce
today, the last example is always true. You wouldn’t be able to create a guard clause for the negation: If ( $obj = Object::init($response) and $obj === false ) { // handle invalid object, which could include something like $obj->failed() } Cheers, Josh > On Sep 26, 2020, at 5:20

Re: [PHP-DEV] [RFC] Add is_list(mixed $value): bool to check for list-like arrays

2020-12-23 Thread Josh Bruce
> >> I actually like the idea of flags added to `is_array()` for this. >> >> Something like: >> >> is_array($value, ZERO_INDEXED | ASSOCIATIVE | INTEGER_INDEXED) >> >> I’m not suggesting these names; they’re for illustration only. > > I'm strongly opposed to adding any flags to is_array

Re: [PHP-DEV] [RFC] Add is_list(mixed $value): bool to check for list-like arrays

2020-12-22 Thread Josh Bruce
>> tl;dr: Could add flags to is_array. > > Please, no. > > PHP needs fewer flags, not more. > > -Mike lol - There’s something to be said for that. Thinking of “simple" bridges that can be built toward a possible larger discussion around naming and defining things and not adding more to the SL

Re: [PHP-DEV] [RFC] Add is_list(mixed $value): bool to check for list-like arrays

2020-12-22 Thread Josh Bruce
> For example, with > >$a = ['foo', 'bar', 'baz’]; > > `is_list()` will return `true`, but if you run `$a` through `asort()`, > `is_list()` will return `false` because the keys are no longer > consecutive integers, but is there any doubt this is still a list? > Maybe in a pure sense, it’s n

Re: [PHP-DEV] [RFC] Add is_list(mixed $value): bool to check for list-like arrays

2020-12-20 Thread Josh Bruce
I appreciate this idea as I ran into the same issue with one of my libraries when I wrote similar rules. Granted, I’m using “array” and “dictionary” not “list” as both terms seem common to the community and used to distinguish the two. But that’s semantics, which I’m sure will be discussed at

Re: [PHP-DEV] Suggestion: Inconsistency: Allow array spread operator to work on string keys

2020-12-02 Thread Josh Bruce
> > The reason why this has been deferred is because of which semantics should > be used for duplicate string keys. > > Do we use the addition between two arrays semantics or the array_merge() > semantics? See: https://3v4l.org/7QbWv > > As the previous RFC you linked initially wanted to use the

Re: [PHP-DEV] [RFC] Deprecate passing null to non-nullable arguments of internal functions

2020-12-01 Thread Josh Bruce
> On Dec 1, 2020, at 8:57 AM, Nikita Popov wrote: > > I've put up an RFC to make the handling of "null" arguments consistent > between internal and user-defined functions: > > https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg >

Re: [PHP-DEV] Nullsafe

2020-11-04 Thread Josh Bruce
> On Nov 4, 2020, at 1:38 PM, Eugene Sidelnyk wrote: > > Yeah... Creating null was a huge mistake. > Now it is probably too late to fix that (maybe some new language can > introduce that). > > But what do you think about introducing special class `NullObject`? I would rather let an instance be

Re: [PHP-DEV] Nullsafe

2020-11-04 Thread Josh Bruce
> Implicit nullable is terrible, moreover I don't see why users should return > null values more often. > They serve their purpose but most of the time you can use another sane/safe > default of the given > property type. > Agreed. I’m not overly opinionated about much, but null as a default

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

2020-09-26 Thread Josh Bruce
continue going through the tutorials from Nikita and others on doing development Internals. Cheers, Josh > On Aug 30, 2020, at 9:32 AM, Josh Bruce wrote: > > Hey Tyson, > > This is great! Thank you so much, sincerely. > > Still slow goings, which is fine, we have

Re: [PHP-DEV] Draft RFC: foreach iteration of keys without values

2020-09-15 Thread Josh Bruce
> * If PHP had either convention or special handling for _ or $_ as a “ignore > this” destination, I wouldn’t have made the proposal. However, it doesn’t; _ > can (apparently!) be a constant, and is also a function, and $_ has no > special handling (and I bet it’s actually used to contain valu

Re: [PHP-DEV] Draft RFC: foreach iteration of keys without values

2020-09-03 Thread Josh Bruce
> > In terms of readability, I'm more likely to do > $keys = array_keys($array); > foreach($keys as $key){ Fair point. I would too. I have actually forgone even grabbing the keys and just using the loop without touching value in the body. Cheers, Josh -- PHP Internals - PHP Runtime Develo

Re: [PHP-DEV] Draft RFC: foreach iteration of keys without values

2020-09-02 Thread Josh Bruce
> On Sep 2, 2020, at 12:05 PM, Michael Voříšek - ČVUT FEL > wrote: > > I like "void", as "null" can be ambiguous. > > Imagine function example($a = 'default value 1', $b = 'default value 2') {} > > With "void", we can allow skipping arguments in advance to the default > pamameter value like

Re: [PHP-DEV] Draft RFC: foreach iteration of keys without values

2020-09-02 Thread Josh Bruce
> On Sep 2, 2020, at 6:27 AM, Dik Takken wrote: > > On 02-09-2020 12:48, Olle Härstedt wrote: >> An alternative syntax would be >> >>foreach($iterable as $key => _) { ... } >> >> Using underscore as a way to signal "I don't care about this value". >> Same could be possible with list dest

Re: [PHP-DEV] Request for couple memory optimized array improvements

2020-09-01 Thread Josh Bruce
That’s interesting as I haven’t played with iterates and generators much. If the iterator can’t take an iterable, the idea of something like __toArray seems way more convenient: https://wiki.php.net/rfc/to-array Cheers, Josh > On Aug 31, 2020, at 4:39 PM, Michael Voříšek - ČVUT FEL > wrote:

Re: [PHP-DEV] array_reject() as counterpart of array_filter()

2020-08-31 Thread Josh Bruce
Just to confirm array_filter(“!is_int”, $collection) Would result in a collection of only non-integers?? I do think there’s something to be said for the communication of intent without syntax. array_without or array_reject reads easier to me than making sure to watch for the bang. Cheers, Jo

Re: [PHP-DEV] Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...)

2020-08-30 Thread Josh Bruce
10:40 AM, tyson andre wrote: > > Hi Josh Bruce, > >> The compelling feature here for me is the idea of an “array walker” that can >> be broken out of. >> >> all() could be and() at which point this should be equivalent. > > Yes, you can write `all($set, $pre

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] Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...)

2020-08-30 Thread Josh Bruce
Think I’m following. The compelling feature here for me is the idea of an “array walker” that can be broken out of. all() could be and() at which point this should be equivalent. $collection = [1, 2, 3]; If (count($collection) === count(array_filter($collection, “is_int”)) any() could be or(

Re: [PHP-DEV] Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...)

2020-08-30 Thread Josh Bruce
>> >> - the default is `any($iterable, fn ($value) => ...)` >> - or `any($iterable, fn ($key) => expr, ARRAY_FILTER_USE_KEY)` >> - or `any($iterable, fn ($value, $key) => expr, ARRAY_FILTER_USE_BOTH)` > > Doesn't the occasional required use of long constant names like > ARRAY_FILTER_USE_KEY and

Re: [PHP-DEV] Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...)

2020-08-29 Thread Josh Bruce
Hello! I’m still finding my understanding of actual internals, so can only comment from a PHP developer perspective. The “any” check is just to if anything in the itrerable passes the predicate, yeah?? What I find myself doing more often is wanting the first thing to satisfy the predicate - a

Re: [PHP-DEV] [Concept] Don't cast keys in array to int

2020-08-17 Thread Josh Bruce
Thanks Rowan. I can appreciate that rationale. Also let’s me in on why we might want to have an indexed array that is not necessarily sequential - but are integers. Thanks again. Cheers, Josh > On Aug 17, 2020, at 4:17 AM, Rowan Tommins wrote: > > On Mon, 17 Aug 2020 at 05:19, Michael Voříše

[PHP-DEV] [Concept] Don't cast keys in array to int

2020-08-16 Thread Josh Bruce
I’m sure this conversation has happened before. But it’s on my mind as I work on some things on wanted to ask internals real quick before getting back to it. [“2” => “hello”, “4” => “internals”] -> [2 => “hello”, 4 => “internals”] Meanwhile: [“hello”, “internals”] -> cast to object -> (“0” => “

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

2020-08-09 Thread Josh Bruce
21, 2020, at 10:34 AM, Josh Bruce wrote: >> Learning more everyday. This thread will be the “official thread” - >> other related threads have been added to the RFC (including one from 11 >> years ago): https://bit.ly/php-0002-rfc <https://bit.ly/php-0002-rfc> >> >

Re: [PHP-DEV] [RFC] Import of variables

2020-08-09 Thread Josh Bruce
Have not tested - just catching up on emails. To verify: A property defined with a default value of the global does not already do this? Developer need: I rarely access global variables directly - usually going through a lib or framework. When I do I would probably wrap the access in a trait o

Re: [PHP-DEV] Allow two words keywords

2020-07-30 Thread Josh Bruce
Maybe add it to that thread?? https://externals.io/message/111218 Cheers, Josh > On Jul 30, 2020, at 4:50 AM, Deleu wrote: > > Such a nice syntax. Even better than @@ and @. I wish this could get more > attention/traction. > >> On Wed, Jul 29, 2020, 19:46 David Rodrigues wrote: >> >> Oh, y

Re: [PHP-DEV] Registration on wiki

2020-07-28 Thread Josh Bruce
Also be sure to add the mailing list address as the final email - the one you want to send emails to. This is the part I missed and received the same error. I don’t know if this counts as the captcha but the label is somewhat confusing, which is perfect if it’s meant to be the captcha Kalle men

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

2020-07-21 Thread Josh Bruce
Learning more everyday. This thread will be the “official thread” - other related threads have been added to the RFC (including one from 11 years ago): https://bit.ly/php-0002-rfc Created fork - with PR on fork to explore and leave notes without hitting the mailing

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 > <https://wiki.php.net/rfc/objects-can-be-falsifiable> > > Updates: > > - Open issues (outstanding questions/concerns) updated > - Future scope

Re: [PHP-DEV] [RFC] Treat namespaced names as single token, relax reserved keyword restrictions

2020-07-16 Thread Josh Bruce
> On Jul 15, 2020, at 3:26 AM, Nikita Popov wrote: > > On Tue, Jul 14, 2020 at 5:37 PM Josh Bruce <mailto:j...@joshbruce.dev>> wrote: > New to the discussion and being this deep; so, apologies for any bumps. > Mainly questions. > > Does this only affect t

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

[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

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Allow objects to declareemptiness and by extension truthiness

2020-07-14 Thread Josh Bruce
> On Jul 14, 2020, at 1:24 PM, Josh Bruce wrote: > > >> On Jul 13, 2020, at 12:14 PM, Christoph M. Becker wrote: >> >> On 13.07.2020 at 17:18, Josh Bruce wrote: >> >>> Re the wiki: I can edit pages now, it doesn’t look like I can create them. >

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Allow objects to declareemptiness and by extension truthiness

2020-07-14 Thread Josh Bruce
> On Jul 13, 2020, at 12:14 PM, Christoph M. Becker wrote: > > On 13.07.2020 at 17:18, Josh Bruce wrote: > >> Re the wiki: I can edit pages now, it doesn’t look like I can create them. >> There’s another thread I’ve been watching and I think I need more karma to >

Re: [PHP-DEV] [RFC] Treat namespaced names as single token, relax reserved keyword restrictions

2020-07-14 Thread Josh Bruce
New to the discussion and being this deep; so, apologies for any bumps. Mainly questions. Does this only affect the string after the “namespace” keyword (make implicit explicit)? So, things like “use” with a stack of classes within a base namespace would still be possible? On reserved words, i

Re: [PHP-DEV] Drop warning about non-public magic methods

2020-07-13 Thread Josh Bruce
Curious. I tend to follow PSR-12 (with few exceptions): https://www.php-fig.org/psr/psr-12/#44-methods-and-functions Which requires visibility declaration on all members (methods and properties). Would dropping the requirement mak

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Allow objects to declare emptiness and by extension truthiness

2020-07-13 Thread Josh Bruce
> > Latest version as we zero in on what this is really about: > https://bit.ly/php-0002 > > > I have a really hard time understanding what is actually being proposed here. > You mention the introduction of the Empt

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Allow objects to declare emptiness and by extension truthiness

2020-07-13 Thread Josh Bruce
>> Latest version as we zero in on what this is really about: >> https://bit.ly/php-0002 >> > 1) The 2 places that you have lists of "this thing produces true/false" could > likely stand to be turned into tables to make it clearer, especially when > demonstrating that

[PHP-DEV] [CONCEPT][DISCUSSION] Allow objects to declare emptiness and by extension truthiness

2020-07-12 Thread Josh Bruce
Latest version as we zero in on what this is really about: https://bit.ly/php-0002 Other threads: 1. https://externals.io/message/110879 2. https://externals.io/message/110881 Thanks for all th

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-12 Thread Josh Bruce
> > Focusing on Bool is, I think, a good choice because it has an argument for it > other than "well it works for strings." You hint at it in the writeup but > really bury the lead: Null objects. > > Being able to not use null or false as a "not found" case and instead return > an "empty" val

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-10 Thread Josh Bruce
>>> >>> Frankly this is something subject to personal opinions and will change >>> over time according to community shifts. >>> >> >> Not sure what's "subject to personal opinions" in the objective bug exposed >> in the snippet above? >> > > So there is a bug in a contrived code snippet ther

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-09 Thread Josh Bruce
> On Jul 8, 2020, at 12:54 PM, Marcio Almada wrote: > > Hello Josh, > >> Link to working draft: https://bit.ly/php-0001 > > From a type safety POV I'd prefer to have an interface available, the > same way we did > to the Stringable interface RFC. But I'd rather keep t

[PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-08 Thread Josh Bruce
Link to working draft: https://bit.ly/php-0001 Discussion on implementing a means by which a class instance can interacted with syntactically as a boolean. At this point in the discuss the only means discussed is creation of a method (magic or via an interface). Abili

Re: [PHP-DEV] Proposal: A way for classes to define a response to any primitive type cast

2020-07-08 Thread Josh Bruce
 > On Jul 7, 2020, at 3:24 PM, Rowan Tommins wrote: > >> On 07/07/2020 18:13, Josh Bruce wrote: >> Decided to put something >> together:https://github.com/joshbruce/external-project-proposals/blob/master/php-concepts/interact-with-instance-as-php.md > > > H

Re: [PHP-DEV] Proposal: A way for classes to define a response to any primitive type cast

2020-07-07 Thread Josh Bruce
er.com/Ocramius > > http://ocramius.github.com/ > > > On Mon, Jul 6, 2020 at 4:17 PM Josh Bruce wrote: > >> Apologies, first time, still learning and have no historical context - >> timing is what it is. >> >> Proposal type: Concept >> >> Imp

[PHP-DEV] Proposal: A way for classes to define a response to any primitive type cast

2020-07-06 Thread Josh Bruce
Apologies, first time, still learning and have no historical context - timing is what it is. Proposal type: Concept Implementer: Unknown, fallback to me after slow learning Presumed simple implementation as the pattern should already be in place: Cast of (string) -> __toString() - already impl