Live data from Hacker News

Making PHP Safer

tech.blog.box.com

1–10 of 53 posts

Re: Making PHP Safer

#4
I'd really like to know why they chose to do this instead of trying to make spltypes and type hinting more robust. Annotations seem like an ugly way of doing this.

Re: Making PHP Safer

#6
I hate annotations in PHP. They feel very tacked-on. I'd much rather see actual enforced typing in the language.

This is a step in the right direction, but it doesn't go far enough, in my opinion.

Re: Making PHP Safer

#8
post #4

I'd really like to know why they chose to do this instead of trying to make spltypes and type hinting more robust. Annotations seem like an ugly way of doing this.

One of the authors here. We didnt want to change the AST in a way that would be backwards incompatible with vanilla PHP. There is some luxury in being able to turn off this extension when needed. We also have a large enough existing codebase that switching to SPL types everywhere was a non-starter. Our goal here was partly to be able to use PHP's native types and still get some good coverage.

Phpdoc may not seem ideal, and it's not, but it has afforded some significant flexibility

Re: Making PHP Safer

#9
post #4

I'd really like to know why they chose to do this instead of trying to make spltypes and type hinting more robust. Annotations seem like an ugly way of doing this.

The reasons are right in the article: they didn't want to fork PHP and they didn't want a run-time performance hit.

It seems like an interesting solution to me.

Re: Making PHP Safer

#10

I hate annotations in PHP. They feel very tacked-on. I'd much rather see actual enforced typing in the language. This is a step in the right direction, but it doesn't go far enough, in my opinion.

That's because PHP is a tacky language. :)
Post reply on HN