@dseguy@phpc.social
@dseguy@phpc.social avatar

dseguy

@dseguy@phpc.social

Static code analysis maestro https://phpc.social/@Exakat #PHP expert elePHPant breeder

This profile is from a federated server and may be incomplete. Browse more on the original instance.

dseguy, to php French
@dseguy@phpc.social avatar

Next round of deprecations for 8.3 is starting.

As for each version, one of the important RFC to monitor.

https://wiki.php.net/rfc/deprecations_php_8_3

dseguy, to php French
@dseguy@phpc.social avatar

😂 This made me chuckle... welcome to 8.3 !

First array is the type, the second is the name of the constant, with the relaxed keyword, and the last one is the value of the array.

dseguy, to php French
@dseguy@phpc.social avatar

A good way to meet your soon-to-be new 8.3 version is to read about its error messages. Now or later, what's the difference ?

https://www.exakat.io/en/new-php-error-messages-in-php-8-3/

dseguy, to random French
@dseguy@phpc.social avatar

Choose your team : condition in a loop, or array_filter() first ?

Make up your mind, and then you can read this new blog post.

The result will NOT surprise you.

https://www.exakat.io/en/array_filter-versus-loop-condition-checks/

dseguy, (edited ) to php French
@dseguy@phpc.social avatar

How big are your source code ? Excluding dependencies (vendor folder)

Generally, is quite compact code, and requires few expressions to achieve its goal.

The largest OSS are 4.9 MLOC (una, bitrix), while the majority is well below 2 000. The figures below partition OSS projects in 4 part of equal size.

Where are you ?

dseguy, to php French
@dseguy@phpc.social avatar

The (array) operator is a simple cast to array. Yet, it is one of the less obvious feature of the language : (array) on integers, on null, on objects, recursive and hidden.

That's a lot to discover for the oldest and most useful operator.

https://www.exakat.io/en/mastering-the-array-cast-operator-in-php-a-comprehensive-guide/

dseguy, to random French
@dseguy@phpc.social avatar

If you forgot in which PHP version a feature was introduced, https://caniphp.com/ did not forget so you can check it there.

dseguy, to php French
@dseguy@phpc.social avatar

Comparison of memory usage and execution speed between associative arrays, named and anonymous classes, stdClasses and extended classes, across PHP versions.

TLDR; using classes is more memory efficient, and a bit faster.

https://www.exakat.io/en/array-classes-and-anonymous-memory-usage/

dseguy, to php French
@dseguy@phpc.social avatar

Useless tip of the day:

Null and booleans accept the array syntax, but always return NULL (and a warning)

Illegal types for array keys lead to a Fatal Error.

But not with NULL and booleans.

https://php-tips.readthedocs.io/en/latest/tips/nullAsArray.html

dseguy, to php French
@dseguy@phpc.social avatar

A quick review of what has changed in switch() with 8.

switch() is impacted by the integer / string comparison evolution, and also by special tricks with null. All these are detailled in this article. Lots of

https://exakat.io/en/php-8-changes-in-switch/

dseguy, to php French
@dseguy@phpc.social avatar

Here is another way to make recursive calls in : use the generator delegation.

The main difference is that it needs to be in a foreach() or a generator using function.

https://3v4l.org/2FDXY

dseguy, to php French
@dseguy@phpc.social avatar

One year ago, we were waiting eagerly for 8.2 and its new features. Now, let's see how those features were adopted in the code repositories.

This means you, DNF types, readonly classes, constants in trait, true/false types.

https://exakat.io/en/php-8-2-features-one-year-later/

dseguy, to php French
@dseguy@phpc.social avatar

8.3 : the future is tomorrow!

Join us online on Wednesday 22 November at 6:30pm (CET)

I share valuable insights into how PHP 8.3 will benefit developers and how you can prepare your code for new features.

Online remote meeting: register https://iomeetups.com/io-php-virtual-meetup-exploring-the-future-php-8-3-is-tomorrow/

dseguy, to php French
@dseguy@phpc.social avatar

