Earlier quoted context omitted.
I worked at WordPress for half a year, and I'm no expert, but the code reviews there were more intense than any I've ever experienced. Every line of code gets reviewed before it gets committed, and if the commit is longer than 20 lines or so, it undergoes an additional scheduled review as well as pre-commit review. They also have pretty good code sniffers that ought to catch errors like OP mentioned. The reason they'…
> The reason they're concerned, I think, is because they try to protect users who have plugins that came from their plugin repository, where the same code quality rules don't apply. Then start making the quality rules apply. Or produce code quality ratings for plugins and display them for people to make decisions on. Making sure that WP can keep working with lower-quality plugins in the name of 'compatibility' just e…
PHP 8
191–200 of 273 posts
Re: PHP 8
#192Earlier quoted context omitted.
Reading the list of things that worry them makes it clear that it's not so much php is breaking bc than it is wordpress lack of cleaning and linting for so long catching up to them. I mean seriously the first thing they list as a worry is that arithmetic operators will now throw an error when one (and only one) of their operand is an array or resource (eg array + array support remains, it's really int + array or stri…
> it's really int + array or string + file_descriptor, things like that I haven't personally used PHP in years, but was curious about this. Based on some quick/dumb experiments it appears int + array has thrown errors as far back as PHP4: - http://sandbox.onlinephpfunctions.com/code/0b2f22ea881b36e58... - http://sandbox.onlinephpfunctions.com/code/0e5fb752fc3ec28e8... Is the post talking about some other scenario? Ma…
Re: PHP 8
#193Earlier quoted context omitted.
Reading the list of things that worry them makes it clear that it's not so much php is breaking bc than it is wordpress lack of cleaning and linting for so long catching up to them. I mean seriously the first thing they list as a worry is that arithmetic operators will now throw an error when one (and only one) of their operand is an array or resource (eg array + array support remains, it's really int + array or stri…
It also sounds as though the internal type checking is going to be a large developer load as well. In PHP7, internal functions return null for type mismatches, and in PHP8, they raise a TypeError. This means going back through every case where they call an internal function and wrapping it with a try/catch for TypeError, in addition to checking for null. That sounds like a pretty significant workload change.
Re: PHP 8
#194Earlier quoted context omitted.
> And so people who ... wish PHP was a different language are the ones influencing language development. That's definitely been my impression. I used to be a professional PHP developer, still use it occasionally for personal projects, and appreciate the language, warts and all, even if I can't truly say I love* it -- but I'm only half-joking when I quip that PHP has evolved from its roots as a cargo cult version of P…
> - but I'm only half-joking when I quip that PHP has evolved from its roots as a cargo cult version of Perl into a cargo cult version of Java. It's a joke in so far as it is funny - but it's absolutely correct. When you only look at the language... When looking at the VM, Java has an absolutely world class VM, with great engineering and decades worth of research poured into it. PHP has... no such thing.
Re: PHP 8
#195https://packages.debian.org/testing/php/php
Is that correct?
Re: PHP 8
#196Already supported by my local provider, https://gigahost.dk/en/features/php >
Re: PHP 8
#197Earlier quoted context omitted.
Reading the list of things that worry them makes it clear that it's not so much php is breaking bc than it is wordpress lack of cleaning and linting for so long catching up to them. I mean seriously the first thing they list as a worry is that arithmetic operators will now throw an error when one (and only one) of their operand is an array or resource (eg array + array support remains, it's really int + array or stri…
> it's really int + array or string + file_descriptor, things like that I haven't personally used PHP in years, but was curious about this. Based on some quick/dumb experiments it appears int + array has thrown errors as far back as PHP4: - http://sandbox.onlinephpfunctions.com/code/0b2f22ea881b36e58... - http://sandbox.onlinephpfunctions.com/code/0e5fb752fc3ec28e8... Is the post talking about some other scenario? Ma…
Re: PHP 8
#198Earlier quoted context omitted.
> Terrible, terrible, behaviour but there are lots of similar examples in PHP So true. One I ran into recently was comparing hashes that start with '0e' and contain only a numeric component after that prefix. Failure to use the identity operator means that you can have two different hashes returning... equality. PHP apparently thought it a good idea to coerce that into 0 raised to an exponent, which of course always…
Is this fixed in php 8? I did not think this was possible as there is no type coercion and not well documented. [1][2] Noticed "0.2" == "0.20" as another example [1] https://www.php.net/manual/en/language.operators.comparison.... [2] https://www.php.net/manual/en/language.types.type-juggling.p...
I don't know. It's one of those cases where fixing it to do the "right" thing would potentially break a lot of software depending on this sort of erroneous behavior. Part of me wants to say "I hope so" and part of me is kinda terrified at what might happen if they did. Shouldn't be difficult to fix, but it would definitely take some time.
Someone should know if there's a decent linter that would pick this up to make it easier to fix, I would imagine!
> I did not think this was possible as there is no type coercion and not well documented.
I think when applying the equality operator (==) in lieu of the identity operator (===) between strings PHP uses heuristics to decide what to do. If it looks like a number, it coerces it into an int or a float. As an example:
php > var_dump('1e12' == 1e12);
bool(true)
As ridiculous as I think it is, I also take the approach that it's just what PHP does. Weird, maybe a bit eccentric, probably a contributor to difficult-to-find bugs, but it's just something we have to keep in mind. Perhaps I'm feeling charitable because it's Thanksgiving!Re: PHP 8
#199Earlier quoted context omitted.
I don't understand why pretty much no language does that these days. I think the argument is that your IDE should do this, and it does in some cases, but still...
You can get a much more powerful alternative for "free" if you support de-structuring assignments (in arguments). JavaScript Example: function test({a,b,c}) { console.log(c,b,a) }; test({ a: 1, b: 2, c: 3 }); If you have this there's really no need for named arguments anymore. If you add features to your de-structuring, your "named arguments" will have them too (things missing for JS specifically: optional objects, T…
function hello($name='Joe',$title='dear')
{
echo "Hello $title $name";
}
hello('Sue');
Try here: https://3v4l.org/6MZHhWith your object properties approach, you always have to use the variable "names".
Re: PHP 8
#200Earlier quoted context omitted.
That is not a problem with PHP itself, but the way that Apache/Nginx operates PHP. However, if you want to go full PHP, there is this extension that is pretty amazing (has a built-in server on it and more): https://www.swoole.co.uk/ ps: https://github.com/swoole/swoole-src/issues/1401 some performances benchmark (they compare it even with golang)
Does Swoole have any comparison to roadrunner ( https://roadrunner.dev/ )?
Apache and nginx are both great, both have pros and cons, although I would go with nginx and fpm as my first choice.
Swoole is totally different approach as it runs php as standalone server in a loop, just like python for example. It is great if you serve api but it kills the benefit of having each request isolated as you would have with nginx or apache. So you need to care about memory leaks, db connection pools etc. Also Swoole docs was not great few months ago.
Roadrunner is kind of between apache/nginx and Swoole. It is a golang server that can execute php in workers. For each worker once php is loaded it will stay in memory and it is super fast. The only downside on this one is that Roadrunner is developed by mostly one guy and not much you can find on the internet. Also Roadrunner features set is IMO very narrowed into what the company behind it needs at the time. IMO there is no clear vision where this project is going.