Sign in

Damien Seguy

@dseguy.bsky.social
683 followers 270 following 392 posts

Code quality fanatic, static analysis expert @exakat, elephpant breeder, husband, father, speaker!

PostsRepliesMedia
Damien Seguy @dseguy.bsky.social · 21/09/2026
Vale reads the comments in your #PHP code and apply checks: grammar, spelling and style, to make sure they are consistent and expressive. A tool for the most human part of the code. Install, review and run. www.exakat.io/vale-reviews...
010
Damien Seguy @dseguy.bsky.social · 18/09/2026
What happens when you chain #PHP list() calls? And when you include a full assignement in the middle? Also, with #PHP 8.6 deprecating the list keyword, modern code likes like chains of arrays. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
<?php

class X { public array $list = [2]; }
$list = new X ;

list($a) = list($b) = $list->list;
echo $a;
echo $b;

[$a] = $c = [$b] = $list->list;

echo $a;
echo $b;
print_r( $c );
010
Damien Seguy @dseguy.bsky.social · 17/09/2026
So, it's too late for #PHP 8.6, but can I ask for composable first class callable of the second order for #PHP 8.7? I tried even with |> operator, it fails. Is the only solution here to do a closure? Try it yourself : 3v4l.org/eUjJ4#v8.5.10 Damned, already talking about #php 8.7?
000
Damien Seguy @dseguy.bsky.social · 01/09/2026
str_replace() replaces ALL occurences. What if you only want to replace one of them? I have 3, but there are others. What other option do #PHP offer? php-tips.readthedocs.io/en/latest/ti... #phptip #phptrick
011
Damien Seguy @dseguy.bsky.social · 17/08/2026
110
Damien Seguy @dseguy.bsky.social · 06/08/2026
TIL that JSON tolerates duplicate keys. #PHP does not: it may only keep the last one, or throw an exception as error. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
<?php

// JSON is decoded
print_r(json_decode('{"a":1,"b":3,"a":2}'));

// with an error
print json_last_error_msg();

// it is actually an error
print_r(json_decode('{"a":1,"b":3,a":2}', flags: JSON_THROW_ON_ERROR));

?>
000
Damien Seguy @dseguy.bsky.social · 17/07/2026
Pop quizz #PHP on Friday evening: How can you remove an argument between the parent class and the child class? Is that an impossible task? #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
<?php

class x {
    function foo(int $a, string $c, string ...$b) {}
}

// OK
class y extends x {
    function foo(int $a, string ...$b) {}
}
100
Damien Seguy @dseguy.bsky.social · 10/07/2026
#PHP 8.4 introduced array_find() to look for a value in an array, and also, its cousin, array_find_key(), which returns the key where to find that value. The second got less attention, but is arguably more useful. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
020
Damien Seguy @dseguy.bsky.social · 30/06/2026
So, it seems that it is possible to paint oneself in a corner and write an unreachable method. How would you call A::foo() in this code below? Come on, #PHP, there must be something here. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
011
Damien Seguy @dseguy.bsky.social · 06/06/2026
Yield or return, when using ... in a function call? Not an easy question to ask on a first date. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
111
Damien Seguy @dseguy.bsky.social · 22/05/2026
Toujours prendre ses elephpants à l #afupday @afup.org
000
Damien Seguy @dseguy.bsky.social · 01/05/2026
Passing array by value, and updating its elements. Nothing new, it is the readonly and array_fill() syndrom for arrays. Better know about it. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 15/04/2026
#PHP quiz of the day: how can a property be both not set, empty() and failing at comparison with falsy value? And more than one of us has this bug ATM. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
011
Damien Seguy @dseguy.bsky.social · 02/04/2026
New word: zombie closure That is when you put $this in a static closure, you can run the #PHP code but you can't call it. Just a reminder about static arrow functions. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 30/03/2026
I’m always moved when a young elePHPant meets Trisaieul, the great grand parent of all elephpants. Thanks Tideways for making this reunion possible. Moni: welcome to the PHPamily!
000
Damien Seguy @dseguy.bsky.social · 28/03/2026
#PHP defined() in action: there are many aspects when checking for a constant existence. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 23/03/2026
preg_split() splits #PHP strings with regexes, captures the separators and can handle an empty regex. You don't need that everyday, but when you do, #PHP has it! #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 19/03/2026
#PHP's NAN is 0 as an integer, 'NAN' as a string and not comparable with itself. Also, there are now warning when using them, so no one can get hurt by this. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 02/03/2026
OK, I'm tired and this #PHP make me chuckle. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
<?php

