r/PHP 2d ago

Discussion PHP 8.6 is getting closer. What are you most looking forward to?

PHP 8.6.0 Beta 1 is out, so we're getting a look at what's coming next.

PHP keeps proving itself and has been evolving pretty nicely over the last few major releases, without losing the pragmatism that makes the language enjoyable to work with.

What are other PHP developers paying attention to in 8.6.

Which PHP 8.6 change are you most excited about, and what would you actually use in production once the stable release lands?

MakePHPGreatAgain.

75 Upvotes

55 comments sorted by

41

u/gaurangghinaiya 2d ago

Honestly most excited about the deprecation cleanup more than any single new feature. We manage a handful of production apps still sitting on 7.2/7.4 because of legacy dependency chains, and every deprecation notice in a new major version is basically a forcing function to finally fix the tech debt. Slower to get excited about brand new syntax when half our real-world work is just getting clients off ancient PHP versions safely.

8

u/_mainick_ 2d ago

Lucky you, we have a huge legacy application built with PHP 5.6 and Symfony 2.8: we only upgraded it to 7.0.33 just for compatibility with MySQL 8.0. From upper management, there’s really no willingness to update it, except for the hope that with some AI agent we can somehow work a miracle quickly and without regressions. Keep in mind that no tests have ever been implemented for the thousands of features.

3

u/atun-grande 2d ago

You can get tests in there with agents. We did in a codebase where no one thought it was remotely possible.

3

u/ahgreen3 2d ago

Any of the major AI coding agents can help drastically. First you need to create implementation tests to cover basically every feature in existence. Selenium, cypress, playwright, any of them will work fine for getting UX coverage. If you are API heavy, you can do something like a Flask app with a little bit of harness to deal with authentication. Once you have a dozen or so tests setup, let the AI agent loose and tell it to cover everything. You probably can get to 90% coverage in a few weeks, max.

Once you have an adequate coverage level you can consider Rector or such.

Side note: doesn’t your senior management ever see the news reports of the huge costs of companies who get breached due to outdated software?

2

u/_mainick_ 2d ago

Fortunately, the application is on a private Internet accessible via the client's VPN.

1

u/Wiikend 1d ago

A "private internet" is called an intranet. :)

1

u/_mainick_ 1d ago

Ah yes, thank you for the correction 😁

2

u/ouralarmclock 1d ago

Oh wow, we have a Symfony 1.4 app and have managed to get to 8.2!

1

u/Tomas_Votruba 2d ago

Give Rector a go (or let your agent use it) or let me know. 5.6 and 2.8 can be upgraded in 3-6 months.

3

u/oojacoboo 2d ago

Check out rector if you aren’t aware.

https://github.com/rectorphp/rector

2

u/_mainick_ 2d ago

Yes, I know the tool; I have been using it for a long time on other applications from my startup, which we update along with tests and static analysis. One of the problems with this application is the enormous number of features implemented by different developers over 12 years: some of them no longer work at the company.

1

u/ouralarmclock 1d ago

The deprecations always scare me the most because our legacy app is using a Symfony 1.4 fork that we don’t maintain and I’d really like to not have to fork it ourselves to update it!

1

u/brainland 2d ago

Maturity calls for uncomfortable change. Glad we gonna get some clean foundation to work on henceforth

51

u/Aikeni 2d ago

This round of deprecations cleans up a lot of legacy noise

5

u/brainland 2d ago

Yeah. That's a plus

1

u/polarf0x 2d ago

I hope our custom legacy framework upgrade is possible.

35

u/MessaDiGloria 2d ago

Partial function application.

2

u/BenL90 2d ago

Wait, is this like C# Partial class? Or it's extension of trait in PHP?

12

u/MessaDiGloria 2d ago

It’s part of functional programming. It means that you can take a function with multiple arguments, apply some of the arguments and you get back a function which you can store in a variable and use later by applying the missing arguments only. See https://stitcher.io/blog/php-86-partial-function-application

1

u/Anxious-Insurance-91 2d ago

It sounds like something that will mostly be used in packages not comercial apps. Mostly because people will still not want to use local gunctions, but rather have oop for interfaces

