Skip to content

Commit 20995cb

Browse files
committed
Add lazy objects example
1 parent 92da78e commit 20995cb

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

releases/8.4/languages/en.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
'bc_gmp' => '<code>GMP</code> class is now final.',
3838
'bc_mysqli_constants' => '<code>MYSQLI_SET_CHARSET_DIR</code>, <code>MYSQLI_STMT_ATTR_PREFETCH_ROWS</code>, <code>MYSQLI_CURSOR_TYPE_FOR_UPDATE</code>, <code>MYSQLI_CURSOR_TYPE_SCROLLABLE</code>, and <code>MYSQLI_TYPE_INTERVAL</code> constants have been removed.',
3939
'bc_mysqli_functions' => '<code>mysqli_ping()</code>, <code>mysqli_kill()</code>, <code>mysqli_refresh()</code> functions, <code>mysqli::ping()</code>, <code>mysqli::kill()</code>, <code>mysqli::refresh()</code> methods, and <code>MYSQLI_REFRESH_*</code> constants have been deprecated.',
40-
'bc_standard' => '<code>tream_bucket_make_writeable()</code> and <code>stream_bucket_new()</code> now return an instance of <code>StreamBucket</code> instead of <code>stdClass</code>.',
40+
'bc_standard' => '<code>stream_bucket_make_writeable()</code> and <code>stream_bucket_new()</code> now return an instance of <code>StreamBucket</code> instead of <code>stdClass</code>.',
4141
'bc_core' => '<code>exit()</code> language construct is now a function.',
4242
'bc_warnings' => '<code>E_STRICT</code> constant has been deprecated.',
4343

releases/8.4/release.inc

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,51 @@ PHP
139139
<a class="php8-rfc" href="https://wiki.php.net/rfc/lazy-objects">RFC</a>
140140
</h2>
141141
<div class="php8-compare__main">
142-
<div class="php8-compare__block example-contents">
143-
<div class="php8-compare__label">PHP &lt; 8.4</div>
142+
<div class="example-contents example-contents-full">
143+
<div class="php8-compare__label php8-compare__label_new">PHP 8.2</div>
144144
<div class="php8-code phpcode">
145145
<?php highlight_php_trimmed(
146146
<<<'PHP'
147-
// TODO
148-
PHP
147+
<?php
148+
149+
class Php
150+
{
151+
public function __construct(private string $version)
152+
{
153+
154+
}
155+
}
156+
157+
$initializer = static function (Php $ghost): void {
158+
$ghost->__construct('8.4');
159+
};
160+
161+
$reflector = new ReflectionClass(Php::class);
162+
$ghost = $reflector->newLazyGhost($initializer);
163+
164+
$initializer = static function (Php $proxy): Php {
165+
return new Php('8.4');
166+
};
167+
168+
$reflector = new ReflectionClass(Php::class);
169+
$proxy = $reflector->newLazyProxy($initializer);
170+
171+
var_dump($ghost);
172+
var_dump($proxy);
173+
/*
174+
lazy ghost object(Php)#3 (0) {
175+
["version":"Php":private]=>
176+
uninitialized(string)
177+
}
178+
179+
lazy proxy object(Php)#2 (0) {
180+
["version":"Php":private]=>
181+
uninitialized(string)
182+
}
183+
*/
149184

150-
); ?>
151-
</div>
152-
</div>
153-
<div class="php8-compare__arrow"></div>
154-
<div class="php8-compare__block example-contents">
155-
<div class="php8-compare__label php8-compare__label_new">PHP 8.4</div>
156-
<div class="php8-code phpcode">
157-
<?php highlight_php_trimmed(
158-
<<<'PHP'
159-
// TODO
160185
PHP
186+
161187
); ?>
162188
</div>
163189
</div>

0 commit comments

Comments
 (0)