Skip to content

Conversation

@jordikroon
Copy link

Within the documentation there are many inconsistencies. One of those is how null and booleans are written.
At some places it is written as NULL where in other places null is used.

Within parameters you generally want to use the lowercase variants. And also when mentioning the type null on its own.
At places like var dump results, you generally want to use the uppercase variant to make it in line with what PHP returns.

This change tries to tackle these inconsistencies. I did my very best not to touch values that are irrelevant, for example the value NULL within SQL. But since it we touch a lot of different files, have a good look.

The same has been done with TRUE/FALSE. Though in those situations it is almost always the lowercase variant.

@jordikroon jordikroon marked this pull request as ready for review December 29, 2025 23:37
@kamil-tekiela
Copy link
Member

What is the actual benefit?

I'd rather not do it. Constants are usually written in all uppercase letters, whereas types are written in lowercase, which makes these three values somewhat ambiguous. https://3v4l.org/7NpFtB

I'd prefer that PHP manual doesn't dictate the style as long as the language doesn't differentiate.

@jordikroon
Copy link
Author

On the technical side there are no benefits since the compiler will use the same Opcode regardless of using the uppercase, lowercase or a variant. E.g. NuLL would also work.

However there are some aspects of interest I believe. Within the stubs the lowercase variant is exclusively used. That means that all documented method/function signatures are all in lowercase already and changing it within examples would make it more consistent.

Secondly internally these are considered special constants but technically they are considered literals. So in some way it remove ambiguity with regular constants or predefined flags.

For example, this would be allowed:

const BOOL = 123;

function test(NULL|BOOL $test ) {
    return BOOL;
}
    
echo test(true);

But this wouldn't because only null/true/false are considered special constants.

const NULL = 123;

function test(NULL|BOOL $test ) {
    return NULL;
}
    
echo test(true);

So while I do agree that this is very opinionated, I believe it aligns more with other resources and modern standards. I also agree that we should not dictate styles. But as you mentioned that we can generally accept constants to be in uppercase (though PHP doesn't differentiate either), we also generally accept literals to be in lowercase.

Though if this change is not desirable within the docs, I am happy to accept that fact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants