TubeSum ← Transcribe a video

PHP in 2026 is so good..

0h 03m video Published Oct 24, 2025 Transcribed Jul 28, 2026 nunomaduro nunomaduro
Intermediate 3 min read For: PHP developers familiar with older PHP versions who want to learn modern practices.
AI Trust Score 85/100
✅ Highly Legit

"Title says 2026 but video covers 2025 features; still delivers on modern PHP improvements."

AI Summary

This video demonstrates how to write modern PHP code in 2025, moving from old, unsafe, untyped code to a clean, typed, and robust style. The presenter shows key features like visibility, type declarations, readonly classes, property promotion, and final classes.

[00:00]
Old PHP vs Modern PHP

Old PHP was unsafe, untyped, and verbose. The video aims to show how to write modern PHP in 2025.

[00:23]
Visibility Modifiers

Replace 'var' with 'private' for properties and add 'public' to functions to make visibility explicit.

[00:34]
Type Declarations

PHP is fully typed. Add type hints to properties (string, int) and function return types.

[01:14]
Strict Types

Add 'declare(strict_types=1);' to enforce strict type checking, e.g., rejecting a string where an int is expected.

[01:28]
Readonly Classes

Use 'readonly' modifier on a class to prevent state mutation. Properties can then be made public, eliminating getters.

[01:57]
Property Promotion

Declare visibility and type directly on constructor arguments, removing redundant property assignments.

[02:27]
Final Classes

Mark classes as 'final' to prevent inheritance, favoring composition over inheritance.

[02:52]
Modern PHP Tooling

PHP has improved tooling: PHPStan (like TypeScript), Pint (linting), and Pest (testing).

Modern PHP in 2025 is a fully typed, robust language with features like readonly classes, property promotion, and final classes. The presenter encourages viewers to explore further and try PHP at php.new.

Mentioned in this Video

Tutorial Checklist

1 00:23 Replace 'var' with 'private' for properties and add 'public' to methods.
2 00:34 Add type hints: string for name, int for age on properties and function signatures.
3 01:14 Add 'declare(strict_types=1);' at the top of the file.
4 01:28 Add 'readonly' modifier to the class to make it immutable.
5 01:50 Make properties public and remove getters since class is readonly.
6 02:00 Use property promotion: declare visibility and type on constructor arguments, remove property assignments.
7 02:27 Add 'final' keyword to the class to prevent inheritance.

Study Flashcards (6)

What keyword replaces 'var' for properties in modern PHP?

easy Click to reveal answer

private

00:23

How do you enforce strict type checking in PHP?

easy Click to reveal answer

Add 'declare(strict_types=1);' at the top of the file.

01:14

What does the 'readonly' modifier do on a class?

medium Click to reveal answer

It prevents mutation of properties after initialization.

01:28

What is property promotion in PHP?

medium Click to reveal answer

Declaring visibility and type directly on constructor arguments, eliminating separate property declarations and assignments.

02:00

What does the 'final' keyword do on a class?

easy Click to reveal answer

It prevents the class from being extended (inherited).

02:27

Name two modern PHP tools mentioned in the video.

medium Click to reveal answer

PHPStan (static analysis) and Pint (linting).

02:52

💡 Key Takeaways

📊

PHP is fully typed

Contrary to common belief, PHP supports full type declarations similar to TypeScript or Rust.

00:34
🔧

Readonly classes for immutability

Using 'readonly' simplifies code by allowing public properties and removing getters.

01:28
🔧

Property promotion reduces boilerplate

Property promotion significantly reduces code verbosity in value objects.

02:00
⚖️

Final classes favor composition

Marking classes as final encourages composition over inheritance, a best practice.

02:27

[00:00] Let's be honest, some of you haven't

[00:01] used PHP for 20 years now. And probably

[00:03] back in the days, it would look

[00:04] something like this. Everything was

[00:06] unsafe. Things were untyped, insanely

[00:09] verbose. So on this video, I'm going to

[00:11] show you how can you move from this into

[00:14] PHP in 2025. My name is Noo-Noo and

