PHP Annotated – July 2022

Greetings everyone!

Welcome to the July installment of PHP Annotated, where we’ll catch up on the most interesting things that have happened in the PHP world over the last month, including curated news, articles, tools, and videos.

News

PHP 8.2.0 Alpha 2 and PHP 8.2.0 Alpha 3 have been released
The third and final alpha has been delivered as scheduled. The next release is PHP 8.2.0 Beta 1, which is expected on July 21.

For a detailed list of what’s coming in PHP 8.2, see php.watch or stitcher.io.

PHP 8.0.21 and PHP 8.1.8 have been released

PHP Foundation Update, June 2022
Check out monthly updates for sponsors.

php.net redesign is being discussed

As a design experiment, I gave the current #php website a makeover. There are quite a few more tweaks I could make, but I’m happy with it so far.

What you think? pic.twitter.com/3o9TYKgKnm

— Mike van Riel (@mvriel) July 1, 2022

Meanwhile, php.net source code now uses friendsofphp/php-cs-fixer to fix coding standard issues, thanks to Andreas Möller.

If you’d like to help PHP’s main site update, make sure to check out the contributing guide.

A popular async framework for PHP ReactPHP turned 10
To celebrate, the team released an all-new async component, reactphp/async, with async & await functions, and it’s built on top of fibers, i.e. PHP 8.1+.

Read the story by Cees-Jan Kiewiet My road to fibers with ReactPHP.

Is PHP dead?
Answered once and forever.

PHP Core

Most of the Core news is covered in detail in the PHP Core Roundup series from the PHP Foundation. The next episode of this series is coming soon, so we’ll only mention updates briefly:

RFC: Disjunctive Normal Form Types #PHP 8.2
The support for Disjunctive Normal Form types has been approved for PHP 8.2. It will allow mixing union and intersection types.

class Foo {
public function bar(): (A & B) | D;
}

Learn more from Derick Rethan’s ? PHP Internals News podcast Episode 103 with George Peter Banyard.

RFC: Fetch properties of enums in const expressions #PHP 8.2
In PHP 8.2 it will be possible to use -> / ?-> to fetch properties of enums in constant expressions.

enum A: string {
case B = ‚B‘;
const C = [self::B->value => self::B];
}

RFC: Random Extension Improvement #PHP 8.2

RFC: Make the iterator_*() family accept all iterables #PHP 8.2.
In PHP 8.2 the $iterator parameter of iterator_to_array() and iterator_count() will be widened from Traversable to iterable (i.e. to Traversable|array).

function foo(iterable $foo) {
$foo = iterator_to_array($foo); //now accepts arrays

return array_map(strlen(…), $foo);
}

RFC: Constants in Traits #PHP 8.2
In PHP 8.2 it will be possible to define constants in traits in the same manner that is currently possible for properties.

trait Foo {
public const PHP_VERSION = ‚8.2‘;
}

class Base {
use Foo;
}

class Bar extends Base {
public function phpVersion(): void {
echo parent::PHP_VERSION; // 8.2
}
}

RFC: New Curl URL API

RFC: json_encode indentation

RFC: Stricter implicit boolean coercions

RFC: Create a global login system for php.net

RFC: Short Closures 2.0

Let’s try and improve the RFC so it can be approved next time ? https://t.co/DIW9AvmECB

— Marcel Pociot ? (@marcelpociot) July 16, 2022

? RFC: Auto-implement Stringable for string backed enums
This RFC proposes that string-backed enums auto-implement Stringable, while still disallowing userland implementations of the method.

? RFC: PDO driver specific sub-classes

? RFC: Unify PHP’s typing modes (aka remove strict_type declare)
A draft idea from George Peter Banyard to make strict_type the default in PHP (9+), along with consideration of its impact on type casting usage and developer burden.

Tools

laravel/pint – A minimalist code style fixer for PHP. Essentially, a wrapper around FriendsOfPHP/PHP-CS-Fixer, but with easier configuration and a fancy output.

DaveLiddament/php-language-extensions – Attributes to define PHP language extensions (to be enforced by static analysis): #[Friend], #[Package], and more.

RobiNN1/phpCacheAdmin – Web dashboard for Redis, Memcache(d), and OPCache.

thecodingmachine/safe – All PHP functions rewritten to throw exceptions instead of returning false.

cerbero90/enum – Zero-dependency PHP library to supercharge enum functionalities.

PrinsFrank/standards – A collection of standards as PHP Enums: ISO3166, ISO4217, ISO639, and more.

soatok/cupcake – A PHP library for simple, secure HTML forms (generation and processing).

