内容简介: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
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
- CakePHP 4.0 – The minimum version requirement was bumped up from 5.6 to PHP 7.2. There is now support for PSR standards (3, 15, 16, 18) and a bunch of improvements , primarily evolutionary.
- Codeception 4.0 – All modules are now extracted as separate packages. Symfony 5 support, phpdotenv 4, and an upgrade script are also included.
- Phalcon 4.0 – There’s been a major update to the framework, which is implemented in C and distributed as a PHP extension. It now requires PHP 7.2. PSR standards support has been added (7, 11, 13, 16, 17), and the interfaces are more strict. You can see more changes in the upgrade guide .
- PHP 7.2.26 – This is the last regular bugfix release of the PHP 7.2 branch. It will now only receive security fixes as needed for the rest of the year, and that will be all.
- PHP IMAP extension will no longer work with Gmail OAuth anymore as it does not support the SASL XOAUTH2 protocol and it is highly unlikely to be upgraded to do so. It is better to use laminas/laminas-mail or a wrapper freescout-helpdesk/ximap .
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 usingstatic
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 classesFoo\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
, anduse 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 tofunction 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 thestring|Stringable
union type in PHP 8, to accept both strings and objects that implement__toString()
.
Tools
- DarkGhostHunter/Preloader – A tool that helps choose files for preloading in PHP 7.4 based on the usage statistics and allows preloader script to be generated automatically.
- nikic/PHP-Fuzzer – An experimental fuzzer for PHP packages. It generates random input data for functions and helps find obscure bugs.
- lukanetconsult/network-address-types – A set of network address types for PHP.
- krakjoe/pthreads – This once-popular extension for multithreading in PHP has been archived. Using krakjoe/parallel is recommended instead.
- php-service-bus/service-bus – A framework, based on Amphp , for building application using Saga, CQRS, EventSourcing, and Message Bus patterns.
- franzliedke/studio – A tool for developing Composer packages while simultaneously using them.
Symfony
- A cheat sheet on the Messenger component .
- Symfony was the backend framework with the most contributors in 2019 .
- Symfony 2010s decade in review .
- A week of Symfony #680 (6-12 January 2020)
Laravel
- Laravel Idea – TheLaravel plugin for PhpStorm has been around for a long time. But, unfortunately, for the last couple of years it has not been actively developed by the author. Now there is a new alternative, theLaravel Idea plugin, which is not free but has many more additional features. The author of the plugin is Adel F , who is known for his other plugin.env files support, and is the author of “Architecture of complex web applications” book.
- laravel/airlock – This is an early version of the package by Taylor Otwell for easy authentication in SPAs and APIs. Check out the introductory post from the community.
- Using GitHub actions to run the tests of Laravel projects and packages with different PHP versions and even different dependencies.
- Building filters using spatie/laravel-query-builder .
- How to avoid large function signatures by using pending objects
- Laravel Snippet #20 – Union Types, SPA Authentication, Laravel UI, Middleware Priority, Laracon 2020.
- Laravel Snippet #21 – Artisan Inspire, Vapor multi-domain support, Laravel Airlock.
Zend/Laminas
- A new project for a new year – Migration of Zend Framework with all packages and projects to Laminas is now complete.
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
- Rules for working with dynamic arrays and custom collection classes .
- Hashing passwords on the server-side, a dead end? Nicolas Grekas asks if we willingly making our servers vulnerable to denial-of-service.
- How to break an entire ecosystem by publishing a release – A history of upgrading doctrine/persistence . The author mentions a nice How to deprecate a type in PHP post.
- How to Develop and Debug PHP Applications in Kubernetes .
- Benchmarks of PHP 5.6 – 7.4 with WordPress, Drupal, Magento 2, Laravel, Symfony, and others (without preloading).
- PHP 7.4 Preloading benchmarks with Laravel.
Videos
- How to upgrade to PHP 7.4 with PhpStorm – 9 minutes of Alt+Enter and someSSR tricks.
- How to Run PHPUnit Tests Using PhpStorm – Check out the related blog post .
- Refactor complex conditionals .
- Single Responsibility principle (SOLID) by Anna Filina .
Podcasts
- The Undercover ElePHPant #5 – Integrating with Third-Party APIs with Nils Adermann (Composer). Check out the main points in the blog post .
- The Undercover ElePHPant #4 – On how to handle retries and timeouts in PHP with Bastian Hofmann .
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 .
Your JetBrains PhpStorm Team
The Drive to Develop
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。