@Crell@phpc.social avatar

Crell

@Crell@phpc.social

Anything worth doing is worth doing well.

Anything worth doing well is worth teaching others to do well.

Author of Thinking Functionally in PHP, now on LeanPub: https://leanpub.com/thinking-functionally-in-php

#tootfinder

This profile is from a federated server and may be incomplete. Browse more on the original instance.

Crell, (edited ) to php
@Crell@phpc.social avatar

I'm noodling with a data storage layer library in . specific. There's 2 options:

  1. Auto-generate SQL tables/views/queries off of PHP data types (with attributes)
  2. Auto-generate PHP classes off of SQL tables/views/queries.

Which would you prefer? The goal is fully typed interaction in PHP space, but I'm not sure which side should be canonical.

Which would you rather work with, and why? Assuming a "good" DX in either case.

Answer why in replies, boost for reach, etc.

Crell, to random
@Crell@phpc.social avatar
Crell, to random
@Crell@phpc.social avatar

PSA: just announced they're changing their privacy policy to default all of your account info, who you support, etc. to public. You need to go into the settings and disable that. (Check the two toggles at the bottom of the Settings page to off.)

And then send Patreon a nasty letter, because default-open is just a stupid model to begin with, period.

Crell, to random
@Crell@phpc.social avatar
Crell, (edited ) to php
@Crell@phpc.social avatar

Hey devs. I'm curious. When using a global class like SplFileInfo, Exception, Attribute, etc, do you say \Exception inline in the code, or do you use it at the top of the file and then use it as Exception inline?

Crell, to php
@Crell@phpc.social avatar

And of course, this site features a half dozen languages and their package system... But forgets about .

Even if you don't use PHP yourself, ignoring one of the largest and best designed package systems (/) is just dumb.

https://deps.dev/

Crell, to php
@Crell@phpc.social avatar

Looking for feedback.

I have a lib build for PHP 7 that has 3 methods:

addFoo($id, $priority)
addFooBefore($id, $before)
addFooAfter($id, $after)

($before/$after refer to some other $id.)

For PHP 8, I am strongly considering just assuming named args and changing it to:

addFoo($id, $priority, $before, $after);

Specify only one of priority/before/after, by name. Multiple is an error.

Is this a good idea/bad idea, and why?

Crell, to php
@Crell@phpc.social avatar

Question for @longhorn attendees: I'm presenting on a library I built recently. Would you rather I spend more time on how to use it, or how it works? Or something else?

It's a new talk so I can customize it easily. ๐Ÿ™‚

Crell, to rust
@Crell@phpc.social avatar

This video is about , but it's comments about error handling are valid for anyone in any language. PHP friends especially, this is the kind of stuff I've been ranting about for a while now. :-)

https://youtu.be/sbVxq7nNtgo

Crell, to rust
@Crell@phpc.social avatar

Thought experiment:

We have languages without null (eg, ), and it's been a good thing.

What would a language without booleans look like? Force things to be context-specific enums or similar.

Something to think about this weekend while avoiding your inlaws...

Crell, to php
@Crell@phpc.social avatar

I find it amusing how often I see people drool over the potential of AOT compilation. ๐Ÿ™‚

Crell, to php
@Crell@phpc.social avatar

Should a serializer differentiate between null and uninitialized? Right now does not, and... I am not convinced that it should.

Discussion: https://github.com/Crell/Serde/pull/25

Crell, to php
@Crell@phpc.social avatar

I have only recently learned of the "before" attribute in @phpunit. It seems appealing. What I don't get is... why would I ever use setUp() when I can instead use a before method? It seems like the easier, more portable solution in ever case except when I actively want to bypass a parent class's setUp().

(Same for beforeClass.)

Crell, to Redis
@Crell@phpc.social avatar

Someone please explain to me how TF to use in (6, specifically, for now) without just praying that I put the right method name on a facade? How can I inject it instead like a grown up?

Seriously, I can find nothing for how to use basics like incr()/decr() other than "it will simply pass the arguments."

Crell, to Israel
@Crell@phpc.social avatar
Crell, to random
@Crell@phpc.social avatar

I have a number of domain names, only some of which I use that are up for renewal soon. My current registrar is good, but also pricey. What's a good registrar these days?

Good: Inexpensive, lets me set custom DNS records, simple UI, no complex upsells to hosting, company isn't malevolent dipshits.

Crell, to php
@Crell@phpc.social avatar

Let's be controversial: In modern , you should never type-hint an array.

https://peakd.com/php/@crell/php-never-type-hint-on-arrays

Crell, to random
@Crell@phpc.social avatar

A friendly reminder that turning a hospital into a military facility filled with human shields is a war crime.

https://www.reuters.com/world/middle-east/israeli-military-says-hamas-hiding-tunnels-operations-centres-gaza-hospital-2023-10-27/

Crell, to random
@Crell@phpc.social avatar
Crell, to php
@Crell@phpc.social avatar

The merging of sequences and maps into a single structure in has cost me many hundreds of hours and innumerable bugs over my career. It is still doing so now.

"Arrays" are PHP's original sin.

Crell, to php
@Crell@phpc.social avatar

Is there a function that would help replace or simplify a function with this description?

Creates a subarray from a given array based on a set of selected fields

@param $existingArray
eg: ["name" => "John", "age" => 25, "address" => ["city" => "New York", "zip" => "10001"]];

@param $selectedFields
eg: ["name", "address" => ["city"]];

@return

  • eg: ["name" => "John", "address" => ["city" => "New York"]];

It feels screwy, but I'm not sure what the better alternative is.

Crell, to random
@Crell@phpc.social avatar

What did we used to call DTOs before the dumb term "data transfer object" was invented? For a simple but explicit data-only or mostly data-only object.

I don't see a need to really distinguish from value objects, personally.

Crell, to php
@Crell@phpc.social avatar

Training exercise:

Try to replace all $foo->isBeep()/$foo->canBar() etc. calls with an instanceof check. $foo instanceof Beepable, $foo instanceof Bars, etc.

What does that do to your data model? If you leverage parameter types instead of manual instanceof checks, how does that simplify your logic flow?

I don't expect it to work for every use case, especially in PHP, but it would be a valuable exercise to try.

Crell, to php
@Crell@phpc.social avatar

Proposal for a conference talk: How to configure and all its tooling extensions (xdebug, phpstan, php-cs-fixer, etc.) to use a docker container consistently.

That could easily fill a tutorial...

Crell, (edited ) to random
@Crell@phpc.social avatar

This is sadly entirely accurate, and the whole problem...

(Edit: Original is here. Go follow the artist. https://mastodon.social/@workchronicles/112417993863156684)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • โ€ข
  • provamag3
  • rosin
  • ngwrru68w68
  • Durango
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • thenastyranch
  • Youngstown
  • khanakhh
  • slotface
  • everett
  • vwfavf
  • kavyap
  • megavids
  • osvaldo12
  • GTA5RPClips
  • ethstaker
  • tacticalgear
  • InstantRegret
  • cisconetworking
  • cubers
  • tester
  • anitta
  • modclub
  • Leos
  • normalnudes
  • JUstTest
  • All magazines