DEV Community

Discussion on: How to write a different PHP?

Collapse
 
erhankilic profile image
Erhan Kılıç • Edited

I never use arrow function. If I wanted to use javascript, I would use it not php. Arrow function destoys the readabilty of the code.
I don't like using everything if it's new, you need to think about it if it's worth or not.

Collapse
 
adnanbabakan profile image
Adnan Babakan (he/him)

Hi Erhan
PHP and JavaScript are different and I don't think only just because you want to use arrow functions you would switch to JavaScript.
On the opposite hand, I think arrow functions increase the readability.

Collapse
 
erhankilic profile image
Erhan Kılıç

Well, If you work on your own project alone it can be ok but real world isn't like that. You can work with a team on a big project and it can be really really messy with arrow function.
I know it because I worked on a big javascript project with a big team and arrow function makes it really mess in my opinion.
Right now my php team doesn't allow using arrow function and I'm happy about it.

Thread Thread
 
adnanbabakan profile image
Adnan Babakan (he/him)

I respect your opinion but really disagree about being messy since arrow functions are made to make code more clear if your function is not that much complicated. If you wanted to use a global variable in PHP you should GLOBAL or $_GLOBAL which is not needed in arrow functions.

Collapse
 
patabah profile image
PatAbah

For functions that perform simple operations, I'll rather a bunch of arrow functions instead.
IMO, It makes such functions more readable 😁