{ PHP snippets }

Jason McCreary

Jason McCreary @gonedark

? Pushing yourself to remove comments is one of the best drivers towards clean code. Here's a few tips on how to spot and replace comments that may be unnecessary… https://t.co/STIK6AIKXt

PHP
Frank de Jonge

Frank de Jonge @frankdejonge

Small #PHP tip: Want to before sure multiple keys of an array are set? Define them in one isset() call, it's so much clearer! if ( ! isset($a['q']) || ! isset($a['w']) || ! isset($a['e'])) { // PANIC } # Becomes if ( ! isset($a['q'], $a['w'], $a['e'])) { // OH NO! }

PHP

The --stop-on-failure flag has been of great help to stop my test suite once it finds a failing test. Pretty useful for large suites where you don't want to spend 2 minutes waiting to know what the failure is about (+300 tests in my case). ? https://t.co/uJOFFyeovO

PHP
Achraf Kassioui

Achraf Kassioui @achrafkassioui

CSS tip: the <main> element isn't recognized as a default block level element in Internet Explorer. Set it to display: block in CSS so IE can display it correctly.

Jason McCreary

Jason McCreary @gonedark

@jesseschutt Well, since you asked, here's my take on a few of the ways you could handle this… On first pass, I use the "Separate Assignment". But may end up with the "Explicit Calls" (when it's simple) or "Refactor" (when it's complex). ? https://t.co/aHFwoBFp8I

PHP
Philipp Kühn ??‍♂️

Philipp Kühn ??‍♂️ @_philippkuehn

@adamwathan funfact: you can also use collect() to pass data to vue. a bit shorter ? <user-profile :user="{{ collect($user) }}"></user-profile>

Adam Wathan

Adam Wathan @adamwathan

? I hate NounVerber classes but if I *have to* extract a single behavior because it needs to be swappable, I like making it invokable and thinking of it as a callback instead of a real "object". Make it way easier to name too ?? https://t.co/MGgAMkeFK9

PHP
Jason McCreary

Jason McCreary @gonedark

? Naming things is most certainly hard. I find full names aimed at relaying a human context yield the most readable code. Here are a few examples to help make naming things a little easier… https://t.co/U2AhdaSwUb

PHP
John T. Bonaccorsi

John T. Bonaccorsi @imjohnbon

? Easy way to improve code clarity: use the JSON_OBJECT_AS_ARRAY predefined constant to make the second parameter of json_decode human readable. https://t.co/Jm9XzlYgS2

PHP

I tend to use `assertArraySubset` to assert many attributes at once in a model. It reads better than asserting each field independently. ? https://t.co/DW6oNVKIYS

PHP