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


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

查看所有标签

猜你喜欢:

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

增长黑客实战

增长黑客实战

范冰、张溪梦 / 电子工业出版社 / 2017-6 / 59.00

《增长黑客实战》围绕硅谷前沿的增长黑客职业,讲解增长理念的树立、增长团队的组建、流程制度的创立、技术营销的运用等团队运营成功实战经验。作者以自身创业经验为蓝本,结合真实案例,并融入一些伟大创业者的智慧,创建了一套思考、验证和追求卓越增长的理论体系。那些想要验证自己的创意、解决实际增长问题和拥有成功事业的人,可以将《增长黑客实战》当成一套清晰的实践指南、一幅组建增长团队的指导蓝图,或者一套值得反复玩......一起来看看 《增长黑客实战》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

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

UNIX 时间戳转换