All the recursive functions in

From classic recursive functions to their quirky cousins like recursive methods, closures, and arrow functions – it's a whole zoo!

Indirect, abstract, and even distributed recursive functions add layers to the complexity. Embrace the challenges and beauty of recursion in !

https://www.exakat.io/en/all-the-recursive-functions-in-php/

dseguy, to random French
@dseguy@phpc.social avatar

Running @Exakat on an application server will make it faster and more flexible. And there comes FrankenPHP!

Here is the port of a complex CLI intensive application on FrankenPHP, and make it run. It was both teaching and straightforward.

https://www.exakat.io/en/exakat-on-frankenphp/

dseguy, to php French
@dseguy@phpc.social avatar

foreach() works on arrays and objects. On objects, it skips uninitialized properties, which may be very convenient with readonly properties : otherwise, it is a fatal error!

https://php-tips.readthedocs.io/en/latest/tips/foreach_skips_uninitialized.html

dseguy, (edited ) to php French
@dseguy@phpc.social avatar

In the list below, there is one fatal error. All others are working as expected, except for the fact that they probably should yield an error and be not legit.

The error says : "Cannot use [] for reading".

Did you guess the one?

dseguy, to random French
@dseguy@phpc.social avatar

To make a class alias, use class_alias();
To make an interface alias, use class_alias();
To make an enum alias, use class_alias();
To make a trait alias, use class_alias();

Also, no ::enum operator, ::trait operator?

dseguy, (edited ) to php French
@dseguy@phpc.social avatar

Here is the PHPuzzle of the day. Which of the following line is wrong in PHP 8.3 ?

Assume that all needed definitions are available for this to run.

dseguy, to php French
@dseguy@phpc.social avatar

What are the features that makes it worthwile to drop backward compatibility and adoption a newer versions?

We reviewed 51 projects to find out what is the modern features that are adopted when they get the chance.

https://www.exakat.io/en/features-that-make-php-go-forward/

dseguy, to random French
@dseguy@phpc.social avatar

TIL file_put_contents() accepts an array as second argument, and will do an implode("", $array) on it when writing.

Who is using this feature?

cc /@Girgias

https://php-tips.readthedocs.io/en/latest/tips/file_put_array.html

dseguy, to php French
@dseguy@phpc.social avatar

In this code, complains about an unexpected semi-colon, which... doesn't exist.

It is actually the closing tag, which acts as a end of command.

via Ryan Chandler

https://php-tips.readthedocs.io/en/latest/tips/no_semi_colon_in_sight.html

dseguy, to php French
@dseguy@phpc.social avatar

A story of compact() and extract()

Compact() and extract() are two sides of the same coin. They are also a good part of the PHP story, along with the variable variables. Let’s see how they can make it into the future of PHP.

https://www.exakat.io/en/a-story-of-compact-and-extract-2/

dseguy, to php French
@dseguy@phpc.social avatar

I finally found an occurrence of this beauty :

$this->$this

It still looks like a typo in the original code, but with the help of __toString, it works. Also, strict_types doesn't help here.

https://php-tips.readthedocs.io/en/latest/tips/this_this.html and more tips!

dseguy, to php French
@dseguy@phpc.social avatar

Thursday, April 11th is @010php day, hosted by @bitfactory.

This month's session is about advanced type usage. See the impact of types on the structure of your code, identify impossible methods and design the others!

Go! https://www.meetup.com/010php/events/299863925/

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • rosin
  • thenastyranch
  • cubers
  • ethstaker
  • InstantRegret
  • DreamBathrooms
  • ngwrru68w68
  • magazineikmin
  • everett
  • Youngstown
  • mdbf
  • slotface
  • kavyap
  • anitta
  • GTA5RPClips
  • khanakhh
  • normalnudes
  • osvaldo12
  • provamag3
  • cisconetworking
  • Durango
  • tacticalgear
  • modclub
  • Leos
  • megavids
  • tester
  • lostlight
  • All magazines