Announcement

Collapse
No announcement yet.

PHP 8.1 Alpha Releases Get Underway With Enums, Fsync, Fibers, More Performance

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP 8.1 Alpha Releases Get Underway With Enums, Fsync, Fibers, More Performance

    Phoronix: PHP 8.1 Alpha Releases Get Underway With Enums, Fsync, Fibers, More Performance

    The PHP 8.1 alpha releases got underway in June in working towards the next annual feature release for the PHP scripting language...

    https://www.phoronix.com/scan.php?pa...PHP-8.1-Alphas

  • #2
    I haven't touched PHP in years, but it seems the progress has been great!

    What do you miss in PHP?

    I miss nullable reference types on class variables. Nullable reference types (question mark to make the type optional so example it is int or null) is already supported for function arguments and return types, but I don't think they are yet supported for instance variables and static variables of classes. This would increase the robustness and safety of the language.

    Comment


    • #3
      Originally posted by uid313 View Post
      I miss nullable reference types on class variables.
      No you don't, otherwise you'd have been using them for a couple years now.

      Comment


      • #4
        Originally posted by curfew View Post

        No you don't, otherwise you'd have been using them for a couple years now.
        I meant as an ex-PHP programmer. These days I mostly work in other languages, like C#, Python, JavaScript and TypeScript.
        But I got started with PHP so it holds a special place in my heart, so I keep up to date with the evolution of PHP and it pleases me that it has gotten so much better over the years.

        Comment


        • #5
          As mentioned, types (including nullable types) for class properties have been available for years now (since 7.4, specifically). I'm still using PHP 7.1 as my baseline, but I'm looking forward to bumping up to 7.4 at some point.

          Personally I'd love to have a built-in method of redefining functions and classes. The necessities of call indirection leads to some often messy and counterintuitive design patterns for the sake of testability as things are.

          Comment


          • #6
            Originally posted by uid313 View Post
            I haven't touched PHP in years, but it seems the progress has been great!

            What do you miss in PHP?

            I miss nullable reference types on class variables. Nullable reference types (question mark to make the type optional so example it is int or null) is already supported for function arguments and return types, but I don't think they are yet supported for instance variables and static variables of classes. This would increase the robustness and safety of the language.
            See e.g. https://3v4l.org/jh5Ze

            Looks like this has been present since PHP 7.4.

            Comment


            • #7
              Originally posted by uid313 View Post

              I meant as an ex-PHP programmer.
              But curfew is right that they have been imlemented for a couple of years now: https://3v4l.org/jh5Ze

              Comment


              • #8
                Originally posted by GingerDog View Post

                See e.g. https://3v4l.org/jh5Ze

                Looks like this has been present since PHP 7.4.
                Originally posted by Vistaus View Post

                But curfew is right that they have been imlemented for a couple of years now: https://3v4l.org/jh5Ze
                Oh then PHP is really good, and I don't think I really miss anything from it.
                I guess it supports nullable references everywhere, as instance variables of classes, as return values and as function arguments. That's great!

                It seems to be no way to get it to enforce that though.
                In the below example I have a non-nullable instance variable called bar but it is never initialized to any value, yet I can new up an instance of the class. 😥️

                https://3v4l.org/sJo0Z

                Comment


                • #9
                  Incorrect. The property is in fact nullable. As it is typed, however, attempting to read from it without first assigning it a value will throw an exception. Nothing prevents the instantiation of a class with uninitialized properties.

                  Comment

                  Working...
                  X