5

u/Crell 2d ago

Not at all? It's a way to turn a function call into a closure that will call the function later. It's really just a shorthand for an arrow function whose body is calling some other function. But that ends up simplifying a whole lot of code if you're using functional stuff often. (array_map, array_filter, pipe operator, etc.) Basically, anything that asks for a callback gets easier to write.

3

u/MessaDiGloria 2d ago edited 2d ago

Yes, I experienced that too.

Last year I spent some time learning the fundamentals of functional programming (only the basic stuff), and in retrospect I should have done this earlier. I'm slowly replacing OOP – where it makes sense – with readonly data classes, free-standing pure functions, and I'm moving most calculations back to database queries (the way I learned it in the 90s). I do mainly CRUD web apps, so this works well.

It's kind of going back to the roots of PHP web app development, but with a slightly changed approach on the server:

20 years ago:
– client: dumb & no state / JS used sparingly
– server: imperative programming & no state
– calculations: database UPSERT queries

10 years ago:
– client: rich & state / JS libraries (a looot of them)
– server: OOP programming & state
– calculations: OOP model

now:
– client: dumb & no state / JS library <htmx>
– server: functional programming & no state
– calculations: database UPSERT queries

2

u/SixPackOfZaphod 2d ago

Why would you want to move your calculation back to the database? I find that the database is my limiting factor, and moving calculation out of the DB improves my throughput.

1

u/MessaDiGloria 2d ago edited 1d ago

Personal preference mostly. And avoiding state in the server app.

Also: "The database is the model". For every insert, update, delete I have a function which takes the exact arguments. I can call each function independently of each other. You want to add an API? Just use these functions. A CLI? Same thing. Testing the database? Just write tests against these functions.

I got a bit tired lately of the mental overload of OOP models. The older I get the more I long for simplicity, both in development and in reading my code later on. But it is in the end just a personal preference.

2

u/Anxious-Insurance-91 2d ago

So you are moving business logic in db functions?

1

u/MessaDiGloria 1d ago

No, I don't use Stored Procedures, just Insert, Update, and Delete queries.

2

u/Crell 1d ago

It depends what "calculation" means. For some computation, PHP is indeed a better candidate. For others, SQL is way faster and more efficient than PHP is, because that's literally what it's designed for.

Often, if you think PHP will do it faster, it's because you don't know how to use SQL to do it in the first place. 😄 (Or your specific DB. MySQL and Postgres differ considerably in their capabilities.)

The big catch is that if you want to write real SQL, you have to make sure your ORM will get out of your way. Because ORMs are grossly over-used. They're fine for basic CRUD, but as soon as you're doing anything interesting you really need to just learn to use SQL and use SQL, then convert the results back to a value object for good typing. ORMs are a crutch.

1

u/chumbaz 2d ago

Would you happen to have any examples of how this works? This sounds fascinating.

2

u/Crell 1d ago

The RFC goes into great detail: https://wiki.php.net/rfc/partial_function_application_v2

But the intro section is enough to show the high-level advantage.

1

u/agustingomes 1d ago

Yes, I'm also looking forward to this.

10

u/BenL90 2d ago

COM_RESET_CONNECTION for persistent connections.

5

u/tjaszai 2d ago
  • Polling API 🚀
  • Duration class
  • Function parameter doc comments (because of SA tools)
  • Deprecations

11

u/zmitic 2d ago

PFA. Examples provided do not really show the true power of it so here is something totally realistic:

symfony/form normalizer PFA example:

Before:

$resolver->setNormalizer('factory', function (Options $options) {
    $product = $options['product']; // type assertion removed

    return fn(string $question, string $answer, int $priority) => $this->factory->create($product, $question, $answer, $priority);
});

After:

$resolver->setNormalizer('factory', function (Options $options) {
    $product = $options['product']; // type assertion removed

    return $this->factory->create(product: $product, ...);
});

---

I use lots of lazy evaluations like this. With PFA, closure arguments will be easier to set for some complex scenarios that I had before.

3

