Toots for dseguy@phpc.social account

Written by dseguy on 2025-01-23 at 16:09

[#]PHP 8.4 is deprecating the usage of _ (underscore) as a class name. Anyone knows why?

The same name is available for functions, methods and constants, so, with named parameters, we can still write the beauty below.

[#]phptip #phptrick

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

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2025-01-17 at 16:44

When using dynamic code with #PHP, the code must provide a string for the method or property name. Although,

[#]phptip #phptrick

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

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2025-01-14 at 16:51

Two things that surprised me today, with static.

First, it looks like a 'static' typed property, until I read the default value. It took me a while to figure out.

Secondly, static properties may be inherited, or be distinct from the parent: redefine it in the child, and that segregate them. 😮

[#]phptip #phptrick

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

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2025-01-13 at 21:26

The most common tools and services used in #PHP open source projects. VCS, CI, SCA, Unit Tests, builders, IDE...

2025 updated list.

https://www.exakat.io/en/common-services-with-php-application/

=> More informations about this toot | View the thread

Written by dseguy on 2025-01-10 at 17:45

[#]PHP trick question, for the Friday developer: where do you put the parenthesis in a new call:

[#]phptip #php trick

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

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2025-01-09 at 12:54

"Cannot call constructor" is a real #PHP error message. And there is also "Must call the parent constructor".

To call or not to call the constructor: definitely a question, and may be, an improvement for #PHP 8.5.

[#]phptip #phptrick

https://www.exakat.io/en/php-constructors-and-inheritance/

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2025-01-05 at 11:55

I already knew that #PHP is

but TIL it is also a hairdresser in slovakia.

And you? What is your own special #PHP meaning?

https://www.exakat.io/en/what-does-php-mean/

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2025-01-03 at 17:43

So, #PHP has fluent interfaces, but it also can do fluent functions: functions that can be chain called.

As usual, it works but it is a tad cumbersome.

[#]phptip #phptrick

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

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-12-26 at 15:12

A #PHP global constant redefinition is a simple warning.

A #PHP class constant redefinition is a full Fatal Error.

I am so used to the Fatal error, that I expected the global constant to behave the same. Shouldn't they?

[#]phptip #phptrick

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

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-12-20 at 15:34

Junior dev: I really really want to use {$a::class} inside a double-quoted #PHP string, but it gives a syntax error!

Me, an intellectual: Hold my beer.

https://php-tips.readthedocs.io/en/latest/tips/no-constant-in-string.html

[#]phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/no-constant-in-string.html

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-12-19 at 13:39

There is a deprecation notice, that request to return an integer, not a boolean, for the custom sorting function of #PHP usort().

Well, it is not harmless, and should be taken seriously.

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

[#]phptip #phptrick

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-12-11 at 20:33

Passing a literal by reference is a Fatal error,

while returning the same literal by reference is a notice.

[#]PHP : Why?

[#]phptip #phptrick

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

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-12-08 at 11:12

How many ways do you know to call a #PHP method in the code ? There are obviously 2 very common ones, but there are a few others, that serve a niche usage.

All the ways to call a method in PHP

In total, I found 11 and missed 2.

[#]phptip #phptrick

https://www.exakat.io/en/call-a-method-in-php/

=> More informations about this toot | View the thread

Written by dseguy on 2024-12-04 at 22:15

How unique are #PHP anonymous objects?

They are all distinct, unless the code of definition is reused multiple and distinct times. Then, such objects are of the same class.

It's a bit weird to understand.

php-tips.readthedocs.io/en/latest/ti...

#phptip #phptrick

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-12-02 at 21:51

[#]PHP Enumerations list all their values, by using ::case(), array_column and the property value.

So convenient!

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

[#]phptip #phptrick

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-11-26 at 22:12

TIL that there are two ways to protect characters in a #PHP regex : preg_quote() and \Q .... \E.

It looks scary, but it might be very useful indeed.

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

[#]phptip #phptrick

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-11-22 at 21:40

How can you get an 'undefined variable' on the same line where the variable is defined?

All is a matter of execution order. Probably not even #PHP related.

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

[#]phptip #phptrick

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-11-21 at 10:54

[#]PHP 8.4 is released. Let the party begin!

New features, modernisation and clean up: the future is here.

Next stop: #PHP 8.5!

https://www.php.net/releases/8.4/en.php

=> More informations about this toot | View the thread

Written by dseguy on 2024-11-19 at 18:28

All #PHP curly braces, and one wrong. Can you spot it?

[#]phptip #phptrick

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

=> View attached media

=> More informations about this toot | View the thread

Written by dseguy on 2024-11-18 at 18:46

[#]PHP 8.4 countdown is on! This is in less than 4 sleeps!

Ready or not, just join us on Thursday, November 21rst to celebrate the release, in The Hague, @wodanbrothers!

News, features, elePHPant, fun and community!

https://www.meetup.com/den-haag-php/events/304263848/

=> More informations about this toot | View the thread

=> This profile with reblog | Go to dseguy@phpc.social account

Proxy Information
Original URL
gemini://mastogem.picasoft.net/profile/109520343178597795
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
400.001985 milliseconds
Gemini-to-HTML Time
8.524933 milliseconds

This content has been proxied by September (ba2dc).