const from = ['yield from'];

$a = fn () => yield yield from from;

foreach($a() as $b) {
    print $b;
}
020
Damien Seguy @dseguy.bsky.social · 27/02/2026
Can you make this #PHP riddle running? This compiles, so you can only add more code to make it work. I asked 5 AI, 2 succeeded, 3 failed. #phptip #phptrick
<?php 
class X { 
    private array $code = []; 
    
    function foo() { 
        return (string) $this<-code; 
    } 
} 

var_dump((new X)->foo());
100
Damien Seguy @dseguy.bsky.social · 25/02/2026
So, #PHP typed class constants are vaguely useful? Here is a nice usage case that will definitely makes everyone love them. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
<?php

class x {
   const int|string A = 1, B = 'abc';
}

echo strlen(X::B);
000
Damien Seguy @dseguy.bsky.social · 19/02/2026
#PHP numeric separator works well on integer, floats and also hexadecimals, octals and ... binary. And most useful in the latter, right? 0b1111_00_111_101_111 #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 11/02/2026
What do you think this #PHP code will write? Could we do better ? #phptip #phptrick cc @lecodeestdanslepre.fr 😉 php-tips.readthedocs.io/en/latest/ti...
<?php

echo 'B', 'A', sqrt(-1), 'A'; 

?>
121
Damien Seguy @dseguy.bsky.social · 11/02/2026
En #PHP, ca marche aussi, mais en majuscules, et je dois reconnaitre que c'est moins élégant.
122
Damien Seguy @dseguy.bsky.social · 25/01/2026
What if you want to convert a #PHP string to the opposite number ? Can you cast (int) and use minus? Well, can you? #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
<?php

$string = '123a';
$integer = -$string; // warning!
120
Damien Seguy @dseguy.bsky.social · 22/01/2026
So, ...[4] means unpacking a single value from a #PHP array. This basically means reading the value itself. Unless it is useful sometimes... #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
<?php

function foo() {
    print_r(func_get_args());
}

$array = [1,2,3];

// Not possible
// cannot use positional argument after unpacking
//foo(...$array, ...$array, 4);

foo(...$array, ...$array, ...[4]);
010
Damien Seguy @dseguy.bsky.social · 21/01/2026
Closure, constant, #PHP 8.5, parenthesis, ants and cast: what could go wrong, right? php-tips.readthedocs.io/en/latest/ti... #phptip #phptrick
010
Damien Seguy @dseguy.bsky.social · 20/01/2026
TIL that it is possible to use cast, like (int) or (string) with constants, since #PHP 8.5. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 15/01/2026
The global keyword imports variables from the outside, and overwrites the local value. Beware, when using it. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
100
Damien Seguy @dseguy.bsky.social · 14/01/2026
ElePHPant alert : Le Monstre, from #frankenphp is available on the shop. Normal or big. lemonstre.frankenphp.dev
100
Damien Seguy @dseguy.bsky.social · 15/12/2025
Can a #PHP class have two methods with the same name? Not with signature overloading, a classic feature, right? But rather one method static and the other one non-static? #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
<?php

class X {
  // Some magic happen here
}

X::foo();
(new x)->foo();
010
Damien Seguy @dseguy.bsky.social · 08/12/2025
Do you think that intval() is a boring #PHP native function that turns string into integers? Well, it does, but it is not boring. Far from it! php-tips.readthedocs.io/en/latest/ti... #phptip #phptrick
<?php

