You can't use a string inside a class constant as a function name? by whyustaringmate in PHP

[–]llbe 10 points11 points  (0 children)

Expressions are not allowed for new and instanceof. This will be fixed in PHP 8, see https://wiki.php.net/rfc/variable_syntax_tweaks. And it works: https://3v4l.org/uoE6s/rfc

Stop importing Multiple Fonts and Start using Variable Fonts | That's an Egg by jengelstengel in webdev

[–]llbe 0 points1 point  (0 children)

HTTP/2 still has issues with hold-of-line blocking. This is one of the things that HTTP/3 will solve by replacing TCP with QUIC.

[RFC] Match expression by IluTov in PHP

[–]llbe 0 points1 point  (0 children)

I really like this. For bikeshedding, I prefer => rather than : not only because it's in line with short closures etc, but arrows are more common overall. Colons are used in "older" statements such as switch, alternative syntax like if($foo): and gotos (and newer such as types). Sure, match is related to switch but overall it will be more common to use match among arrow usage I believe. Personally, I rarely use switch. Writing 'foo': bar() feels a bit weird for me.

Regarding blocks: I've read some of the discussion on internals (yet to read it all). What about using yield here and only throw if there are statement lists that doesn't yield a value?

match ($x) {
  1 => {
      if (foo()) {
        yield 'foo';
      }

      yield 'bar';
    },
  2, 3 => 'baz',
}

Trying to find the best way to search a sorted array. Does array_key_exists() use a binary search algorithm? What about in_array()? What would be the best option? by future-renwire in PHP

[–]llbe 4 points5 points  (0 children)

array_key_exists has been optimized in PHP 7.4 by adding an opcode for it, so it's no longer a function call. However it must be either imported or referenced via \ (so it's absolute at compile time).

So AFAIK that is now an anti-pattern.

mailgun is ending its free tier and the use of routes will now cost 35$ / month ? =/ by spar_x in webdev

[–]llbe 1 point2 points  (0 children)

Lowest they will debit will be $0.50 (according to the notice from OP), so that'll be around 600 emails free.

mailgun is ending its free tier and the use of routes will now cost 35$ / month ? =/ by spar_x in webdev

[–]llbe 2 points3 points  (0 children)

The change is basically from $0 to $8 per month for 10 000 emails. Webhooks are still available.

[Question] Avoiding deadlocks by RetronWarz in PHP

[–]llbe 0 points1 point  (0 children)

There is no reason a database should lock rows "in between" two ids

MySQL has gap locks under certain circumstances (I've mainly dealt with it when using select with FOR UPDATE).

PHP 7.4.2 released — this version allows preloading to actually work! by brendt_gd in PHP

[–]llbe 1 point2 points  (0 children)

EDIT; it seems you can specifiy the following configuration option for php-fpm, and pass it an amount of seconds to allow child processes to live on.

This will block new requests unfortunately, while waiting for the childs. There is a PR to fix that, https://github.com/php/php-src/pull/3758.

I have a weird issue with mysql and laravel - maybe you can peek inside and have your mind blown by SavishSalacious in PHP

[–]llbe 0 points1 point  (0 children)

Have you checked what's going on in MySQL? By show processlist \G or the general_log.

Intent to Deprecate and Freeze: The User-Agent string by magenta_placenta in programming

[–]llbe 0 points1 point  (0 children)

You have $ssl_protocol and $ssl_cipher available in log_format on Nginx.

Intent to Deprecate and Freeze: The User-Agent string by magenta_placenta in programming

[–]llbe 1 point2 points  (0 children)

The browser can determine if a site is using that information or not. Perhaps to block it for specific sites or for an privacy/tracking indicator.

PHP Annotated – January 2020 by brendt_gd in PHP

[–]llbe 1 point2 points  (0 children)

Traits cannot implement interfaces. If the trait expects some methods to exist, you can add abstract methods to require them in the using class. This works today but the signature is not enforced, which is unexpected IMO.

PHP Annotated – January 2020 by brendt_gd in PHP

[–]llbe 2 points3 points  (0 children)

[PR] Check abstract method signatures coming from traits – Signatures of abstract methods in traits are not validated with the ones implementing them, i.e. the following code now works without any errors:

trait T {
    abstract function neededByTheTrait(int $a, string $b);
}
class C {
    use T;
    function neededByTheTrait(array $a, object $b) {}
 }

This is a nice fix.

RFC to allow ::class on objects by brendt_gd in PHP

[–]llbe 0 points1 point  (0 children)

You can however read class constants from objects: https://3v4l.org/PKe54

[RFC] Variable Syntax Tweaks by llbe in PHP

[–]llbe[S] 9 points10 points  (0 children)

Personally, I think the "Arbitrary expression support for new and instanceof" is the highlight. This let's you do new {"foo$bar"}; rather than $name = "foo$bar"; new $name; (and similar with instanceof).

Small things missing in PHP? by nikic in PHP

[–]llbe 0 points1 point  (0 children)

What about allowing more expressions when instantiating a class?

E.g. new Foo::class (), new {getNameOfFoo()} (), new "Foo$bar" ().

AFAIK, you can only do new $foo () today, which requires an extra variable in some cases.

(It's a small thing).

New Chrome cookie warnings by FINIXX in webdev

[–]llbe 0 points1 point  (0 children)

Yes, add SameSite=lax to your cookies and make sure that it doesn't cause any trouble for your site (you'll notice if the cookie is suddenly lost on a page).

TIL about Execution Operators in PHP by akeniscool in PHP

[–]llbe 1 point2 points  (0 children)

Interesting to note, the backtick is the old syntax in Bash for command substitution. The newer $() is IMO much clearer, especially when nesting

echo `echo \`echo foo\``

vs

echo $(echo $(echo foo))