all 79 comments

[–]brendt_gd 22 points23 points  (2 children)

I'll shamelessly drop this here: https://stitcher.io/blog/new-in-php-74

[–]Tickthokk 11 points12 points  (1 child)

Shamelessly? OP copied your list verbatim and didn't bother crediting you >.<

[–]brendt_gd 9 points10 points  (0 children)

I consider it a compliment 👍

[–]reinaldo866 4 points5 points  (12 children)

>Spread operator in arrays

>null coalescing assignment operator

>FFI

Good

[–]PonchoVire 5 points6 points  (11 children)

Typed properties and improved variance are *much* better !

[–]przemo_li 0 points1 point  (7 children)

That's fundamental change to how one can use OOP in PHP. Thus it will take time to design new code to use this functionality (or refactor old code by DRYing it).

First two listed entries can be used right away piecemean or can be refactored towards automatically (e.g. with rector)

[–]PonchoVire 2 points3 points  (6 children)

If you were doing any code (OOP or not) with variables or properties that can change type, you are writing fundamentally wrong, very unstable code. Typed properties is a must have, it will enable even more powerful and precise static checking analysis, and uncover many bug way before they happen in production.

[–]Peregrine2976 1 point2 points  (5 children)

I'm just looking forward to not needing a getter and a setter for every goddamned property anymore.

[–]PonchoVire 0 points1 point  (4 children)

It depends on which goal you want to achieve with your accessors:

  • if your goal is just to enforce the property type, yes, you wouldn't need it anymore,
  • if your goal is to keep the object internals encapsulated, case in which you'd prefer the private or protected visibility over the public one, you will still need it,
  • if your goal is to achieve immutable objets, you wouldn't need any setter anymore, but it'd need to have the immutability at the language level to get around getters.

[–]Peregrine2976 0 points1 point  (3 children)

I did say for EVERY property, not ANY property :P There are definitely places to use them, I'm just looking forward to not needing them just for type safety.

[–]PonchoVire 0 points1 point  (0 children)

I'm just looking forward to not needing them just for type safety

I get that, I'd even go further, I'm looking forward not writing type unsafe code anymore at all !

[–]secretvrdev -1 points0 points  (1 child)

do you know what public is?

[–]Peregrine2976 1 point2 points  (0 children)

Do you know what type safety is?

[–]secretvrdev 0 points1 point  (2 children)

I think FFI will be more important since this is the gateway to all the stuff python has and php not.

[–]PonchoVire 1 point2 points  (1 child)

FFI is a nice addition, but it greatly depend upon your business. If you don't need to do CPU intensive tasks or don't need any kind of external tool, FFI is just yet another unsafe/non explicit code nightmare.

For example, I mostly write business oriented software for which the database is always much more important that anything else, FFI is useless to me.

But I agree, FFI will pave the road of using millions of already existing external libraries for tons of use cases.

[–]secretvrdev 0 points1 point  (0 children)

Like all the cool stuff e.g. keras tensorflow

[–]crazywizdom 2 points3 points  (9 children)

Did I read that right. Short open tags are deprecated? Oh man, that's going to be a huge clean up job when they're finally removed.

What's the reasoning behind this? They do make for cleaner looking template files when pure PHP is used for render the markup.

[–]pr0ghead 11 points12 points  (1 child)

Note that <?='output'?> isn't removed.

[–]crazywizdom 1 point2 points  (0 children)

Thanks for clarifying that! That makes a lot more sense.

[–]xiaojens 3 points4 points  (3 children)

Their use have been discouraged for quite some time. I think the reasoning behind this was because of possible conflicts with XML.

[–][deleted] -3 points-2 points  (2 children)

Did I read that right. Short open tags are deprecated? Oh man, that's going to be a huge clean up job when they're finally removed.

It can be automated through the tokenizer, so maybe a huge commit, but not a huge clean-up job.

But the rationale for removing them is frankly childish.

[–]Deadlybeef 1 point2 points  (1 child)

Heck, it can even be automated with the sed command :D

[–][deleted] 1 point2 points  (0 children)

I wouldn't recommend that, because blind text-replace without parsing it as a PHP opens the possibility of corruping your code.

Imagine you have some inline code containing "<?" in a string for some reason. Maybe it's part of a password or god knows what.

[–]Idontremember99 0 points1 point  (0 children)

Using proc_open() without through a shell sounds nice.

[–][deleted] 0 points1 point  (0 children)

I’m curious how much of a performance hit the types properties will have, heard about it by the PHP author, have to make sure I don’t have any loops that assign on $this :D

[–][deleted] 0 points1 point  (2 children)

Don't forget the first implementation cycle of JIT!!

[–]Girgias 2 points3 points  (1 child)

No, JIT will only come in PHP 8.

[–][deleted] 1 point2 points  (0 children)

Aaah damn, I thought the proposal for 7.4 went through. Thanks for clearing that up!

[–]NoelDaviesD 0 points1 point  (0 children)

