Psalm 7 release: PHP security&static analysis software
46 points by danogentili 2 days ago | 24 comments
anthk 4 hours ago
Thou shall use the Rust rewrite of PHP.
replyY-bar 3 hours ago
”Rewrite in Rust” fanboys are more annoying than crypto bros. How is such a feat even possible?
replyscronkfinkle 28 minutes ago
I dunno,unlike the crypto/NFT era, Rust rewrites have demonstrated measured performance and memory savings gains. Some grimace when they see "written in Rust" as a tagline but my immediate thought tends to land more on the "thank God this isn't an electron app" side of things
replyorigini 5 hours ago
Ah boy o boy, PHP was the first lanuage I teached myself but man it still needs PHPDoc comment on return types?
replyCome on PHP has so many shitty things, but even something basic like this is still not in the lanuage itself?
monster_truck 4 hours ago
It's had return type declarations since 7. There's even intersection and literal types now. You could have typed this into google and it would have told you
replybakugo 3 hours ago
Type declarations are still quite limited, though. For example, you can declare that a function returns an array or a string, but not an array of strings.
replylofaszvanitt 3 hours ago
Use a class if you need them.
replybakugo 3 hours ago
How does that solve the problem? You can't declare an array of strings inside a class, either.
replyspiderfarmer 4 hours ago
"Cool! A PHP article on HN, let's rehash some of my comments that got lots of upvotes 11 years ago!"
replyorigini 3 hours ago
Yepp, especially because not much changed and other languages did quite a lot. Strong contrast don't you think?
replywesammikhail 2 hours ago
Hmmm not much changed you say... Lets take a look at https://wiki.php.net/rfc
replyooh wait, you couldn't be more wrong. Pikachuface.png
origini 2 hours ago
Core issues have not been fixed.
replyYou remember when HHVM / hack came out from Facebook? Besides the fact that it was quite a dick move from Facebook to bring it out and then stop supporting it, it pushed PHP to take performance temporarily serious and there was so much air in it.
But the standard library is still inconsistent as hell, type system is still garbage especially mixxing strict and non strict.
The concurrency implementation? Has to be fixed again by frameworks.
And yeah i mean the critisism of my original comment stands as well and thats just an eye sore.
There are two major static analysis tools for PHP, Psalm and PHPstan, both written in PHP. The latter used to be much slower, but last time I tried it there was little difference (about 20 s for 100k lines + dependencies).
My guess is that a new contender, Mago, written in Rust, will probably soon replace those other tools. Its commands (analyze, lint) are already almost as complete as psalm/phpstan. Though the migration won't be easy because it does not have a notion of levels.
PHP even has union types, just like TypeScript.
The major issue is the lack of array types and it's 90% of the reason I see projects using extra linting tools.
[1] https://php.watch/versions/8.0/union-types
PHP still doesn't have generics, right? IMO any type system without higher-order types is definitely on the minimal side.
I haven't actually run into a single issue with PHP's type system in the last few years. Literally the only thing that remains is typed arrays but that seems to be ways off due to fragmentation in how the core devs want it handled.