Puan
28,728
Çözümler
0
- Konum
- Freanchey
- Mesajlar
- 1,522
- Katılım
- 2 Eki 2026
- Tepkime puanı
- 215,504
- Puan
- 28,728
- Web sitesi
- glomaxgpt.com
Want to check out an issue? Sign up to receive a special offer.
Stop Writing PHP Like This (8.6 Fixes It)
Posted by Scott Keck-Warren on September 23, 2026
This is how PHP 8.6 lets you write a string transformation, with no closures and no temp variables.
$name = 'Scott Keck-Warren';
$fixed = $name
|> str_replace('Scott', 'Alice', ?)
// string(17) "alice keck-warren"
var_dump($fixed);
It’s going to be released November 19, and I’ll also show you a deprecation that’s almost certainly in your codebase right now, and the one-line grep to find it.
Overall
At the time of this being published, PHP 8.6 is scheduled for release on November 19, 2026, after it has gone through the alpha, beta, and release candidate phases.
I have two disclaimers before we go any further.
This video was made using beta release 3 on the official Docker image (php:8.6.0beta3-cli if you want to try at home), but functionality may change between now and the actual release.
This video also represents my selection of features that I think are going to make my life better. Tell me which one I should have covered in the comments.
Partial Function Application
Partial Function Application (PFA) is a computer science term that just refers to the process of setting up a function with only some of its required parameters so you can pass the others at a later time.
I’m sure that’s perfectly clear, but maybe an example will help. Pre-8.6, we might have something like the following:
$result = array_map(static fn(string $string): string => str_replace('Scott', 'Alice', $string), $names);
It’s a little hard to read but not impossible, but that’s less than ideal for us when our goal is to make our code as readable as possible.
With PFAs, we can do something like the following:
$names = ['Scott Keck-Warren'];
$renameScott = str_replace('Scott', 'Alice', ?);
//Output: array(1) {
// [0]=>
// string(17) "Alice Keck-Warren"
//}
var_dump(array_map($renameScott, $names));
The “?” is the “argument placeholder” symbol, and it’s telling the engine to replace that variable with the one that’s being sent. We can also use “…” to signify zero or more parameters.
The amazing part about this is that we can leverage the pipe operator (|>) that was added in PHP 8.5 and PFAs to make some consistent code:
$name = 'Scott Keck-Warren';
$fixed = $name
|> str_replace('Scott', 'Alice', ?)
// string(17) "alice keck-warren"
var_dump($fixed);
Stop Writing PHP Like This (8.6 Fixes It)
Posted by Scott Keck-Warren on September 23, 2026
This is how PHP 8.6 lets you write a string transformation, with no closures and no temp variables.
$name = 'Scott Keck-Warren';
$fixed = $name
|> str_replace('Scott', 'Alice', ?)
// string(17) "alice keck-warren"
var_dump($fixed);
It’s going to be released November 19, and I’ll also show you a deprecation that’s almost certainly in your codebase right now, and the one-line grep to find it.
Overall
At the time of this being published, PHP 8.6 is scheduled for release on November 19, 2026, after it has gone through the alpha, beta, and release candidate phases.
I have two disclaimers before we go any further.
This video was made using beta release 3 on the official Docker image (php:8.6.0beta3-cli if you want to try at home), but functionality may change between now and the actual release.
This video also represents my selection of features that I think are going to make my life better. Tell me which one I should have covered in the comments.
Partial Function Application
Partial Function Application (PFA) is a computer science term that just refers to the process of setting up a function with only some of its required parameters so you can pass the others at a later time.
I’m sure that’s perfectly clear, but maybe an example will help. Pre-8.6, we might have something like the following:
$result = array_map(static fn(string $string): string => str_replace('Scott', 'Alice', $string), $names);
It’s a little hard to read but not impossible, but that’s less than ideal for us when our goal is to make our code as readable as possible.
With PFAs, we can do something like the following:
$names = ['Scott Keck-Warren'];
$renameScott = str_replace('Scott', 'Alice', ?);
//Output: array(1) {
// [0]=>
// string(17) "Alice Keck-Warren"
//}
var_dump(array_map($renameScott, $names));
The “?” is the “argument placeholder” symbol, and it’s telling the engine to replace that variable with the one that’s being sent. We can also use “…” to signify zero or more parameters.
The amazing part about this is that we can leverage the pipe operator (|>) that was added in PHP 8.5 and PFAs to make some consistent code:
$name = 'Scott Keck-Warren';
$fixed = $name
|> str_replace('Scott', 'Alice', ?)
// string(17) "alice keck-warren"
var_dump($fixed);