echo intval('1AZ') .PHP_EOL; // 1
echo intval('1AZ', 11).PHP_EOL; // 21
echo intval('1AZ', 21).PHP_EOL; // 31
echo intval('1AZ', 36).PHP_EOL; // 1691
echo intval('1AZ', 37).PHP_EOL; // 0

echo intval( 123, 11).PHP_EOL; // 123
echo intval('123', 11).PHP_EOL; // 246
020
Damien Seguy @dseguy.bsky.social · 06/11/2025
November 20th, 2025: PHP 8.5 arrives! 🐘 We’re throwing a release party at PHP Rotterdam, and you’re invited! Expect PHPun, knowledge-sharing, and great company at Last Mile Solutions! eventy.io/events/q8lmw... #PHP #PHP85 #Community #Rotterdam #Developers
A PHP elephant, near the iconic Erasmus bridge, in Rotterdam
070
Damien Seguy @dseguy.bsky.social · 22/10/2025
It is easy to create a map from a list of object, using #PHP array_column() and the second argument null. That null represents the whole object, and the third argument is the indexing key. array_column($list_of_objects, null, 'id'); #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
011
Damien Seguy @dseguy.bsky.social · 02/10/2025
It is not possible to cast any #PHP enum cases to (string) or (int) even when... they are backed! That looks like a natural feature, though. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
130
Damien Seguy @dseguy.bsky.social · 01/10/2025
Dynamic class constants is achieved with #PHP 8.3 class constant syntax, and the constant() function. It also applies to enumeration cases. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 21/09/2025
#PHP callable arrays are checked for 2 elements and only using index 0 and 1. No one said that 0 and 1 have to be in that order, and it works perfectly! Well done #PHP, well done! #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
010
Damien Seguy @dseguy.bsky.social · 19/09/2025
There are, at least, 4 ways to create a closure in #PHP. They all will be callable later. On the other hand, they behave differently to check the underlying method. All is in the timing. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
100
Damien Seguy @dseguy.bsky.social · 18/09/2025
A few days ago, I warned about isset() and a possible #PHP Fatal error. Given that isset() and ?? share the same code, it is not suprising that ?? hold the same trap. That bug should go away, the sooner the beter. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 15/09/2025
When using #PHP isset(), the language construct hides errors because, that's what is being tested there. Unless there is an object, where an array is expected. Then, it leads to a fatal error. It prevents the usage of an optimisation. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 05/09/2025
It is Friday, so why not cram as many #PHP operators in one single operation, and make it work? Look at this beauty! Could you make it run? #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
010
Damien Seguy @dseguy.bsky.social · 27/08/2025
A rare find: A syntax that worked before #PHP 8.1 and after #PHP 8.2 but not in #PHP 8.1 Here is the never arrow function. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
010
Damien Seguy @dseguy.bsky.social · 03/07/2025
So, take a #PHP array, but some value in it (like, anything). Can you make an infinite loop out of this? #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 29/06/2025
#PHP properties may be a reference. #PHP properties may be promoted. #PHP properties may have a hook. Just not both at the same time. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 25/06/2025
In #PHP array_merge_recursive(), what is recursive? Does it go deep in the guts of the arrays, or does it merges values that look alike? Or something else? #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 22/06/2025
Did you know that #PHP 's own $GLOBALS variable is actually undefined? I'm going to miss the hedonism of those error messages once they are all fixed. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
010
Damien Seguy @dseguy.bsky.social · 18/06/2025
Since #PHP 8.4, we can have properties in interfaces! Thank you, property hooks! #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
230
Damien Seguy @dseguy.bsky.social · 16/06/2025
The humble bitwise operators (& ^ | ) have a hidden secret : they work on integers and also on strings. But not on both at the same time. One of the earliest #PHP feature, still available 30 years later. #phptip #phptrick php-tips.readthedocs.io/en/latest/ti...
000
Damien Seguy @dseguy.bsky.social · 13/06/2025
#PHP and Rotterdam is a love story. A huge crowd of PHP aficionados congregated to treehouse, to listen to Gina and eat cake. 
 
Home is where the elePHPant is.
171
Damien Seguy @dseguy.bsky.social · 11/06/2025
This one? Or the Powered by one?
100