An Interest In:
Web News this Week
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
- April 12, 2024
April 18, 2024 07:49 pm GMT
Original Link: https://dev.to/graceman9/php-80-81-82-83-whats-new-cheatsheet-191g
PHP 8.0, 8.1, 8.2, 8.3... what's new?! CheatSheet.
The idea of this note is to write down PHP 8+ what's news briefly, so they are visible all at once on a single page. Like a cheat-sheet.
Keep in mind that these are just the basic features, see each version's link for more details.
- Named function arguments (i.e.
arg_name: value
, instead of filling preceding default arguments) - Attributes (instead of DocBlock comments)
- Constructor property promotion (properties in constructor instead of normal declaration)
- Union types (i.e.
int|string $varname
) - Match expression (to replace some of
switch-case
) - Nullsafe operator (instead of nesteds ifs)
- Saner string to number comparisons (i.e.
0 == 'somestrval' // not true anymore
) - Consistent type errors for internal functions (internal functions throws typed exceptions now)
- Just-In-Time compilation (2x performance in some specific long-running applications)
- and more
- Enumerations (enums)
- Readonly Properties (for VO and DTO)
- First-class Callable Syntax (to get a reference to any function, i.e.
$fn = strlen(...);
) - New in initializers (for nested attributes)
- Pure Intersection Types (
Iterator&Countable $value
but notA&B|C
) - Never return type (to be clear that function returns nothing)
- Final class constants (cannot override functions and inherit classes)
- Explicit Octal numeral notation
// TODO: add some description below
- Fibers
- Array unpacking support for string-keyed arrays
- and more
- Readonly classes
- Disjunctive Normal Form (DNF) Types
- Allow
null
,false
, andtrue
as stand-alone types - New "Random" extension
- Constants in traits
- Deprecate dynamic properties
- and more
- Typed class constants
- Dynamic class constant fetch
- New
#[\Override]
attribute - Deep-cloning of readonly properties
- New
json_validate()
function - New
Randomizer::getBytesFromString()
method - New
Randomizer::getFloat()
andRandomizer::nextFloat()
methods - Command line linter supports multiple files
- and more
Original Link: https://dev.to/graceman9/php-80-81-82-83-whats-new-cheatsheet-191g
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To