Skip to content

Commit 026e261

Browse files
committedNov 28, 2021
Sync with EN: migration to 8.1
1 parent 281e3e9 commit 026e261

File tree

6 files changed

+220
-18
lines changed

6 files changed

+220
-18
lines changed
 

‎appendices/migration80.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
33
<!-- EN-Revision: d7a2a4e3f7114ec8f0a71da90ed7e55b70fb77ec Maintainer: julionc Status: ready -->
4-
<!-- Reviewed: no -->
4+
<!-- Reviewed: yes Maintainer: julionc -->
55

66
<appendix xml:id="migration80" xmlns="http://docbook.org/ns/docbook" xmlns:phd="http://www.php.net/ns/phd">
77
<title>Migración de PHP 7.4.x a PHP 8.0.x</title>
@@ -16,7 +16,8 @@
1616
Esta nueva versión mayor trae consigo una serie de
1717
<link linkend="migration80.new-features">nuevas características</link> y
1818
<link linkend="migration80.incompatible">algunas incompatibilidades</link>
19-
que debe ser probado antes de cambiar las versiones de PHP en los entornos de producción.
19+
que deben probarse antes de cambiar las versiones de PHP en entornos
20+
de producción.
2021
</para>
2122

2223
<para>

‎appendices/migration81.xml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
<!-- EN-Revision: d7a2a4e3f7114ec8f0a71da90ed7e55b70fb77ec Maintainer: julionc Status: ready -->
4+
<!-- Reviewed: yes Maintainer: julionc -->
5+
6+
<appendix xml:id="migration81" xmlns="http://docbook.org/ns/docbook" xmlns:phd="http://www.php.net/ns/phd">
7+
<title>Migración de PHP 8.0.x a PHP 8.1.x</title>
8+
9+
&appendices.migration81.new-features;
10+
&appendices.migration81.new-classes;
11+
&appendices.migration81.new-functions;
12+
&appendices.migration81.constants;
13+
&appendices.migration81.incompatible;
14+
&appendices.migration81.deprecated;
15+
&appendices.migration81.other-changes;
16+
17+
<sect1 phd:chunk="false" xml:id="migration81.intro">
18+
<para>
19+
Esta nueva versión menor trae consigo una serie de
20+
<link linkend="migration81.new-features">nuevas características</link> y
21+
<link linkend="migration81.incompatible">algunas incompatibilidades</link>
22+
que deben probarse antes de cambiar las versiones de PHP en entornos
23+
de producción.
24+
</para>
25+
26+
<para>
27+
&manual.migration.seealso;
28+
<link linkend="migration71">7.1.x</link>,
29+
<link linkend="migration72">7.2.x</link>,
30+
<link linkend="migration73">7.3.x</link>,
31+
<link linkend="migration74">7.4.x</link>,
32+
<link linkend="migration80">8.0.x</link>.
33+
</para>
34+
</sect1>
35+
</appendix>
36+
<!-- Keep this comment at the end of the file
37+
Local variables:
38+
mode: sgml
39+
sgml-omittag:t
40+
sgml-shorttag:t
41+
sgml-minimize-attributes:nil
42+
sgml-always-quote-attributes:t
43+
sgml-indent-step:1
44+
sgml-indent-data:t
45+
indent-tabs-mode:nil
46+
sgml-parent-document:nil
47+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
48+
sgml-exposed-tags:nil
49+
sgml-local-catalogs:nil
50+
sgml-local-ecat-files:nil
51+
End:
52+
vim600: syn=xml fen fdm=syntax fdl=2 si
53+
vim: et tw=78 syn=sgml
54+
vi: ts=1 sw=1
55+
-->

‎appendices/migration81/incompatible.xml

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
<!-- EN-Revision: 485e0b4b4426d607dedf46f5b30df4011102dd73 Maintainer: julionc Status: pending -->
4+
<!-- Reviewed: no Maintainer: julionc -->
5+
26
<sect1 xml:id="migration81.incompatible" xmlns:xlink="http://www.w3.org/1999/xlink">
3-
<title>Backward Incompatible Changes</title>
7+
<title>Cambios incompatibles con versiones anteriores</title>
48