T-Regx/T-Regx – A PHP regular expression brought up to modern standards. Check out the section about preg_* inconsistencies in the readme.

deComplex.me – A web tool to compare the complexity of two code blocks side by side.

PiotrPress/wordpress-hooks – What a nice use case for attributes! The library allows you to use them to automatically add WordPress Hooks (Filters and Actions) to objects’ methods.

markrogoyski/itertools-php – PHP iteration tools to power up your loops.

Composer 2.4 will be released later this year, and it will feature two new commands:

New composer audit Command and security audits by Ayesh Karunaratne.
New composer bump Command by Ayesh Karunaratne.

Symfony

Launched ux.symfony.com and released 4 New UX Components.
The website is a playground for touching and sampling each UX component.

Twig Smoke Rendering – Fortune Favors the Bold by Tomas Votruba.

Laravel

Vite is now the default frontend asset bundler in new Laravel projects, including Breeze and Jetstream.

Today we’re pumped to announce that new Laravel projects use Vite to bundle frontend assets. Breeze and Jetstream have been updated as well. ?

Experience lightning fast Hot Module Replacement when using the new Breeze / Vite stack with Inertia Vue or React. ⚡

— Taylor Otwell ? (@taylorotwell) June 28, 2022

Check out the Moving A Laravel Webpack Project To Vite tutorial by Christoph Rumpel.

hammerstonedev/sidecar – The package allows you to deploy and execute AWS Lambda functions from your Laravel application. An example use case is making screenshots via Browsershot.

calebporzio/parental – Brings STI (Single Table Inheritance) capabilities to Eloquent.

spatie/laravel-onboard – A package to create step-by-step user onboarding for your app.

zgabievi/laravel-promocodes – A powerful generator of coupons and promotional codes.

abrouter/laravel-abtest – A simple package to run A/B tests with Laravel.

Running PHPStan on max with Laravel by Steve McDougall.

Add comments to SQL queries made by Laravel by Freek Van der Herten.

Containerizing Laravel Applications by Matt Casperson.

Misc

The very useful variadic argument by Damien Seguy.

5 ways to give a name to your booleans by Damien Seguy.

Top 100 PHP classes that you should know by Damien Seguy.

PHP version stats: July, 2022 by Brent Roose.

5 Pitfalls of Upgrade to Native PHP Enums and How to Avoid Them by Tomas Votruba.

On the use of enums by Larry Garfield – When should you use PHP enums, and when shouldn’t you?

Effective immutability with PHPStan by Matthias Noback – DateTimeImmutable is actually mutable.

Benchmarking serialization by Larry Garfield.

Decoupling your security user from your user model by Matthias Noback.

Complete guide for PHP & Neo4j and using graph databases by Michal Štefaňák.

How to automatically add return type declarations with Rector and without breaking your code.

PHP-FPM tuning: Using ‘pm static’ for max performance by Hayden James.

How can I trust my test suite? by Antonello D’Ippolito.

Audio/Video

? The evolution of PHP objects: from PHP 5.6 to PHP 8.2 by Brent Roose.

? The problem with null by Brent Roose.

? Free The Geek podcast Episode 38 – With Steve McDougall. This episode also covers streaming as well as learning Laravel and PHP.

? PHP Roundtable 85: The State of PHP User Groups.

? Road Runner video tutorials.

? How To Install Xdebug 3 with Docker & PhpStorm.

Community

A Field Guide to ElePHPants edited by Philip Sharp.
Did you know that there are 57 different elephpants?

PUFA – It’s like wordle, but for guessing PHP functions and keywords.

When programming, it’s important to write syntax properly, otherwise, your program won’t work. #protip #masterprogrammer pic.twitter.com/DUAQ66pa6B

— Steve Bauman (@realstevebauman) June 29, 2022

I just came back from the future, this is what I read on a tombstone#PHP #PhpNotDead pic.twitter.com/gAzpqwh8mH

— Frédéric Bouchery (@FredBouchery) June 20, 2022

That’s all for today – thanks for reading!

If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post or send me a tweet.

Subscribe to PHP Annotated

Your JetBrains PhpStorm team
The Drive to Develop

Roman Pronskiy

Product marketing manager for @PhpStorm, helped to launch @The PHP Foundation.

Twitter | GitHub

Sergey Panteleev

PHP 8.2 release manager, PHP Documentation maintainer.

Twitter | GitHub

The PhpStorm Blog : The Lightning-Smart IDE for PHP Programming | The JetBrains Blog
Read More

Generated by Feedzy