[00:17] welcome to my channel. Just like in C or

[00:19] Java, you can also assign visibility to

[00:21] properties in functions in PHP. So let's

[00:23] start by that and replacing this var

[00:25] with something like private. And then

[00:27] every time we have a function, let's

[00:28] make explicit that this function is

[00:29] public by assigning the visibility

[00:31] public to this functions. Next, unlike

[00:34] you might think, PHP just like

[00:35] TypeScript or Rust is also fully typed.

[00:38] Meaning that I can go to this properties

[00:39] and I can type them. Let's type here

[00:41] that this name is a string but also this

[00:43] age is an integer. We can do the same

[00:45] thing not only on the arguments but also

[00:47] on properties. Let's go all the way up

[00:49] and say that this name is a string and

[00:51] this age is an integer. but also in the

[00:53] getters. Every time I get the name, it

[00:55] will be a string, but also every time I

[00:57] get an age, this will be an integer. So,

[01:00] PHP in 2025 is equally fully typed. Hey,

[01:03] just a quick pause to say that I have

[01:05] this dream of reaching 100K subscribers

[01:07] and still be talking about PHP. So, if

[01:09] you enjoy this video just a little bit,

[01:11] go all the way down, subscribe this

[01:12] channel, and like this video. Now, if

[01:14] you want to be a little bit more strict

[01:15] about types, you can go all the way top

[01:17] and add this declare strict types one.

[01:19] What this will do is that even if you

[01:21] provide a string with a value zero, PHP

[01:24] won't accept it because it needs to be

[01:26] explicitly an integer value. Now this

[01:28] class is the value object. So we don't

[01:30] actually plan to change the state

[01:32] inside. So what we can do is instruct

[01:34] PHP about that and use this readonly

[01:36] modifier before the class to instruct

[01:38] PHP that the state will never change.

[01:41] And in fact, if we try to mutate the

[01:43] name or the H, PHP will prevent that

[01:45] from happening thanks to the readonly

[01:47] keyword. And not that the state can

[01:48] change, what we can do is actually make

[01:50] these properties fully public because

[01:52] they cannot change anyways. Meaning that

[01:53] we can go all the way down and also

[01:55] remove all these getters. There is a few

[01:57] more things we can do to make this code

[01:59] a little bit better. One of them is

[02:00] called property promotion. So when you

[02:02] are providing arguments to a constructor

[02:05] and those arguments will be assigned

[02:06] directly to properties. What you can do

[02:08] is assign those properties directly on

[02:10] those arguments. So what I will do here

[02:12] is declare the visibility of the name

[02:14] directly on the argument and do the same

[02:16] thing with the age. And by doing this we

[02:18] can effectively remove this code but

[02:20] also this code making effectively the

[02:22] guest class looking as beautiful as

[02:25] this. Now there is one final thing you

[02:27] can do to favor composition instead of

[02:29] inheritance which is marking classes as

[02:32] final especially classes that you want

[02:34] to strictly forbid them for being

[02:35] inherited. So what you can do is add

[02:37] this final keyword meaning that if

[02:39] someone were to extend this class, PHP

[02:42] will prevent that from happening. Now

[02:44] that was just a small example in PHP in

[02:46] 20125. There is many things we haven't

[02:48] covered today. Things like enums,

[02:50] attributes, name it arguments and more.

[02:52] If you want to know more about PHP, make

[02:54] sure to subscribe my channel because I'm

[02:55] literally talking about them every

[02:57] single time. Just like any modern

[02:59] language, PHP's tooling have also

[03:01] massively improved in 2025. We have our

[03:04] own TypeScript with PHP stand. We have

[03:06] our own linking with pint but also

[03:09] testing. We have past PHP. Hope this

[03:11] video gives you a different perspective

[03:13] how modern PHP is today. If you want to

[03:15] start with PHP, go to php.new and is

[03:18] literally one command. Hope you enjoyed

[03:20] the video and catch you guys next time.

[03:26] [Music]

⚡ Saved you 0h 03m reading this? Transcribe any YouTube video for free — no signup needed.