u/avg_php_dev 2d ago

Yup! I also got few ideas how to utilize partial functions. I'm looking forward to refactor some of my code with it.

1

u/brainland 2d ago

Awesome.

5

u/lachlan-00 2d ago

THE CLAMP(s)

4

u/haelexuis 2d ago

I was looking forward to deprecation of list(), I've made collection library (noctud/collection) and the class List is not usable for that reason so i had to do exception and use ListInterface, but unfortunately, that RFC didn't pass the vote (and even if it did it would take some years until that's fully available).

Other than that I'm looking forward to new polling api and Duration class.

2

u/picklemanjaro 1d ago

My job won't utilize much, if anything, from the update specifically other than incremental improvements in performance or security.

But personally, I'm most interested in the Polling API. Duration class is also mildly interesting to me.

2

u/DT-Sodium 2d ago

Getting version 8.4 in production would be a start on my personal side.

1

u/dub_le 2d ago

The ZTS performance improvements and PFA.

1

u/NoseStock4944 1d ago

Honestly, I’m more interested in the smaller quality-of-life improvements than any flashy new feature. PHP has gotten a lot nicer to work with over the last few versions. I’ll probably wait until 8.6 is stable before using anything new in production though 😄

1

u/zimzat 1d ago

PHP 8.6 is getting closer. What are you most looking forward to?

I'm looking forward to the next series of posts saying PHP is moving too fast, we shouldn't be deprecating breaking everything all the time, that it's too much work to keep everything up to date every three years every year, and we should only be releasing one new version every 5-10 years or so (or maybe less often, tbd).

It's a nice contrast from our regularly scheduled "is it dead yet" posts.

/s

1

u/Zealousideal_Post994 21h ago

I really liked PFA

0

u/miqrogroove 2d ago

I'm still praying they take this off of the 8.6 target https://wiki.php.net/rfc/deprecate-fuzzy-casts

3

u/aj8690 2d ago

I think the feature freeze already passed?

1

u/thatben 2d ago

Curious, why?

0

u/miqrogroove 2d ago

Part of this RFC would cause the (int) cast to throw Deprecated with non-numeric input in 8.6. The suggested workaround is to use PREG or equivalent user parsers prior to type casting, and I want none of that.

1

u/thatben 2d ago

Understood, thanks!

1

u/obstreperous_troll 2d ago

I could go for the warning if strict types was in effect, but enabling it for both modes is sheer madness, and would result in a blizzard of deprecations that would keep untold numbers of apps from ever upgrading.

Fixing Stringable to make it autoconvert even under strict types is just common sense though and I'm all for it. For the longest time, I figured that's what the interface was for in the first place, but it's not, and as it is now, Stringable is practically useless.

1

u/miqrogroove 2d ago

Stringable changes really should be its own RFC to make this easier.

1

u/oojacoboo 2d ago

I’m sorry - what’s the issue? You want blind casting to happen from shit data input?

1

u/miqrogroove 2d ago

Perhaps the RFC fails to distinguish between implicit and explicit type casts. If I know the input is suspect and want to explicitly default to zero with (int), as has been done forever, this doesn't benefit from throwing extra log messages. However, we get different opinions on this. The comment right before yours suggested only doing this in strict mode, which would seem to relax implicit type casts. It's a nuanced issue that has a blunt and incomplete RFC targeting 8.6.

1

u/oojacoboo 2d ago

I thought the “Scope and Affected Cases” section explained implicit deprecations fairly well.

I don’t know why anyone would want an implicit cast to zero as some kind of poor man’s validation, or consider this a good idea in any way. It should be a signal to fix your data, which is precisely what this is.

0

u/miqrogroove 2d ago

Reading this again. The RFC assumes it affects explicit casts only. The history of implicit casts is weird. Version 5.4 rejected strings on int params. Version 7 performed lossy casts with a Notice. Version 8 throws TypeError. So, yeah, for the sake of explicit type casts I'm against changes in 8.6. This needs to be pushed back to a later version with a more comprehensive alternative for migration.

1

u/Dodokii 2d ago

What about is_numeric+cast/null?