PHP Annotated – January 2020

栏目: IT技术 · 发布时间: 4年前

内容简介:Greetings everyone,It’s time for 2020’s first edition of PHP Annotated! This edition includes 4 new RFCs from PHP Internals and a few interesting updates for PHP 8 in pull-requests. We’ll catch up on the fresh releases from the end of 2019: Codeception 4.0

PHP Annotated – January 2020

Greetings everyone,

It’s time for 2020’s first edition of PHP Annotated! This edition includes 4 new RFCs from PHP Internals and a few interesting updates for PHP 8 in pull-requests. We’ll catch up on the fresh releases from the end of 2019: Codeception 4.0, Phalcon 4.0, CakePHP 4.0. We’ve also got articles on Laravel and Symfony, useful tools, videos, podcasts, and a whole lot more!

:zap:️ News & Releases

 PHP Internals

  • [RFC] Weak maps – This proposal has been accepted and merged into the PHP 8 branch.
  • [RFC] Variable Syntax Tweaks – This RFC proposes to fix some inconsistencies related to dereferencing that were not addressed in PHP 7 in the scope of the Uniform Variable Syntax RFC .
  • [RFC] Static return type – The static keyword in the context of type declaration refers to the late static binding . This document proposes to allow using static for return-type declarations for methods. This can be useful for static constructors and fluent interfaces.
    class Test {
        public function doWhatever(): static {
            // Do whatever.
            return $this;
        }
    }
     
    
    For properties and method parameters, however, this does not make sense and will not work.
  • [RFC] Allow ::class on objects – There’s a proposal to allow getting a fully qualified name from the class instance $object::class in PHP 8, in a way similar to how it now works for classes Foo\Bar::class .
  • [RFC] “use global functions/consts” statement – If a function or constant is used without a prefix, PHP will try to find it first in the current namespace and then in the global one. The author proposes to add the statements use global function , and use global consts

    , which will make the interpreter look first globally for functions and constants without a prefix.

    A few changes are available as pull-requests:

  • [PR] Deprecate required param after optional – This one will make PHP throw a deprecation notice when there is an optional parameter before a required one in the function signature
    function test(FooBar $param = null, $param2)
    This made sense when there were no nullable types, back before PHP 7.2. But it can now be converted to function test(?FooBar $param, $param2) .
  • [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) {}
    }
     
    
  • [PR] Ensure correct signatures for PHP magic methods – This pull request adds checks for magic methods signatures. At the moment, this only works as expected for __toString() and __clone() , and the following code, for example, does not show any error messages:
    class Foo {
    	function __get(int $name) {}
    }
     
    (new Foo)->{42};
     
    
  • [PR] Add Stringable interface – This PR introduces a new Stringable interface that ppl can declare when implementing __toString . The goal is to allow using the string|Stringable union type in PHP 8, to accept both strings and objects that implement __toString() .

 Tools

Symfony

Laravel

Zend/Laminas

Yii

 Async PHP

  • Screencast on DriftPHP , the async PHP framework built on top of ReactPHP Symfony components.
  • amphp/http-client 4.0 – The updated HTTP client from Amphp now has full HTTP/2 support and many other improvements. Also, when running on PHP 7.4 you can install nghttp2 , which will be used via FFI.

 Misc

 Videos

 Podcasts

Thanks for reading!

If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post, or tweet me .

Subscribe to PHP Annotated

Your JetBrains PhpStorm Team

The Drive to Develop


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

新经济,新规则

新经济,新规则

[美]Kevin Kelly / 刘仲涛 / 译言·东西文库/电子工业出版社 / 2014-7 / CNY 45.00

近年来,互联网持续震动着全世界各个行业以至于整个经济规则……在中国,以小米为代表的各类“互联网思维”轰轰烈烈地颠覆着各个行业……而这一切的一切,凯文凯利早就通过这本小书轻松写定。《新规则,新经济》一书介绍互联网时代,互联网影响下的经济运行的十个新游戏规则。一起来看看 《新经济,新规则》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换