Live data from Hacker News

PHP 8.1.0

php.net

11–20 of 286 posts

Re: PHP 8.1.0

#11

Earlier quoted context omitted.

Definitely some JS influence plus a little Swift and Java. PHP seems to be evolving faster than it has in years

It's actually becoming a problem keeping pace with PHP major updates

PHP isn't Linux with its strict "never break userspace" dogma - but for real, a PHP version upgrade should not be that bad to follow.

Re: PHP 8.1.0

#12
What is this?

  class User 
  {
    /**
     * @Assert\All({
     *     @Assert\NotNull,
     *     @Assert\Length(min=5)
     * })
     */
    public string $name = '';
  }
  PHP 8.1
  class User 
  {
    #[\Assert\All(
        new \Assert\NotNull,
        new \Assert\Length(min: 6))
    ]
    public string $name = '';
  }

Re: PHP 8.1.0

#13
post #7

Fibers "allow blocking and non-blocking implementations to share the same API" That's an interesting contrast to Python where the need to use "value = await fn()" v.s. "value = fn()" depending on whether or not that function is awaitable causes all kinds of API design complexity, all the way up to the existence of tools like https://github.com/python-trio/unasync which can code-generate the non-async version of a lib…

But if you are writing framework or library that has to deal with both, its:

    result = fn()
    if isawaitable(result):
        result = await result
And turns out isawaitable is not that fast so things like GraphQL libraries that run above logic thousands of times per request get noticeably slow.

Re: PHP 8.1.0

#14
post #12

What is this? class User { /** * @Assert\All({ * @Assert\NotNull, * @Assert\Length(min=5) * }) */ public string $name = ''; } PHP 8.1 class User { #[\Assert\All( new \Assert\NotNull, new \Assert\Length(min: 6)) ] public string $name = ''; }

These are attributes which add metadata that can be programatically acessed by applications and tooling.

That piece of code is about data validation.

See more at https://www.php.net/manual/en/language.attributes.overview.p...

Re: PHP 8.1.0

#15
post #12

What is this? class User { /** * @Assert\All({ * @Assert\NotNull, * @Assert\Length(min=5) * }) */ public string $name = ''; } PHP 8.1 class User { #[\Assert\All( new \Assert\NotNull, new \Assert\Length(min: 6)) ] public string $name = ''; }

An annotation syntax no outside of doc strings. Something PHP desperately needed.

Very similar to Java annotations.

Re: PHP 8.1.0

#16
post #14
post #12

What is this? class User { /** * @Assert\All({ * @Assert\NotNull, * @Assert\Length(min=5) * }) */ public string $name = ''; } PHP 8.1 class User { #[\Assert\All( new \Assert\NotNull, new \Assert\Length(min: 6)) ] public string $name = ''; }

These are attributes which add metadata that can be programatically acessed by applications and tooling. That piece of code is about data validation. See more at https://www.php.net/manual/en/language.attributes.overview.p...

[deleted]

Re: PHP 8.1.0

#17
post #12

What is this? class User { /** * @Assert\All({ * @Assert\NotNull, * @Assert\Length(min=5) * }) */ public string $name = ''; } PHP 8.1 class User { #[\Assert\All( new \Assert\NotNull, new \Assert\Length(min: 6)) ] public string $name = ''; }

Just going to link to this from earlier today.

https://front-line-php.com/cheat-sheet

It’s covered under “Attributes”.

Re: PHP 8.1.0

#18
Everyone laughing at PHP hasn't tried it for years, I'd bet. It started clumsy, true, but it became a solid and quite elegant way of doing things.

And by things I don't mean just web development.

The current limitations I see in PHP is that there is not an official multi-core coroutines solution.

Re: PHP 8.1.0

#20
post #18

Everyone laughing at PHP hasn't tried it for years, I'd bet. It started clumsy, true, but it became a solid and quite elegant way of doing things. And by things I don't mean just web development. The current limitations I see in PHP is that there is not an official multi-core coroutines solution.

I wasn't laughing at it until I tried to follow this link and the server was down.
Post reply on HN