1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
|
<?xml version="1.0" encoding="utf-8"?>
<sect1 xml:id="migration84.new-features">
<title>New Features</title>
<!-- TODO: Core features for 8.4 -->
<sect2 xml:id="migration84.new-features.core">
<title>PHP Core</title>
<!-- RFC: https://wiki.php.net/rfc/property-hooks -->
<sect3 xml:id="migration84.new-features.core.property-hooks">
<title>Property Hooks</title>
<simpara>
Object properties may now have additional logic associated with their
<literal>get</literal> and <literal>set</literal> operations.
Depending on the usage, that may or may not make the property virtual,
that is, it has no backing value at all.
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
class Person
{
// A "virtual" property. It may not be set explicitly.
public string $fullName {
get => $this->firstName . ' ' . $this->lastName;
}
// All write operations go through this hook, and the result is what is written.
// Read access happens normally.
public string $firstName {
set => ucfirst(strtolower($value));
}
// All write operations go through this hook, which has to write to the backing value itself.
// Read access happens normally.
public string $lastName {
set {
if (strlen($value) < 2) {
throw new \InvalidArgumentException('Too short');
}
$this->lastName = $value;
}
}
}
$p = new Person();
$p->firstName = 'peter';
print $p->firstName; // Prints "Peter"
$p->lastName = 'Peterson';
print $p->fullName; // Prints "Peter Peterson"
]]>
</programlisting>
</informalexample>
</sect3>
<!-- RFC: https://wiki.php.net/rfc/asymmetric-visibility-v2 -->
<sect3 xml:id="migration84.new-features.core.asymmetric-property-visibility">
<title>Asymmetric Property Visibility</title>
<simpara>
Object properties may now have their <literal>set</literal> visibility
controlled separately from the <literal>get</literal> visibility.
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
class Example
{
// The first visibility modifier controls the get-visibility, and the second modifier
// controls the set-visibility. The get-visibility must not be narrower than set-visibility.
public protected(set) string $name;
public function __construct(string $name)
{
$this->name = $name;
}
}
]]>
</programlisting>
</informalexample>
</sect3>
<!-- RFC: https://wiki.php.net/rfc/lazy-objects -->
<sect3 xml:id="migration84.new-features.core.lazy-objects">
<title>Lazy Objects</title>
<simpara>
It is now possible to create objects whose initialization is deferred until
they are accessed. Libraries and frameworks can leverage these lazy objects
to defer fetching data or dependencies required for initialization.
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
class Example
{
public function __construct(private int $data)
{
}
// ...
}
$initializer = static function (Example $ghost): void {
// Fetch data or dependencies
$data = ...;
// Initialize
$ghost->__construct($data);
};
$reflector = new ReflectionClass(Example::class);
$object = $reflector->newLazyGhost($initializer);
]]>
</programlisting>
</informalexample>
</sect3>
<!-- RFC: https://wiki.php.net/rfc/deprecated_attribute -->
<sect3 xml:id="migration84.new-features.core.deprecated-attribute">
<title><code>#[\Deprecated]</code> attribute</title>
<simpara>
The new <classname>Deprecated</classname> attribute can be used to mark functions, methods,
and class constants as deprecated. The behavior of functionality deprecated with this
attribute matches the behavior of the existing deprecation mechanism for functionality
provided by PHP itself. The only exception is that the emitted error code is
<constant>E_USER_DEPRECATED</constant> instead of <constant>E_DEPRECATED</constant>.
</simpara>
<simpara>
Existing deprecations in functionality provided by PHP itself have been updated to use
the attribute, improving the emitted error messages by including a short explanation.
</simpara>
</sect3>
<!-- RFC: https://wiki.php.net/rfc/rfc1867-non-post -->
<sect3 xml:id="migration84.new-features.core.rfc1867">
<title>Parsing RFC1867 (multipart) requests in non-POST HTTP requests</title>
<!-- TODO: expand? -->
<simpara>
Added <function>request_parse_body</function> function that allows parsing
RFC1867 (multipart) requests in non-POST HTTP requests.
</simpara>
</sect3>
<!-- RFC: https://wiki.php.net/rfc/new_without_parentheses -->
<sect3 xml:id="migration84.new-features.core.new-chaining">
<title>Chaining &new; expressions without parentheses</title>
<!-- TODO: expand and examples? -->
<simpara>
New expressions with constructor arguments are now dereferencable, meaning
they allow chaining method calls, property accesses, etc. without enclosing
the expression in parentheses.
</simpara>
</sect3>
<sect3 xml:id="migration84.new-features.core.debug-weakref">
<title>Improved Debugging Info for <classname>WeakReference</classname></title>
<!-- TODO: expand and examples? -->
<simpara>
Getting the debug info for <classname>WeakReference</classname> will now
also output the object it references, or &null; if the reference is no
longer valid.
</simpara>
</sect3>
<sect3 xml:id="migration84.new-features.core.debug-closure">
<title>Improved Debugging Info for <classname>Closure</classname></title>
<!-- TODO: expand and examples? -->
<simpara>
The output of <methodname>Closure::__debugInfo</methodname> now includes
the name, file, and line of the <classname>Closure</classname>.
</simpara>
</sect3>
<!-- Is this really a feature? Should this be moved to other changes? -->
<sect3 xml:id="migration84.new-features.core.multiple-namespaces-symbols">
<title>Defining Identical Symbols in Different Namespace Blocks</title>
<!-- TODO: expand and examples? -->
<simpara>
Exiting a namespace now clears seen symbols.
This allows using a symbol in a namespace block, even if a previous
namespace block declared a symbol with the same name.
<!-- See Zend/tests/use_function/ns_end_resets_seen_symbols_1.phpt. -->
</simpara>
</sect3>
</sect2>
<sect2 xml:id="migration84.new-features.curl">
<title>cURL</title>
<simpara>
<function>curl_version</function> returns an additional
<literal>feature_list</literal> value, which is an associative array
of all known cURL features, and whether they are supported (&true;)
or not (&false;).
</simpara>
<simpara>
Added <constant>CURL_HTTP_VERSION_3</constant> and
<constant>CURL_HTTP_VERSION_3ONLY</constant> constants (available
since libcurl 7.66 and 7.88) as available options for
<constant>CURLOPT_HTTP_VERSION</constant>.
</simpara>
<simpara>
Added <constant>CURLOPT_PREREQFUNCTION</constant> as a cURL option that
accepts a <type>callable</type> to be called after the connection is made,
but before the request is sent.
This callable must return either <constant>CURL_PREREQFUNC_OK</constant> or
<constant>CURL_PREREQFUNC_ABORT</constant> to allow or abort the request.
</simpara>
<simpara>
Added <constant>CURLOPT_SERVER_RESPONSE_TIMEOUT</constant>,
which was formerly known as <constant>CURLOPT_FTP_RESPONSE_TIMEOUT</constant>.
Both constants hold the same value.
</simpara>
<para>
Added <constant>CURLOPT_DEBUGFUNCTION</constant> as a cURL option that
accepts a <type>callable</type> that gets called during the request lifetime
with the <classname>CurlHandle</classname> object,
an integer containing the debug message type, and a string containing the
debug message.
The debug message type is one of the following constants:
<simplelist>
<member><constant>CURLINFO_TEXT</constant></member>
<member><constant>CURLINFO_HEADER_IN</constant></member>
<member><constant>CURLINFO_HEADER_OUT</constant></member>
<member><constant>CURLINFO_DATA_IN</constant></member>
<member><constant>CURLINFO_DATA_OUT</constant></member>
<member><constant>CURLINFO_SSL_DATA_IN</constant></member>
<member><constant>CURLINFO_SSL_DATA_OUT</constant></member>
</simplelist>
Once this option is set, <constant>CURLINFO_HEADER_OUT</constant>
must not be set because it uses the same libcurl functionality.
</para>
<simpara>
The <function>curl_getinfo</function> now returns an additional
<literal>posttransfer_time_us</literal> key, containing the number of
microseconds from the start until the last byte is sent.
When a redirect is followed, the time from each request is added together.
This value can also be retrieved by passing
<constant>CURLINFO_POSTTRANSFER_TIME_T</constant> to the
<function>curl_getinfo</function> <parameter>option</parameter> parameter.
This requires libcurl 8.10.0 or later.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.dom">
<title>DOM</title>
<!-- RFC: https://wiki.php.net/rfc/domdocument_html5_parser -->
<!-- RFC: https://wiki.php.net/rfc/opt_in_dom_spec_compliance -->
<simpara>
Added the <package>Dom</package> namespace with new classes as counterparts
to the existing DOM classes (e.g. <classname>Dom\Node</classname> is the new
<classname>DOMNode</classname>).
These classes are compatible with HTML 5 and are WHATWG spec-compliant;
solving long-standing bugs in the DOM extension.
The old DOM classes remain available for backwards compatibility.
</simpara>
<para>
Added the <methodname>DOMNode::compareDocumentPosition</methodname>
with its associated constants:
<simplelist>
<member><constant>DOMNode::DOCUMENT_POSITION_DISCONNECTED</constant></member>
<member><constant>DOMNode::DOCUMENT_POSITION_PRECEDING</constant></member>
<member><constant>DOMNode::DOCUMENT_POSITION_FOLLOWING</constant></member>
<member><constant>DOMNode::DOCUMENT_POSITION_CONTAINS</constant></member>
<member><constant>DOMNode::DOCUMENT_POSITION_CONTAINED_BY</constant></member>
<member><constant>DOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC</constant></member>
</simplelist>
</para>
<!-- RFC: https://wiki.php.net/rfc/improve_callbacks_dom_and_xsl -->
<simpara>
It is now possible to pass any callable to
<methodname>DOMXPath::registerPhpFunctions</methodname>.
Furthermore, with <methodname>DOMXPath::registerPhpFunctionNs</methodname>,
callbacks can now be registered that will use native function call syntax
rather than using <code>php:function('name')</code>.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.intl">
<title>Intl</title>
<simpara>
Added the <constant>NumberFormatter::ROUND_HALFODD</constant> to
complement the existing <constant>NumberFormatter::ROUND_HALFEVEN</constant>
functionality.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.openssl">
<title>OpenSSL</title>
<simpara>
Added support for Curve25519 + Curve448 based keys.
Specifically x25519, ed25519, x448 and ed448 fields are supported in
<function>openssl_pkey_new</function>,
<function>openssl_pkey_get_details</function>,
<function>openssl_sign</function>, and
<function>openssl_verify</function> were extended to support those keys.
</simpara>
<simpara>
Implement PASSWORD_ARGON2 password hashing.
Requires OpenSSL 3.2 and NTS build.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.pcre">
<title>PCRE</title>
<simpara>
The bundled pcre2lib has been updated to version 10.44.
As a consequence, LoongArch JIT support has been added, spaces
are now allowed between braces in Perl-compatible items, and
variable-length lookbehind assertions are now supported.
</simpara>
<simpara>
With pcre2lib version 10.44, the maximum length of named capture groups
has changed from <literal>32</literal> to <literal>128</literal>.
</simpara>
<simpara>
Added support for the <literal>r</literal> (PCRE2_EXTRA_CASELESS_RESTRICT)
modifier, as well as the <literal>(?r)</literal> mode modifier.
When enabled along with the case-insensitive modifier (<literal>i</literal>),
the expression locks out mixing of ASCII and non-ASCII characters.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.pdo">
<title>PDO</title>
<!-- RFC: https://wiki.php.net/rfc/pdo_driver_specific_subclasses -->
<simpara>
Added support for driver-specific subclasses.
This RFC adds subclasses for PDO in order to better support
database-specific functionalities.
The new classes are instantiatable either via calling the
<methodname>PDO::connect</methodname> method or by instantiating an instance
of the driver-specific subclass directly.
</simpara>
<!-- RFC: https://wiki.php.net/rfc/pdo_driver_specific_parsers -->
<para>
Added support for driver specific SQL parsers.
The default parser supports:
<simplelist>
<member>
single and double-quoted literals, with doubling as escaping mechanism
</member>
<member>
two-dashes and non-nested C-style comments
</member>
</simplelist>
</para>
</sect2>
<sect2 xml:id="migration84.new-features.pdo-mysql">
<title>PDO_MYSQL</title>
<!-- RFC: https://wiki.php.net/rfc/pdo_driver_specific_parsers -->
<para>
Added a custom parser supporting:
<simplelist>
<member>
single and double-quoted literals, with doubling and backslash as escaping
mechanism
</member>
<member>
backtick literal identifiers and with doubling as escaping mechanism
</member>
<member>
two dashes followed by at least 1 whitespace, non-nested C-style comments,
and hash-comments
</member>
</simplelist>
</para>
</sect2>
<sect2 xml:id="migration84.new-features.pdo-pgsql">
<title>PDO_PGSQL</title>
<!-- RFC: https://wiki.php.net/rfc/pdo_driver_specific_parsers -->
<para>
Added a custom parser supporting:
<simplelist>
<member>
single and double-quoted literals, with doubling as escaping mechanism
</member>
<member>
C-style "escape" string literals (<literal>E'string'</literal>)
</member>
<member>
dollar-quoted string literals
</member>
<member>
two-dashes and C-style comments (non-nested)
</member>
<member>
support for <literal>??</literal> as escape sequence for the
<literal>?</literal> operator
</member>
</simplelist>
</para>
</sect2>
<sect2 xml:id="migration84.new-features.pdo-sqlite">
<title>PDO_SQLITE</title>
<!-- RFC: https://wiki.php.net/rfc/pdo_driver_specific_parsers -->
<para>
Added a custom parser supporting:
<simplelist>
<member>
single, double-quoted, and backtick literals, with doubling as
escaping mechanism
</member>
<member>
square brackets quoting for identifiers
</member>
<member>
two-dashes and C-style comments (non-nested)
</member>
</simplelist>
</para>
</sect2>
<sect2 xml:id="migration84.new-features.phar">
<title>Phar</title>
<simpara>
Added support for the Unix timestamp extension for Zip archives.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.readline">
<title>Readline</title>
<simpara>
Added ability to change the <literal>.php_history</literal> path through
the <envar>PHP_HISTFILE</envar> environment variable.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.reflection">
<title>Reflection</title>
<simpara>
<classname>ReflectionAttribute</classname> now contains a
<property>name</property> property to improve the debugging experience.
</simpara>
<simpara>
<methodname>ReflectionClassConstant::__toString</methodname> and
<methodname>ReflectionProperty::__toString</methodname> now returns the
attached doc comments.
</simpara>
<!-- RFC: https://wiki.php.net/rfc/lazy-objects -->
<para>
Multiple new methods and constants which are related to the lazy objects
feature have been added:
<simplelist>
<member>
<methodname>ReflectionClass::newLazyGhost</methodname>
</member>
<member>
<methodname>ReflectionClass::newLazyProxy</methodname>
</member>
<member>
<methodname>ReflectionClass::resetAsLazyGhost</methodname>
</member>
<member>
<methodname>ReflectionClass::resetAsLazyProxy</methodname>
</member>
<member>
<methodname>ReflectionClass::isUninitializedLazyObject</methodname>
</member>
<member>
<methodname>ReflectionClass::initializeLazyObject</methodname>
</member>
<member>
<methodname>ReflectionClass::markLazyObjectAsInitialized</methodname>
</member>
<member>
<methodname>ReflectionClass::getLazyInitializer</methodname>
</member>
<member>
<methodname>ReflectionProperty::skipLazyInitialization</methodname>
</member>
<member>
<methodname>ReflectionProperty::setRawValueWithoutLazyInitialization</methodname>
</member>
<member>
<constant>ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE</constant>
</member>
<member>
<constant>ReflectionClass::SKIP_DESTRUCTOR</constant>
</member>
</simplelist>
</para>
</sect2>
<sect2 xml:id="migration84.new-features.soap">
<title>SOAP</title>
<simpara>
Added support for clark notation for namespaces in class map.
It is now possible to specify entries in a class map with clark notation
to resolve a type with a specific namespace to a specific class.
For example: <code>'{http://example.com}foo' => 'FooClass'</code>.
</simpara>
<simpara>
Instances of <interfacename>DateTimeInterface</interfacename> that are
passed to <literal>xsd:datetime</literal> or similar elements are now
serialized as such instead of being serialized as an empty string.
</simpara>
<simpara>
Session persistence now works with a shared session module.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.standard">
<title>Standard</title>
<!-- RFC: https://wiki.php.net/rfc/correctly_name_the_rounding_mode_and_make_it_an_enum -->
<simpara>
<!-- Should this use <enumname> -->
Added a new <classname>RoundingMode</classname> enum with clearer naming
and improved discoverability compared to the
<constant>PHP_ROUND_<replaceable>*</replaceable></constant> constants.
Moreover, four new rounding modes were added which are only available via
the new <classname>RoundingMode</classname> enum.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.xsl">
<title>XSL</title>
<simpara>
It is now possible to use parameters that contain both single and double
quotes.
</simpara>
<!-- RFC: https://wiki.php.net/rfc/improve_callbacks_dom_and_xsl -->
<simpara>
It is now possible to pass any callable to
<methodname>XSLTProcessor::registerPhpFunctions</methodname>.
<!-- TODO Mention XSLTProcessor::registerPHPFunctionNS ? -->
</simpara>
<simpara>
Added <property>XSLTProcessor::$maxTemplateDepth</property> and
<property>XSLTProcessor::$maxTemplateVars</property>
to control the recursion depth of XSL template evaluation.
</simpara>
</sect2>
<sect2 xml:id="migration84.new-features.zip">
<title>Zip</title>
<simpara>
Added the <constant>ZipArchive::ER_TRUNCATED_ZIP</constant>
constant, which was added in libzip 1.11.
</simpara>
</sect2>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
|