mirror of
https://github.com/php/web-php.git
synced 2026-03-23 23:02:13 +01:00
Share common markup for PHP 8.0 release page translations (#1530)
This commit is contained in:
@@ -69,3 +69,13 @@ function language_chooser(string $currentLang): void {
|
||||
</form>
|
||||
';
|
||||
}
|
||||
|
||||
function message($code, $language = 'en')
|
||||
{
|
||||
$original = require __DIR__ . '/languages/en.php';
|
||||
if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) {
|
||||
$translation = require __DIR__ . '/languages/' . $language . '.php';
|
||||
}
|
||||
|
||||
return $translation[$code] ?? $original[$code] ?? $code;
|
||||
}
|
||||
|
||||
@@ -1,506 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/de.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 ist ein Major-Update der Sprache PHP. ' .
|
||||
'Es beinhaltet viele neue Funktionen und Optimierungen wie beispielsweise ' .
|
||||
'Named Arguments, Union Types, Attribute, Constructor Property Promotion, ' .
|
||||
'Match Ausdrücke, Nullsafe Operator, JIT und Verbesserungen des Typen-Systems, ' .
|
||||
'der Fehlerbehandlung und der Konsistenz.');
|
||||
$lang = 'de';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('de'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Released!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 ist ein Major-Update der Sprache PHP.<br class="display-none-md"> Es beinhaltet viele neue Funktionen
|
||||
und Optimierungen wie beispielsweise Named Arguments, Union Types, Attribute, Constructor Property Promotion,
|
||||
Match Ausdrücke, Nullsafe Operator, JIT und Verbesserungen des Typen-Systems, der Fehlerbehandlung und der
|
||||
Konsistenz.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Wechsle jetzt zu PHP 8!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Named Arguments
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/de/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Gib nur notwendige Parameter an, überspringe optionale.</li>
|
||||
<li>Parameter sind unabhängig von der Reihenfolge und selbstdokumentierend.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Attribute
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/de/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Anstelle von PHPDoc Annotations kannst du nun strukturierte Meta-Daten in nativer PHP Syntax nutzen.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Constructor Property Promotion
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/de/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Weniger Codewiederholungen für das Definieren und Initialisieren von Objektattributen.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Union Types
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/de/language.types.declarations.php#language.types.declarations.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Anstelle von PHPDoc Annotations für kombinierte Typen kannst du native Union-Type-Deklarationen verwenden,
|
||||
welche zur Laufzeit validiert werden.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Match Ausdruck
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/de/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh nein!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "Das hatte ich erwartet";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh nein!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh nein!",
|
||||
8.0 => "Das hatte ich erwartet",
|
||||
};
|
||||
//> Das hatte ich erwartet',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Der neue Match Ausdruck ist ähnlich wie die Switch Anweisung und bietet folgende Funktionen:</p>
|
||||
<ul>
|
||||
<li>Da Match ein Ausdruck ist, kann sein Ergebnis in einer Variable gespeichert oder ausgegeben werden.</li>
|
||||
<li>Match Zweige unterstützen nur einzeilige Ausdrücke und benötigen keinen break; Ausdruck.</li>
|
||||
<li>Match führt strikte Vergleiche durch.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Nullsafe Operator
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Anstelle von Null-Checks kannst du Funktionsaufrufe nun direkt mit dem neuen Nullsafe Operator
|
||||
aneinanderreihen. Wenn ein Funktionsaufruf innerhalb der Kette Null zurückliefert, wird die weitere
|
||||
Ausführung abgebrochen und die gesamte Kette wird zu Null ausgewertet.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Vernünftige String-zu-Zahl Vergleiche
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Wenn eine Zahl mit einem numerischen String verglichen wird, benutzt PHP 8 einen Zahlen-Vergleich. Andernfalls
|
||||
wird die Zahl zu einem String konvertiert und ein String-Vergleich durchgeführt.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Konsistente Typen-Fehler für interne Funktionen
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Die meisten internen Funktionen erzeugen nun eine Error Exception wenn die Typenvalidierung der Parameter
|
||||
fehlschlägt.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">Just-In-Time Compiler</h2>
|
||||
<p>
|
||||
PHP 8 führt zwei JIT Compiler Engines ein. Tracing-JIT, der vielversprechendere der beiden, zeigt eine bis zu drei
|
||||
mal bessere Performance in synthetischen Benchmarks und eine 1,5 bis zweifache Verbesserung in einigen speziellen,
|
||||
langlaufenden Anwendungen. Die Performance einer typischen Anwendung ist auf dem Niveau von PHP 7.4.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
Relativer Beitrag des JIT Compilers zur Performance von PHP 8
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Verbesserungen am Typen-System und an der Fehlerbehandlung</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Striktere Typen-Checks für arithmetische/bitweise Operatoren
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Validierung abstrakter Methoden in einem Trait <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Korrekte Signaturen magischer Funktionen <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Neue Klassifizierung von Engine-Warnings <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Inkompatiblen Methoden-Signaturen erzeugen einen Fatal Error <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Der @ Operator unterdrückt keine Fatal Errors mehr.
|
||||
</li>
|
||||
<li>
|
||||
Vererbung mit privaten Methoden <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Mixed Typ <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Static als Rückgabetyp <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Typen für interne Funktionen
|
||||
<a href="https://externals.io/message/106522">E-Mail-Thread</a>
|
||||
</li>
|
||||
<li>
|
||||
Objekte ohne Methoden anstelle des resource Typs für
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, und
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
Extension
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Weitere Syntax-Anpassungen und Verbesserungen</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Erlauben eines abschließenden Kommas in Parameter-Listen <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
und Closure Use Listen <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>.
|
||||
</li>
|
||||
<li>
|
||||
Catches ohne Exception-Variable <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Anpassungen an der Syntax für Variablen <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Namespaces werden als ein Token ausgewertet <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw ist jetzt ein Ausdruck <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Nutzung von ::class auf Objekten <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Neue Klassen, Interfaces, und Funktionen</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> Klasse
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/stringable">Stringable</a> Interface
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> mit einer Objekt-Implementierung
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">Neue APIs für DOM-Traversal and -Manipulation</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Bessere Performance, bessere Syntax, optimierte Typsicherheit.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Wechsle jetzt zu PHP 8!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
Für den direkten Code-Download von PHP 8 schaue bitte auf der <a href="http://www.php.net/downloads">Downloads</a> Seite vorbei.
|
||||
Windows Pakete können auf der <a href="http://windows.php.net/download">PHP für Windows</a> Seite gefunden werden.
|
||||
Die Liste der Änderungen ist im <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a> festgehalten.
|
||||
</p>
|
||||
<p>
|
||||
Der <a href="/manual/de/migration80.php">Migration Guide</a> ist im PHP Manual verfügbar. Lies dort
|
||||
nach für detaillierte Informationen zu den neuen Funktionen und inkompatiblen Änderungen zu vorherigen PHP
|
||||
Versionen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,505 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/en.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 is a major update of the PHP language. ' .
|
||||
'It contains many new features and optimizations including ' .
|
||||
'named arguments, union types, attributes, constructor property promotion, ' .
|
||||
'match expression, nullsafe operator, JIT, and ' .
|
||||
'improvements in the type system, error handling, and consistency.');
|
||||
$lang = 'en';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('en'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Released!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 is a major update of the PHP language.<br class="display-none-md"> It contains many new features and
|
||||
optimizations including named arguments, union types, attributes, constructor property promotion, match
|
||||
expression, nullsafe operator, JIT, and improvements in the type system, error handling, and consistency.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Upgrade to PHP 8 now!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Named arguments
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/en/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Specify only required parameters, skipping optional ones.</li>
|
||||
<li>Arguments are order-independent and self-documented.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Attributes
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Instead of PHPDoc annotations, you can now use structured metadata with PHP's native syntax.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Constructor property promotion
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Less boilerplate code to define and initialize properties.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Union types
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.types.declarations.php#language.types.declarations.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Instead of PHPDoc annotations for a combination of types, you can use native union type declarations that are
|
||||
validated at runtime.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Match expression
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/en/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>The new match is similar to switch and has the following features:</p>
|
||||
<ul>
|
||||
<li>Match is an expression, meaning its result can be stored in a variable or returned.</li>
|
||||
<li>Match branches only support single-line expressions and do not need a break; statement.</li>
|
||||
<li>Match does strict comparisons.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Nullsafe operator
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Instead of null check conditions, you can now use a chain of calls with the new nullsafe operator. When the
|
||||
evaluation of one element in the chain fails, the execution of the entire chain aborts and the entire chain
|
||||
evaluates to null.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Saner string to number comparisons
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>When comparing to a numeric string, PHP 8 uses a number comparison. Otherwise, it converts the number to a
|
||||
string and uses a string comparison.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Consistent type errors for internal functions
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Most of the internal functions now throw an Error exception if the validation of the parameters fails.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">Just-In-Time compilation</h2>
|
||||
<p>
|
||||
PHP 8 introduces two JIT compilation engines. Tracing JIT, the most promising of the two, shows about 3 times better
|
||||
performance on synthetic benchmarks and 1.5–2 times improvement on some specific long-running applications. Typical
|
||||
application performance is on par with PHP 7.4.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
Relative JIT contribution to PHP 8 performance
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Type system and error handling improvements</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Stricter type checks for arithmetic/bitwise operators
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Abstract trait method validation <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Correct signatures of magic methods <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Reclassified engine warnings <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Fatal error for incompatible method signatures <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
The @ operator no longer silences fatal errors.
|
||||
</li>
|
||||
<li>
|
||||
Inheritance with private methods <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Mixed type <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Static return type <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Types for internal functions
|
||||
<a href="https://externals.io/message/106522">Email thread</a>
|
||||
</li>
|
||||
<li>
|
||||
Opaque objects instead of resources for
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, and
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
extensions
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Other syntax tweaks and improvements</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Allow a trailing comma in parameter lists <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
and closure use lists <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Non-capturing catches <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Variable Syntax Tweaks <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Treat namespaced names as single token <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw is now an expression <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Allow ::class on objects <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">New Classes, Interfaces, and Functions</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> class
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/stringable">Stringable</a> interface
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> object implementation
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">New DOM Traversal and Manipulation APIs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Better performance, better syntax, improved type safety.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Upgrade to PHP 8 now!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
For source downloads of PHP 8 please visit the <a href="http://www.php.net/downloads">downloads</a> page.
|
||||
Windows binaries can be found on the <a href="http://windows.php.net/download">PHP for Windows</a> site.
|
||||
The list of changes is recorded in the <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="/manual/en/migration80.php">migration guide</a> is available in the PHP Manual. Please
|
||||
consult it for a detailed list of new features and backward-incompatible changes.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,500 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/es.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 es una actualización importante del lenguaje php que contiene nuevos recursos y optimizaciones incluyendo ' .
|
||||
'argumentos nombrados, tipos de uniones, atributos, promoción de propiedades constructivas, expresiones de equivalencia, ' .
|
||||
'operador nullsafe, JIT (traducción dinámica) y también mejoras en el sistema de tipos, manejo de errores y consistencia en general.');
|
||||
$lang = 'es';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('es'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Released!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 es una actualización importante del lenguaje PHP que contiene nuevos recursos y optimizaciones
|
||||
incluyendo argumentos nombrados, tipos de uniones, atributos, promoción de propiedades constructivas,
|
||||
expresiones match, operador nullsafe, JIT (traducción dinámica) y también mejoras en el sistema de tipos,
|
||||
manejo de errores y consistencia en general.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Actualizate a PHP 8!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Argumentos nombrados
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/es/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Solamente especifica los parámetros requeridos, omite los opcionales.</li>
|
||||
<li>Los argumentos son independientes del orden y se documentan automáticamente.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Atributos
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/es/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>En vez de anotaciones en PHPDoc, puedes usar metadatos estructurados con la sintaxis nativa de PHP.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Promoción de propiedades constructivas
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Menos código repetitivo para definir e inicializar una propiedad.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Tipos de unión
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/en/language.types.declarations.php#language.types.declarations.composite.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>En vez de anotaciones en PHPDoc para combinar tipos, puedes usar una declaración de tipo unión nativa que será validada en el momento de ejecución.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Expresiones match
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/en/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
|
||||
<p>Las nuevas expresiones match son similares a switch y tienen las siguientes características: </p>
|
||||
<ul>
|
||||
<li>Match es una expresión; esto quiere decir que pueden ser almacenadas como variables o devueltas.</li>
|
||||
<li>Match soporta expresiones de una línea y no necesitan romper declarar un break.</li>
|
||||
<li>Match hace comparaciones estrictas.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Operador Nullsafe
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>En vez de verificar condiciones nulas, tu puedes utilizar una cadena de llamadas con el nuevo operador nullsafe.
|
||||
Cuando la evaluación de un elemento falla, la ejecución de la entire cadena es abortada y la cadena entera es evaluada como nula.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Comparaciones inteligentes entre “strings” y números
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p> Cuando comparas con un “string” numérico, PHP8 usa comparación numérica o de otro caso convierte el número a
|
||||
un "string" y asi los compara.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Errores consistentes para funciones internas.
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>La mayoría de las funciones internas ahora proveen un error de excepción si el parámetro no es validado.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">JIT (traducciones dinámicas)</h2>
|
||||
<p>
|
||||
PHP8 introduce 2 motores de compilación JIT. Transit JIT, es el más prometedor de los dos y performa 3 veces mejor
|
||||
en benchmarks sintéticos y 1.5-2 mejor en algunas aplicaciones específicas a largo plazo. Performancia de aplicaciones
|
||||
típicas es a la par de las de PHP7.4
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
JIT contribuciones al funcionamiento relativo de PHP8
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Mejorias en los tipos de sistemas y manejo de errores</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Verificaciones estrictas de operadores aritméticos/bitwise.
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Validación de métodos con características abstractas <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Firmas correctas de métodos mágicos <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Reclacificamiento de errores fatales <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Errores fatales incompatibles con el método de firma <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
El operador @ no omitirá errores fatales.
|
||||
</li>
|
||||
<li>
|
||||
Herencia con métodos privados <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipos mixtos <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipo retorno statico <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipos para funciones internas
|
||||
<a href="https://externals.io/message/106522">Email thread</a>
|
||||
</li>
|
||||
<li>
|
||||
Objetos opacos en ves de recursos para
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>,
|
||||
y <a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a> extensiones
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Otros ajustes y mejoras del sintax</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Permitir una coma al final de una lista de parámetros <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
y lista de use en closures <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Catches que no capturan <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Ajustes al syntax variable <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tratamiento de nombres de namespace como tokens únicos<a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw es ahora una expresión <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Permitir ::class on objects <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Nuevas clases, interfaces y funciones</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> clase
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/stringable">Stringable</a> interface
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> Implementación de objeto
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">New DOM Traversal and Manipulation APIs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Mejor performancia, mejor syntax, aumentada seguridad de tipos.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Actualizate a PHP8!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
Para bajar el código fuente de PHP8 visita la página <a href="http://www.php.net/downloads">downloads</a>.
|
||||
Código binario para windows lo puedes encontrar en la página <a href="http://windows.php.net/download">PHP for Windows</a>.
|
||||
La lista de cambios está disponible en la página <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
La <a href="/manual/en/migration80.php">guía de migración</a> está disponible en el manual de PHP.
|
||||
Por favor consultala para una lista detallada de alteraciones cambios y compatibilidad.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,511 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/en.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
"PHP 8.0 est une mise à jour majeure du langage PHP. " .
|
||||
"Elle contient beaucoup de nouvelle fonctionnalités et d'optimisations, " .
|
||||
"incluant les arguments nommés, les types d'union, attributs, " .
|
||||
"promotion de propriétés de constructeur, l'expression match, " .
|
||||
"l'opérateur nullsafe, JIT (Compilation à la Volée), " .
|
||||
"et des améliorations dans le système de typage, " .
|
||||
"la gestion d'erreur, et de cohérence.");
|
||||
$lang = 'fr';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('fr'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Released!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 est une mise à jour majeure du langage PHP.<br class="display-none-md">
|
||||
Elle contient beaucoup de nouvelles fonctionnalités et d'optimisations, incluant les arguments nommés,
|
||||
les types d'union, attributs, promotion de propriété de constructeur, l'expression match, l'opérateur
|
||||
nullsafe, JIT (Compilation à la Volée), et des améliorations dans le système de typage, la gestion
|
||||
d'erreur, et de cohérence.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Migrez à PHP 8 maintenant!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Arguments nommés
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/fr/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Spécifiez uniquement les paramètres requis, omettant ceux optionnels.</li>
|
||||
<li>Les arguments sont indépendants de l'ordre et auto-documentés.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Attributs
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/fr/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'/**
|
||||
* @Route("/api/posts/{id}", methods={"GET", "HEAD"})
|
||||
*/
|
||||
class User
|
||||
{',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])]
|
||||
class User
|
||||
{',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Au lieux d'annotations PHPDoc, vous pouvez désormais utiliser les métadonnées structurés avec la syntaxe native de PHP.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Promotion de propriétés de constructeur
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/fr/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Moins de code redondant pour définir et initialiser les propriétés.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Types d'union
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/fr/language.types.declarations.php#language.types.declarations.composite.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>
|
||||
Au lieu d'annotation PHPDoc pour une combinaison de type, vous pouvez utiliser les déclarations de types
|
||||
d'union native qui sont validées lors de l'exécution.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Expression match
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/fr/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>La nouvelle instruction match est similaire à switch et a les fonctionnalités suivantes :</p>
|
||||
<ul>
|
||||
<li>Match est une expression, signifiant que son résultat peut être enregistré dans une variable ou retourné.</li>
|
||||
<li>Les branches de match supportent uniquement les expressions d'une seule ligne, et n'a pas besoin d'une déclaration break;.</li>
|
||||
<li>Match fait des comparaisons strictes.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Opérateur Nullsafe
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>
|
||||
Au lieu de faire des vérifications conditionnelles de null, vous pouvez utiliser une chaîne d'appel
|
||||
avec le nouvel opérateur nullsafe. Qui lorsque l'évaluation d'un élément de la chaîne échoue, l'exécution
|
||||
de la chaîne complète est terminée et la chaîne entière évalue à null.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Comparaisons entre les chaînes de caractères et les nombres plus saines
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>
|
||||
Lors de la comparaison avec une chaîne numérique, PHP 8 utilise une comparaison de nombre.
|
||||
Sinon, il convertit le nombre à une chaîne de caractères et utilise une comparaison de chaîne de caractères.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Erreurs de type cohérent pour les fonctions internes
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>La plupart des fonctions internes lancent désormais une exception Error si la validation du paramètre échoue.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">Compilation Juste-à-Temps (JIT)</h2>
|
||||
<p>
|
||||
PHP 8 introduit deux moteurs de compilation JIT (juste à temps/compilation à la volée).
|
||||
Le Tracing JIT, le plus prometteur des deux, montre environ 3 fois plus de performances sur des benchmarks
|
||||
synthétiques et 1,5-2 fois plus de performances sur certaines applications à longue durée d'exécution.
|
||||
Généralement les performances des applications sont identiques à PHP 7.4.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
Contribution relative du JIT à la performance de PHP 8
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Amélioration du système de typage et de la gestion d'erreur</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Vérification de type plus sévère pour les opérateurs arithmétiques et bit à bit
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Validation de méthode abstraite des traits <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Signature valide des méthodes magiques <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Reclassifications des avertissements du moteur <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Erreur fatale pour des signatures de méthodes incompatibles <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
L'opérateur @ ne silence plus les erreurs fatales.
|
||||
</li>
|
||||
<li>
|
||||
Héritages avec les méthodes privées <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Type mixed <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Type de retour static <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Types pour les fonctions internes
|
||||
<a href="https://externals.io/message/106522">Discussion e-mail</a>
|
||||
</li>
|
||||
<li>
|
||||
Objets opaques au lieu de ressources pour les extensions
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, et
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Autres ajustements de syntaxe et améliorations</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Autorisation des virgules trainantes dans les listes de paramètres <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
et dans les listes des use d'une fermeture <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Les catchs non capturant <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Ajustement de la Syntaxe des Variables <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Traite les noms des espaces de nom comme un seul token <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw est désormais une expression <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Autorisation de ::class sur les objets <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Nouvelles Classes, Interfaces, et Fonctions</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Classe <a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a>
|
||||
</li>
|
||||
<li>
|
||||
Interface <a href="https://wiki.php.net/rfc/stringable">Stringable</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
Implémentation objet de <a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">Nouvelles APIs pour traverser et manipuler le DOM</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Meilleures performances, meilleure syntaxe, amélioration de la sécurité de type.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Migrez à PHP 8 maintenant!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
Pour le téléchargement des sources de PHP 8 veuillez visiter la page de <a href="http://www.php.net/downloads">téléchargement</a>.
|
||||
Les binaires Windows peuvent être trouvés sur le site de <a href="http://windows.php.net/download">PHP pour Windows</a>.
|
||||
La liste des changements est notée dans le <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
Le <a href="/manual/fr/migration80.php">guide de migration</a> est disponible dans le manuel PHP.
|
||||
Veuillez le consulter pour une liste détaillée des nouvelles fonctionnalités et changements non rétrocompatibles.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,503 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/it.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 è una nuova versione major del linguaggio PHP. ' .
|
||||
'Contiene molte nuove funzionalità ed ottimizzazioni quali ' .
|
||||
'i named arguments, la definizione di tipi unione, gli attributi, la promozione a proprietà degli argomenti del costruttore, ' .
|
||||
'l\'espressione match, l\'operatore nullsafe, la compilazione JIT e ' .
|
||||
'miglioramenti al sistema dei tipi, alla gestione degli errori e alla consistenza.');
|
||||
$lang = 'it';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('it'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Released!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 è una nuova versione major del linguaggio PHP.<br class="display-none-md">
|
||||
Contiene molte nuove funzionalità ed ottimizzazioni quali i named arguments,
|
||||
la definizione di tipi unione, gli attributi, la promozione a proprietà degli argomenti del costruttore,
|
||||
l'espressione match, l'operatore nullsafe, la compilazione JIT e
|
||||
miglioramenti al sistema dei tipi, alla gestione degli errori e alla consistenza.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Aggiorna a PHP 8!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Named arguments
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/en/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Indica solamente i parametri richiesti, saltando quelli opzionali.</li>
|
||||
<li>Gli argomenti sono indipendenti dall'ordine e auto-documentati.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Attributi
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Invece delle annotazioni PHPDoc, ora puoi usare metadati strutturati nella sintassi nativa PHP.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Promozione a proprietà degli argomenti del costruttore
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Meno ripetizioni di codice per definire ed inizializzare le proprietà.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Tipi unione
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.types.declarations.php#language.types.declarations.composite.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Invece di indicare una combinazione di tipi con le annotazioni PHPDoc, puoi usare una dichiarazione nativa
|
||||
di tipo unione che viene validato durante l'esecuzione.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Espressione match
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/en/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>La nuova espressione match è simile allo switch e ha le seguenti funzionalità:</p>
|
||||
<ul>
|
||||
<li>Match è un'espressione, ovvero il suo risultato può essere salvato in una variabile o ritornato.</li>
|
||||
<li>I rami del match supportano solo espressioni a singola linea e non necessitano di un'espressione break;.</li>
|
||||
<li>Match esegue comparazioni strict.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Operatore nullsafe
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Invece di controllare la presenza di un null, puoi ora usare una catena di chiamate con il nuovo operatore nullsafe. Quando
|
||||
la valutazione di un elemento della catena fallisce, l'esecuzione della catena si interrompe e l'intera catena
|
||||
restituisce il valore null.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Comparazioni più coerenti di stringhe e numeri
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Nella comparazione di una stringa numerica, PHP 8 usa la comparazione numerica. Altrimenti, converte il numero
|
||||
in una stringa e usa la comparazione tra stringhe.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Tipi di errori consistenti per le funzioni native
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>La maggior parte delle funzioni native ora lanciano una eccezione Error se la validazione degli argomenti fallisce.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">Compilazione Just-In-Time</h2>
|
||||
<p>
|
||||
PHP 8 intrduce due motori di compilazione JIT. Tracing JIT, il più promettente dei due, mostra delle prestazioni 3
|
||||
volte superiori nei benchmarks sintetici e 1.5–2 volte superiori per alcuni specifici processi applicativi a lunga esecuzione.
|
||||
Le prestazioni delle tipiche applicazioni web sono al pari con PHP 7.4.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
Miglioramenti delle performance in PHP 8 grazie a JIT
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Sistema dei tipi e miglioramenti alla gestione degli errori</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Controlli più stringenti per gli operatori aritmetici e bitwise
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Validazione dei metodi astratti nei trait <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Firme corrette nei metodi magici <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Riclassificazione degli errori <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Errori fatali per firme di metodi non compatibili <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
L'operatore @ non silenzia più gli errori fatali.
|
||||
</li>
|
||||
<li>
|
||||
Ereditarietà e metodi privati <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipo mixed <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipo di ritorno static <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipi per le funzioni native
|
||||
<a href="https://externals.io/message/106522">Email thread</a>
|
||||
</li>
|
||||
<li>
|
||||
Oggetti opachi invece che risorse per le estensioni
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, e
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Altre ritocchi e migliorie di sintassi </h2>
|
||||
<ul>
|
||||
<li>
|
||||
Permessa una virgola finale nella lista dei parametri <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
e nell'espressione use per le closure <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Catch senza argomento <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Correzioni alla sintassi di variabile <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Trattamento dei nomi di namespace come un singolo token <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw è ora un'espressione <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Permesso l'utilizzo di ::class sugli oggetti <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Nuove classi, interfacce e funzioni</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Classe <a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a>
|
||||
</li>
|
||||
<li>
|
||||
Interfaccia <a href="https://wiki.php.net/rfc/stringable">Stringable</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
Classe <a href="https://wiki.php.net/rfc/token_as_object">PhpToken</a> come alternativa a token_get_all()
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">New DOM Traversal and Manipulation APIs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Performance migliorate, migliore sintassi, e migliore sicurezza dei tipi.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Aggiorna a PHP 8!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
Per scaricare il codice sorgente visita di PHP 8 visita la pagina di <a href="http://www.php.net/downloads">download</a>.
|
||||
I binari eseguibili per Windows possono essere trovati sul sito <a href="http://windows.php.net/download">PHP for Windows</a>.
|
||||
Una lista dei cambiamenti è registrata nel <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
La <a href="/manual/en/migration80.php">guida alla migrazione</a> è disponibile nel manuale PHP.
|
||||
Consultatelo per una lista completa delle nuove funzionalità e dei cambiamenti non retrocompatibili.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,510 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/en.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 は、PHP 言語のメジャーアップデートです。' .
|
||||
'このアップデートには、たくさんの新機能や最適化が含まれています。たとえば' .
|
||||
'名前付き引数、union 型、アトリビュート、コンストラクタでのプロパティのプロモーション、' .
|
||||
'match 式、 nullsafe 演算子、JIT、' .
|
||||
'型システムの改善、エラーハンドリング、一貫性の向上などです。');
|
||||
$lang = 'ja';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('ja'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Released!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 は、PHP 言語のメジャーアップデートです。<br class="display-none-md"> このアップデートには、たくさんの新機能や最適化が含まれています。
|
||||
たとえば 名前付き引数、 union 型、アトリビュート、コンストラクタでのプロパティのプロモーション、match 式、nullsafe 演算子、JIT、型システムの改善、エラーハンドリング、一貫性の向上などです。
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">PHP 8 にアップデートしよう!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
名前付き引数
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/ja/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>必須の引数だけを指定し、オプションの引数はスキップしています。</li>
|
||||
<li>引数の順番に依存せず、自己文書化(self-documented)されています。</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
アトリビュート
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/ja/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>PHPDoc のアノテーションの代わりに、PHP ネイティブの文法で構造化されたメタデータを扱えるようになりました。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
コンストラクタでの、プロパティのプロモーション
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/ja/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>ボイラープレートのコードを減らすため、コンストラクタでプロパティを定義し、初期化します。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Union 型
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/ja/language.types.declarations.php#language.types.declarations.composite.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>PHPDoc のアノテーションを使って型を組み合わせる代わりに、実行時に検証が行われる union型 をネイティブで使えるようになりました。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Match 式
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/ja/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>match は switch 文に似ていますが、以下の機能があります:</p>
|
||||
<ul>
|
||||
<li>match は式なので、結果を返したり、変数に保存したりできます。</li>
|
||||
<li>match の分岐は一行の式だけをサポートしており、break; 文は不要です。</li>
|
||||
<li>match は、型と値について、厳密な比較を行います。</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Nullsafe 演算子
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>null チェックの条件を追加する代わりに、nullsafe演算子 を使って呼び出しをチェインさせられるようになりました。呼び出しチェインのひとつが失敗すると、チェインの実行全体が停止し、null と評価されます。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
数値と文字列の比較
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>数値形式の文字列と比較する場合は、PHP 8 は数値として比較を行います。それ以外の場合は、数値を文字列に変換し、文字列として比較を行います。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
<!--Consistent type errors for internal functions-->
|
||||
内部関数の型に関するエラーが一貫したものに
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>ほとんどの内部関数は、引数の検証に失敗すると Error 例外をスローするようになりました。</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">JIT (ジャストインタイム) コンパイル</h2>
|
||||
<p>
|
||||
PHP 8 は JITコンパイル のエンジンをふたつ搭載しています。
|
||||
トレーシングJITは、もっとも有望なふたつの人工的なベンチマークで、
|
||||
約3倍のパフォーマンスを示しました。
|
||||
また、長期間動いている特定のあるアプリケーションでは、1.5-2倍のパフォーマンス向上が見られました。
|
||||
典型的なアプリケーションのパフォーマンスは、PHP 7.4 と同等でした。
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
PHP 8 のパフォーマンスに対するJITの貢献
|
||||
<!--
|
||||
Relative JIT contribution to PHP 8 performance
|
||||
-->
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">型システムとエラーハンドリングの改善</h2>
|
||||
<ul>
|
||||
<li>
|
||||
算術/ビット演算子のより厳密な型チェック
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
トレイトの抽象メソッドの検証 <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
マジックメソッドのシグネチャ <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
エンジンの警告を整理 <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
互換性のないメソッドシグネチャは fatal error に。
|
||||
<a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
@ 演算子は、致命的なエラーを隠さなくなりました。
|
||||
</li>
|
||||
<li>
|
||||
private メソッドの継承時のシグネチャチェック <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Mixed 型のサポート <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
戻り値で static 型をサポート <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
内部関数に型アノテーション
|
||||
<a href="https://externals.io/message/106522">Email thread</a>
|
||||
</li>
|
||||
<li>
|
||||
一部の拡張機能が、リソースからオブジェクトに移行:
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">その他文法の調整や改善</h2>
|
||||
<ul>
|
||||
<li>
|
||||
引数やクロージャーのuseリストの最後にカンマがつけられるように <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
<a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
catch で例外のキャプチャが不要に <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
変数の文法の調整 <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
名前空間の名前を単一のトークンとして扱う <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw は式になりました <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
オブジェクトに対して ::class が使えるように <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">新しいクラス、インターフェイス、関数</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> クラス
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/stringable">Stringable</a> インターフェイス
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> をオブジェクトベースで実装
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">New DOM Traversal and Manipulation APIs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
<!--
|
||||
Better performance, better syntax, improved type safety.
|
||||
-->
|
||||
パフォーマンスの向上、より良い文法、型システムの改善
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">PHP 8 にアップデートしよう!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
PHP 8 のソースコードのダウンロードは、
|
||||
<a href="http://www.php.net/downloads">downloads</a> のページをどうぞ。
|
||||
Windows 用のバイナリは <a href="http://windows.php.net/download">PHP for Windows</a> のページにあります。
|
||||
変更の一覧は <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a> にあります。
|
||||
</p>
|
||||
<p>
|
||||
<a href="/manual/ja/migration80.php">移行ガイド</a> が PHP マニュアルで利用できます。
|
||||
新機能や下位互換性のない変更の詳細については、移行ガイドを参照して下さい。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,505 +1,6 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/ka.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 — PHP ენის დიდი განახლება. ' .
|
||||
'ის შეიცავს ბევრ ახალ შესაძლებლობას და ოპტიმიზაციებს, ' .
|
||||
'მათ შორის დასახელებული არგუმენტები, union type, ატრიბუტები, ' .
|
||||
'თვისებების გამარტივებული განსაზღვრა კონსტრუქტორში, გამოსახულება match, ' .
|
||||
'ოპერატორი nullsafe, JIT და გაუმჯობესებები ტიპის სისტემაში, ' .
|
||||
'შეცდომების დამუშავება და თანმიმდევრულობა.');
|
||||
$lang = 'ka';
|
||||
$documentation = 'en';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('ka'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">რელიზი!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 — PHP ენის დიდი განახლება.<br class="display-none-md"> ის შეიცავს ბევრ ახალ შესაძლებლობას და ოპტიმიზაციებს,
|
||||
მათ შორის დასახელებული არგუმენტები, union type, ატრიბუტები, თვისებების გამარტივებული განსაზღვრა კონსტრუქტორში, გამოსახულება match,
|
||||
ოპერატორი nullsafe, JIT და გაუმჯობესებები ტიპის სისტემაში, შეცდომების დამუშავება და თანმიმდევრულობა.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">გადადით PHP 8-ზე!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
დასახელებული არგუმენტები
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/en/functions.arguments.php#functions.named-arguments">დოკუმენტაცია</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>მიუთითეთ მხოლოდ საჭირო პარამეტრები, გამოტოვეთ არასავალდებულო.</li>
|
||||
<li>არგუმენტების თანმიმდევრობა არ არის მნიშვნელოვანი, არგუმენტები თვითდოკუმენტირებადია.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Attributes
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.attributes.php">დოკუმენტაცია</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>PHPDoc ანოტაციების ნაცვლად, შეგიძლიათ გამოიყენოთ სტრუქტურული მეტამონაცემები ნატიური PHP სინტაქსით.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
თვისებების განახლება კონსტრუქტორში
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion">დოკუმენტაცია</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>ნაკლები შაბლონური კოდი თვისებების განსაზღვრისა და ინიციალიზაციისთვის.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Union types
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.types.declarations.php#language.types.declarations.composite.union">დოკუმენტაცია</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // შეცდომები არაა',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>PHPDoc ანოტაციების ნაცვლად, გაერთიანებული ტიპებისთვის შეგიძლიათ გამოიყენოთ განცხადება union type,
|
||||
რომლებიც მოწმდება შესრულების დროს.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
გამოსახულება Match
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/en/control-structures.match.php">დოკუმენტაცია</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "ოოო არა!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "ის, რასაც მე ველოდი";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> ოოო არა!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "ის, რასაც მე ველოდი",
|
||||
};
|
||||
//> ის, რასაც მე ველოდი',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>ახალი გამოსახულება match, switch ოპერატორის მსგავსია შემდეგი მახასიათებლებით:</p>
|
||||
<ul>
|
||||
<li>Match — ეს არის გამოსახულება, მისი შედეგი შეიძლება შენახული იყოს ცვლადში ან დაბრუნდეს.</li>
|
||||
<li>პირობა match მხარს უჭერერს მხოლოდ ერთსტრიქონიან გამოსახულებებს, რომლებიც არ საჭიროებენ break; კონტროლის კონსტრუქციას.</li>
|
||||
<li>გამოსახულება match იყენებს მკაცრ შედარებას.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
ოპერატორი Nullsafe
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>null-ის შემოწმების ნაცვლად, შეგიძლიათ გამოიყენოთ გამოძახების თანმიმდევრობა ახალ Nullsafe ოპერატორით.
|
||||
როდესაც ერთ-ერთი ელემენტი თანმიმდევრობაში აბრუნებს null-ს, შესრულება ჩერდება და მთელი თანმიმდევრობა აბრუნებს null-ს.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
სტრიქონებისა და რიცხვების გაუმჯობესებული შედარება
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>PHP 8 რიცხვითი სტრიქონის შედარებისას იყენებს რიცხვების შედარებას. წინააღმდეგ შემთხვევაში,
|
||||
რიცხვი გარდაიქმნება სტრიქონად და გამოიყენება სტრიქონების შედარება.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
ტიპების თანმიმდევრულობის შეცდომები ჩაშენებული ფუნქციებისთვის
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>შიდა ფუნქციების უმეტესობა უკვე გამორიცხავს Error გამონაკლისს, თუ შეცდომა მოხდა პარამეტრის შემოწმებისას.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">კომპილაცია Just-In-Time</h2>
|
||||
<p>
|
||||
PHP 8 წარმოგიდგენთ JIT-კომპილაციის ორ მექანიზმს. JIT ტრასირება, მათგან ყველაზე პერსპექტიულია,
|
||||
სინთეზურ ბენჩმარკზე აჩვენებს მუშაობის გაუმჯობესებას დაახლოებით 3-ჯერ და 1.5-2-ჯერ ზოგიერთ დიდ ხანს მომუშავე აპლიკაციებში.
|
||||
აპლიკაციის სტანდარტული წარმადობა ერთ და იგივე დონეზეა PHP 7.4-თან.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
JIT-ის შედარებითი წვლილი PHP 8-ის წარმადობაში
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">გაუმჯობესებები ტიპის სისტემაში და შეცდომების დამუშავება</h2>
|
||||
<ul>
|
||||
<li>
|
||||
ტიპის უფრო მკაცრი შემოწმება არითმეტიკული/ბიტიური ოპერატორებისთვის
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
აბსტრაქტული თვისებების მეთოდების შემოწმება <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
ჯადოსნური მეთოდების სწორი სიგნატურები <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
ძრავის გაფრთხილებების ხელახალი კლასიფიკაცია <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
ფატალური შეცდომა, როდესაც მეთოდის სიგნატურა შეუთავსებელია <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
@ ოპერატორი აღარ აჩუმებს ფატალურ შეცდომებს.
|
||||
</li>
|
||||
<li>
|
||||
მემკვიდრეობა private მეთოდებთან <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
ახალი ტიპი mixed <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
დაბრუნების ტიპი static <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
ტიპები სტანდარტული ფუნქციებისთვის
|
||||
<a href="https://externals.io/message/106522">Email თემა</a>
|
||||
</li>
|
||||
<li>
|
||||
გაუმჭვირვალე ობიექტები რესურსების ნაცვლად
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, and
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
გაფართოებებისთვის
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">სინტაქსის სხვა გაუმჯობესება</h2>
|
||||
<ul>
|
||||
<li>
|
||||
მძიმე დაშვებულია პარამეტრების სიის ბოლოს <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
და use დამოკლების სიაში <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
ბლოკი catch ცვლადის მითითების გარეშე <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
ცვლადის სინტაქსის ცვლილება <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
სახელების სივრცეში სახელები განიხილება, როგორც ერთიამნი ტოკენი <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
გამოსახულება Throw <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
დამატება ::class ობიექტებისთვის <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">ახალი კლასები, ინტერფეისები და ფუნქციები</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> class
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/stringable">Stringable</a> interface
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> ობიექტზე-ორიენტირებული ფუნქცია
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">ახალი API-ები DOM-ის გადასასვლელად და დასამუშავებლად</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
უკეთესი წარმადობა, უკეთესი სინტაქსი, უფრო საიმედო ტიპების სისტემა.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">გადადით PHP 8-ზე!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
PHP 8 წყაროს კოდის ჩამოსატვირთად ეწვიეთ <a href="http://www.php.net/downloads">ჩამოტვირთვის</a> გვერდს.
|
||||
Windows-ის ბინარული ფაილები განთავსებულია საიტზე <a href="http://windows.php.net/download">PHP Windows-თვის</a>.
|
||||
ცვლილებების სია წარმოდგენილია <a href="http://www.php.net/ChangeLog-8.php">ChangeLog-ში</a>.
|
||||
</p>
|
||||
<p>
|
||||
<a href="/manual/en/migration80.php">მიგრაციის გზამკვლევი</a> ხელმისაწვდომია დოკუმენტაციის განყოფილებაში. გთხოვთ,
|
||||
შეისწავლოთ იგი ახალი ფუნქციების დეტალური ჩამონათვალის მისაღებად და უკუ შეუთავსებელი ცვლილებებისთვის.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
84
releases/8.0/languages/de.php
Normal file
84
releases/8.0/languages/de.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 ist ein Major-Update der Sprache PHP. Es beinhaltet viele neue Funktionen und Optimierungen wie beispielsweise Named Arguments, Union Types, Attribute, Constructor Property Promotion, Match Ausdrücke, Nullsafe Operator, JIT und Verbesserungen des Typen-Systems, der Fehlerbehandlung und der Konsistenz.',
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Released!',
|
||||
'main_subtitle' => 'PHP 8.0 ist ein Major-Update der Sprache PHP.<br class="display-none-md"> Es beinhaltet viele neue Funktionen und Optimierungen wie beispielsweise Named Arguments, Union Types, Attribute, Constructor Property Promotion, Match Ausdrücke, Nullsafe Operator, JIT und Verbesserungen des Typen-Systems, der Fehlerbehandlung und der Konsistenz.',
|
||||
'upgrade_now' => 'Wechsle jetzt zu PHP 8!',
|
||||
|
||||
'named_arguments_title' => 'Named Arguments',
|
||||
'named_arguments_description' => '<li>Gib nur notwendige Parameter an, überspringe optionale.</li><li>Parameter sind unabhängig von der Reihenfolge und selbstdokumentierend.</li>',
|
||||
'attributes_title' => 'Attribute',
|
||||
'attributes_description' => 'Anstelle von PHPDoc Annotations kannst du nun strukturierte Meta-Daten in nativer PHP Syntax nutzen.',
|
||||
'constructor_promotion_title' => 'Constructor Property Promotion',
|
||||
'constructor_promotion_description' => 'Weniger Codewiederholungen für das Definieren und Initialisieren von Objektattributen.',
|
||||
'union_types_title' => 'Union Types',
|
||||
'union_types_description' => 'Anstelle von PHPDoc Annotations für kombinierte Typen kannst du native Union-Type-Deklarationen verwenden, welche zur Laufzeit validiert werden.',
|
||||
'match_expression_title' => 'Match Ausdruck',
|
||||
'match_expression_description' => '<p>Der neue <code>match</code> Ausdruck ist ähnlich wie die <code>switch</code> Anweisung und bietet folgende Funktionen:</p>
|
||||
<ul>
|
||||
<li>Da Match ein Ausdruck ist, kann sein Ergebnis in einer Variable gespeichert oder ausgegeben werden.</li>
|
||||
<li>Match Zweige unterstützen nur einzeilige Ausdrücke und benötigen keinen <code>break</code> Ausdruck.</li>
|
||||
<li>Match führt strikte Vergleiche durch.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Nullsafe Operator',
|
||||
'nullsafe_operator_description' => 'Anstelle von Null-Checks kannst du Funktionsaufrufe nun direkt mit dem neuen Nullsafe Operator aneinanderreihen. Wenn ein Funktionsaufruf innerhalb der Kette Null zurückliefert, wird die weitere Ausführung abgebrochen und die gesamte Kette wird zu Null ausgewertet.',
|
||||
'saner_string_number_comparisons_title' => 'Vernünftige String-zu-Zahl Vergleiche',
|
||||
'saner_string_number_comparisons_description' => 'Wenn eine Zahl mit einem numerischen String verglichen wird, benutzt PHP 8 einen Zahlen-Vergleich. Andernfalls wird die Zahl zu einem String konvertiert und ein String-Vergleich durchgeführt.',
|
||||
'consistent_internal_function_type_errors_title' => 'Konsistente Typen-Fehler für interne Funktionen',
|
||||
'consistent_internal_function_type_errors_description' => 'Die meisten internen Funktionen erzeugen nun eine <code>Error</code> Exception wenn die Typenvalidierung der Parameter fehlschlägt.',
|
||||
|
||||
'jit_compilation_title' => 'Just-In-Time Compiler',
|
||||
'jit_compilation_description' => 'PHP 8 führt zwei JIT Compiler Engines ein. Tracing-JIT, der vielversprechendere der beiden, zeigt eine bis zu drei mal bessere Performance in synthetischen Benchmarks und eine 1,5 bis zweifache Verbesserung in einigen speziellen, langlaufenden Anwendungen. Die Performance einer typischen Anwendung ist auf dem Niveau von PHP 7.4.',
|
||||
'jit_performance_title' => 'Relativer Beitrag des JIT Compilers zur Performance von PHP 8',
|
||||
|
||||
'type_improvements_title' => 'Verbesserungen am Typen-System und an der Fehlerbehandlung',
|
||||
'arithmetic_operator_type_checks' => 'Striktere Typen-Checks für arithmetische/bitweise Operatoren',
|
||||
'abstract_trait_method_validation' => 'Validierung abstrakter Methoden in einem Trait',
|
||||
'magic_method_signatures' => 'Korrekte Signaturen magischer Funktionen',
|
||||
'engine_warnings' => 'Neue Klassifizierung von Engine-Warnings',
|
||||
'lsp_errors' => 'Inkompatiblen Methoden-Signaturen erzeugen einen Fatal Error',
|
||||
'at_operator_no_longer_silences_fatal_errors' => 'Der <code>@</code> Operator unterdrückt keine Fatal Errors mehr.',
|
||||
'inheritance_private_methods' => 'Vererbung mit privaten Methoden',
|
||||
'mixed_type' => '<code>mixed</code> Typ',
|
||||
'static_return_type' => '<code>static</code> als Rückgabetyp',
|
||||
'internal_function_types' => 'Typen für interne Funktionen',
|
||||
'email_thread' => 'E-Mail-Thread',
|
||||
'opaque_objects_instead_of_resources' => 'Objekte ohne Methoden anstelle des resource Typs für
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, und
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
Extension',
|
||||
|
||||
'other_improvements_title' => 'Weitere Syntax-Anpassungen und Verbesserungen',
|
||||
'allow_trailing_comma' => 'Erlauben eines abschließenden Kommas in Parameter-Listen <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
und Closure Use Listen <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>.',
|
||||
'non_capturing_catches' => 'Catches ohne Exception-Variable',
|
||||
'variable_syntax_tweaks' => 'Anpassungen an der Syntax für Variablen',
|
||||
'namespaced_names_as_token' => 'Namespaces werden als ein Token ausgewertet',
|
||||
'throw_expression' => '<code>throw</code> ist jetzt ein Ausdruck',
|
||||
'class_name_literal_on_object' => 'Nutzung von <code>::class</code> auf Objekten',
|
||||
|
||||
'new_classes_title' => 'Neue Klassen, Interfaces, und Funktionen',
|
||||
'weak_map_class' => '<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> Klasse',
|
||||
'stringable_interface' => '<a href="https://wiki.php.net/rfc/stringable">Stringable</a> Interface',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> mit einer Objekt-Implementierung',
|
||||
'new_dom_apis' => 'Neue APIs für DOM-Traversal and -Manipulation',
|
||||
|
||||
'footer_title' => 'Bessere Performance, bessere Syntax, optimierte Typsicherheit.',
|
||||
'footer_description' => '<p>
|
||||
Für den direkten Code-Download von PHP 8 schaue bitte auf der <a href="http://www.php.net/downloads">Downloads</a> Seite vorbei.
|
||||
Windows Pakete können auf der <a href="http://windows.php.net/download">PHP für Windows</a> Seite gefunden werden.
|
||||
Die Liste der Änderungen ist im <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a> festgehalten.
|
||||
</p>
|
||||
<p>
|
||||
Der <a href="/manual/de/migration80.php">Migration Guide</a> ist im PHP Manual verfügbar. Lies dort
|
||||
nach für detaillierte Informationen zu den neuen Funktionen und inkompatiblen Änderungen zu vorherigen PHP
|
||||
Versionen.
|
||||
</p>',
|
||||
];
|
||||
89
releases/8.0/languages/en.php
Normal file
89
releases/8.0/languages/en.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 is a major update of the PHP language. It contains many new features and optimizations including named arguments, union types, attributes, constructor property promotion, match expression, nullsafe operator, JIT, and improvements in the type system, error handling, and consistency.',
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Released!',
|
||||
'main_subtitle' => 'PHP 8.0 is a major update of the PHP language.<br class="display-none-md"> It contains many new features and optimizations including named arguments, union types, attributes, constructor property promotion, match expression, nullsafe operator, JIT, and improvements in the type system, error handling, and consistency.',
|
||||
'upgrade_now' => 'Upgrade to PHP 8 now!',
|
||||
|
||||
'named_arguments_title' => 'Named arguments',
|
||||
'named_arguments_description' => '<li>Specify only required parameters, skipping optional ones.</li><li>Arguments are order-independent and self-documented.</li>',
|
||||
'attributes_title' => 'Attributes',
|
||||
'attributes_description' => 'Instead of PHPDoc annotations, you can now use structured metadata with PHP\'s native syntax.',
|
||||
'constructor_promotion_title' => 'Constructor property promotion',
|
||||
'constructor_promotion_description' => 'Less boilerplate code to define and initialize properties.',
|
||||
'union_types_title' => 'Union types',
|
||||
'union_types_description' => 'Instead of PHPDoc annotations for a combination of types, you can use native union type declarations that are validated at runtime.',
|
||||
'ok' => 'Ok',
|
||||
'oh_no' => 'Oh no!',
|
||||
'this_is_expected' => 'This is what I expected',
|
||||
'match_expression_title' => 'Match expression',
|
||||
'match_expression_description' => '<p>The new <code>match</code> is similar to <code>switch</code> and has the following features:</p>
|
||||
<ul>
|
||||
<li>Match is an expression, meaning its result can be stored in a variable or returned.</li>
|
||||
<li>Match branches only support single-line expressions and do not need a <code>break</code> statement.</li>
|
||||
<li>Match does strict comparisons.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Nullsafe operator',
|
||||
'nullsafe_operator_description' => 'Instead of <code>null</code> check conditions, you can now use a chain of calls with the new nullsafe operator. When the evaluation of one element in the chain fails, the execution of the entire chain aborts and the entire chain evaluates to <code>null</code>.',
|
||||
'saner_string_number_comparisons_title' => 'Saner string to number comparisons',
|
||||
'saner_string_number_comparisons_description' => 'When comparing to a numeric string, PHP 8 uses a number comparison. Otherwise, it converts the number to a string and uses a string comparison.',
|
||||
'consistent_internal_function_type_errors_title' => 'Consistent type errors for internal functions',
|
||||
'consistent_internal_function_type_errors_description' => 'Most of the internal functions now throw an <code>Error</code> exception if the validation of the parameters fails.',
|
||||
|
||||
'jit_compilation_title' => 'Just-In-Time compilation',
|
||||
'jit_compilation_description' => 'PHP 8 introduces two JIT compilation engines. Tracing JIT, the most promising of the two, shows about 3 times better performance on synthetic benchmarks and 1.5–2 times improvement on some specific long-running applications. Typical application performance is on par with PHP 7.4.',
|
||||
'jit_performance_title' => 'Relative JIT contribution to PHP 8 performance',
|
||||
|
||||
'type_improvements_title' => 'Type system and error handling improvements',
|
||||
'arithmetic_operator_type_checks' => 'Stricter type checks for arithmetic/bitwise operators',
|
||||
'abstract_trait_method_validation' => 'Abstract trait method validation',
|
||||
'magic_method_signatures' => 'Correct signatures of magic methods',
|
||||
'engine_warnings' => 'Reclassified engine warnings',
|
||||
'lsp_errors' => 'Fatal error for incompatible method signatures',
|
||||
'at_operator_no_longer_silences_fatal_errors' => 'The <code>@</code> operator no longer silences fatal errors.',
|
||||
'inheritance_private_methods' => 'Inheritance with private methods',
|
||||
'mixed_type' => '<code>mixed</code> type',
|
||||
'static_return_type' => '<code>static</code> return type',
|
||||
'internal_function_types' => 'Types for internal functions',
|
||||
'email_thread' => 'Email thread',
|
||||
'opaque_objects_instead_of_resources' => 'Opaque objects instead of resources for
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, and
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
extensions',
|
||||
|
||||
'other_improvements_title' => 'Other syntax tweaks and improvements',
|
||||
'allow_trailing_comma' => 'Allow a trailing comma in parameter lists <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
and closure use lists <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'Non-capturing catches',
|
||||
'variable_syntax_tweaks' => 'Variable Syntax Tweaks',
|
||||
'namespaced_names_as_token' => 'Treat namespaced names as single token',
|
||||
'throw_expression' => '<code>throw</code> is now an expression',
|
||||
'class_name_literal_on_object' => 'Allow <code>::class</code> on objects',
|
||||
|
||||
'new_classes_title' => 'New Classes, Interfaces, and Functions',
|
||||
'weak_map_class' => '<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> class',
|
||||
'stringable_interface' => '<a href="https://wiki.php.net/rfc/stringable">Stringable</a> interface',
|
||||
'new_str_functions' => '<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> object implementation',
|
||||
'new_dom_apis' => 'New DOM Traversal and Manipulation APIs',
|
||||
|
||||
'footer_title' => 'Better performance, better syntax, improved type safety.',
|
||||
'footer_description' => '<p>
|
||||
For source downloads of PHP 8 please visit the <a href="http://www.php.net/downloads">downloads</a> page.
|
||||
Windows binaries can be found on the <a href="http://windows.php.net/download">PHP for Windows</a> site.
|
||||
The list of changes is recorded in the <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="/manual/en/migration80.php">migration guide</a> is available in the PHP Manual. Please
|
||||
consult it for a detailed list of new features and backward-incompatible changes.
|
||||
</p>',
|
||||
];
|
||||
81
releases/8.0/languages/es.php
Normal file
81
releases/8.0/languages/es.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 es una actualización importante del lenguaje php que contiene nuevos recursos y optimizaciones incluyendo argumentos nombrados, tipos de uniones, atributos, promoción de propiedades constructivas, expresiones de equivalencia, operador nullsafe, JIT (traducción dinámica) y también mejoras en el sistema de tipos, manejo de errores y consistencia en general.',
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Released!',
|
||||
'main_subtitle' => 'PHP 8.0 es una actualización importante del lenguaje PHP que contiene nuevos recursos y optimizaciones incluyendo argumentos nombrados, tipos de uniones, atributos, promoción de propiedades constructivas, expresiones match, operador nullsafe, JIT (traducción dinámica) y también mejoras en el sistema de tipos, manejo de errores y consistencia en general.',
|
||||
'upgrade_now' => 'Actualizate a PHP 8!',
|
||||
|
||||
'named_arguments_title' => 'Argumentos nombrados',
|
||||
'named_arguments_description' => '<li>Solamente especifica los parámetros requeridos, omite los opcionales.</li><li>Los argumentos son independientes del orden y se documentan automáticamente.</li>',
|
||||
'attributes_title' => 'Atributos',
|
||||
'attributes_description' => 'En vez de anotaciones en PHPDoc, puedes usar metadatos estructurados con la sintaxis nativa de PHP.',
|
||||
'constructor_promotion_title' => 'Promoción de propiedades constructivas',
|
||||
'constructor_promotion_description' => 'Menos código repetitivo para definir e inicializar una propiedad.',
|
||||
'union_types_title' => 'Tipos de unión',
|
||||
'union_types_description' => 'En vez de anotaciones en PHPDoc para combinar tipos, puedes usar una declaración de tipo unión nativa que será validada en el momento de ejecución.',
|
||||
'match_expression_title' => 'Expresiones match',
|
||||
'match_expression_description' => '<p>Las nuevas expresiones <code>match</code> son similares a <code>switch</code> y tienen las siguientes características: </p>
|
||||
<ul>
|
||||
<li>Match es una expresión; esto quiere decir que pueden ser almacenadas como variables o devueltas.</li>
|
||||
<li>Match soporta expresiones de una línea y no necesitan romper declarar un <code>break</code>.</li>
|
||||
<li>Match hace comparaciones estrictas.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Operador Nullsafe',
|
||||
'nullsafe_operator_description' => 'En vez de verificar condiciones nulas, tu puedes utilizar una cadena de llamadas con el nuevo operador nullsafe. Cuando la evaluación de un elemento falla, la ejecución de la entire cadena es abortada y la cadena entera es evaluada como <code>null</code>.',
|
||||
'saner_string_number_comparisons_title' => 'Comparaciones inteligentes entre “strings” y números',
|
||||
'saner_string_number_comparisons_description' => 'Cuando comparas con un “string” numérico, PHP8 usa comparación numérica o de otro caso convierte el número a un "string" y asi los compara.',
|
||||
'consistent_internal_function_type_errors_title' => 'Errores consistentes para funciones internas.',
|
||||
'consistent_internal_function_type_errors_description' => 'La mayoría de las funciones internas ahora proveen un <code>Error</code> de excepción si el parámetro no es validado.',
|
||||
|
||||
'jit_compilation_title' => 'JIT (traducciones dinámicas)',
|
||||
'jit_compilation_description' => 'PHP8 introduce 2 motores de compilación JIT. Transit JIT, es el más prometedor de los dos y performa 3 veces mejor en benchmarks sintéticos y 1.5-2 mejor en algunas aplicaciones específicas a largo plazo. Performancia de aplicaciones típicas es a la par de las de PHP7.4',
|
||||
'jit_performance_title' => 'JIT contribuciones al funcionamiento relativo de PHP8',
|
||||
|
||||
'type_improvements_title' => 'Mejorias en los tipos de sistemas y manejo de errores',
|
||||
'arithmetic_operator_type_checks' => 'Verificaciones estrictas de operadores aritméticos/bitwise.',
|
||||
'abstract_trait_method_validation' => 'Validación de métodos con características abstractas',
|
||||
'magic_method_signatures' => 'Firmas correctas de métodos mágicos',
|
||||
'engine_warnings' => 'Reclacificamiento de errores fatales',
|
||||
'lsp_errors' => 'Errores fatales incompatibles con el método de firma',
|
||||
'at_operator_no_longer_silences_fatal_errors' => 'El operador <code>@</code> no omitirá errores fatales.',
|
||||
'inheritance_private_methods' => 'Herencia con métodos privados',
|
||||
'mixed_type' => 'Tipo <code>mixed</code>',
|
||||
'static_return_type' => 'Tipo retorno <code>static</code>',
|
||||
'internal_function_types' => 'Tipos para funciones internas',
|
||||
'email_thread' => 'Email thread',
|
||||
'opaque_objects_instead_of_resources' => 'Objetos opacos en ves de recursos para
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>,
|
||||
y <a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a> extensiones',
|
||||
|
||||
'other_improvements_title' => 'Otros ajustes y mejoras del sintax',
|
||||
'allow_trailing_comma' => 'Permitir una coma al final de una lista de parámetros <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
y lista de use en closures <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'Catches que no capturan',
|
||||
'variable_syntax_tweaks' => 'Ajustes al syntax variable',
|
||||
'namespaced_names_as_token' => 'Tratamiento de nombres de namespace como tokens únicos',
|
||||
'throw_expression' => '<code>throw</code> es ahora una expresión',
|
||||
'class_name_literal_on_object' => 'Permitir <code>::class</code> on objects',
|
||||
|
||||
'new_classes_title' => 'Nuevas clases, interfaces y funciones',
|
||||
'weak_map_class' => '<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> clase',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> Implementación de objeto',
|
||||
'new_dom_apis' => 'New DOM Traversal and Manipulation APIs',
|
||||
|
||||
'footer_title' => 'Mejor performancia, mejor syntax, aumentada seguridad de tipos.',
|
||||
'footer_description' => '<p>
|
||||
Para bajar el código fuente de PHP8 visita la página <a href="http://www.php.net/downloads">downloads</a>.
|
||||
Código binario para windows lo puedes encontrar en la página <a href="http://windows.php.net/download">PHP for Windows</a>.
|
||||
La lista de cambios está disponible en la página <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
La <a href="/manual/en/migration80.php">guía de migración</a> está disponible en el manual de PHP.
|
||||
Por favor consultala para una lista detallada de alteraciones cambios y compatibilidad.
|
||||
</p>',
|
||||
];
|
||||
82
releases/8.0/languages/fr.php
Normal file
82
releases/8.0/languages/fr.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => "PHP 8.0 est une mise à jour majeure du langage PHP. Elle contient beaucoup de nouvelle fonctionnalités et d'optimisations, incluant les arguments nommés, les types d'union, attributs, promotion de propriétés de constructeur, l'expression match, l'opérateur nullsafe, JIT (Compilation à la Volée), et des améliorations dans le système de typage, la gestion d'erreur, et de cohérence.",
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Released!',
|
||||
'main_subtitle' => 'PHP 8.0 est une mise à jour majeure du langage PHP.<br class="display-none-md"> Elle contient beaucoup de nouvelles fonctionnalités et d\'optimisations, incluant les arguments nommés, les types d\'union, attributs, promotion de propriété de constructeur, l\'expression match, l\'opérateur nullsafe, JIT (Compilation à la Volée), et des améliorations dans le système de typage, la gestion d\'erreur, et de cohérence.',
|
||||
'upgrade_now' => 'Migrez à PHP 8 maintenant!',
|
||||
|
||||
'named_arguments_title' => 'Arguments nommés',
|
||||
'named_arguments_description' => '<li>Spécifiez uniquement les paramètres requis, omettant ceux optionnels.</li><li>Les arguments sont indépendants de l\'ordre et auto-documentés.</li>',
|
||||
'attributes_title' => 'Attributs',
|
||||
'attributes_description' => 'Au lieux d\'annotations PHPDoc, vous pouvez désormais utiliser les métadonnées structurés avec la syntaxe native de PHP.',
|
||||
'constructor_promotion_title' => 'Promotion de propriétés de constructeur',
|
||||
'constructor_promotion_description' => 'Moins de code redondant pour définir et initialiser les propriétés.',
|
||||
'union_types_title' => "Types d'union",
|
||||
'union_types_description' => "Au lieu d'annotation PHPDoc pour une combinaison de type, vous pouvez utiliser les déclarations de types d'union native qui sont validées lors de l'exécution.",
|
||||
'match_expression_title' => 'Expression match',
|
||||
'match_expression_description' => '<p>La nouvelle instruction <code>match</code> est similaire à <code>switch</code> et a les fonctionnalités suivantes :</p>
|
||||
<ul>
|
||||
<li>Match est une expression, signifiant que son résultat peut être enregistré dans une variable ou retourné.</li>
|
||||
<li>Les branches de <code>match</code> supportent uniquement les expressions d\'une seule ligne, et n\'a pas besoin d\'une déclaration <code>break</code>.</li>
|
||||
<li>Match fait des comparaisons strictes.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Opérateur Nullsafe',
|
||||
'nullsafe_operator_description' => "Au lieu de faire des vérifications conditionnelles de <code>null</code>, vous pouvez utiliser une chaîne d'appel avec le nouvel opérateur nullsafe. Qui lorsque l'évaluation d'un élément de la chaîne échoue, l'exécution de la chaîne complète est terminée et la chaîne entière évalue à <code>null</code>.",
|
||||
'saner_string_number_comparisons_title' => 'Comparaisons entre les chaînes de caractères et les nombres plus saines',
|
||||
'saner_string_number_comparisons_description' => 'Lors de la comparaison avec une chaîne numérique, PHP 8 utilise une comparaison de nombre. Sinon, il convertit le nombre à une chaîne de caractères et utilise une comparaison de chaîne de caractères.',
|
||||
'consistent_internal_function_type_errors_title' => 'Erreurs de type cohérent pour les fonctions internes',
|
||||
'consistent_internal_function_type_errors_description' => 'La plupart des fonctions internes lancent désormais une exception <code>Error</code> si la validation du paramètre échoue.',
|
||||
|
||||
'jit_compilation_title' => 'Compilation Juste-à-Temps (JIT)',
|
||||
'jit_compilation_description' => "PHP 8 introduit deux moteurs de compilation JIT (juste à temps/compilation à la volée). Le Tracing JIT, le plus prometteur des deux, montre environ 3 fois plus de performances sur des benchmarks synthétiques et 1,5-2 fois plus de performances sur certaines applications à longue durée d'exécution. Généralement les performances des applications sont identiques à PHP 7.4.",
|
||||
'jit_performance_title' => 'Contribution relative du JIT à la performance de PHP 8',
|
||||
|
||||
'type_improvements_title' => "Amélioration du système de typage et de la gestion d'erreur",
|
||||
'arithmetic_operator_type_checks' => 'Vérification de type plus sévère pour les opérateurs arithmétiques et bit à bit',
|
||||
'abstract_trait_method_validation' => 'Validation de méthode abstraite des traits',
|
||||
'magic_method_signatures' => 'Signature valide des méthodes magiques',
|
||||
'engine_warnings' => 'Reclassifications des avertissements du moteur',
|
||||
'lsp_errors' => 'Erreur fatale pour des signatures de méthodes incompatibles',
|
||||
'at_operator_no_longer_silences_fatal_errors' => "L'opérateur <code>@</code> ne silence plus les erreurs fatales.",
|
||||
'inheritance_private_methods' => 'Héritages avec les méthodes privées',
|
||||
'mixed_type' => 'Type <code>mixed</code>',
|
||||
'static_return_type' => 'Type de retour <code>static</code>',
|
||||
'internal_function_types' => 'Types pour les fonctions internes',
|
||||
'email_thread' => 'Discussion e-mail',
|
||||
'opaque_objects_instead_of_resources' => 'Objets opaques au lieu de ressources pour les extensions
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, et
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>',
|
||||
|
||||
'other_improvements_title' => 'Autres ajustements de syntaxe et améliorations',
|
||||
'allow_trailing_comma' => 'Autorisation des virgules trainantes dans les listes de paramètres <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
et dans les listes des use d\'une fermeture <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'Les catchs non capturant',
|
||||
'variable_syntax_tweaks' => 'Ajustement de la Syntaxe des Variables',
|
||||
'namespaced_names_as_token' => 'Traite les noms des espaces de nom comme un seul token',
|
||||
'throw_expression' => '<code>throw</code> est désormais une expression',
|
||||
'class_name_literal_on_object' => 'Autorisation de <code>::class</code> sur les objets',
|
||||
|
||||
'new_classes_title' => 'Nouvelles Classes, Interfaces, et Fonctions',
|
||||
'weak_map_class' => 'Classe <a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a>',
|
||||
'stringable_interface' => 'Interface <a href="https://wiki.php.net/rfc/stringable">Stringable</a>',
|
||||
'token_as_object' => 'Implémentation objet de <a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a>',
|
||||
'new_dom_apis' => 'Nouvelles APIs pour traverser et manipuler le DOM',
|
||||
|
||||
'footer_title' => 'Meilleures performances, meilleure syntaxe, amélioration de la sécurité de type.',
|
||||
'footer_description' => '<p>
|
||||
Pour le téléchargement des sources de PHP 8 veuillez visiter la page de <a href="http://www.php.net/downloads">téléchargement</a>.
|
||||
Les binaires Windows peuvent être trouvés sur le site de <a href="http://windows.php.net/download">PHP pour Windows</a>.
|
||||
La liste des changements est notée dans le <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
Le <a href="/manual/fr/migration80.php">guide de migration</a> est disponible dans le manuel PHP.
|
||||
Veuillez le consulter pour une liste détaillée des nouvelles fonctionnalités et changements non rétrocompatibles.
|
||||
</p>',
|
||||
];
|
||||
82
releases/8.0/languages/it.php
Normal file
82
releases/8.0/languages/it.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 è una nuova versione major del linguaggio PHP. Contiene molte nuove funzionalità ed ottimizzazioni quali i named arguments, la definizione di tipi unione, gli attributi, la promozione a proprietà degli argomenti del costruttore, l\'espressione match, l\'operatore nullsafe, la compilazione JIT e miglioramenti al sistema dei tipi, alla gestione degli errori e alla consistenza.',
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Released!',
|
||||
'main_subtitle' => 'PHP 8.0 è una nuova versione major del linguaggio PHP.<br class="display-none-md"> Contiene molte nuove funzionalità ed ottimizzazioni quali i named arguments, la definizione di tipi unione, gli attributi, la promozione a proprietà degli argomenti del costruttore, l\'espressione match, l\'operatore nullsafe, la compilazione JIT e miglioramenti al sistema dei tipi, alla gestione degli errori e alla consistenza.',
|
||||
'upgrade_now' => 'Aggiorna a PHP 8!',
|
||||
|
||||
'named_arguments_title' => 'Named arguments',
|
||||
'named_arguments_description' => '<li>Indica solamente i parametri richiesti, saltando quelli opzionali.</li><li>Gli argomenti sono indipendenti dall\'ordine e auto-documentati.</li>',
|
||||
'attributes_title' => 'Attributi',
|
||||
'attributes_description' => 'Invece delle annotazioni PHPDoc, ora puoi usare metadati strutturati nella sintassi nativa PHP.',
|
||||
'constructor_promotion_title' => 'Promozione a proprietà degli argomenti del costruttore',
|
||||
'constructor_promotion_description' => 'Meno ripetizioni di codice per definire ed inizializzare le proprietà.',
|
||||
'union_types_title' => 'Tipi unione',
|
||||
'union_types_description' => 'Invece di indicare una combinazione di tipi con le annotazioni PHPDoc, puoi usare una dichiarazione nativa di tipo unione che viene validato durante l\'esecuzione.',
|
||||
'match_expression_title' => 'Espressione match',
|
||||
'match_expression_description' => '<p>La nuova espressione <code>match</code> è simile allo <code>switch</code> e ha le seguenti funzionalità:</p>
|
||||
<ul>
|
||||
<li>Match è un\'espressione, ovvero il suo risultato può essere salvato in una variabile o ritornato.</li>
|
||||
<li>I rami del <code>match</code> supportano solo espressioni a singola linea e non necessitano di un\'espressione <code>break</code>.</li>
|
||||
<li>Match esegue comparazioni strict.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Operatore nullsafe',
|
||||
'nullsafe_operator_description' => "Invece di controllare la presenza di un <code>null</code>, puoi ora usare una catena di chiamate con il nuovo operatore nullsafe. Quando la valutazione di un elemento della catena fallisce, l'esecuzione della catena si interrompe e l'intera catena restituisce il valore <code>null</code>.",
|
||||
'saner_string_number_comparisons_title' => 'Comparazioni più coerenti di stringhe e numeri',
|
||||
'saner_string_number_comparisons_description' => 'Nella comparazione di una stringa numerica, PHP 8 usa la comparazione numerica. Altrimenti, converte il numero in una stringa e usa la comparazione tra stringhe.',
|
||||
'consistent_internal_function_type_errors_title' => 'Tipi di errori consistenti per le funzioni native',
|
||||
'consistent_internal_function_type_errors_description' => 'La maggior parte delle funzioni native ora lanciano una eccezione <code>Error</code> se la validazione degli argomenti fallisce.',
|
||||
|
||||
'jit_compilation_title' => 'Compilazione Just-In-Time',
|
||||
'jit_compilation_description' => 'PHP 8 intrduce due motori di compilazione JIT. Tracing JIT, il più promettente dei due, mostra delle prestazioni 3 volte superiori nei benchmarks sintetici e 1.5–2 volte superiori per alcuni specifici processi applicativi a lunga esecuzione. Le prestazioni delle tipiche applicazioni web sono al pari con PHP 7.4.',
|
||||
'jit_performance_title' => 'Miglioramenti delle performance in PHP 8 grazie a JIT',
|
||||
|
||||
'type_improvements_title' => 'Sistema dei tipi e miglioramenti alla gestione degli errori',
|
||||
'arithmetic_operator_type_checks' => 'Controlli più stringenti per gli operatori aritmetici e bitwise',
|
||||
'abstract_trait_method_validation' => 'Validazione dei metodi astratti nei trait',
|
||||
'magic_method_signatures' => 'Firme corrette nei metodi magici',
|
||||
'engine_warnings' => 'Riclassificazione degli errori',
|
||||
'lsp_errors' => 'Errori fatali per firme di metodi non compatibili',
|
||||
'at_operator_no_longer_silences_fatal_errors' => "L'operatore <code>@</code> non silenzia più gli errori fatali.",
|
||||
'inheritance_private_methods' => 'Ereditarietà e metodi privati',
|
||||
'mixed_type' => 'Tipo <code>mixed</code>',
|
||||
'static_return_type' => 'Tipo di ritorno <code>static</code>',
|
||||
'internal_function_types' => 'Tipi per le funzioni native',
|
||||
'email_thread' => 'Email thread',
|
||||
'opaque_objects_instead_of_resources' => 'Oggetti opachi invece che risorse per le estensioni
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, e
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>',
|
||||
|
||||
'other_improvements_title' => 'Altre ritocchi e migliorie di sintassi',
|
||||
'allow_trailing_comma' => 'Permessa una virgola finale nella lista dei parametri <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
e nell\'espressione use per le closure <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'Catch senza argomento',
|
||||
'variable_syntax_tweaks' => 'Correzioni alla sintassi di variabile',
|
||||
'namespaced_names_as_token' => 'Trattamento dei nomi di namespace come un singolo token',
|
||||
'throw_expression' => "<code>throw</code> è ora un'espressione",
|
||||
'class_name_literal_on_object' => "Permesso l'utilizzo di <code>::class</code> sugli oggetti",
|
||||
|
||||
'new_classes_title' => 'Nuove classi, interfacce e funzioni',
|
||||
'weak_map_class' => 'Classe <a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a>',
|
||||
'stringable_interface' => 'Interfaccia <a href="https://wiki.php.net/rfc/stringable">Stringable</a>',
|
||||
'token_as_object' => 'Classe <a href="https://wiki.php.net/rfc/token_as_object">PhpToken</a> come alternativa a token_get_all()',
|
||||
'new_dom_apis' => 'New DOM Traversal and Manipulation APIs',
|
||||
|
||||
'footer_title' => 'Performance migliorate, migliore sintassi, e migliore sicurezza dei tipi.',
|
||||
'footer_description' => '<p>
|
||||
Per scaricare il codice sorgente visita di PHP 8 visita la pagina di <a href="http://www.php.net/downloads">download</a>.
|
||||
I binari eseguibili per Windows possono essere trovati sul sito <a href="http://windows.php.net/download">PHP for Windows</a>.
|
||||
Una lista dei cambiamenti è registrata nel <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
La <a href="/manual/en/migration80.php">guida alla migrazione</a> è disponibile nel manuale PHP.
|
||||
Consultatelo per una lista completa delle nuove funzionalità e dei cambiamenti non retrocompatibili.
|
||||
</p>',
|
||||
];
|
||||
83
releases/8.0/languages/ja.php
Normal file
83
releases/8.0/languages/ja.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 は、PHP 言語のメジャーアップデートです。このアップデートには、たくさんの新機能や最適化が含まれています。たとえば名前付き引数、union 型、アトリビュート、コンストラクタでのプロパティのプロモーション、match 式、 nullsafe 演算子、JIT、型システムの改善、エラーハンドリング、一貫性の向上などです。',
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Released!',
|
||||
'main_subtitle' => 'PHP 8.0 は、PHP 言語のメジャーアップデートです。<br class="display-none-md"> このアップデートには、たくさんの新機能や最適化が含まれています。たとえば 名前付き引数、 union 型、アトリビュート、コンストラクタでのプロパティのプロモーション、match 式、nullsafe 演算子、JIT、型システムの改善、エラーハンドリング、一貫性の向上などです。',
|
||||
'upgrade_now' => 'PHP 8 にアップデートしよう!',
|
||||
|
||||
'named_arguments_title' => '名前付き引数',
|
||||
'named_arguments_description' => '<li>必須の引数だけを指定し、オプションの引数はスキップしています。</li><li>引数の順番に依存せず、自己文書化(self-documented)されています。</li>',
|
||||
'attributes_title' => 'アトリビュート',
|
||||
'attributes_description' => 'PHPDoc のアノテーションの代わりに、PHP ネイティブの文法で構造化されたメタデータを扱えるようになりました。',
|
||||
'constructor_promotion_title' => 'コンストラクタでの、プロパティのプロモーション',
|
||||
'constructor_promotion_description' => 'ボイラープレートのコードを減らすため、コンストラクタでプロパティを定義し、初期化します。',
|
||||
'union_types_title' => 'Union 型',
|
||||
'union_types_description' => 'PHPDoc のアノテーションを使って型を組み合わせる代わりに、実行時に検証が行われる union型 をネイティブで使えるようになりました。',
|
||||
'match_expression_title' => 'Match 式',
|
||||
'match_expression_description' => '<p><code>match</code> は <code>switch</code> 文に似ていますが、以下の機能があります:</p>
|
||||
<ul>
|
||||
<li><code>match</code> は式なので、結果を返したり、変数に保存したりできます。</li>
|
||||
<li><code>match</code> の分岐は一行の式だけをサポートしており、<code>break</code> 文は不要です。</li>
|
||||
<li><code>match</code> は、型と値について、厳密な比較を行います。</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Nullsafe 演算子',
|
||||
'nullsafe_operator_description' => '<code>null</code> チェックの条件を追加する代わりに、nullsafe演算子 を使って呼び出しをチェインさせられるようになりました。呼び出しチェインのひとつが失敗すると、チェインの実行全体が停止し、<code>null</code> と評価されます。',
|
||||
'saner_string_number_comparisons_title' => '数値と文字列の比較',
|
||||
'saner_string_number_comparisons_description' => '数値形式の文字列と比較する場合は、PHP 8 は数値として比較を行います。それ以外の場合は、数値を文字列に変換し、文字列として比較を行います。',
|
||||
'consistent_internal_function_type_errors_title' => '内部関数の型に関するエラーが一貫したものに',
|
||||
'consistent_internal_function_type_errors_description' => 'ほとんどの内部関数は、引数の検証に失敗すると <code>Error</code> 例外をスローするようになりました。',
|
||||
|
||||
'jit_compilation_title' => 'JIT (ジャストインタイム) コンパイル',
|
||||
'jit_compilation_description' => 'PHP 8 は JITコンパイル のエンジンをふたつ搭載しています。トレーシングJITは、もっとも有望なふたつの人工的なベンチマークで、約3倍のパフォーマンスを示しました。また、長期間動いている特定のあるアプリケーションでは、1.5-2倍のパフォーマンス向上が見られました。典型的なアプリケーションのパフォーマンスは、PHP 7.4 と同等でした。',
|
||||
'jit_performance_title' => 'PHP 8 のパフォーマンスに対するJITの貢献',
|
||||
|
||||
'type_improvements_title' => '型システムとエラーハンドリングの改善',
|
||||
'arithmetic_operator_type_checks' => '算術/ビット演算子のより厳密な型チェック',
|
||||
'abstract_trait_method_validation' => 'トレイトの抽象メソッドの検証',
|
||||
'magic_method_signatures' => 'マジックメソッドのシグネチャ',
|
||||
'engine_warnings' => 'エンジンの警告を整理',
|
||||
'lsp_errors' => '互換性のないメソッドシグネチャは fatal error に。',
|
||||
'at_operator_no_longer_silences_fatal_errors' => '<code>@</code> 演算子は、致命的なエラーを隠さなくなりました。',
|
||||
'inheritance_private_methods' => 'private メソッドの継承時のシグネチャチェック',
|
||||
'mixed_type' => '<code>mixed</code> 型のサポート',
|
||||
'static_return_type' => '戻り値で <code>static</code> 型をサポート',
|
||||
'internal_function_types' => '内部関数に型アノテーション',
|
||||
'email_thread' => 'Email thread',
|
||||
'opaque_objects_instead_of_resources' => '一部の拡張機能が、リソースからオブジェクトに移行:
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>',
|
||||
|
||||
'other_improvements_title' => 'その他文法の調整や改善',
|
||||
'allow_trailing_comma' => '引数やクロージャーのuseリストの最後にカンマがつけられるように <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
<a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'catch で例外のキャプチャが不要に',
|
||||
'variable_syntax_tweaks' => '変数の文法の調整',
|
||||
'namespaced_names_as_token' => '名前空間の名前を単一のトークンとして扱う',
|
||||
'throw_expression' => '<code>throw</code> は式になりました',
|
||||
'class_name_literal_on_object' => 'オブジェクトに対して <code>::class</code> が使えるように',
|
||||
|
||||
'new_classes_title' => '新しいクラス、インターフェイス、関数',
|
||||
'weak_map_class' => '<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> クラス',
|
||||
'stringable_interface' => '<a href="https://wiki.php.net/rfc/stringable">Stringable</a> インターフェイス',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> をオブジェクトベースで実装',
|
||||
'new_dom_apis' => 'New DOM Traversal and Manipulation APIs',
|
||||
|
||||
'footer_title' => 'パフォーマンスの向上、より良い文法、型システムの改善',
|
||||
'footer_description' => '<p>
|
||||
PHP 8 のソースコードのダウンロードは、
|
||||
<a href="http://www.php.net/downloads">downloads</a> のページをどうぞ。
|
||||
Windows 用のバイナリは <a href="http://windows.php.net/download">PHP for Windows</a> のページにあります。
|
||||
変更の一覧は <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a> にあります。
|
||||
</p>
|
||||
<p>
|
||||
<a href="/manual/ja/migration80.php">移行ガイド</a> が PHP マニュアルで利用できます。
|
||||
新機能や下位互換性のない変更の詳細については、移行ガイドを参照して下さい。
|
||||
</p>',
|
||||
];
|
||||
84
releases/8.0/languages/ka.php
Normal file
84
releases/8.0/languages/ka.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 — PHP ენის დიდი განახლება. ის შეიცავს ბევრ ახალ შესაძლებლობას და ოპტიმიზაციებს, მათ შორის დასახელებული არგუმენტები, union type, ატრიბუტები, თვისებების გამარტივებული განსაზღვრა კონსტრუქტორში, გამოსახულება match, ოპერატორი nullsafe, JIT და გაუმჯობესებები ტიპის სისტემაში, შეცდომების დამუშავება და თანმიმდევრულობა.',
|
||||
'documentation' => 'დოკუმენტაცია',
|
||||
'main_title' => 'რელიზი!',
|
||||
'main_subtitle' => 'PHP 8.0 — PHP ენის დიდი განახლება.<br class="display-none-md"> ის შეიცავს ბევრ ახალ შესაძლებლობას და ოპტიმიზაციებს, მათ შორის დასახელებული არგუმენტები, union type, ატრიბუტები, თვისებების გამარტივებული განსაზღვრა კონსტრუქტორში, გამოსახულება match, ოპერატორი nullsafe, JIT და გაუმჯობესებები ტიპის სისტემაში, შეცდომების დამუშავება და თანმიმდევრულობა.',
|
||||
'upgrade_now' => 'გადადით PHP 8-ზე!',
|
||||
|
||||
'named_arguments_title' => 'დასახელებული არგუმენტები',
|
||||
'named_arguments_description' => '<li>მიუთითეთ მხოლოდ საჭირო პარამეტრები, გამოტოვეთ არასავალდებულო.</li><li>არგუმენტების თანმიმდევრობა არ არის მნიშვნელოვანი, არგუმენტები თვითდოკუმენტირებადია.</li>',
|
||||
'attributes_title' => 'Attributes',
|
||||
'attributes_description' => 'PHPDoc ანოტაციების ნაცვლად, შეგიძლიათ გამოიყენოთ სტრუქტურული მეტამონაცემები ნატიური PHP სინტაქსით.',
|
||||
'constructor_promotion_title' => 'თვისებების განახლება კონსტრუქტორში',
|
||||
'constructor_promotion_description' => 'ნაკლები შაბლონური კოდი თვისებების განსაზღვრისა და ინიციალიზაციისთვის.',
|
||||
'union_types_title' => 'Union types',
|
||||
'union_types_description' => 'PHPDoc ანოტაციების ნაცვლად, გაერთიანებული ტიპებისთვის შეგიძლიათ გამოიყენოთ განცხადება union type, რომლებიც მოწმდება შესრულების დროს.',
|
||||
'ok' => 'შეცდომები არაა',
|
||||
'oh_no' => 'ოოო არა!',
|
||||
'this_is_expected' => 'ის, რასაც მე ველოდი',
|
||||
'match_expression_title' => 'გამოსახულება Match',
|
||||
'match_expression_description' => '<p>ახალი გამოსახულება <code>match</code>, <code>switch</code> ოპერატორის მსგავსია შემდეგი მახასიათებლებით:</p>
|
||||
<ul>
|
||||
<li>Match — ეს არის გამოსახულება, მისი შედეგი შეიძლება შენახული იყოს ცვლადში ან დაბრუნდეს.</li>
|
||||
<li>პირობა <code>match</code> მხარს უჭერერს მხოლოდ ერთსტრიქონიან გამოსახულებებს, რომლებიც არ საჭიროებენ <code>break</code> კონტროლის კონსტრუქციას.</li>
|
||||
<li>გამოსახულება <code>match</code> იყენებს მკაცრ შედარებას.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'ოპერატორი Nullsafe',
|
||||
'nullsafe_operator_description' => 'null-ის შემოწმების ნაცვლად, შეგიძლიათ გამოიყენოთ გამოძახების თანმიმდევრობა ახალ Nullsafe ოპერატორით. როდესაც ერთ-ერთი ელემენტი თანმიმდევრობაში აბრუნებს null-ს, შესრულება ჩერდება და მთელი თანმიმდევრობა აბრუნებს null-ს.',
|
||||
'saner_string_number_comparisons_title' => 'სტრიქონებისა და რიცხვების გაუმჯობესებული შედარება',
|
||||
'saner_string_number_comparisons_description' => 'PHP 8 რიცხვითი სტრიქონის შედარებისას იყენებს რიცხვების შედარებას. წინააღმდეგ შემთხვევაში, რიცხვი გარდაიქმნება სტრიქონად და გამოიყენება სტრიქონების შედარება.',
|
||||
'consistent_internal_function_type_errors_title' => 'ტიპების თანმიმდევრულობის შეცდომები ჩაშენებული ფუნქციებისთვის',
|
||||
'consistent_internal_function_type_errors_description' => 'შიდა ფუნქციების უმეტესობა უკვე გამორიცხავს <code>Error</code> გამონაკლისს, თუ შეცდომა მოხდა პარამეტრის შემოწმებისას.',
|
||||
|
||||
'jit_compilation_title' => 'კომპილაცია Just-In-Time',
|
||||
'jit_compilation_description' => 'PHP 8 წარმოგიდგენთ JIT-კომპილაციის ორ მექანიზმს. JIT ტრასირება, მათგან ყველაზე პერსპექტიულია, სინთეზურ ბენჩმარკზე აჩვენებს მუშაობის გაუმჯობესებას დაახლოებით 3-ჯერ და 1.5-2-ჯერ ზოგიერთ დიდ ხანს მომუშავე აპლიკაციებში. აპლიკაციის სტანდარტული წარმადობა ერთ და იგივე დონეზეა PHP 7.4-თან.',
|
||||
'jit_performance_title' => 'JIT-ის შედარებითი წვლილი PHP 8-ის წარმადობაში',
|
||||
|
||||
'type_improvements_title' => 'გაუმჯობესებები ტიპის სისტემაში და შეცდომების დამუშავება',
|
||||
'arithmetic_operator_type_checks' => 'ტიპის უფრო მკაცრი შემოწმება არითმეტიკული/ბიტიური ოპერატორებისთვის',
|
||||
'abstract_trait_method_validation' => 'აბსტრაქტული თვისებების მეთოდების შემოწმება',
|
||||
'magic_method_signatures' => 'ჯადოსნური მეთოდების სწორი სიგნატურები',
|
||||
'engine_warnings' => 'ძრავის გაფრთხილებების ხელახალი კლასიფიკაცია',
|
||||
'lsp_errors' => 'ფატალური შეცდომა, როდესაც მეთოდის სიგნატურა შეუთავსებელია',
|
||||
'at_operator_no_longer_silences_fatal_errors' => '<code>@</code> ოპერატორი აღარ აჩუმებს ფატალურ შეცდომებს.',
|
||||
'inheritance_private_methods' => 'მემკვიდრეობა private მეთოდებთან',
|
||||
'mixed_type' => 'ახალი ტიპი <code>mixed</code>',
|
||||
'static_return_type' => 'დაბრუნების ტიპი <code>static</code>',
|
||||
'internal_function_types' => 'ტიპები სტანდარტული ფუნქციებისთვის',
|
||||
'email_thread' => 'Email თემა',
|
||||
'opaque_objects_instead_of_resources' => 'გაუმჭვირვალე ობიექტები რესურსების ნაცვლად
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, and
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
გაფართოებებისთვის',
|
||||
|
||||
'other_improvements_title' => 'სინტაქსის სხვა გაუმჯობესება',
|
||||
'allow_trailing_comma' => 'მძიმე დაშვებულია პარამეტრების სიის ბოლოს <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
და use დამოკლების სიაში <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'ბლოკი catch ცვლადის მითითების გარეშე',
|
||||
'variable_syntax_tweaks' => 'ცვლადის სინტაქსის ცვლილება',
|
||||
'namespaced_names_as_token' => 'სახელების სივრცეში სახელები განიხილება, როგორც ერთიამნი ტოკენი',
|
||||
'throw_expression' => 'გამოსახულება <code>throw</code>',
|
||||
'class_name_literal_on_object' => 'დამატება <code>::class</code> ობიექტებისთვის',
|
||||
|
||||
'new_classes_title' => 'ახალი კლასები, ინტერფეისები და ფუნქციები',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> ობიექტზე-ორიენტირებული ფუნქცია',
|
||||
'new_dom_apis' => 'ახალი API-ები DOM-ის გადასასვლელად და დასამუშავებლად',
|
||||
|
||||
'footer_title' => 'უკეთესი წარმადობა, უკეთესი სინტაქსი, უფრო საიმედო ტიპების სისტემა.',
|
||||
'footer_description' => '<p>
|
||||
PHP 8 წყაროს კოდის ჩამოსატვირთად ეწვიეთ <a href="http://www.php.net/downloads">ჩამოტვირთვის</a> გვერდს.
|
||||
Windows-ის ბინარული ფაილები განთავსებულია საიტზე <a href="http://windows.php.net/download">PHP Windows-თვის</a>.
|
||||
ცვლილებების სია წარმოდგენილია <a href="http://www.php.net/ChangeLog-8.php">ChangeLog-ში</a>.
|
||||
</p>
|
||||
<p>
|
||||
<a href="/manual/en/migration80.php">მიგრაციის გზამკვლევი</a> ხელმისაწვდომია დოკუმენტაციის განყოფილებაში. გთხოვთ,
|
||||
შეისწავლოთ იგი ახალი ფუნქციების დეტალური ჩამონათვალის მისაღებად და უკუ შეუთავსებელი ცვლილებებისთვის.
|
||||
</p>',
|
||||
];
|
||||
81
releases/8.0/languages/nl.php
Normal file
81
releases/8.0/languages/nl.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 is een omvangrijke update van de PHP programmeertaal. Het bevat veel nieuwe mogelijkheden en optimalisaties, waaronder argument naamgeving, unie types, attributen, promotie van constructor eigenschappen, expressie vergelijking, null-veilige operator, JIT, en verbeteringen aan het type systeem, foute afhandeling, en consistentie.',
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Beschikbaar!',
|
||||
'main_subtitle' => 'PHP 8.0 is een omvangrijke update van de PHP programmeertaal.<br class="display-none-md"> Het bevat veel nieuwe mogelijkheden en optimalisaties, waaronder argument naamgeving, unie types, attributen, promotie van constructor eigenschappen, expressie vergelijking, null-veilige operator, JIT, en verbeteringen aan het type systeem, foute afhandeling, en consistentie.',
|
||||
'upgrade_now' => 'Update naar PHP 8!',
|
||||
|
||||
'named_arguments_title' => 'Argument naamgeving',
|
||||
'named_arguments_description' => '<li>Geef enkel vereiste parameters op, sla optionele parameters over.</li><li>Argumenten hebben een onafhankelijke volgorde en documenteren zichzelf.</li>',
|
||||
'attributes_title' => 'Attributen',
|
||||
'attributes_description' => 'In plaats van met PHPDoc annotaties kan je nu gestructureerde metadata gebruiken in PHP\'s eigen syntaxis.',
|
||||
'constructor_promotion_title' => 'Promotie van constructor eigenschappen',
|
||||
'constructor_promotion_description' => 'Minder standaardcode nodig om eigenschappen te definiëren en initialiseren.',
|
||||
'union_types_title' => 'Unie types',
|
||||
'union_types_description' => 'In plaats van met PHPDoc annotaties kan je de mogelijke types via unie types declareren zodat deze ook gevalideerd worden tijdens de runtime.',
|
||||
'match_expression_title' => 'Expressie vergelijking',
|
||||
'match_expression_description' => '<p>De nieuwe <code>match</code> is gelijkaardig aan <code>switch</code> en heeft volgende eigenschappen:</p>
|
||||
<ul>
|
||||
<li>Match is een expressie, dit wil zeggen dat je het in een variabele kan bewaren of teruggeven.</li>
|
||||
<li>Match aftakkingen zijn expressies van één enkele lijn en bevatten geen <code>break</code> statements.</li>
|
||||
<li>Match vergelijkingen zijn strikt.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Null-veilige operator',
|
||||
'nullsafe_operator_description' => 'In plaats van een controle op <code>null</code> uit te voeren kan je nu een ketting van oproepen vormen met de null-veilige operator. Wanneer één expressie in de ketting faalt, zal de rest van de ketting niet uitgevoerd worden en is het resultaat van de hele ketting <code>null</code>.',
|
||||
'saner_string_number_comparisons_title' => 'Verstandigere tekst met nummer vergelijkingen',
|
||||
'saner_string_number_comparisons_description' => 'Wanneer PHP 8 een vergelijking uitvoert tegen een numerieke tekst zal er een numerieke vergelijking uitgevoerd worden. Anders zal het nummer naar een tekst omgevormd worden en er een tekstuele vergelijking uitgevoerd worden.',
|
||||
'consistent_internal_function_type_errors_title' => 'Consistente type fouten voor interne functies',
|
||||
'consistent_internal_function_type_errors_description' => 'De meeste interne functies gooien nu een <code>Error</code> exception als de validatie van parameters faalt.',
|
||||
|
||||
'jit_compilation_title' => 'Just-In-Time compilatie',
|
||||
'jit_compilation_description' => 'PHP 8 introduceert twee systemen voor JIT compilatie. De tracerende JIT is veelbelovend en presteert ongeveer 3 keer beter bij synthetische metingen en kan sommige langlopende applicaties 1.5–2 keer verbeteren. Prestaties van typische web applicaties ligt in lijn met PHP 7.4.',
|
||||
'jit_performance_title' => 'Relatieve JIT bijdrage aan de prestaties van PHP 8',
|
||||
|
||||
'type_improvements_title' => 'Type systeem en verbeteringen van de fout afhandeling',
|
||||
'arithmetic_operator_type_checks' => 'Strikte type controles bij rekenkundige/bitsgewijze operatoren',
|
||||
'abstract_trait_method_validation' => 'Validatie voor abstracte trait methodes',
|
||||
'magic_method_signatures' => 'Correcte signatures bij magic methods',
|
||||
'engine_warnings' => 'Herindeling van de engine warnings',
|
||||
'lsp_errors' => 'Fatal error bij incompatibele method signatures',
|
||||
'at_operator_no_longer_silences_fatal_errors' => 'De <code>@</code> operator werkt niet meer bij het onderdrukken van fatale fouten.',
|
||||
'inheritance_private_methods' => 'Overerving bij private methods',
|
||||
'mixed_type' => '<code>mixed</code> type',
|
||||
'static_return_type' => '<code>static</code> return type',
|
||||
'internal_function_types' => 'Types voor interne functies',
|
||||
'email_thread' => 'Email draadje',
|
||||
'opaque_objects_instead_of_resources' => 'Opaque objects in plaats van resources voor
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, and
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
extensies',
|
||||
|
||||
'other_improvements_title' => 'Andere syntaxis aanpassingen en verbeteringen',
|
||||
'allow_trailing_comma' => 'Sta toe om een komma te plaatsen bij het laatste parameter in een lijst <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
en bij de use in closures <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'Catches die niets vangen',
|
||||
'variable_syntax_tweaks' => 'Variabele Syntaxis Aanpassingen',
|
||||
'namespaced_names_as_token' => 'Namespaced namen worden als één enkel token afgehandeld',
|
||||
'throw_expression' => '<code>throw</code> is nu een expressie',
|
||||
'class_name_literal_on_object' => '<code>::class</code> werkt bij objecten',
|
||||
|
||||
'new_classes_title' => 'Nieuwe Classes, Interfaces, en Functies',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> object implementatie',
|
||||
'new_dom_apis' => 'New DOM Traversal and Manipulation APIs',
|
||||
|
||||
'footer_title' => 'Betere prestaties, betere syntaxis, verbeterd type systeem.',
|
||||
'footer_description' => '<p>
|
||||
Ga naar de <a href="http://www.php.net/downloads">downloads</a> pagina om de PHP 8 code te verkrijgen.
|
||||
Uitvoerbare bestanden voor Windows kan je vinden op de <a href="http://windows.php.net/download">PHP voor Windows</a> website.
|
||||
De volledige lijst met wijzigingen is vastgelegd in een <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
De <a href="/manual/en/migration80.php">migratie gids</a> is beschikbaar in de PHP Handleiding. Gebruik
|
||||
deze om een gedetailleerde lijst te krijgen van nieuwe opties en neerwaarts incompatibele aanpassingen.
|
||||
</p>',
|
||||
];
|
||||
88
releases/8.0/languages/pt_BR.php
Normal file
88
releases/8.0/languages/pt_BR.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 é uma atualização importante da linguagem PHP. Ela contém muitos novos recursos e otimizações, incluindo argumentos nomeados, união de tipos, atributos, promoção de propriedade do construtor, expressão match, operador nullsafe, JIT e melhorias no sistema de tipos, tratamento de erros e consistência.',
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Released!',
|
||||
'main_subtitle' => 'PHP 8.0 é uma atualização importante da linguagem PHP. <br class="display-none-md"> Ela contém muitos novos recursos e otimizações, incluindo argumentos nomeados, união de tipos, atributos, promoção de propriedade do construtor, expressão match, operador nullsafe, JIT e melhorias no sistema de tipos, tratamento de erros e consistência.',
|
||||
'upgrade_now' => 'Atualize para o PHP 8!',
|
||||
|
||||
'named_arguments_title' => 'Argumentos nomeados',
|
||||
'named_arguments_description' => '<li>Especifique apenas os parâmetros obrigatórios, pulando os opcionais.</li><li>Os argumentos são independentes da ordem e autodocumentados.</li>',
|
||||
'attributes_title' => 'Atributos',
|
||||
'attributes_description' => 'Em vez de anotações PHPDoc, agora você pode usar metadados estruturados com a sintaxe nativa do PHP.',
|
||||
'constructor_promotion_title' => 'Promoção de propriedade de construtor',
|
||||
'constructor_promotion_description' => 'Menos código boilerplate para definir e inicializar propriedades.',
|
||||
'union_types_title' => 'União de tipos',
|
||||
'union_types_description' => 'Em vez de anotações PHPDoc para uma combinação de tipos, você pode usar declarações de união de tipos nativa que são validados em tempo de execução',
|
||||
'match_expression_title' => 'Expressão match',
|
||||
'match_expression_description' => '<p>A nova expressão <code>match</code> é semelhante ao <code>switch</code> e tem os seguintes recursos:</p>
|
||||
<ul>
|
||||
<li>Match é uma expressão, o que significa que seu resultado pode ser armazenado em uma variável ou
|
||||
retornado.</li>
|
||||
<li>Match suporta apenas expressões de uma linha e não precisa de uma declaração <code>break</code>.</li>
|
||||
<li>Match faz comparações estritas.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Operador nullsafe',
|
||||
'nullsafe_operator_description' => 'Em vez de verificar condições nulas, agora você pode usar uma cadeia de chamadas com o novo operador nullsafe. Quando a avaliação de um elemento da cadeia falha, a execução de toda a cadeia é abortada e toda a cadeia é avaliada como nula.',
|
||||
'saner_string_number_comparisons_title' => 'Comparações mais inteligentes entre strings e números',
|
||||
'saner_string_number_comparisons_description' => 'Ao comparar com uma string numérica, o PHP 8 usa uma comparação numérica. Caso contrário, ele converte o número em uma string e usa uma comparação de string.',
|
||||
'consistent_internal_function_type_errors_title' => 'Erros consistentes para tipos de dados em funções internas',
|
||||
'consistent_internal_function_type_errors_description' => 'A maioria das funções internas agora lançam uma exceção <code>Error</code> se a validação do parâmetro falhar.',
|
||||
|
||||
'jit_compilation_title' => 'Compilação Just-In-Time',
|
||||
'jit_compilation_description' => 'PHP 8 apresenta dois motores de compilação JIT. Tracing JIT, o mais promissor dos dois, mostra desempenho cerca de 3 vezes melhor em benchmarks sintéticos e melhoria de 1,5 a 2 vezes em alguns aplicativos específicos de longa execução. O desempenho típico das aplicações está no mesmo nível do PHP 7.4.',
|
||||
'jit_performance_title' => 'Relative JIT contribution to PHP 8 performance',
|
||||
|
||||
'type_improvements_title' => 'Melhorias no sistema de tipo e tratamento de erros',
|
||||
'arithmetic_operator_type_checks' => 'Verificações de tipo mais rígidas para operadores aritméticos / bit a bit',
|
||||
'abstract_trait_method_validation' => 'Validação de método abstrato em traits',
|
||||
'magic_method_signatures' => 'Assinaturas corretas de métodos mágicos',
|
||||
'engine_warnings' => 'Avisos de motor reclassificados',
|
||||
'lsp_errors' => 'Erro fatal para assinaturas de método incompatíveis',
|
||||
'at_operator_no_longer_silences_fatal_errors' => 'O operador <code>@</code> não silencia mais os erros fatais.',
|
||||
'inheritance_private_methods' => 'Herança com métodos privados',
|
||||
'mixed_type' => 'Tipo <code>mixed</code>',
|
||||
'static_return_type' => 'Tipo de retorno <code>static</code>',
|
||||
'internal_function_types' => 'Tipagem de funções internas',
|
||||
'email_thread' => 'Discussão por email',
|
||||
'opaque_objects_instead_of_resources' => 'Objetos opacos em vez de recursos para
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, e
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
extensões',
|
||||
|
||||
'other_improvements_title' => 'Outros ajustes e melhorias de sintaxe',
|
||||
'allow_trailing_comma' => 'Permitir vírgula no final da lista de parâmetros <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
e listas de uso em closures <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'Catches sem variável na captura de exceção',
|
||||
'variable_syntax_tweaks' => 'Ajustes de sintaxe para variáveis',
|
||||
'namespaced_names_as_token' => 'Tratamento de nomes de namespace como token único',
|
||||
'throw_expression' => '<code>throw</code> como expressão',
|
||||
'class_name_literal_on_object' => 'Permitir <code>::class</code> em objetos',
|
||||
|
||||
'new_classes_title' => 'Novas classes, interfaces e funções',
|
||||
'weak_map_class' => 'Classe <a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a>',
|
||||
'stringable_interface' => 'Interface <a href="https://wiki.php.net/rfc/stringable">Stringable</a>',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> implementado com objetos',
|
||||
'new_dom_apis' => 'New DOM Traversal and Manipulation APIs',
|
||||
|
||||
'footer_title' => 'Obtenha melhoria de desempenho gratuita.<br class="display-none-lg display-block-md">
|
||||
Obtenha melhor sintaxe.<br class="display-block-lg display-none-md display-block-sm">
|
||||
Obtenha mais segurança de tipos.',
|
||||
'footer_description' => '<p>
|
||||
Para downloads do código-fonte do PHP 8, visite a página de
|
||||
<a href="http://www.php.net/downloads">downloads</a>.
|
||||
Os binários do Windows podem ser encontrados na página <a href="http://windows.php.net/download">PHP para
|
||||
Windows</a>.
|
||||
A lista de mudanças é registrada no <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
O <a href="/manual/pt_BR/migration80.php">guia de migração</a> está disponível no Manual do PHP.
|
||||
Consulte-o para obter uma lista detalhada de novos recursos e alterações incompatíveis com versões anteriores.
|
||||
</p>',
|
||||
];
|
||||
86
releases/8.0/languages/ru.php
Normal file
86
releases/8.0/languages/ru.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 — большое обновление языка PHP. Оно содержит множество новых возможностей и оптимизаций, включая именованные аргументы, тип union, атрибуты, упрощённое определение свойств в конструкторе, выражение match, оператор nullsafe, JIT и улучшения в системе типов, обработке ошибок и консистентности.',
|
||||
'documentation' => 'Документация',
|
||||
'main_title' => 'доступен!',
|
||||
'main_subtitle' => 'PHP 8.0 — большое обновление языка PHP.<br class="display-none-md"> Оно содержит множество новых возможностей и оптимизаций, включая именованные аргументы, union type, атрибуты, упрощённое определение свойств в конструкторе, выражение match, оператор nullsafe, JIT и улучшения в системе типов, обработке ошибок и консистентности.',
|
||||
'upgrade_now' => 'Переходите на PHP 8!',
|
||||
|
||||
'named_arguments_title' => 'Именованные аргументы',
|
||||
'named_arguments_description' => '<li>Указывайте только необходимые параметры, пропускайте необязательные.</li><li>Порядок аргументов не важен, аргументы самодокументируемы.</li>',
|
||||
'attributes_title' => 'Атрибуты',
|
||||
'attributes_description' => 'Вместо аннотаций PHPDoc вы можете использовать структурные метаданные с нативным синтаксисом PHP.',
|
||||
'constructor_promotion_title' => 'Объявление свойств в конструкторе',
|
||||
'constructor_promotion_description' => 'Меньше шаблонного кода для определения и инициализации свойств.',
|
||||
'union_types_title' => 'Тип Union',
|
||||
'union_types_description' => 'Вместо аннотаций PHPDoc для объединённых типов вы можете использовать объявления типа union, которые проверяются во время выполнения.',
|
||||
'ok' => 'Нет ошибки',
|
||||
'oh_no' => 'О нет!',
|
||||
'this_is_expected' => 'То, что я и ожидал',
|
||||
'match_expression_title' => 'Выражение Match',
|
||||
'match_expression_description' => '<p>Новое выражение <code>match</code> похоже на оператор <code>switch</code> со следующими особенностями:</p>
|
||||
<ul>
|
||||
<li>Match — это выражение, его результат может быть сохранён в переменной или возвращён.</li>
|
||||
<li>Условия match поддерживают только однострочные выражения, для которых не требуется управляющая конструкция <code>break</code>.</li>
|
||||
<li>Выражение match использует строгое сравнение.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Оператор Nullsafe',
|
||||
'nullsafe_operator_description' => 'Вместо проверки на <code>null</code> вы можете использовать последовательность вызовов с новым оператором Nullsafe. Когда один из элементов в последовательности возвращает null, выполнение прерывается и вся последовательность возвращает <code>null</code>.',
|
||||
'saner_string_number_comparisons_title' => 'Улучшенное сравнение строк и чисел',
|
||||
'saner_string_number_comparisons_description' => 'При сравнении с числовой строкой PHP 8 использует сравнение чисел. В противном случае число преобразуется в строку и используется сравнение строк.',
|
||||
'consistent_internal_function_type_errors_title' => 'Ошибки согласованности типов для встроенных функций',
|
||||
'consistent_internal_function_type_errors_description' => 'Большинство внутренних функций теперь выбрасывают исключение <code>Error</code>, если при проверке параметра возникает ошибка.',
|
||||
|
||||
'jit_compilation_title' => 'Компиляция Just-In-Time',
|
||||
'jit_compilation_description' => 'PHP 8 представляет два механизма JIT-компиляции. Трассировка JIT, наиболее перспективная из них, на синтетических бенчмарках показывает улучшение производительности примерно в 3 раза и в 1,5–2 раза на некоторых долго работающих приложениях. Стандартная производительность приложения находится на одном уровне с PHP 7.4.',
|
||||
'jit_performance_title' => 'Относительный вклад JIT в производительность PHP 8',
|
||||
|
||||
'type_improvements_title' => 'Улучшения в системе типов и обработке ошибок',
|
||||
'arithmetic_operator_type_checks' => 'Более строгие проверки типов для арифметических/побитовых операторов',
|
||||
'abstract_trait_method_validation' => 'Проверка методов абстрактных трейтов',
|
||||
'magic_method_signatures' => 'Правильные сигнатуры магических методов',
|
||||
'engine_warnings' => 'Реклассификация предупреждений движка',
|
||||
'lsp_errors' => 'Фатальная ошибка при несовместимости сигнатур методов',
|
||||
'at_operator_no_longer_silences_fatal_errors' => 'Оператор <code>@</code> больше не подавляет фатальные ошибки.',
|
||||
'inheritance_private_methods' => 'Наследование с private методами',
|
||||
'mixed_type' => 'Новый тип <code>mixed</code>',
|
||||
'static_return_type' => 'Возвращаемый тип <code>static</code>',
|
||||
'internal_function_types' => 'Типы для стандартных функций',
|
||||
'email_thread' => 'E-mail Тема',
|
||||
'opaque_objects_instead_of_resources' => 'Непрозрачные объекты вместо ресурсов для
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, e
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
расширения',
|
||||
|
||||
'other_improvements_title' => 'Прочие улучшения синтаксиса',
|
||||
'allow_trailing_comma' => 'Разрешена запятая в конце списка параметров <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
и в списке use замыканий <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'Блок catch без указания переменной',
|
||||
'variable_syntax_tweaks' => 'Изменения синтаксиса переменных',
|
||||
'namespaced_names_as_token' => 'Имена в пространстве имен рассматриваются как единый токен',
|
||||
'throw_expression' => 'Выражение <code>throw</code>',
|
||||
'class_name_literal_on_object' => 'Добавление <code>::class</code> для объектов',
|
||||
|
||||
'new_classes_title' => 'Новые классы, интерфейсы и функции',
|
||||
'weak_map_class' => 'Класс <a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a>',
|
||||
'stringable_interface' => 'Интерфейс <a href="https://wiki.php.net/rfc/stringable">Stringable</a>',
|
||||
'token_as_object' => 'Объектно-ориентированная функция <a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a>',
|
||||
'new_dom_apis' => 'Новые API для обходения и обработки DOM',
|
||||
|
||||
'footer_title' => 'Выше производительность, лучше синтаксис, надежнее система типов.',
|
||||
'footer_description' => '<p>
|
||||
Для загрузки исходного кода PHP 8 посетите страницу <a href="http://www.php.net/downloads">downloads</a>.
|
||||
Бинарные файлы Windows находятся на сайте <a href="http://windows.php.net/download">PHP для Windows</a>.
|
||||
Список изменений представлен в <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
<a href="/manual/ru/migration80.php">Руководство по миграции</a> доступно в разделе документации. Пожалуйста,
|
||||
изучите его для получения подробного списка новых возможностей и обратно несовместимых изменений.
|
||||
</p>',
|
||||
];
|
||||
85
releases/8.0/languages/tr.php
Normal file
85
releases/8.0/languages/tr.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0, PHP dili için önemli bir güncellemedir. Optimizasyonlar ve yeni özellikler: Adlandırılmış Değişkenler, Union Types, Attributes, Kurucularda Özellik Tanımı, Match İfadesi, Nullsafe Operatorü, JIT(Anında Derleme) yanında tip sistemi, hata işleme ve tutarlılıkta iyileştirmeler içerir.',
|
||||
'documentation' => 'Doc',
|
||||
'main_title' => 'Yayında!',
|
||||
'main_subtitle' => 'PHP 8.0, PHP dili için önemli bir güncellemedir.<br class="display-none-md"> Optimizasyonlar ve yeni özellikler: Adlandırılmış Değişkenler, Union Types, Attributes, Kurucularda Özellik Tanımı, Match İfadesi, Nullsafe Operatorü, JIT(Anında Derleme) yanında tip sistemi, hata işleme ve tutarlılıkta iyileştirmeler içerir.',
|
||||
'upgrade_now' => "PHP 8'e geçiş yapın!",
|
||||
|
||||
'named_arguments_title' => 'Adlandırılmış Değişkenler',
|
||||
'named_arguments_description' => '<li>Opsiyonel parametreleri atlayabiliyor ve yalnızca zorunlu olanları belirtebiliyorsunuz.</li><li>Parametrelerin sırası önemli değil ve kendi kendilerini dokümante ediyorlar.</li>',
|
||||
'attributes_title' => 'Attributes',
|
||||
'attributes_description' => 'PHPDoc yorum satırları yerine PHP sözdizimi ile yapılandırılmış metadata kullanılabiliyor.',
|
||||
'constructor_promotion_title' => 'Kurucularda Özellik Tanımı',
|
||||
'constructor_promotion_description' => 'Sınıfların özelliklerini tanımlamak için daha az kodlama yapılabiliyor.',
|
||||
'union_types_title' => 'Union types',
|
||||
'union_types_description' => 'Değişken türlerinin kombinasyonu için PHPDoc açıklamaları yerine çalışma zamanında doğrulanan birleşim türleri (union types) tanımlamaları kullanılabiliyor.',
|
||||
'match_expression_title' => 'Match İfadesi',
|
||||
'match_expression_description' => '<p>Yeni <code>match</code> ifadesi <code>switch</code>\'e çok benzer ve aşağıdaki özelliklere sahiptir:</p>
|
||||
<ul>
|
||||
<li>Match bir ifadedir, sonucu bir değişkende saklanabilir veya döndürülebilir.</li>
|
||||
<li>Match\'in karşılıkları tek satır ifadeleri destekler ve <code>break</code> kullanılması gerekmez.</li>
|
||||
<li>Match katı (strict) tip karşılaştırma yapar.</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Nullsafe Operatorü',
|
||||
'nullsafe_operator_description' => 'Null koşulları için kontroller yazmak yerine yeni Nullsafe operatörüyle çağrı zinciri oluşturabilirsiniz. Oluşturduğunuz zincirdeki herhangi bir parça hatalı değerlendirilirse tüm zincirin işlevi durur ve null olarak değerlendirilir.',
|
||||
'saner_string_number_comparisons_title' => 'Daha Akıllı String ve Sayı Karşılaştırmaları',
|
||||
'saner_string_number_comparisons_description' => 'Sayısal string karşılaştırılırken PHP 8 sayısal olarak karşılaştırır. Aksi halde sayı bir string\'e çevrilir ve string olarak karşılaştırılır.',
|
||||
'consistent_internal_function_type_errors_title' => 'Dahili İşlevler için Tutarlı Hata Türleri',
|
||||
'consistent_internal_function_type_errors_description' => 'Artık dahili işlevlere gönderilen parametreler doğrulanamazsa <code>Error</code> exception fırlatıyorlar.',
|
||||
|
||||
'jit_compilation_title' => 'Just-In-Time Derlemesi (JIT)',
|
||||
'jit_compilation_description' => 'PHP 8, iki JIT derleme motoru sunuyor. Tracing JIT, ikisi arasında en yetenekli olanı. Karşılaştırmalarda yaklaşık 3 kat daha iyi performans ve uzun süre işlem yapan bazı uygulamalarda 1,5–2 kat iyileşme gösteriyor. Normal uygulamalarda performansı PHP 7.4 ile aynı.',
|
||||
'jit_performance_title' => 'PHP 8 performasına JIT katkısının karşılaştırması',
|
||||
|
||||
'type_improvements_title' => 'Tip sistemi ve hata işlemede iyileştirmeler',
|
||||
'arithmetic_operator_type_checks' => 'Aritmetik/bitsel operatörler için daha katı tip denetimi',
|
||||
'abstract_trait_method_validation' => 'Soyut özellikli metodlar için doğrulama',
|
||||
'magic_method_signatures' => 'Sihirli metodlar için doğru işaretlemeler',
|
||||
'engine_warnings' => 'Yeniden sınıflandırılan motor hataları',
|
||||
'lsp_errors' => 'Uyumsuz metod işaretleri için fatal error',
|
||||
'at_operator_no_longer_silences_fatal_errors' => '<code>@</code> operatörü artık önemli hataları susturmuyor',
|
||||
'inheritance_private_methods' => 'Private methodlarda kalıtımlar',
|
||||
'mixed_type' => '<code>mixed</code> tipi',
|
||||
'static_return_type' => '<code>static</code> return tipi',
|
||||
'internal_function_types' => 'Dahili işlevler için tip açıklamaları',
|
||||
'email_thread' => 'E-posta konusu',
|
||||
'opaque_objects_instead_of_resources' => 'Eklentiler için özkaynak türleri(resources) yerine opak nesneler:
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a> ve
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>.',
|
||||
|
||||
'other_improvements_title' => 'Diğer PHP sözdizimi düzenlemeleri ve iyileştirmeleri',
|
||||
'allow_trailing_comma' => 'Parametre ve closure listelerinin sonunda virgül kullanılabilmesi <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
<a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => 'Değişken atamasına gerek olmayan hataların yakalanabilmesi',
|
||||
'variable_syntax_tweaks' => 'Değişken sözdizimlerinde iyileştirmeler',
|
||||
'namespaced_names_as_token' => 'İsim alanındaki tanımları tek bir belirteç olarak değerlendirme',
|
||||
'throw_expression' => '<code>throw</code> deyimi artık bir ifade (expression)',
|
||||
'class_name_literal_on_object' => 'Nesnelerde <code>::class</code> kullanılabilmesi',
|
||||
|
||||
'new_classes_title' => 'Yeni Sınıflar, Arayüzler ve Fonksiyonlar',
|
||||
'weak_map_class' => '<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> sınıfı',
|
||||
'stringable_interface' => '<a href="https://wiki.php.net/rfc/stringable">Stringable</a> arayüzü',
|
||||
'new_str_functions' => '<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a> fonksiyonları',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> nesne implementasyonu',
|
||||
'new_dom_apis' => 'New DOM Traversal and Manipulation APIs',
|
||||
|
||||
'footer_title' => 'Daha iyi performans, daha iyi sözdizimi, geliştirilmiş tip desteği.',
|
||||
'footer_description' => '<p>
|
||||
PHP 8\'i indirmek için <a href="http://www.php.net/downloads">downloads</a> sayfasını ziyaret edebilirsiniz.
|
||||
Windows için derlenmiş sürümüne <a href="http://windows.php.net/download">PHP for Windows</a> sayfasından ulaşabilirsiniz.
|
||||
Değişiklikler için <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>\'a göz atabilirsiniz.
|
||||
</p>
|
||||
<p>
|
||||
PHP Kılavuzundan PHP 8 için <a href="/manual/tr/migration80.php">Göç Belgelerine</a> ulaşabilirsiniz.
|
||||
Yeni özellikler ve geriye dönük uyumluluğu etkileyecek değişikliklerin ayrıntılı listesi için göç belgesini inceleyiniz.
|
||||
</p>',
|
||||
];
|
||||
86
releases/8.0/languages/zh.php
Normal file
86
releases/8.0/languages/zh.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'common_header' => 'PHP 8.0 是 PHP 语言的一次重大更新。它包含了很多新功能与优化项,包括命名参数、联合类型、注解、构造器属性提升、match 表达式、Nullsafe 运算符、JIT,并改进了类型系统、错误处理、语法一致性。',
|
||||
'documentation' => '文档',
|
||||
'main_title' => '已发布!',
|
||||
'main_subtitle' => 'PHP 8.0 是 PHP 语言的一次重大更新。<br class="display-none-md"> 它包含了很多新功能与优化项,包括命名参数、联合类型、注解、构造器属性提升、match 表达式、nullsafe 运算符、JIT,并改进了类型系统、错误处理、语法一致性。',
|
||||
'upgrade_now' => '更新到 PHP 8!',
|
||||
|
||||
'named_arguments_title' => '命名参数',
|
||||
'named_arguments_description' => '<li>仅仅指定必填参数,跳过可选参数。</li><li>参数的顺序无关、自己就是文档(self-documented)</li>',
|
||||
'attributes_title' => '注解',
|
||||
'attributes_description' => '现在可以用 PHP 原生语法来使用结构化的元数据,而非 PHPDoc 声明。',
|
||||
'constructor_promotion_title' => '构造器属性提升',
|
||||
'constructor_promotion_description' => '更少的样板代码来定义并初始化属性。',
|
||||
'union_types_title' => '联合类型',
|
||||
'union_types_description' => '相较于以前的 PHPDoc 声明类型的组合, 现在可以用原生支持的联合类型声明取而代之,并在运行时得到校验。',
|
||||
'match_expression_title' => 'Match 表达式',
|
||||
'match_expression_description' => '<p>新的 <code>match</code> 类似于 <code>switch</code>,并具有以下功能:</p>
|
||||
<ul>
|
||||
<li>Match 是一个表达式,它可以储存到变量中亦可以直接返回。</li>
|
||||
<li>Match 分支仅支持单行,它不需要一个 <code>break</code> 语句。</li>
|
||||
<li>Match 使用严格比较。</li>
|
||||
</ul>',
|
||||
|
||||
'nullsafe_operator_title' => 'Nullsafe 运算符',
|
||||
'nullsafe_operator_description' => '现在可以用新的 nullsafe 运算符链式调用,而不需要条件检查 null。 如果链条中的一个元素失败了,整个链条会中止并认定为 Null。',
|
||||
'saner_string_number_comparisons_title' => '字符串与数字的比较更符合逻辑',
|
||||
'saner_string_number_comparisons_description' => 'PHP 8 比较数字字符串(numeric string)时,会按数字进行比较。不是数字字符串时,将数字转化为字符串,按字符串比较。',
|
||||
'consistent_internal_function_type_errors_title' => '内部函数类型错误的一致性。',
|
||||
'consistent_internal_function_type_errors_description' => '现在大多数内部函数在参数验证失败时抛出 <code>Error</code> 级异常。',
|
||||
|
||||
'jit_compilation_title' => '即时编译',
|
||||
'jit_compilation_description' => 'PHP 8 引入了两个即时编译引擎。 Tracing JIT 在两个中更有潜力,它在综合基准测试中显示了三倍的性能,并在某些长时间运行的程序中显示了 1.5-2 倍的性能改进。典型的应用性能则和 PHP 7.4 不相上下。',
|
||||
'jit_performance_title' => '关于 JIT 对 PHP 8 性能的贡献',
|
||||
|
||||
'type_improvements_title' => '类型系统与错误处理的改进',
|
||||
'arithmetic_operator_type_checks' => '算术/位运算符更严格的类型检测',
|
||||
'abstract_trait_method_validation' => 'Abstract trait 方法的验证',
|
||||
'magic_method_signatures' => '确保魔术方法签名正确',
|
||||
'engine_warnings' => 'PHP 引擎 warning 警告的重新分类',
|
||||
'lsp_errors' => '不兼容的方法签名导致 Fatal 错误',
|
||||
'at_operator_no_longer_silences_fatal_errors' => '操作符 <code>@</code> 不再抑制 fatal 错误。',
|
||||
'inheritance_private_methods' => '私有方法继承',
|
||||
'mixed_type' => '<code>mixed</code> 类型',
|
||||
'static_return_type' => '<code>static</code> 返回类型',
|
||||
'internal_function_types' => '内部函数的类型',
|
||||
'email_thread' => 'Email thread',
|
||||
'opaque_objects_instead_of_resources' => '扩展
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>、
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>、
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>、
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>、
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>、
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
以 Opaque 对象替换 resource。',
|
||||
|
||||
'other_improvements_title' => '其他语法调整和改进',
|
||||
'allow_trailing_comma' => '允许参数列表中的末尾逗号 <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>、
|
||||
闭包 use 列表中的末尾逗号 <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>',
|
||||
'non_capturing_catches' => '无变量捕获的 catch',
|
||||
'variable_syntax_tweaks' => '变量语法的调整',
|
||||
'namespaced_names_as_token' => 'Namespace 名称作为单个 token',
|
||||
'throw_expression' => '现在 <code>throw</code> 是一个表达式',
|
||||
'class_name_literal_on_object' => '允许对象的 <code>::class</code>',
|
||||
|
||||
'new_classes_title' => '新的类、接口、函数',
|
||||
'weak_map_class' => '<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> 类',
|
||||
'stringable_interface' => '<a href="https://wiki.php.net/rfc/stringable">Stringable</a> 接口',
|
||||
'new_str_functions' => '<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>、
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>、
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>',
|
||||
'token_as_object' => '<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> 对象实现',
|
||||
'new_dom_apis' => 'New DOM Traversal and Manipulation APIs',
|
||||
|
||||
'footer_title' => '性能更好,语法更好,类型安全更完善',
|
||||
'footer_description' => '<p>
|
||||
请访问 <a href="http://www.php.net/downloads">下载</a> 页面下载 PHP 8 源代码。
|
||||
在 <a href="http://windows.php.net/download">PHP for Windows</a> 站点中可找到 Windows 二进制文件。
|
||||
<a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a> 中有变更历史记录清单。
|
||||
</p>
|
||||
<p>
|
||||
PHP 手册中有 <a href="/manual/zh/migration80.php">迁移指南</a>。
|
||||
请参考它描述的新功能详细清单、向后不兼容的变化。
|
||||
</p>',
|
||||
];
|
||||
@@ -1,506 +1,6 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/nl.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 is een omvangrijke update van de PHP programmeertaal. ' .
|
||||
'Het bevat veel nieuwe mogelijkheden en optimalisaties, waaronder ' .
|
||||
'argument naamgeving, unie types, attributen, promotie van constructor eigenschappen, ' .
|
||||
'expressie vergelijking, null-veilige operator, JIT, en ' .
|
||||
'verbeteringen aan het type systeem, foute afhandeling, en consistentie.');
|
||||
$lang = 'nl';
|
||||
$documentation = 'en';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('nl'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Beschikbaar!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 is een omvangrijke update van de PHP programmeertaal.<br class="display-none-md"> Het bevat
|
||||
veel nieuwe mogelijkheden en optimalisaties, waaronder argument naamgeving, unie types, attributen,
|
||||
promotie van constructor eigenschappen, expressie vergelijking, null-veilige operator, JIT, en
|
||||
verbeteringen aan het type systeem, foute afhandeling, en consistentie.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Update naar PHP 8!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Argument naamgeving
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/en/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Geef enkel vereiste parameters op, sla optionele parameters over.</li>
|
||||
<li>Argumenten hebben een onafhankelijke volgorde en documenteren zichzelf.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Attributen
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>In plaats van met PHPDoc annotaties kan je nu gestructureerde metadata gebruiken in PHP's eigen syntaxis.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Promotie van constructor eigenschappen
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Minder standaardcode nodig om eigenschappen te definiëren en initialiseren.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Unie types
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.types.declarations.php#language.types.declarations.composite.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>In plaats van met PHPDoc annotaties kan je de mogelijke types via unie types declareren zodat
|
||||
deze ook gevalideerd worden tijdens de runtime.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Expressie vergelijking
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/en/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>De nieuwe match is gelijkaardig aan switch en heeft volgende eigenschappen:</p>
|
||||
<ul>
|
||||
<li>Match is een expressie, dit wil zeggen dat je het in een variabele kan bewaren of teruggeven.</li>
|
||||
<li>Match aftakkingen zijn expressies van één enkele lijn en bevatten geen break statements.</li>
|
||||
<li>Match vergelijkingen zijn strikt.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Null-veilige operator
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>In plaats van een controle op null uit te voeren kan je nu een ketting van oproepen vormen met de null-veilige operator.
|
||||
Wanneer één expressie in de ketting faalt, zal de rest van de ketting niet uitgevoerd worden en is het resultaat van
|
||||
de hele ketting null.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Verstandigere tekst met nummer vergelijkingen
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Wanneer PHP 8 een vergelijking uitvoert tegen een numerieke tekst zal er een numerieke vergelijking uitgevoerd
|
||||
worden. Anders zal het nummer naar een tekst omgevormd worden en er een tekstuele vergelijking uitgevoerd worden.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Consistente type fouten voor interne functies
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>De meeste interne functies gooien nu een Error exception als de validatie van parameters faalt.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">Just-In-Time compilatie</h2>
|
||||
<p>
|
||||
PHP 8 introduceert twee systemen voor JIT compilatie. De tracerende JIT is veelbelovend en presteert ongeveer 3 keer beter
|
||||
bij synthetische metingen en kan sommige langlopende applicaties 1.5–2 keer verbeteren. Prestaties van typische web applicaties
|
||||
ligt in lijn met PHP 7.4.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
Relatieve JIT bijdrage aan de prestaties van PHP 8
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilatie">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Type systeem en verbeteringen van de fout afhandeling</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Strikte type controles bij rekenkundige/bitsgewijze operatoren
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Validatie voor abstracte trait methodes <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Correcte signatures bij magic methods <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Herindeling van de engine warnings <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Fatal error bij incompatibele method signatures <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
De @ operator werkt niet meer bij het onderdrukken van fatale fouten.
|
||||
</li>
|
||||
<li>
|
||||
Overerving bij private methods <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Mixed type <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Static return type <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Types voor interne functies
|
||||
<a href="https://externals.io/message/106522">Email draadje</a>
|
||||
</li>
|
||||
<li>
|
||||
Opaque objects in plaats van resources voor
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, and
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
extensies
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Andere syntaxis aanpassingen en verbeteringen</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Sta toe om een komma te plaatsen bij het laatste parameter in een lijst <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
en bij de use in closures <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Catches die niets vangen <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Variabele Syntaxis Aanpassingen <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Namespaced namen worden als één enkel token afgehandeld <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw is nu een expressie <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
::class werkt bij objecten <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Nieuwe Classes, Interfaces, en Functies</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> class
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/stringable">Stringable</a> interface
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> object implementatie
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">New DOM Traversal and Manipulation APIs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Betere prestaties, betere syntaxis, verbeterd type systeem.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Update naar PHP 8!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
Ga naar de <a href="http://www.php.net/downloads">downloads</a> pagina om de PHP 8 code te verkrijgen.
|
||||
Uitvoerbare bestanden voor Windows kan je vinden op de <a href="http://windows.php.net/download">PHP voor Windows</a> website.
|
||||
De volledige lijst met wijzigingen is vastgelegd in een <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
De <a href="/manual/en/migration80.php">migratie gids</a> is beschikbaar in de PHP Handleiding. Gebruik
|
||||
deze om een gedetailleerde lijst te krijgen van nieuwe opties en neerwaarts incompatibele aanpassingen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,513 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/pt_BR.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 é uma atualização importante da linguagem PHP. ' .
|
||||
'Ela contém muitos novos recursos e otimizações, ' .
|
||||
'incluindo argumentos nomeados, união de tipos, atributos, ' .
|
||||
'promoção de propriedade do construtor, expressão match, ' .
|
||||
'operador nullsafe, JIT e melhorias no sistema de tipos, ' .
|
||||
'tratamento de erros e consistência.');
|
||||
$lang = 'pt_BR';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('pt_BR'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Released!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 é uma atualização importante da linguagem PHP. <br class="display-none-md"> Ela contém muitos novos
|
||||
recursos e otimizações, incluindo argumentos nomeados, união de tipos, atributos, promoção de propriedade do
|
||||
construtor, expressão match, operador nullsafe, JIT e melhorias no sistema de tipos, tratamento de
|
||||
erros e consistência.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Atualize para o PHP 8!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Argumentos nomeados
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/pt_BR/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Especifique apenas os parâmetros obrigatórios, pulando os opcionais.</li>
|
||||
<li>Os argumentos são independentes da ordem e autodocumentados.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Atributos
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/pt_BR/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Em vez de anotações PHPDoc, agora você pode usar metadados estruturados com a sintaxe nativa do PHP.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Promoção de propriedade de construtor
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/pt_BR/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Menos código boilerplate para definir e inicializar propriedades.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
União de tipos
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/pt_BR/language.types.declarations.php#language.types.declarations.composite.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Em vez de anotações PHPDoc para uma combinação de tipos, você pode usar declarações de união de tipos nativa
|
||||
que são validados em tempo de execução.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Expressão match
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/pt_BR/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>A nova expressão match é semelhante ao switch e tem os seguintes recursos:</p>
|
||||
<ul>
|
||||
<li>Match é uma expressão, o que significa que seu resultado pode ser armazenado em uma variável ou
|
||||
retornado.</li>
|
||||
<li>Match suporta apenas expressões de uma linha e não precisa de uma declaração break;.</li>
|
||||
<li>Match faz comparações estritas.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Operador nullsafe
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Em vez de verificar condições nulas, agora você pode usar uma cadeia de chamadas com o novo operador nullsafe.
|
||||
Quando a avaliação de um elemento da cadeia falha, a execução de toda a cadeia é abortada e toda a cadeia é
|
||||
avaliada como nula.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Comparações mais inteligentes entre strings e números
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Ao comparar com uma string numérica, o PHP 8 usa uma comparação numérica. Caso contrário, ele converte o
|
||||
número em uma string e usa uma comparação de string.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Erros consistentes para tipos de dados em funções internas
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>A maioria das funções internas agora lançam uma exceção Error se a validação do parâmetro falhar.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">Compilação Just-In-Time</h2>
|
||||
<p>
|
||||
PHP 8 apresenta dois motores de compilação JIT. Tracing JIT, o mais promissor dos dois, mostra desempenho cerca de
|
||||
3 vezes melhor em benchmarks sintéticos e melhoria de 1,5 a 2 vezes em alguns aplicativos específicos de longa
|
||||
execução. O desempenho típico das aplicações está no mesmo nível do PHP 7.4.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
Relative JIT contribution to PHP 8 performance
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Melhorias no sistema de tipo e tratamento de erros</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Verificações de tipo mais rígidas para operadores aritméticos / bit a bit
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Validação de método abstrato em traits
|
||||
<a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Assinaturas corretas de métodos mágicos <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Avisos de motor reclassificados <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Erro fatal para assinaturas de método incompatíveis <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
O operador @ não silencia mais os erros fatais.
|
||||
</li>
|
||||
<li>
|
||||
Herança com métodos privados <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipo mixed <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipo de retorno static <a href="">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tipagem de funções internas
|
||||
<a href="https://externals.io/message/106522">Discussão por email</a>
|
||||
</li>
|
||||
<li>
|
||||
Objetos opacos em vez de recursos para
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, e
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
extensões
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Outros ajustes e melhorias de sintaxe</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Permitir vírgula no final da lista de parâmetros
|
||||
<a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a> e listas de uso em closures
|
||||
<a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Catches sem variável na captura de exceção <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Ajustes de sintaxe para variáveis <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Tratamento de nomes de namespace como token único
|
||||
<a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw como expressão <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Permitir ::class em objetos <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Novas classes, interfaces e funções</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Classe <a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a>
|
||||
</li>
|
||||
<li>
|
||||
Interface <a href="https://wiki.php.net/rfc/stringable">Stringable</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> implementado com objetos
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">New DOM Traversal and Manipulation APIs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Obtenha melhoria de desempenho gratuita.<br class="display-none-lg display-block-md">
|
||||
Obtenha melhor sintaxe.<br class="display-block-lg display-none-md display-block-sm">
|
||||
Obtenha mais segurança de tipos.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Atualize para o PHP 8!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
Para downloads do código-fonte do PHP 8, visite a página de
|
||||
<a href="http://www.php.net/downloads">downloads</a>.
|
||||
Os binários do Windows podem ser encontrados na página <a href="http://windows.php.net/download">PHP para
|
||||
Windows</a>.
|
||||
A lista de mudanças é registrada no <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
O <a href="/manual/pt_BR/migration80.php">guia de migração</a> está disponível no Manual do PHP.
|
||||
Consulte-o para obter uma lista detalhada de novos recursos e alterações incompatíveis com versões anteriores.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
505
releases/8.0/release.inc
Normal file
505
releases/8.0/release.inc
Normal file
@@ -0,0 +1,505 @@
|
||||
<?php
|
||||
|
||||
use function releases\php80\common_header;
|
||||
use function releases\php80\language_chooser;
|
||||
use function releases\php80\message;
|
||||
|
||||
if (!isset($lang)) {
|
||||
$lang = 'en';
|
||||
}
|
||||
if (!isset($documentation)) {
|
||||
$documentation = $lang;
|
||||
}
|
||||
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/' . $lang . '.php';
|
||||
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
common_header(message('common_header', $lang));
|
||||
|
||||
$ohNoText = message('oh_no', $lang);
|
||||
$expectedText = message('this_is_expected', $lang);
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php language_chooser($lang); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title"><?= message('main_title', $lang) ?></div>
|
||||
<div class="php8-subtitle"><?= message('main_subtitle', $lang) ?></div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads"><?= message('upgrade_now', $lang) ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
<?= message('named_arguments_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/functions.arguments.php#functions.named-arguments"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
htmlspecialchars($string, double_encode: false);
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<?= message('named_arguments_description', $lang) ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
<?= message('attributes_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.attributes.php"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p><?= message('attributes_description', $lang) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
<?= message('constructor_promotion_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.oop5.decon.php#language.oop5.decon.constructor.promotion"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p><?= message('constructor_promotion_description', $lang) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
<?= message('union_types_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.types.declarations.php#language.types.declarations.union"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number('NaN'); //
|
||||
PHP
|
||||
. ' ' . message('ok', $lang),
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number('NaN'); // TypeError
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p><?= message('union_types_description', $lang) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
<?= message('match_expression_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/control-structures.match.php"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<PHP
|
||||
switch (8.0) {
|
||||
case '8.0':
|
||||
\$result = "{$ohNoText}";
|
||||
break;
|
||||
case 8.0:
|
||||
\$result = "{$expectedText}";
|
||||
break;
|
||||
}
|
||||
echo \$result;
|
||||
//> {$ohNoText}
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<PHP
|
||||
echo match (8.0) {
|
||||
'8.0' => "{$ohNoText}",
|
||||
8.0 => "{$expectedText}",
|
||||
};
|
||||
//> {$expectedText}
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<?= message('match_expression_description', $lang) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
<?= message('nullsafe_operator_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
$country = $session?->user?->getAddress()?->country;
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p><?= message('nullsafe_operator_description', $lang) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
<?= message('saner_string_number_comparisons_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
0 == 'foobar' // true
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
0 == 'foobar' // false
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p><?= message('saner_string_number_comparisons_description', $lang) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
<?= message('consistent_internal_function_type_errors_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p><?= message('consistent_internal_function_type_errors_description', $lang) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2" id="jit_compilation"><?= message('jit_compilation_title', $lang) ?></h2>
|
||||
<p><?= message('jit_compilation_description', $lang) ?></p>
|
||||
<h3 class="php8-h3"><?= message('jit_performance_title', $lang) ?></h3>
|
||||
<div class="php8-chart__table">
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</div>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top" id="type_improvements"><?= message('type_improvements_title', $lang) ?></h2>
|
||||
<div class="php8-compare__content php8-compare__content--block" style="margin-top: 0">
|
||||
<ul>
|
||||
<li>
|
||||
<?= message('arithmetic_operator_type_checks', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('abstract_trait_method_validation', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('magic_method_signatures', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('engine_warnings', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('lsp_errors', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li><?= message('at_operator_no_longer_silences_fatal_errors', $lang) ?></li>
|
||||
<li>
|
||||
<?= message('inheritance_private_methods', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('mixed_type', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('static_return_type', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('internal_function_types', $lang) ?>
|
||||
<a href="https://externals.io/message/106522"><?= message('email_thread', $lang) ?></a>
|
||||
</li>
|
||||
<li><?= message('opaque_objects_instead_of_resources', $lang) ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top" id="other_improvements"><?= message('other_improvements_title', $lang) ?></h2>
|
||||
<div class="php8-compare__content php8-compare__content--block" style="margin-top: 0">
|
||||
<ul>
|
||||
<li><?= message('allow_trailing_comma', $lang) ?></li>
|
||||
<li>
|
||||
<?= message('non_capturing_catches', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('variable_syntax_tweaks', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('namespaced_names_as_token', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('throw_expression', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
<?= message('class_name_literal_on_object', $lang) ?>
|
||||
<a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top" id="new_classes"><?= message('new_classes_title', $lang) ?></h2>
|
||||
<div class="php8-compare__content php8-compare__content--block" style="margin-top: 0">
|
||||
<ul>
|
||||
<li><?= message('weak_map_class', $lang) ?></li>
|
||||
<li><?= message('stringable_interface', $lang) ?></li>
|
||||
<li><?= message('new_str_functions', $lang) ?></li>
|
||||
<li><a href="https://github.com/php/php-src/pull/4769">fdiv()</a></li>
|
||||
<li><a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a></li>
|
||||
<li><a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a></li>
|
||||
<li><?= message('token_as_object', $lang) ?></li>
|
||||
<li><a href="https://wiki.php.net/rfc/dom_living_standard_api"><?= message('new_dom_apis', $lang) ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center"><?= message('footer_title', $lang) ?></h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads"><?= message('upgrade_now', $lang) ?></a>
|
||||
</div>
|
||||
<div class="php8-footer__content"><?= message('footer_description', $lang) ?></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php
|
||||
|
||||
site_footer();
|
||||
@@ -1,504 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/ru.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 — большое обновление языка PHP. ' .
|
||||
'Оно содержит множество новых возможностей и оптимизаций, ' .
|
||||
'включая именованные аргументы, тип union, атрибуты, ' .
|
||||
'упрощённое определение свойств в конструкторе, выражение match, ' .
|
||||
'оператор nullsafe, JIT и улучшения в системе типов, ' .
|
||||
'обработке ошибок и консистентности.');
|
||||
$lang = 'ru';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('ru'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">доступен!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 — большое обновление языка PHP.<br class="display-none-md"> Оно содержит множество новых возможностей и
|
||||
оптимизаций, включая именованные аргументы, union type, атрибуты, упрощённое определение свойств в конструкторе, выражение match,
|
||||
оператор nullsafe, JIT и улучшения в системе типов, обработке ошибок и консистентности.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Переходите на PHP 8!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Именованные аргументы
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/ru/functions.arguments.php#functions.named-arguments">Документация</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Указывайте только необходимые параметры, пропускайте необязательные.</li>
|
||||
<li>Порядок аргументов не важен, аргументы самодокументируемы.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Атрибуты
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/ru/language.attributes.php">Документация</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Вместо аннотаций PHPDoc вы можете использовать структурные метаданные с нативным синтаксисом PHP.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Объявление свойств в конструкторе
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/ru/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Документация</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Меньше шаблонного кода для определения и инициализации свойств.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Тип Union
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/ru/language.types.declarations.php#language.types.declarations.composite.union">Документация</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Нет ошибки',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Вместо аннотаций PHPDoc для объединённых типов вы можете использовать объявления типа union, которые
|
||||
проверяются во время выполнения.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Выражение Match
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/ru/control-structures.match.php">Документация</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "О нет!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "То, что я и ожидал";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> О нет!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "О нет!",
|
||||
8.0 => "То, что я и ожидал",
|
||||
};
|
||||
//> То, что я и ожидал',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Новое выражение match похоже на оператор switch со следующими особенностями:</p>
|
||||
<ul>
|
||||
<li>Match — это выражение, его результат может быть сохранён в переменной или возвращён.</li>
|
||||
<li>Условия match поддерживают только однострочные выражения, для которых не требуется управляющая конструкция break;.</li>
|
||||
<li>Выражение match использует строгое сравнение.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Оператор Nullsafe
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Вместо проверки на null вы можете использовать последовательность вызовов с новым оператором Nullsafe. Когда
|
||||
один из элементов в последовательности возвращает null, выполнение прерывается и вся последовательность
|
||||
возвращает null.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Улучшенное сравнение строк и чисел
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>При сравнении с числовой строкой PHP 8 использует сравнение чисел. В противном случае число преобразуется в
|
||||
строку и используется сравнение строк.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Ошибки согласованности типов для встроенных функций
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Большинство внутренних функций теперь выбрасывают исключение Error, если при проверке параметра возникает ошибка.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">Компиляция Just-In-Time</h2>
|
||||
<p>
|
||||
PHP 8 представляет два механизма JIT-компиляции. Трассировка JIT, наиболее перспективная из них, на синтетических бенчмарках показывает
|
||||
улучшение производительности примерно в 3 раза и в 1,5–2 раза на некоторых долго работающих приложениях. Стандартная
|
||||
производительность приложения находится на одном уровне с PHP 7.4.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
Относительный вклад JIT в производительность PHP 8
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Компиляция Just-In-Time">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Улучшения в системе типов и обработке ошибок</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Более строгие проверки типов для арифметических/побитовых операторов
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Проверка методов абстрактных трейтов <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Правильные сигнатуры магических методов <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Реклассификация предупреждений движка <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Фатальная ошибка при несовместимости сигнатур методов <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Оператор @ больше не подавляет фатальные ошибки.
|
||||
</li>
|
||||
<li>
|
||||
Наследование с private методами <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Новый тип mixed <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Возвращаемый тип static <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Типы для стандартных функций
|
||||
<a href="https://externals.io/message/106522">E-mail Тема</a>
|
||||
</li>
|
||||
<li>
|
||||
Непрозрачные объекты вместо ресурсов для
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>, e
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
расширения
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Прочие улучшения синтаксиса</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Разрешена запятая в конце списка параметров <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
и в списке use замыканий <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Блок catch без указания переменной <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Изменения синтаксиса переменных <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Имена в пространстве имен рассматриваются как единый токен <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Выражение Throw <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Добавление ::class для объектов <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Новые классы, интерфейсы и функции</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Класс <a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a>
|
||||
</li>
|
||||
<li>
|
||||
Интерфейс <a href="https://wiki.php.net/rfc/stringable">Stringable</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
Объектно-ориентированная функция <a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">Новые API для обходения и обработки DOM</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Выше производительность, лучше синтаксис, надежнее система типов.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">Переходите на PHP 8!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
Для загрузки исходного кода PHP 8 посетите страницу <a href="http://www.php.net/downloads">downloads</a>.
|
||||
Бинарные файлы Windows находятся на сайте <a href="http://windows.php.net/download">PHP для Windows</a>.
|
||||
Список изменений представлен в <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>.
|
||||
</p>
|
||||
<p>
|
||||
<a href="/manual/ru/migration80.php">Руководство по миграции</a> доступно в разделе документации. Пожалуйста,
|
||||
изучите его для получения подробного списка новых возможностей и обратно несовместимых изменений.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,502 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/tr.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0, PHP dili için önemli bir güncellemedir. Optimizasyonlar ve yeni özellikler: Adlandırılmış ' .
|
||||
'Değişkenler, Union Types, Attributes, Kurucularda Özellik Tanımı, Match İfadesi, Nullsafe Operatorü, ' .
|
||||
'JIT(Anında Derleme) yanında tip sistemi, hata işleme ve tutarlılıkta iyileştirmeler içerir.');
|
||||
$lang = 'tr';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('tr'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">Yayında!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0, PHP dili için önemli bir güncellemedir.<br class="display-none-md"> Optimizasyonlar ve yeni özellikler:
|
||||
Adlandırılmış Değişkenler, Union Types, Attributes, Kurucularda Özellik Tanımı, Match İfadesi, Nullsafe
|
||||
Operatorü, JIT(Anında Derleme) yanında tip sistemi, hata işleme ve tutarlılıkta iyileştirmeler içerir.
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">PHP 8'e geçiş yapın!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
Adlandırılmış Değişkenler
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/tr/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>Opsiyonel parametreleri atlayabiliyor ve yalnızca zorunlu olanları belirtebiliyorsunuz.</li>
|
||||
<li>Parametrelerin sırası önemli değil ve kendi kendilerini dokümante ediyorlar.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
Attributes
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/tr/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>PHPDoc yorum satırları yerine PHP sözdizimi ile yapılandırılmış metadata kullanılabiliyor.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
Kurucularda Özellik Tanımı
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Sınıfların özelliklerini tanımlamak için daha az kodlama yapılabiliyor.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
Union types
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/en/language.types.declarations.php#language.types.declarations.composite.union">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Değişken türlerinin kombinasyonu için PHPDoc açıklamaları yerine çalışma zamanında doğrulanan
|
||||
birleşim türleri (union types) tanımlamaları kullanılabiliyor.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Match İfadesi
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/en/control-structures.match.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Yeni match ifadesi switch'e çok benzer ve aşağıdaki özelliklere sahiptir:</p>
|
||||
<ul>
|
||||
<li>Match bir ifadedir, sonucu bir değişkende saklanabilir veya döndürülebilir.</li>
|
||||
<li>Match'in karşılıkları tek satır ifadeleri destekler ve break; kullanılması gerekmez.</li>
|
||||
<li>Match katı (strict) tip karşılaştırma yapar.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Nullsafe Operatorü
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Null koşulları için kontroller yazmak yerine yeni Nullsafe operatörüyle çağrı zinciri
|
||||
oluşturabilirsiniz. Oluşturduğunuz zincirdeki herhangi bir parça hatalı
|
||||
değerlendirilirse tüm zincirin işlevi durur ve null olarak değerlendirilir.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
Daha Akıllı String ve Sayı Karşılaştırmaları
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Sayısal string karşılaştırılırken PHP 8 sayısal olarak karşılaştırır. Aksi halde sayı bir
|
||||
string'e çevrilir ve string olarak karşılaştırılır.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
Dahili İşlevler için Tutarlı Hata Türleri
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>Artık dahili işlevlere gönderilen parametreler doğrulanamazsa Error exception fırlatıyorlar.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">Just-In-Time Derlemesi (JIT)</h2>
|
||||
<p>
|
||||
PHP 8, iki JIT derleme motoru sunuyor. Tracing JIT, ikisi arasında en yetenekli olanı. Karşılaştırmalarda
|
||||
yaklaşık 3 kat daha iyi performans ve uzun süre işlem yapan bazı uygulamalarda 1,5–2 kat iyileşme gösteriyor.
|
||||
Normal uygulamalarda performansı PHP 7.4 ile aynı.
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
PHP 8 performasına JIT katkısının karşılaştırması
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Tip sistemi ve hata işlemede iyileştirmeler</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Aritmetik/bitsel operatörler için daha katı tip denetimi
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Soyut özellikli metodlar için doğrulama <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Sihirli metodlar için doğru işaretlemeler <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Yeniden sınıflandırılan motor hataları <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Uyumsuz metod işaretleri için fatal error <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
@ operatörü artık önemli hataları susturmuyor
|
||||
</li>
|
||||
<li>
|
||||
Private methodlarda kalıtımlar <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Mixed tipi <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Static return tipi <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Dahili işlevler için tip açıklamaları
|
||||
<a href="https://externals.io/message/106522">E-posta konusu</a>
|
||||
</li>
|
||||
<li>
|
||||
Eklentiler için özkaynak türleri(resources) yerine opak nesneler:
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>,
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>,
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>,
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>,
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a> ve
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Diğer PHP sözdizimi düzenlemeleri ve iyileştirmeleri</h2>
|
||||
<ul>
|
||||
<li>
|
||||
Parametre ve closure listelerinin sonunda virgül kullanılabilmesi <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>
|
||||
<a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Değişken atamasına gerek olmayan hataların yakalanabilmesi <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Değişken sözdizimlerinde iyileştirmeler <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
İsim alanındaki tanımları tek bir belirteç olarak değerlendirme <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Throw deyimi artık bir ifade (expression) <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Nesnelerde ::class kullanılabilmesi <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">Yeni Sınıflar, Arayüzler ve Fonksiyonlar</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> sınıfı
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/stringable">Stringable</a> arayüzü
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>,
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a> fonksiyonları
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> nesne implementasyonu
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">New DOM Traversal and Manipulation APIs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
Daha iyi performans, daha iyi sözdizimi, geliştirilmiş tip desteği.
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">PHP 8'e geçiş yapın!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
PHP 8'i indirmek için <a href="http://www.php.net/downloads">downloads</a> sayfasını ziyaret edebilirsiniz.
|
||||
Windows için derlenmiş sürümüne <a href="http://windows.php.net/download">PHP for Windows</a> sayfasından ulaşabilirsiniz.
|
||||
Değişiklikler için <a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a>'a göz atabilirsiniz.
|
||||
</p>
|
||||
<p>
|
||||
PHP Kılavuzundan PHP 8 için <a href="/manual/tr/migration80.php">Göç Belgelerine</a> ulaşabilirsiniz.
|
||||
Yeni özellikler ve geriye dönük uyumluluğu etkileyecek değişikliklerin ayrıntılı listesi için göç belgesini inceleyiniz.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,495 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.0/zh.php';
|
||||
include_once __DIR__ . '/common.php';
|
||||
|
||||
releases\php80\common_header(
|
||||
'PHP 8.0 是 PHP 语言的一次重大更新。它包含了很多新功能与优化项,' .
|
||||
'包括命名参数、联合类型、注解、构造器属性提升、match 表达式、' .
|
||||
'Nullsafe 运算符、JIT,并改进了类型系统、错误处理、语法一致性。');
|
||||
$lang = 'zh';
|
||||
|
||||
?>
|
||||
<section class="php8-section php8-section_dark php8-section_header center">
|
||||
<div class="page-tools">
|
||||
<div class="change-language">
|
||||
<?php releases\php80\language_chooser('zh'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-section__content">
|
||||
<div class="php8-logo">
|
||||
<img src="/images/php8/logo_php8.svg" alt="php8" height="126" width="343">
|
||||
</div>
|
||||
<div class="php8-title">已发布!</div>
|
||||
<div class="php8-subtitle">
|
||||
PHP 8.0 是 PHP 语言的一次重大更新。
|
||||
<br class="display-none-md"> 它包含了很多新功能与优化项,
|
||||
包括命名参数、联合类型、注解、构造器属性提升、match 表达式、nullsafe 运算符、JIT,并改进了类型系统、错误处理、语法一致性。
|
||||
</div>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">更新到 PHP 8!</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section center">
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="named-arguments">
|
||||
命名参数
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/named_params">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/zh/functions.arguments.php#functions.named-arguments">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);',
|
||||
);?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'htmlspecialchars($string, double_encode: false);',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<ul>
|
||||
<li>仅仅指定必填参数,跳过可选参数。</li>
|
||||
<li>参数的顺序无关、自己就是文档(self-documented)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="attributes">
|
||||
注解
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes_v2">RFC</a> <a class="php8-rfc" href="/manual/zh/language.attributes.php">Doc</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/posts/{id}", methods={"GET"})
|
||||
*/
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class PostsController
|
||||
{
|
||||
#[Route("/api/posts/{id}", methods: ["GET"])]
|
||||
public function get($id) { /* ... */ }
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>现在可以用 PHP 原生语法来使用结构化的元数据,而非 PHPDoc 声明。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="constructor-property-promotion">
|
||||
构造器属性提升
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/constructor_promotion">RFC</a> <a class="php8-rfc" href="/manual/zh/language.oop5.decon.php#language.oop5.decon.constructor.promotion">文档</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public float $x;
|
||||
public float $y;
|
||||
public float $z;
|
||||
public function __construct(
|
||||
float $x = 0.0,
|
||||
float $y = 0.0,
|
||||
float $z = 0.0
|
||||
) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Point {
|
||||
public function __construct(
|
||||
public float $x = 0.0,
|
||||
public float $y = 0.0,
|
||||
public float $z = 0.0,
|
||||
) {}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>更少的样板代码来定义并初始化属性。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="union-types">
|
||||
联合类型
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/union_types_v2">RFC</a> <a class="php8-rfc" href="/manual/zh/language.types.declarations.php#language.types.declarations.composite.union">文档</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
/** @var int|float */
|
||||
private $number;
|
||||
/**
|
||||
* @param float|int $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
}
|
||||
new Number(\'NaN\'); // Ok',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'class Number {
|
||||
public function __construct(
|
||||
private int|float $number
|
||||
) {}
|
||||
}
|
||||
new Number(\'NaN\'); // TypeError',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>相较于以前的 PHPDoc 声明类型的组合,
|
||||
现在可以用原生支持的联合类型声明取而代之,并在运行时得到校验。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="match-expression">
|
||||
Match 表达式
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/match_expression_v2">RFC</a> <a class="php8-rfc" href="/manual/zh/control-structures.match.php">文档</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'switch (8.0) {
|
||||
case \'8.0\':
|
||||
$result = "Oh no!";
|
||||
break;
|
||||
case 8.0:
|
||||
$result = "This is what I expected";
|
||||
break;
|
||||
}
|
||||
echo $result;
|
||||
//> Oh no!',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'echo match (8.0) {
|
||||
\'8.0\' => "Oh no!",
|
||||
8.0 => "This is what I expected",
|
||||
};
|
||||
//> This is what I expected',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>新的 match 类似于 switch,并具有以下功能:</p>
|
||||
<ul>
|
||||
<li>Match 是一个表达式,它可以储存到变量中亦可以直接返回。</li>
|
||||
<li>Match 分支仅支持单行,它不需要一个 break; 语句。</li>
|
||||
<li>Match 使用严格比较。</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="nullsafe-operator">
|
||||
Nullsafe 运算符
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/nullsafe_operator">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = null;
|
||||
if ($session !== null) {
|
||||
$user = $session->user;
|
||||
if ($user !== null) {
|
||||
$address = $user->getAddress();
|
||||
|
||||
if ($address !== null) {
|
||||
$country = $address->country;
|
||||
}
|
||||
}
|
||||
}',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'$country = $session?->user?->getAddress()?->country;',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>现在可以用新的 nullsafe 运算符链式调用,而不需要条件检查 null。
|
||||
如果链条中的一个元素失败了,整个链条会中止并认定为 Null。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="saner-string-to-number-comparisons">
|
||||
字符串与数字的比较更符合逻辑
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/string_to_number_comparison">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // true',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'0 == \'foobar\' // false',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>PHP 8 比较数字字符串(numeric string)时,会按数字进行比较。
|
||||
不是数字字符串时,将数字转化为字符串,按字符串比较。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="consistent-type-errors-for-internal-functions">
|
||||
内部函数类型错误的一致性。
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/consistent_type_errors">RFC</a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label">PHP 7</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given
|
||||
array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__arrow"></div>
|
||||
<div class="php8-compare__block example-contents">
|
||||
<div class="php8-compare__label php8-compare__label_new">PHP 8</div>
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given
|
||||
array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0',
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="php8-compare__content">
|
||||
<p>现在大多数内部函数在参数验证失败时抛出 Error 级异常。</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_light">
|
||||
<h2 class="php8-h2">即时编译</h2>
|
||||
<p>
|
||||
PHP 8 引入了两个即时编译引擎。
|
||||
Tracing JIT 在两个中更有潜力,它在综合基准测试中显示了三倍的性能,
|
||||
并在某些长时间运行的程序中显示了 1.5-2 倍的性能改进。
|
||||
典型的应用性能则和 PHP 7.4 不相上下。
|
||||
</p>
|
||||
<h3 class="php8-h3">
|
||||
关于 JIT 对 PHP 8 性能的贡献
|
||||
</h3>
|
||||
<p>
|
||||
<img src="/images/php8/scheme.svg" width="900" alt="Just-In-Time compilation">
|
||||
</p>
|
||||
|
||||
<div class="php8-columns">
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">类型系统与错误处理的改进</h2>
|
||||
<ul>
|
||||
<li>
|
||||
算术/位运算符更严格的类型检测
|
||||
<a href="https://wiki.php.net/rfc/arithmetic_operator_type_checks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Abstract trait 方法的验证 <a href="https://wiki.php.net/rfc/abstract_trait_method_validation">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
确保魔术方法签名正确 <a href="https://wiki.php.net/rfc/magic-methods-signature">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
PHP 引擎 warning 警告的重新分类 <a href="https://wiki.php.net/rfc/engine_warnings">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
不兼容的方法签名导致 Fatal 错误 <a href="https://wiki.php.net/rfc/lsp_errors">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
操作符 @ 不再抑制 fatal 错误。
|
||||
</li>
|
||||
<li>
|
||||
私有方法继承 <a href="https://wiki.php.net/rfc/inheritance_private_methods">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Mixed 类型 <a href="https://wiki.php.net/rfc/mixed_type_v2">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Static 返回类型 <a href="https://wiki.php.net/rfc/static_return_type">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
内部函数的类型
|
||||
<a href="https://externals.io/message/106522">Email thread</a>
|
||||
</li>
|
||||
<li>
|
||||
扩展
|
||||
<a href="https://php.watch/versions/8.0/resource-CurlHandle">Curl</a>、
|
||||
<a href="https://php.watch/versions/8.0/gdimage">Gd</a>、
|
||||
<a href="https://php.watch/versions/8.0/sockets-sockets-addressinfo">Sockets</a>、
|
||||
<a href="https://php.watch/versions/8.0/OpenSSL-resource">OpenSSL</a>、
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XMLWriter</a>、
|
||||
<a href="https://php.watch/versions/8.0/xmlwriter-resource">XML</a>
|
||||
以 Opaque 对象替换 resource。
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="php8-column">
|
||||
<h2 class="php8-h2 php8-h2_margin-top">其他语法调整和改进</h2>
|
||||
<ul>
|
||||
<li>
|
||||
允许参数列表中的末尾逗号 <a href="https://wiki.php.net/rfc/trailing_comma_in_parameter_list">RFC</a>、
|
||||
闭包 use 列表中的末尾逗号 <a href="https://wiki.php.net/rfc/trailing_comma_in_closure_use_list">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
无变量捕获的 catch <a href="https://wiki.php.net/rfc/non-capturing_catches">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
变量语法的调整 <a href="https://wiki.php.net/rfc/variable_syntax_tweaks">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
Namespace 名称作为单个 token <a href="https://wiki.php.net/rfc/namespaced_names_as_token">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
现在 throw 是一个表达式 <a href="https://wiki.php.net/rfc/throw_expression">RFC</a>
|
||||
</li>
|
||||
<li>
|
||||
允许对象的 ::class <a href="https://wiki.php.net/rfc/class_name_literal_on_object">RFC</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="php8-h2 php8-h2_margin-top">新的类、接口、函数</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/weak_maps">Weak Map</a> 类
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/stringable">Stringable</a> 接口
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/str_contains">str_contains()</a>、
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_starts_with()</a>、
|
||||
<a href="https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions">str_ends_with()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/4769">fdiv()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/get_debug_type">get_debug_type()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/php/php-src/pull/5427">get_resource_id()</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/token_as_object">token_get_all()</a> 对象实现
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.php.net/rfc/dom_living_standard_api">New DOM Traversal and Manipulation APIs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="php8-section php8-section_dark php8-section_footer php8-footer">
|
||||
<div class="php8-section__content">
|
||||
<h2 class="php8-h2 center">
|
||||
性能更好,语法更好,类型安全更完善
|
||||
</h2>
|
||||
<div class="php8-button-wrapper center">
|
||||
<a class="php8-button php8-button_light" href="/downloads">更新到 PHP 8!</a>
|
||||
</div>
|
||||
<div class="php8-footer__content">
|
||||
<p>
|
||||
请访问 <a href="http://www.php.net/downloads">下载</a> 页面下载 PHP 8 源代码。
|
||||
在 <a href="http://windows.php.net/download">PHP for Windows</a> 站点中可找到 Windows 二进制文件。
|
||||
<a href="http://www.php.net/ChangeLog-8.php">ChangeLog</a> 中有变更历史记录清单。
|
||||
</p>
|
||||
<p>
|
||||
PHP 手册中有 <a href="/manual/zh/migration80.php">迁移指南</a>。
|
||||
请参考它描述的新功能详细清单、向后不兼容的变化。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php site_footer();
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang = 'ka';
|
||||
$documentation = 'en';
|
||||
|
||||
include_once __DIR__ . '/release.inc';
|
||||
|
||||
@@ -7,6 +7,9 @@ use function releases\php81\message;
|
||||
if (!isset($lang)) {
|
||||
$lang = 'en';
|
||||
}
|
||||
if (!isset($documentation)) {
|
||||
$documentation = $lang;
|
||||
}
|
||||
|
||||
$_SERVER['BASE_PAGE'] = 'releases/8.1/' . $lang . '.php';
|
||||
|
||||
@@ -37,7 +40,8 @@ common_header(message('common_header', $lang));
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="enumerations">
|
||||
<?= message('enumerations_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/enumerations">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/language.enumerations.php"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/enumerations">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.enumerations.php"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
@@ -84,7 +88,8 @@ PHP
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="readonly_properties">
|
||||
<?= message('readonly_properties_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/readonly_properties_v2">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/language.oop5.properties.php#language.oop5.properties.readonly-properties"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/readonly_properties_v2">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.oop5.properties.php#language.oop5.properties.readonly-properties"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
@@ -95,15 +100,15 @@ PHP
|
||||
class BlogData
|
||||
{
|
||||
private Status $status;
|
||||
|
||||
public function __construct(Status $status)
|
||||
|
||||
public function __construct(Status $status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getStatus(): Status
|
||||
|
||||
public function getStatus(): Status
|
||||
{
|
||||
return $this->status;
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
PHP
|
||||
@@ -120,8 +125,8 @@ PHP
|
||||
class BlogData
|
||||
{
|
||||
public readonly Status $status;
|
||||
|
||||
public function __construct(Status $status)
|
||||
|
||||
public function __construct(Status $status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
@@ -139,7 +144,8 @@ PHP
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="first_class_callable_syntax">
|
||||
<?= message('first_class_callable_syntax_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/first_class_callable_syntax">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/functions.first_class_callable_syntax.php"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/first_class_callable_syntax">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/functions.first_class_callable_syntax.php"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
@@ -184,10 +190,10 @@ PHP
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class Service
|
||||
class Service
|
||||
{
|
||||
private Logger $logger;
|
||||
|
||||
|
||||
public function __construct(
|
||||
?Logger $logger = null,
|
||||
) {
|
||||
@@ -204,10 +210,10 @@ PHP
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class Service
|
||||
class Service
|
||||
{
|
||||
private Logger $logger;
|
||||
|
||||
|
||||
public function __construct(
|
||||
Logger $logger = new NullLogger(),
|
||||
) {
|
||||
@@ -229,7 +235,7 @@ PHP
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class User
|
||||
class User
|
||||
{
|
||||
/**
|
||||
* @Assert\All({
|
||||
@@ -249,7 +255,7 @@ PHP
|
||||
<div class="php8-code phpcode">
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
class User
|
||||
class User
|
||||
{
|
||||
#[\Assert\All(
|
||||
new \Assert\NotNull,
|
||||
@@ -267,7 +273,8 @@ PHP
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="pure_intersection_types">
|
||||
<?= message('pure_intersection_types_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/pure-intersection-types">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/language.types.declarations.php#language.types.declarations.composite.intersection"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/pure-intersection-types">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.types.declarations.php#language.types.declarations.composite.intersection"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
@@ -317,7 +324,8 @@ PHP
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="never_return_type">
|
||||
<?= message('never_return_type_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/noreturn_type">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/language.types.declarations.php#language.types.declarations.never"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/noreturn_type">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.types.declarations.php#language.types.declarations.never"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
@@ -329,7 +337,7 @@ function redirect(string $uri) {
|
||||
header('Location: ' . $uri);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
function redirectToLoginPage() {
|
||||
redirect('/login');
|
||||
echo 'Hello'; // <- dead code
|
||||
@@ -349,10 +357,10 @@ function redirect(string $uri): never {
|
||||
header('Location: ' . $uri);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
function redirectToLoginPage(): never {
|
||||
redirect('/login');
|
||||
echo 'Hello'; // <- dead code detected by static analysis
|
||||
echo 'Hello'; // <- dead code detected by static analysis
|
||||
}
|
||||
PHP
|
||||
|
||||
@@ -368,7 +376,8 @@ PHP
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="final_class_constants">
|
||||
<?= message('final_class_constants_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/final_class_const">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/language.oop5.final.php#language.oop5.final.example.php81"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/final_class_const">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.oop5.final.php#language.oop5.final.example.php81"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
@@ -419,7 +428,8 @@ PHP
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="explicit_octal_numeral_notation">
|
||||
<?= message('octal_numeral_notation_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/explicit_octal_notation">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/migration81.new-features.php#migration81.new-features.core.octal-literal-prefix"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/explicit_octal_notation">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/migration81.new-features.php#migration81.new-features.core.octal-literal-prefix"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
@@ -428,7 +438,7 @@ PHP
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
016 === 16; // false because `016` is octal for `14` and it's confusing
|
||||
016 === 14; // true
|
||||
016 === 14; // true
|
||||
PHP
|
||||
|
||||
);?>
|
||||
@@ -441,7 +451,7 @@ PHP
|
||||
<?php highlight_php_trimmed(
|
||||
<<<'PHP'
|
||||
0o16 === 16; // false — not confusing with explicit notation
|
||||
0o16 === 14; // true
|
||||
0o16 === 14; // true
|
||||
PHP
|
||||
);?>
|
||||
</div>
|
||||
@@ -455,7 +465,8 @@ PHP
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="fibers">
|
||||
<?= message('fibers_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/fibers">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/language.fibers.php"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/fibers">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.fibers.php"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
@@ -496,7 +507,8 @@ PHP
|
||||
<div class="php8-compare">
|
||||
<h2 class="php8-h2" id="array_unpacking_support_for_string_keyed_arrays">
|
||||
<?= message('array_unpacking_title', $lang) ?>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/array_unpacking_string_keys">RFC</a> <a class="php8-rfc" href="/manual/<?= $lang ?>/language.types.array.php#language.types.array.unpacking"><?= message('documentation', $lang) ?></a>
|
||||
<a class="php8-rfc" href="https://wiki.php.net/rfc/array_unpacking_string_keys">RFC</a>
|
||||
<a class="php8-rfc" href="/manual/<?= $documentation ?>/language.types.array.php#language.types.array.unpacking"><?= message('documentation', $lang) ?></a>
|
||||
</h2>
|
||||
<div class="php8-compare__main">
|
||||
<div class="php8-compare__block example-contents">
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 597 KiB After Width: | Height: | Size: 601 KiB |
Reference in New Issue
Block a user