内容简介:Greetings everyone,We’re pleased to present the March edition of PHP Annotated. It includes 4 new RFCs from PHP Internals, including Attributes v2 and a PHP language evolution proposal. It also covers Laravel 7, CodeIgniter 4, and other releases, as well a
Greetings everyone,
We’re pleased to present the March edition of PHP Annotated. It includes 4 new RFCs from PHP Internals, including Attributes v2 and a PHP language evolution proposal. It also covers Laravel 7, CodeIgniter 4, and other releases, as well as articles on Laravel and Symfony, useful tools, videos, podcasts, and plenty of other exciting posts!
:zap:️ News & Releases
- CodeIgniter 4.0 – After 5 years of development, a new version of the framework has been released. It’s been rewritten from scratch, and it works on PHP 7.2+ and implements PSR-1,3, and 4.
- PHP 7.4.3 – This release has a long-awaited fix for the
opcache.preload_user
bug, and preloading can now be used in production
PHP Internals
- Accepted proposals: [RFC] Variable Syntax Tweaks , [RFC] Static return type , [RFC] Allow ::class on objects
- [RFC] Stringable – This proposal from Nicolas Grekas has also been accepted. In PHP 8, it will be possible to use the
string|Stringable
union type in places where a string is expected, and it will be possible to pass a class in them with the__toString()
method.Interestingly, there’s no need to add
implements Stringable
explicitly, as this will be implemented automatically behind the scenes for all classes with__toString()
. - Language evolution – Nikita has started a discussion about how to keep PHP moving forward without breaking legacy code. One option is to introduce “editions,” similar to what Rust has , and declare them using per-file declares (for example,
declare(edition=2020)
). - [RFC] Write-Once Properties – This is a proposal to add a new property modifier that will allow you to initialize specific properties but disable their modification. There are several options for the name of the modifier:
final
,immutable
,readonly
,writeonce
,locked
,sealed
.class Foo { <keyword> public int $a = 1; <keyword> public string $b; <keyword> public array $c = ["foo"]; <keyword> public object $d; public function __construct() { $this->b = "foo"; } } $foo = new Foo(); $foo->a = 42; // EXCEPTION: property a has already been initialized $foo->b = "bar"; // EXCEPTION: property b has already been initialized $foo->a++; // EXCEPTION: incrementing/decrementing is forbidden unset($foo->c); // EXCEPTION: unsetting is forbidden $foo->c[] = "bar"; // EXCEPTION: arrays can't be modified $var= &$this->c; // EXCEPTION: reference isn't allowed $foo->d = new Foo(); // SUCCESS: property d hasn't been initialized before $foo->d->foo = "foo"; // SUCCESS: objects are still mutable internally
- [RFC] Allow explicit call-site pass-by-reference annotation – This updated RFC suggests making it possible to explicitly indicate the passing of arguments by reference. This will warn a developer that the passed variable is going to change. It is also proposes adding a directive to make the mode optional.
declare(require_explicit_send_by_ref=1); function byRef(&$ref) {...} byRef(&$var);
- [RFC] Increment/Decrement Fixes – In some cases, incremental and decremental operators do not behave in the same way that the explicit addition and subtraction of 1 with an assignment do. For example:
<?php $a = []; $a = ++$a; // [] and no errors $a = $a + 1; // Fatal error
It is proposed to fix inconsistencies in PHP 8 and throw an
Error
where appropriate. - [RFC] Attributes v2 – This is a second attempt to add full annotations in PHP with double bracket syntax
<<...>>
. There have been previous proposals for simple annotations and attributes , though the latter did not pass the voting.use Doctrine\ORM\Mapping as ORM; <<ORM\Entity(["repositoryClass" => UserRepository::class])>> <<ORM\Table("users")>> class User { <<ORM\Id, ORM\Column, ORM\GeneratedValue>> public int $id; <<ORM\Column(["unique" => true])>> public string $email; <<ORM\ManyToOne()>> public ?Address $address; }
- [PR] Make sorting stable – The standard sorting functions in PHP are not stable. This means that the preservation of the original order of elements with the same values is not guaranteed. Here’s an example . There’s been a suggestion to fix this and make the sorting stable. However, with a large number of identical elements, such a fix would affect performance.
Tools
- T-Regx/T-Regx – A package with a user-friendly interface for working with regular expressions.
- spiral/RoadRunner – PHP Application Server on Golang. It now has file watchers so the workers will be reloaded automatically .
- tightenco/overload – A simple but interesting implementation of overloading methods through a collection of closures.
- cmorrell.com/php-fpm – A nice tool for generating php-fpm config.
- minicli/minicli – Dependency-free toolkit for building CLI-centric applications in PHP. Check out this series of posts about building the tool .
- shivammathur/setup-php – A GitHub action to set up the PHP environment and then use it as a base for your workflows.
Symfony
- Charming Development in Symfony 5 – An ongoing series on SymfonyCasts.
- Auto-configuration of Doctrine repositories as services .
- A Week of Symfony #688 (2-8 March 2020) .
Laravel
- Laravel 7 – In this release:
• laravel/airlock – A new component for authentication in SPA.
• Custom Eloquent Casts – See how to use them in this tutorial .
• Blade components can now be defined as classes and custom HTML tags instead of@component
tags.
• HTTP Client – The framework comes with a Guzzle wrapper with a simple interface for common tasks. It’s based on kitetail/zttp .
Find out more with the video overviews of what’s new on Laracasts and on Coder’s Tape channel . - Livewire v1.0 – The frontend framework for Laravel, which allows you to make Blade bindings to PHP classes without having to write additional JS code. Check out this video tutorial on building a contact form.
- nunomaduro/laravel-mojito – A simple package to test views in isolation. And here’s a demo of using it .
- Optimizing circular relationships in Laravel .
- How to write exceptionally good exceptions in PHP
- Laravel Snippet #23 : Laravel 7.x, Forge, Vapor, Speaking vs. Silence.
- Laracon Australia 2019 videos .
Yii
- Yii news 2020, issue 2 – Many updates from Yii 3 are included.
- yiisoft/friendly-exception – The first package from Yii 3 is released. It provides an interface to define human-readable exceptions with recommended solutions.
Zend/Laminas
- Inaugural Technical Steering Committee Meeting – You can learn about Laminas’ plans for development and financing from the minutes .
Async PHP
- Interview with Marc Morera , an author of DriftPHP , about driftphp/reactphp-dbal DBAL for ReactPHPand ORMs.
- driftphp/tiny-load-balancer – Tiny load balancer on top of ReactPHP.
Misc
- Understanding PHP 8’s JIT .
- When does PHP call __destruct()?
- Bitwise booleans in PHP .
- PHPUnit: A Security Risk? – Learn about how the older versions of PHPUnit can lead to security problems if the vendor folder is publicly accessible.
- How @miguelxpn found a bug in PHP’s standard library and fixed it.
- Clean Code and Object Calisthenics Rules from Benjamin Eberlei .
Videos
- What’s coming in PhpStorm 2020.1 – Every week we publish a new 5-minute video.
- PHP Tutorial for Absolute Beginners – PHP Course 2020 – 5 hours of video tutorials.
Podcasts
- PHP Internals News
• #40 with Nikita Popov on three small accepted RFCs.
• #41 with Steven Wade on the proposal to add a magic__toArray()
.
• #42 with Jan Böhmer on userspace operator overloading .
• #43 with Nikita Popov on a fix for traits and improvement to the tokenizer . - The Undercover ElePHPant
• #8 about tuning php-fpm with Arne Blankerts from thephp.cc . Also see An Introduction to PHP-FPM Tuning blog post.
• #9 on background processes and workers with Samuel Rose (Symfony core). Also, see Five Challenges for Running Reliable PHP Background Processes . - Voices of the ElePHPant with Sara Golemon and Derick Rethans , a discussion of various updates in PHP 8.
Thanks for reading!
If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post, or send me a tweet .
Your JetBrains PhpStorm team
The Drive to Develop
以上所述就是小编给大家介绍的《PHP Annotated – March 2020》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Java学习笔记
林信良 / 清华大学出版社 / 2015-3-1 / CNY 68.00
●本书是作者多年来教学实践经验的总结,汇集了学员在学习课程或认证考试中遇到的概念、操作、应用等问题及解决方案 ●针对Java SE 8新功能全面改版,无论是章节架构或范例程序代码,都做了重新编写与全面翻新 ●详细介绍了JVM、JRE、Java SE API、JDK与IDE之间的对照关系 ●从Java SE API的源代码分析,了解各种语法在Java SE API中的具体应用 ......一起来看看 《Java学习笔记》 这本书的介绍吧!