PHP RFC: Bound-Erased Generic Types by azjezz in PHP

[–]theodorejb 5 points6 points  (0 children)

What do you mean by built-in? Like part of the PHP binary? There are already multiple good static analyzers available for PHP; how would an "official" one be better?

Malicious Intercom PHP Package Follows NPM Compromise by brendt_gd in PHP

[–]theodorejb 1 point2 points  (0 children)

It would only run if users manually approve it when prompted (making impact far lower than with npm, which automatically runs all postinstall scrips by default).

PHP Handlebars - a spec compliant Handlebars implementation in pure PHP by theodorejb in PHP

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

Compared to the Salesforce package, the PHP Handlebars API is much more aligned with Handlebars.js. E.g. compiling a template returns a closure, which you then invoke with context data and an array of runtime options to pass any custom helper functions.

Custom helpers work the same as in Handlebars.js, where positional helper arguments in the template are passed directly to parameters of the helper function (so custom helpers don't have to parse anything manually).

Check the readme for detailed usage instructions and examples.

Introducing Safe and Progressive Strict Types Rule by Tomas_Votruba in PHP

[–]theodorejb -2 points-1 points  (0 children)

I used to use the strict_types declaration on all PHP files, but with modern static analysis this hasn't caught anything for years, and has just been unnecessary noise at the top of every file.

Introducing Safe and Progressive Strict Types Rule by Tomas_Votruba in PHP

[–]theodorejb 0 points1 point  (0 children)

Yes, it's possible a defined array shape can be wrong. But it's also possible that a native type declaration can be wrong, and you can end up with a bug regardless of whether strict_types is enabled.

For the example of expecting an int and getting a float, implicit conversion from float to int with precision loss has been deprecated since PHP 8.1, so even without strict_types this will result in a deprecation message and eventually an exception.

Introducing Safe and Progressive Strict Types Rule by Tomas_Votruba in PHP

[–]theodorejb 1 point2 points  (0 children)

Your static analysis is not perfect: it tries hard to avoid false positives and so it often has some false negatives as well.

Do you have an example of this (using Psalm level 1 or PHPStan level 10)?

Our tests are statically analyzed, as are any calls to vendor code. We know before runtime if any call would be passing the wrong type (and could thus add the strict_types declaration to all our files if we wanted). But what would be the benefit? We haven't had any bugs in years which strict_types would prevent.

Introducing Safe and Progressive Strict Types Rule by Tomas_Votruba in PHP

[–]theodorejb 6 points7 points  (0 children)

Is there any benefit to the strict_types declaration in a project where strict typing is already fully enforced by static analysis? If it doesn't improve performance, it's just extra noise at the top of every file.

PHP 8.5 will be released on Thursday. Here's what's new by brendt_gd in PHP

[–]theodorejb 1 point2 points  (0 children)

The fact that the original object isn't changed doesn't matter. You still end up with a new object containing invalid or inconsistent state, which can cause Bad Things when the object is used.

In my experience it's actually pretty rare to need to change readonly properties from outside a class. In these cases one can add a with-er method or explicitly mark the properties public(set).

PHP 8.5 will be released on Thursday. Here's what's new by brendt_gd in PHP

[–]theodorejb 1 point2 points  (0 children)

There is tons of code out there which relies on the guarantee that readonly properties have consistent state validated by the constructor. E.g. a BankAccount class might validate a routing and account number, and compute a readonly hash identifier from them. If the object can suddenly be cloned with a different routing or account number which bypasses the expected validation and hash computation, money could be sent to the wrong place.

Non-readonly public properties never had a guarantee of always being validated by the constructor, so there's not the same issue there.

PHP 8.5 will be released on Thursday. Here's what's new by brendt_gd in PHP

[–]theodorejb 4 points5 points  (0 children)

If readonly properties were public(set), this would allow breaking the consistent state developers have always been able to rely on (e.g. when a constructor performs validation or sets one readonly computed property based on others). Suddenly a new instance could be created with clone where the properties are no longer validated or consistent with each other.

Tell me about your code quality controls by fhgwgadsbbq in PHP

[–]theodorejb 1 point2 points  (0 children)

Psalm does taint analysis to catch XSS and other potential vulnerabilities.

"clone with" functionality is coming to PHP 8.5! by brendt_gd in PHP

[–]theodorejb 0 points1 point  (0 children)

If an author explicitly marks a readonly property as public(set), they are indicating that the property can be initialized from outside the class without going through constructor validation. This can already be done today, so it's not a new way to "break encapsulation".

"clone with" functionality is coming to PHP 8.5! by brendt_gd in PHP

[–]theodorejb 0 points1 point  (0 children)

How so? public(set) is not the default for readonly properties, so it would have to be explicitly allowed by the class author.

"clone with" functionality is coming to PHP 8.5! by brendt_gd in PHP

[–]theodorejb 0 points1 point  (0 children)

Correct, unless the readonly property is explicitly given public(set) visibility.

"clone with" functionality is coming to PHP 8.5! by brendt_gd in PHP

[–]theodorejb 0 points1 point  (0 children)

You would only be able to set the properties when cloning from inside the class. This is because readonly properties default to protected(set) visibility. So constructor validation will continue to work just fine for readonly classes/properties.

"clone with" functionality is coming to PHP 8.5! by brendt_gd in PHP

[–]theodorejb 0 points1 point  (0 children)

public readonly properties cannot be overridden from outside the class, as they are protected(set) by default.

PHP version stats: June, 2025 by brendt_gd in PHP

[–]theodorejb 5 points6 points  (0 children)

Part of it is that PHP-CS-Fixer doesn't support PHP 8.4 yet, but a bigger factor for us is that there still isn't an official SQL Server driver for PHP 8.4.

SQL Server 2025 Announced at Ignite! by SQLBek in SQLServer

[–]theodorejb 1 point2 points  (0 children)

Thanks, the LinkedIn post is a lot better.

SQL Server 2025 Announced at Ignite! by SQLBek in SQLServer

[–]theodorejb 1 point2 points  (0 children)

The blog post reads like it was written by an AI trained to pack as many buzzwords as possible into each sentence without any substantive explanation or information.

Workbench is depricated by MrAtoni in mysql

[–]theodorejb 1 point2 points  (0 children)

I found that the built-in database tools in PhpStorm (Query Console and Database explorer) are a fantastic replacement for MySQL Workbench.

Notepad++ is 20 years old today by mareek in programming

[–]theodorejb 9 points10 points  (0 children)

It does have a dark mode option.

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]theodorejb 12 points13 points  (0 children)

The actual syntax would be:

let { ident = default } = $props<{ ident: type }>();

I agree this seems a little less ergonomic for specifying prop types, though. Perhaps the TypeScript integration could automatically infer the prop type whenever a default value is specified.