59
<sect2 xml:id="migration81.incompatible.core">
610
<title>PHP Core</title>
@@ -125,21 +129,21 @@ var_dump(B::counter()); // int(4), previously int(2)
125129
<para>
126130
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return,
127131
respectively, <classname>PgSql\Connection</classname> objects instead of
128-
<literal>ppgsql link</literal> &resource;s.
132+
<literal>pgsql link</literal> &resource;s.
129133
</para>
130134
</listitem>
131135
<listitem>
132136
<para>
133137
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return,
134138
respectively, <classname>PgSql\Result</classname> objects instead of
135-
<literal>ppgsql result</literal> &resource;s.
139+
<literal>pgsql result</literal> &resource;s.
136140
</para>
137141
</listitem>
138142
<listitem>
139143
<para>
140144
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return,
141145
respectively, <classname>PgSql\Lob</classname> objects instead of
142-
<literal>ppgsql large object</literal> &resource;s.
146+
<literal>pgsql large object</literal> &resource;s.
143147
</para>
144148
</listitem>
145149
<listitem>

‎appendices/migration81/new-features.xml

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
<!-- EN-Revision: 485e0b4b4426d607dedf46f5b30df4011102dd73 Maintainer: julionc Status: pending -->
4+
<!-- Reviewed: no Maintainer: julionc -->
5+
26
<sect1 xml:id="migration81.new-features" xmlns:xlink="http://www.w3.org/1999/xlink">
37
<title>New Features</title>
48

@@ -63,7 +67,7 @@
6367
<title>Enumerations</title>
6468

6569
<para>
66-
Support for <!--<link linkend="language.enumeration">-->Enumerations<!--</link>--> has been added.
70+
Support for <link linkend="language.enumerations">Enumerations</link> has been added.
6771
<!-- RFC: https://wiki.php.net/rfc/enumerations -->
6872
</para>
6973
</sect3>
@@ -135,7 +139,7 @@
135139
<title>Readonly properties</title>
136140

137141
<para>
138-
Support for <code>readonly</code> properties has been added.
142+
Support for <link linkend="language.oop5.properties.readonly-properties">readonly</link> has been added.
139143
<!-- RFC: https://wiki.php.net/rfc/readonly_properties_v2 -->
140144
</para>
141145
</sect3>
@@ -153,7 +157,7 @@
153157

154158
<sect2 xml:id="migration81.new-features.curl">
155159
<title>CURL</title>
156-
160+
157161
<para>
158162
Added the <constant>CURLOPT_DOH_URL</constant> option.
159163
</para>
@@ -354,7 +358,7 @@ echo $h, "\n";
354358
<title>Binding parameters in execute</title>
355359

356360
<para>
357-
It is now possible to bind parameters by passing them as an array to
361+
It is now possible to bind parameters by passing them as an array to
358362
<methodname>mysqli_stmt::execute</methodname>. All values will be bound as
359363
strings. Only list arrays are allowed. This new feature is not available
360364
when MySQLi is compiled with libmysqlclient.