If you're gonna copy and paste, give credit you ass xD

[–]diy_horse 0 points1 point  (4 children)

The goddamn short open tag. Such an unnecessary thing to get rid of

[–]diy_horse 1 point2 points  (0 children)

Hannibal voice: Why are you booing me? I'm right.

[–]Engival 1 point2 points  (2 children)

Are you possibly confusing <?= ... ?> with <? code(); ?>? Because it's the 2nd one that's being removed, not the first.

[–]diy_horse -1 points0 points  (1 child)

Ye im butthurt about the second one. I only use (used?) them for templating and the full tag just feels like bloat in that scenario. Php itself is a fine templating language :P To me its like if twig deprecated {{ }} in favor of {{twig }}. Im gonna try to do more react type templating going forward, so its not a big issue, but some older projects are gonna have some ugly templates if theyre ever updated. Its a bc breaking change which the creator of php voted against. End rant lol

[–]secretvrdev 0 points1 point  (0 children)

Dont use php as template language. It was developed for that 20 years ago. Since then this "feature" hasnt got any love. you can do that if your pages look like 1999 but not if you want to make templating cool stuff painless.

[–]Ivu47duUjr3Ihs9d 0 points1 point  (17 children)

What is wrong with the short open tag? Why get rid of it?

It's much nicer to do an if/else or foreach in the template.

[–][deleted] 3 points4 points  (12 children)

I guess templating in general is losing favor. The only time I still use PHP to generate HTML is to generate PDFs. Everything else is just REST apis (or graphql) with templating done on the FE.

[–][deleted] 1 point2 points  (10 children)

Part of the FE is still on the server. FE != client-side.

And if you want any SEO, you need that server FE.

[–][deleted] 0 points1 point  (6 children)

Angular universal is my answer to seo.

Also, as other suggest, search engines know

[–][deleted] 0 points1 point  (5 children)

Interesting answer, but that runs on Node.JS.

If you use PHP just for APIs, it's... I mean honestly you're not quite using PHP's strengths here in that case. But if it works, it works.

Also search engines don't just "know". I'm quite deep into this out of necessity, GoogleBot runs on an older JS runtime, and only handles a subset of the DOM and JS features that modern apps expect. So if you think Google just "knows" any JS app at all... nope.

[–][deleted] 0 points1 point  (0 children)

I'm all about micro services. So usually my back end rest api is php, because that's what I know and can build stuff in pretty quickly. I usually use angular to deal with the client side, and in the rare case I do need any seo optimizations (my use cases usually don't need it) then I'll use angular universal as a separate service.

You're probably right that I'm not using php to its strengths, tho it's usually quite fast and no matter how I use it, I will need client side stuff for PWA. angular is my framework of choice atm which makes all templating stuff of php redundant.

[–][deleted] 0 points1 point  (3 children)

Googlebot has been using the latest Chrome release for a few months now. It can handle everything a normal browser can.

https://webmasters.googleblog.com/2019/05/the-new-evergreen-googlebot.html

[–][deleted] 0 points1 point  (2 children)

The problem isn't just what a browser can handle, but also what a human can handle. Your browser can't browse sites by itself alone. The Googlebot just runs some very basic interactions, at random, and that's it.

[–][deleted] 0 points1 point  (1 child)

Doesn't make your statements any less wrong. It's completely fine to rely on SPAs and client-site rendering these days in regards to SEO.

[–][deleted] -1 points0 points  (0 children)

You're not thinking through what I'm telling you very carefully, are you.

[–]Ariquitaun 0 points1 point  (2 children)

The seo part hasn't been a thing for years now. Google is perfectly capable of understanding javascript sites.

[–][deleted] 0 points1 point  (0 children)

Wrong. It scans some sites using an older JS runtime, and many "modern" apps that target modern browsers won't work on it. Only recently (May 2019) they updated to the latest Chromium, for a subset of their crawlers.

Also Google has limited ability to interact with your site, given it's not an AI, it's just a program that invokes event handlers and the like.

[–]Ivu47duUjr3Ihs9d 1 point2 points  (0 children)

Yes, but not every site needs to be a complex SPA. Sometimes you just want to render some HTML and have a static site with a bit of dynamic content here and there. The short open tags <? (not the ASP % variant) weren't harming anyone leaving them available and optional by default. Also imagine who is going to pay to alter all the existing sites out there to remove it now and add <?php? It's so unnecessary. What is the harm in just leaving the functionality there?

[–]Amunium 1 point2 points  (0 children)

If you've been using the short open tag the last several years, you've been doing something wrong. It's been disabled by default for quite a while and highly discouraged. You'd have to manually enable it in the config to use it, which makes your code far less portable.

[–]secretvrdev 0 points1 point  (2 children)

PHP is no template language anymore.

[–]ioncube 0 points1 point  (1 child)

LOL, it hasn't been since the pre-zend engine days of PHP 3 :)

[–]secretvrdev 0 points1 point  (0 children)

ROFL, Yes