Skip to content

Commit 1027001

Browse files
saundefinedTimWolla
andcommitted
Apply suggestions from code review
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
1 parent 5fc81d6 commit 1027001

2 files changed

Lines changed: 52 additions & 193 deletions

File tree

releases/8.5/languages/en.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

33
return [
4-
'common_header' => 'PHP 8.5 is a major update of the PHP language. It contains many new features, such as Pipe operator, Final Property Promotion, Attributes on Constants, performance improvements, bug fixes, and general cleanup.',
4+
'common_header' => 'PHP 8.5 is a major update of the PHP language. It contains many new features, such as the new URI extension, support for modifying properties while cloning, the Pipe operator, performance improvements, bug fixes, and general cleanup.',
55
'documentation' => 'Doc',
66
'main_title' => 'Released!',
7-
'main_subtitle' => 'PHP 8.5 is a major update of the PHP language.<br class="display-none-md"> It contains many new features, such as Pipe operator, Final Property Promotion, Attributes on Constants, performance improvements, bug fixes, and general cleanup.',
7+
'main_subtitle' => 'PHP 8.5 is a major update of the PHP language.<br class="display-none-md"> It contains many new features, such as the new URI extension, support for modifying properties while cloning, the Pipe operator, performance improvements, bug fixes, and general cleanup.',
88
'upgrade_now' => 'Upgrade to PHP 8.5 now!',
99

1010
'pipe_operator_title' => 'Pipe operator',
@@ -16,10 +16,6 @@
1616
'fcc_in_const_expr_title' => 'First Class Callables in constant expressions',
1717
'curl_share_persistence_improvement_title' => 'Persistent cURL share handle improvement',
1818
'array_first_last_title' => 'New <code>array_first()</code> and <code>array_last()</code> functions',
19-
'final_promotion_title' => 'Final Property Promotion',
20-
'attributes_on_constants_title' => 'Attributes on Constants',
21-
'override_properties_title' => 'Attribute <code>#[\Override]</code> extended to target properties',
22-
'static_aviz_title' => 'Asymmetric Visibility for Static Properties',
2319
'deprecated_traits_title' => 'Attribute <code>#[\Deprecated]</code> available for traits',
2420

2521
'new_classes_title' => 'New Classes, Interfaces, and Functions',

releases/8.5/release.inc

Lines changed: 50 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ PHP
6161
<div class="php8-code phpcode" style="display: table-cell;">
6262
<?php highlight_php_trimmed(
6363
<<<'PHP'
64-
$uri = new Uri\Rfc3986\Uri("https://php.net/releases/8.5/en.php");
64+
use Uri\Rfc3986\Uri;
65+
66+
$uri = new Uri("https://php.net/releases/8.5/en.php");
6567
6668
var_dump($uri->getHost());
6769
// string(7) "php.net"
@@ -86,9 +88,9 @@ PHP
8688
<div class="php8-code phpcode">
8789
<?php highlight_php_trimmed(
8890
<<<'PHP'
89-
class PhpVersion {
91+
final readonly class PhpVersion {
9092
public function __construct(
91-
private string $version = 'PHP 8.4'
93+
public string $version = 'PHP 8.4',
9294
) {}
9395
9496
public function withVersion(string $version) {
@@ -100,6 +102,7 @@ class PhpVersion {
100102
}
101103
102104
var_dump(new PhpVersion()->withVersion('PHP 8.5'));
105+
// Fatal error: Uncaught Error: Cannot modify readonly property PhpVersion::$version
103106
PHP
104107

105108
); ?>
@@ -111,17 +114,22 @@ PHP
111114
<div class="php8-code phpcode" style="display: table-cell;">
112115
<?php highlight_php_trimmed(
113116
<<<'PHP'
114-
class PhpVersion {
117+
final readonly class PhpVersion {
115118
public function __construct(
116-
private readonly string $version = 'PHP 8.4'
119+
public string $version = 'PHP 8.4',
117120
) {}
118121
119122
public function withVersion(string $version) {
120123
return clone($this, ['version' => $version]);
121124
}
122125
}
123126
124-
var_dump(new PhpVersion()->withVersion('PHP 8.5'));
127+
$version = new PhpVersion();
128+
129+
var_dump(
130+
$version->withVersion('PHP 8.5'),
131+
$version->version,
132+
);
125133
PHP
126134
); ?>
127135
</div>
@@ -219,14 +227,31 @@ PHP
219227
<h2 class="php8-h2" id="fcc_in_const_expr">
220228
<?= message('fcc_in_const_expr_title', $lang) ?>
221229
<a class="php8-rfc" href="https://wiki.php.net/rfc/fcc_in_const_expr">RFC</a>
230+
<a class="php8-rfc" href="https://wiki.php.net/rfc/closures_in_const_expr">RFC</a>
222231
</h2>
223232
<div class="php8-compare__main">
224233
<div class="php8-compare__block example-contents">
225234
<div class="php8-compare__label">PHP &lt; 8.5</div>
226235
<div class="php8-code phpcode">
227236
<?php highlight_php_trimmed(
228237
<<<'PHP'
229-
// TODO
238+
final class CalculatorTest extends \PHPUnit\Framework\TestCase
239+
{
240+
#[DataProvider('subtractionProvider')]
241+
public function testSubtraction(int $minuend, int $subtrahend, int $result): void
242+
{
243+
$this->assertSame($result, Calculator::subtract($minuend, $subtrahend));
244+
}
245+
246+
public static function subtractionProvider(): iterable
247+
{
248+
for ($i = -10; $i <= 10; $i++) {
249+
yield [$i, $i, 0];
250+
yield [$i, 0, $i];
251+
yield [0, $i, -$i];
252+
}
253+
}
254+
}
230255
PHP
231256

232257
); ?>
@@ -238,7 +263,20 @@ PHP
238263
<div class="php8-code phpcode" style="display: table-cell;">
239264
<?php highlight_php_trimmed(
240265
<<<'PHP'
241-
// TODO
266+
final class CalculatorTest
267+
{
268+
#[Test\CaseGenerator(static function (): iterable {
269+
for ($i = -10; $i <= 10; $i++) {
270+
yield [$i, $i, 0];
271+
yield [$i, 0, $i];
272+
yield [0, $i, ($i * -1)];
273+
}
274+
})]
275+
public function testSubtraction(int $minuend, int $subtrahend, int $result)
276+
{
277+
\assert(Calculator::subtract($minuend, $subtrahend) === $result);
278+
}
279+
}
242280
PHP
243281
); ?>
244282
</div>
@@ -318,185 +356,6 @@ PHP
318356
</div>
319357
</div>
320358

321-
<div class="php8-compare">
322-
<h2 class="php8-h2" id="final_promotion">
323-
<?= message('final_promotion_title', $lang) ?>
324-
<a class="php8-rfc" href="https://wiki.php.net/rfc/final_promotion">RFC</a>
325-
</h2>
326-
<div class="php8-compare__main">
327-
<div class="php8-compare__block example-contents">
328-
<div class="php8-compare__label">PHP &lt; 8.5</div>
329-
<div class="php8-code phpcode">
330-
<?php highlight_php_trimmed(
331-
<<<'PHP'
332-
class PhpVersion {
333-
public function __construct(
334-
final public string $version = 'PHP 8.4'
335-
) {
336-
337-
}
338-
}
339-
340-
var_dump(new PhpVersion()->version);
341-
// Fatal error: Cannot use the final modifier on a parameter
342-
PHP
343-
344-
); ?>
345-
</div>
346-
</div>
347-
<div class="php8-compare__arrow"></div>
348-
<div class="php8-compare__block example-contents" style="display: table;">
349-
<div class="php8-compare__label php8-compare__label_new">PHP 8.5</div>
350-
<div class="php8-code phpcode" style="display: table-cell;">
351-
<?php highlight_php_trimmed(
352-
<<<'PHP'
353-
class PhpVersion {
354-
public function __construct(
355-
final public string $version = 'PHP 8.5'
356-
) {
357-
358-
}
359-
}
360-
361-
var_dump(new PhpVersion()->version);
362-
// string(7) "PHP 8.5"
363-
PHP
364-
); ?>
365-
</div>
366-
</div>
367-
</div>
368-
</div>
369-
370-
<div class="php8-compare">
371-
<h2 class="php8-h2" id="attributes_on_constants">
372-
<?= message('attributes_on_constants_title', $lang) ?>
373-
<a class="php8-rfc" href="https://wiki.php.net/rfc/attributes-on-constants">RFC</a>
374-
</h2>
375-
<div class="php8-compare__main">
376-
<div class="php8-compare__block example-contents">
377-
<div class="php8-compare__label">PHP &lt; 8.5</div>
378-
<div class="php8-code phpcode">
379-
<?php highlight_php_trimmed(
380-
<<<'PHP'
381-
<?php
382-
383-
#[NewFeatures]
384-
const VERSION = '8.4';
385-
386-
var_dump(VERSION);
387-
// Parse error: syntax error, unexpected token "const"
388-
PHP
389-
390-
); ?>
391-
</div>
392-
</div>
393-
<div class="php8-compare__arrow"></div>
394-
<div class="php8-compare__block example-contents" style="display: table;">
395-
<div class="php8-compare__label php8-compare__label_new">PHP 8.5</div>
396-
<div class="php8-code phpcode" style="display: table-cell;">
397-
<?php highlight_php_trimmed(
398-
<<<'PHP'
399-
<?php
400-
401-
#[NewFeatures]
402-
const VERSION = '8.5';
403-
404-
var_dump(VERSION);
405-
// string(3) "8.5"
406-
PHP
407-
); ?>
408-
</div>
409-
</div>
410-
</div>
411-
</div>
412-
413-
<div class="php8-compare">
414-
<h2 class="php8-h2" id="override_properties">
415-
<?= message('override_properties_title', $lang) ?>
416-
<a class="php8-rfc" href="https://wiki.php.net/rfc/override_properties">RFC</a>
417-
</h2>
418-
<div class="php8-compare__main">
419-
<div class="php8-compare__block example-contents">
420-
<div class="php8-compare__label">PHP &lt; 8.5</div>
421-
<div class="php8-code phpcode">
422-
<?php highlight_php_trimmed(
423-
<<<'PHP'
424-
// TODO
425-
PHP
426-
427-
); ?>
428-
</div>
429-
</div>
430-
<div class="php8-compare__arrow"></div>
431-
<div class="php8-compare__block example-contents" style="display: table;">
432-
<div class="php8-compare__label php8-compare__label_new">PHP 8.5</div>
433-
<div class="php8-code phpcode" style="display: table-cell;">
434-
<?php highlight_php_trimmed(
435-
<<<'PHP'
436-
// TODO
437-
PHP
438-
); ?>
439-
</div>
440-
</div>
441-
</div>
442-
</div>
443-
444-
<div class="php8-compare">
445-
<h2 class="php8-h2" id="static_aviz">
446-
<?= message('static_aviz_title', $lang) ?>
447-
<a class="php8-rfc" href="https://wiki.php.net/rfc/static-aviz">RFC</a>
448-
</h2>
449-
<div class="php8-compare__main">
450-
<div class="php8-compare__block example-contents">
451-
<div class="php8-compare__label">PHP &lt; 8.5</div>
452-
<div class="php8-code phpcode">
453-
<?php highlight_php_trimmed(
454-
<<<'PHP'
455-
class PhpVersion
456-
{
457-
private static string $version = '8.4';
458-
459-
public function getVersion(): string
460-
{
461-
return self::$version;
462-
}
463-
464-
public function increment(): void
465-
{
466-
[$major, $minor] = explode('.', self::$version);
467-
$minor++;
468-
self::$version = "{$major}.{$minor}";
469-
}
470-
}
471-
PHP
472-
473-
); ?>
474-
</div>
475-
</div>
476-
<div class="php8-compare__arrow"></div>
477-
<div class="php8-compare__block example-contents" style="display: table;">
478-
<div class="php8-compare__label php8-compare__label_new">PHP 8.5</div>
479-
<div class="php8-code phpcode" style="display: table-cell;">
480-
<?php highlight_php_trimmed(
481-
<<<'PHP'
482-
class PhpVersion
483-
{
484-
public static private(set) string $version = '8.5';
485-
486-
public function increment(): void
487-
{
488-
[$major, $minor] = explode('.', self::$version);
489-
$minor++;
490-
self::$version = "{$major}.{$minor}";
491-
}
492-
}
493-
PHP
494-
); ?>
495-
</div>
496-
</div>
497-
</div>
498-
</div>
499-
500359
<div class="php8-compare">
501360
<h2 class="php8-h2" id="deprecated_traits">
502361
<?= message('deprecated_traits_title', $lang) ?>
@@ -553,6 +412,10 @@ PHP
553412
<h2 class="php8-h2" id="other_new_things"><?= message('new_classes_title', $lang) ?></h2>
554413
<div class="php8-compare__content php8-compare__content--block">
555414
<ul>
415+
<li>Property Promotion is now available for <code>final</code></li>
416+
<li>Attributes are now available for constants</li>
417+
<li>Attribute <code>#[\Override]</code> now works on properties</li>
418+
<li>Asymmetric Visibility for Static Properties</li>
556419
<li>New <code>#[\DelayedTargetValidation]</code> attribute is available</li>
557420
<li>New <code>get_error_handler()</code>, <code>get_exception_handler()</code> functions, and <code>Closure::getCurrent</code> method are available.</li>
558421
<li>New <code>Dom\Element::getElementsByClassName()</code> and <code>Dom\Element::insertAdjacentHTML()</code> methods are available.</li>

0 commit comments

Comments
 (0)