‎diccionario.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ argument..........: argumento (no "parámetro"; argumento es el valor que se le
2323
available as of PHP: disponible a partir de PHP
2424

2525
*** B ***
26+
Backward Incompatible Changes: Cambios incompatibles con versiones anteriores
2627
binary-safe.......: (ser) seguro al trabajar/tratar con datos binarios
2728
binding...........: ligadura / adaptación (según el contexto)
2829
bound.............: ligado / enlazado
@@ -112,6 +113,7 @@ placeholder.......: parámetro de sustitución
112113
*** R ***
113114
raw...............: sin tratar
114115
read into.........: transferir (contenido)
116+
readonly properties: propiedades readonly (no se traduce a solo lectura)
115117
request...........: petición
116118
rollback..........: revertir, volver a un estado anterior
117119
run out of........: agotar, quedarse sin
@@ -141,7 +143,7 @@ Toolchain.........: cadena de herramientas.
141143
trailer/trailor...: tráiler (se refiere a esto: http://en.wikipedia.org/wiki/Trailer_%28information_technology%29)
142144
tweaking..........: modificación menor, ajuste, perfeccionamiento
143145
Type juggling.....: manipulación de tipos.
144-
Typed properties..: Propiedades tipadas
146+
Typed properties..: Propiedades tipadas.
145147

146148
*** U ***
147149
Underlying framework: marco de referencia base.

‎language/oop5/properties.xml

+143-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 9ee9eccf455188ab6eb352194eb6f9eb99e15606 Maintainer: seros Status: ready -->
3+
<!-- EN-Revision: d73c3dcbd6e2b085781115aa42d17b80ea285b9e Maintainer: seros Status: ready -->
44
<!-- Reviewed: yes Maintainer: seros -->
55

66
<sect1 xml:id="language.oop5.properties" xmlns="http://docbook.org/ns/docbook">
@@ -64,12 +64,12 @@ hola mundo
6464
EOD;
6565
public $var3 = 1+2;
6666
// Declaraciones de propiedades inválidas:
67-
public $var4 = self::miMétodoEstático();
67+
public $var4 = self::miMetodoEstatico();
6868
public $var5 = $myVar;
6969
7070
// Declaraciones de propiedades válidas:
7171
public $var6 = miConstante;
72-
public $var7 = array(true, false);
72+
public $var7 = [true, false];
7373
7474
public $var8 = <<<'EOD'
7575
hola mundo
@@ -83,16 +83,15 @@ EOD;
8383

8484
<note>
8585
<para>
86-
Existen varias funciones interesantes para manipular clases y objetos.
87-
Puede ser interesante echarle un vistazo a las
88-
<link linkend="ref.classobj">Funciones de clases/objetos</link>.
86+
Existen varias funciones para manipular clases y objetos.
87+
Véase <link linkend="ref.classobj">Las funciones de clases/objetos</link>.
8988
</para>
9089
</note>
9190

9291
<sect2 xml:id="language.oop5.properties.typed-properties">
9392
<title>Declaraciones de tipo</title>
9493
<para>
95-
A partir de PHP 7.4.0, las definiciones de propiedades pueden incluir un
94+
A partir de PHP 7.4.0, las definiciones de propiedades pueden incluirse
9695
<xref linkend="language.types.declarations" />,
9796
con la excepción de los <type>callable</type>.
9897
<example>
@@ -193,6 +192,143 @@ Fatal error: Uncaught Error: Typed property Shape::$numberOfSides must not be ac
193192
</para>
194193
</sect2>
195194

195+
<sect2 xml:id="language.oop5.properties.readonly-properties">
196+
<title>Propiedad Readonly</title>
197+
<para>
198+
A partir de PHP 8.1.0, una propiedad se puede declarar con el modificador <code>readonly</code> (de solo lectura), lo que impide la modificación de la propiedad después de la inicialización.
199+
<example>
200+
<title>Ejemplo de propiedades de solo lectura</title>
201+
<programlisting role="php">
202+
<![CDATA[
203+
<?php
204+
205+
class Test {
206+
public readonly string $prop;
207+
208+
public function __construct(string $prop) {
209+
// Inicialización.
210+
$this->prop = $prop;
211+
}
212+
}
213+
214+
$test = new Test("foobar");
215+
// Lectura.
216+
var_dump($test->prop); // string(6) "foobar"
217+
218+
// Reasignación ilegal. No importa que el valor asignado sea el mismo.
219+
$test->prop = "foobar";
220+
// Error: Cannot modify readonly property Test::$prop
221+
?>
222+
]]>
223+
</programlisting>
224+
</example>
225+
<note>
226+
<para>
227+
El modificador readonly solo se puede aplicar a las <link linkend="language.oop5.properties.typed-properties">propiedades tipadas</link>.
228+
Se puede crear una propiedad readonly sin restricciones mediante el tipo <xref linkend="language.types.declarations.mixed" />.
229+
</para>
230+
</note>
231+
<note>
232+
<para>
233+
El modificador readonly no son compatibles en propiedades estáticas.
234+
</para>
235+
</note>
236+
</para>
237+
<para>
238+
Una propiedad readonly solo se puede inicializar una vez, y solo desde el ámbito en el que se ha declarado. Cualquier otra asignación o modificación de la propiedad dará lugar a una excepción de <classname>Error</classname>.
239+
<example>
240+
<title>Inicialización ilegal de propiedades readonly</title>
241+
<programlisting role="php">
242+
<![CDATA[
243+
<?php
244+
class Test1 {
245+
public readonly string $prop;
246+
}
247+
248+
$test1 = new Test1;
249+
// Inicialización ilegal fuera del ámbito privado.
250+
$test1->prop = "foobar";
251+
// Error: Cannot initialize readonly property Test1::$prop from global scope
252+
?>
253+
]]>
254+
</programlisting>
255+
</example>
256+
</para>
257+
<note>
258+
<para>
259+
No se permite especificar un valor predeterminado explícito en las propiedades readonly, porque una propiedad readonly con un valor predeterminado es esencialmente la misma que una constante y, por lo tanto, no es particularmente útil.
260+
<example>
261+
<programlisting role="php">
262+
<![CDATA[
263+
<?php
264+
265+
class Test {
266+
// Fatal error: Readonly property Test::$prop cannot have default value
267+
public readonly int $prop = 42;
268+
}
269+
?>
270+
]]>
271+
</programlisting>
272+
</example>
273+
</para>
274+
</note>
275+
<note>
276+
<para>
277+
Las propiedades readonly no pueden usarse con la función <function>unset</function> una vez inicializadas. Sin embargo, es posible desactivar una propiedad readonly antes de la inicialización, desde el ámbito donde se ha declarado la propiedad.
278+
</para>
279+
</note>
280+
<para>
281+
Las modificaciones no son necesariamente asignaciones simples, todo lo siguiente también dará lugar a una excepción <classname>Error</classname>:
282+
<example>
283+
<programlisting role="php">
284+
<![CDATA[
285+
<?php
286+
287+
class Test {
288+
public function __construct(
289+
public readonly int $i = 0,
290+
public readonly array $ary = [],
291+
) {}
292+
}
293+
294+
$test = new Test;
295+
$test->i += 1;
296+
$test->i++;
297+
++$test->i;
298+
$test->ary[] = 1;
299+
$test->ary[0][] = 1;
300+
$ref =& $test->i;
301+
$test->i =& $ref;
302+
byRef($test->i);
303+
foreach ($test as &$prop);
304+
?>
305+
]]>
306+
</programlisting>
307+
</example>
308+
</para>
309+
<para>
310+
Sin embargo, las propiedades readonly no excluyen la mutabilidad interior. Los objetos (o recursos) almacenados en propiedades readonly aún pueden modificarse internamente:
311+
<example>
312+
<programlisting role="php">
313+
<![CDATA[
314+
<?php
315+
316+
class Test {
317+
public function __construct(public readonly object $obj) {}
318+
}
319+
320+
$test = new Test(new stdClass);
321+
// Mutación interior.
322+
$test->obj->foo = 1;
323+
// Reasignación ilegal.
324+
$test->obj = new stdClass;
325+
?>
326+
]]>
327+
</programlisting>
328+
</example>
329+
</para>
330+
</sect2>
331+
196332
</sect1>
197333

198334
<!-- Keep this comment at the end of the file

0 commit comments

Comments
 (0)
Please sign in to comment.