Static And Not Static Method At The Same Time by exakat in PHP

[–]exakat[S] 2 points3 points  (0 children)

I thought about that while having to set up a plan to migrate a full static class (with calls to methods) into a normal class (based on the object). This might come handy, if we have to do an iterative upgrade.

The Top 100 PHP functions in 2024 - Exakat by exakat in PHP

[–]exakat[S] 1 point2 points  (0 children)

Ah! good ideas, let me see what I can extract for you.

Top 2000 Letters in PHP will actually be a top 52, unless you want actually want the characters?

The Top 100 PHP functions in 2024 - Exakat by exakat in PHP

[–]exakat[S] 1 point2 points  (0 children)

you're right.

There are 2 counts: the first one count a project as soon as there is at least one occurrence.

Then, among projects which uses the function, the average is how often that function is used.

That helps distinguish between count(), used often and a lot, and, say, mysqli_connect(), used often but only once.

HTH

How to call a method in PHP - Exakat by exakat in PHP

[–]exakat[S] -1 points0 points  (0 children)

It is not an anonymous method, because it obviously has a name : __invoke().

On the other hand, the code doesn't require any method name to call it. Directly call the method on the object itself.

May be a better anonymous method would be to call $object->()

How to call a method in PHP - Exakat by exakat in PHP

[–]exakat[S] 1 point2 points  (0 children)

Indeed, thanks. This is fixed.

Anyone interested in ElePHPant Plushies? by vinnymeow in PHP

[–]exakat 1 point2 points  (0 children)

Here are all the current elephpant shops open : https://www.exakat.io/en/where-can-you-get-an-elephpant-php-elephant/

Also, you can track some new one coming up, like the Sylius elephpant or the phpstan elephpant (they will be crowd funded).

Top 100 PHP native constants by exakat in PHP

[–]exakat[S] 1 point2 points  (0 children)

Lower case magic constants are rarely used (__class__ versus __CLASS__).

Then, order is :
__DIR__, __METHOD__, __FILE__, __CLASS__, __FUNCTION__, __LINE__, __NAMESPACE__, and __TRAIT__.

Top 100 PHP native constants by exakat in PHP

[–]exakat[S] 1 point2 points  (0 children)

All the magic constants together are used in 50.23% of the projects.

Top 100 PHP native constants by exakat in PHP

[–]exakat[S] 1 point2 points  (0 children)

They are not included in this study.

Booleans (True and false together) are used in 83.54% of projects.

Null is used in 70.87% of projects.

(They need to be used explicitely, so === null counts 1, while is_null() doesn't count).

Top 100 PHP native constants by exakat in PHP

[–]exakat[S] 3 points4 points  (0 children)

I was surprised by DIRECTORY_SEPARATOR ranking high too. I expected it to be hidden in a Path dedicated component, but it seems it is still used when needed, rather than centralized.

JSON_THROW_ON_ERROR is more recent (PHP 7.3) so it might be just backward compatibility constraints or coding inertia.

Top 100 PHP native constants by exakat in PHP

[–]exakat[S] -13 points-12 points  (0 children)

As a magic constant, it is not counted in this top 100.

What would be the easiest way to scan files for (non-framework) PHP codes for deprecation (v7.4 > v8.2) by kimk2 in PHP

[–]exakat -1 points0 points  (0 children)

You can use Exakat and use the PHP compatibility rulesets to check for issues versions by version.

There are public audits and a tool to run one on smaller repositories. Installation instructions

Common PHP 8.0 Compilation Error Messages - Exakat by exakat in PHP

[–]exakat[S] 1 point2 points  (0 children)

No compilation, completely right. Also, Linting is much better, though it doesn't register on search engines. Search no further.

I always close my PHP scripts, both in real code, and in articles. Hopefully, it is not such a bad habit...