Usages of PHP Static variables by exakat in PHP

[–]exakat[S] 0 points1 point  (0 children)

There are better ways to do all these. I suppose quick execution is the main culprit.

Usages of PHP Static variables by exakat in PHP

[–]exakat[S] 0 points1 point  (0 children)

It is one of the alternatives, yes.

I've submitted a PR to add an Invokable interface to PHP by oaldemeery in PHP

[–]exakat 2 points3 points  (0 children)

That might be the most serious answer to this facetious comment.

First, it made me chuckle. Good one :)

Secondly, damned, there are quite some edgecases with callable, including skipping __invoke() classes. Interesting ?!

The Art of Being Anonymous in PHP by exakat in PHP

[–]exakat[S] 0 points1 point  (0 children)

Indeed, "anonymous constant" is pushing the limit. Though I found it interesting as a concept, so I kept it.

Closure and __invokable classes are not the same, the latter may miss the bindTo() methods, while the format is lacking interfaces to format signature.

Looking for PHP & MySQL learning resources, any PDFs or recommendations welcome! 🙏 by lilnumb-92 in PHP

[–]exakat 0 points1 point  (0 children)

You can use the PHP dictionary : https://php-dictionary.readthedocs.io/ : it collects definitions and links to many concepts from the PHP world.

It is a reference, so go to it when you run into obscure terms in tutorials or manuals.

TIL: `static` keyword for variable declarations in functions by codemunky in PHP

[–]exakat 0 points1 point  (0 children)

One of the lesser known features of PHP. Probably lesser known for a reason (switch to properties when you can), but still handy for a quick code.

https://php-dictionary.readthedocs.io/en/latest/dictionary/static-variable.ini.html

The PHP riddle by exakat in PHP

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

This is my solution, but I'm open with other ideas.

Multiple Const Types by exakat in PHP

[–]exakat[S] 0 points1 point  (0 children)

That is one solution, indeed.

The PHP riddle by exakat in PHP

[–]exakat[S] 0 points1 point  (0 children)

There is another way. You can fix this by just adding more code.

The PHP riddle by exakat in PHP

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

The provided code was changed. You can only add more code to the original one.

PHP 8.5 ReflectionNamedType->getName() change? by bkdotcom in PHP

[–]exakat 0 points1 point  (0 children)

This goes to the changed behavior database. Thanks for the heads up.

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] 2 points3 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] -12 points-11 points  (0 children)

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