Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: splfile CI #69

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
491 changes: 491 additions & 0 deletions appendices/migration81/new-features.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion features/cookies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- EN-Revision: 3ec11b4caeafba24c7547e2a9444c45686a0b081 Maintainer: seros Status: ready -->
<!-- Reviewed: yes Maintainer: seros -->
<chapter xml:id="features.cookies" xmlns="http://docbook.org/ns/docbook">
<title>'Cookies'</title>
<title>Cookies</title>

<para>
PHP tiene soporte para las «cookies» de <acronym>HTTP</acronym> de forma transparente. Las cookies son un
Expand Down
2 changes: 1 addition & 1 deletion install/macos/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</para>
&install.macos.packages;
&install.macos.bundled;
&install.macos.compile;
&install.macos.compile;
</chapter>

<!-- Keep this comment at the end of the file
Expand Down
123 changes: 122 additions & 1 deletion language/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2009,8 +2009,129 @@ var_export($x); // Salida 1
</sect2>
</sect1>

</chapter>
<sect1 xml:id="functions.first_class_callable_syntax">
<title>First class callable syntax</title>

<para>
The first class callable syntax is introduced as of PHP 8.1.0, as a way of creating <link linkend="functions.anonymous">anonymous functions</link> from <link linkend="language.types.callable">callable</link>.
It supersedes existing callable syntax using strings and arrays.
The advantage of this syntax is that it is accessible to static analysis, and uses the scope at the point where the callable is acquired.
</para>

<para>
<code>CallableExpr(...)</code> syntax is used to create a <classname>Closure</classname> object from callable. <code>CallableExpr</code> accepts any expression that can be directly called in the PHP grammar:
<example>
<title>Simple first class callable syntax</title>
<programlisting role="php">
<![CDATA[
<?php

class Foo {
public function method() {}
public static function staticmethod() {}
public function __invoke() {}
}

$obj = new Foo();
$classStr = 'Foo';
$methodStr = 'method';
$staticmethodStr = 'staticmethod';


$f1 = strlen(...);
$f2 = $obj(...); // invokable object
$f3 = $obj->method(...);
$f4 = $obj->$methodStr(...);
$f5 = Foo::staticmethod(...);
$f6 = $classStr::$staticmethodStr(...);

// traditional callable using string, array
$f7 = 'strlen'(...);
$f8 = [$obj, 'method'](...);
$f9 = [Foo::class, 'staticmethod'](...);
?>
]]>
</programlisting>
</example>
</para>

<note>
<para>
The <code>...</code> is part of the syntax, and not an omission.
</para>
</note>

<para>
<code>CallableExpr(...)</code> has the same semantics as <methodname>Closure::fromCallable</methodname>.
That is, unlike callable using strings and arrays, <code>CallableExpr(...)</code> respects the scope at the point where it is created:
<example>
<title>Scope comparison of <code>CallableExpr(...)</code> and traditional callable</title>
<programlisting role="php">
<![CDATA[
<?php

class Foo {
public function getPrivateMethod() {
return [$this, 'privateMethod'];
}

private function privateMethod() {
echo __METHOD__, "\n";
}
}

$foo = new Foo;
$privateMethod = $foo->getPrivateMethod();
$privateMethod();
// Fatal error: Call to private method Foo::privateMethod() from global scope
// This is because call is performed outside from Foo and visibility will be checked from this point.

class Foo1 {
public function getPrivateMethod() {
// Uses the scope where the callable is acquired.
return $this->privateMethod(...); // identical to Closure::fromCallable([$this, 'privateMethod']);
}

private function privateMethod() {
echo __METHOD__, "\n";
}
}

$foo1 = new Foo1;
$privateMethod = $foo1->getPrivateMethod();
$privateMethod(); // Foo1::privateMethod
?>
]]>
</programlisting>
</example>

</para>

<note>
<para>
Object creation by this syntax (e.g <code>new Foo(...)</code>) is not supported, because <code>new Foo()</code> syntax is not considered a call.
</para>
</note>

<note>
<para>
The first-class callable syntax cannot be combined with the <link linkend="language.oop5.basic.nullsafe">nullsafe operator</link>. Both of the following result in a compile-time error:
<example>
<programlisting role="php">
<![CDATA[
<?php
$obj?->method(...);
$obj?->prop->method(...);
?>
]]>
</programlisting>
</example>
</para>
</note>
</sect1>

</chapter>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
1 change: 1 addition & 0 deletions language/oop5/autoload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ Fatal error: Class 'ExcepciónAusente' not found in testExcepcionAusente.php on
<simplelist>
<member><function>unserialize</function></member>
<member><link linkend="ini.unserialize-callback-func">unserialize_callback_func</link></member>
<member><link linkend="ini.unserialize-max-depth">unserialize_max_depth</link></member>
<member><function>spl_autoload_register</function></member>
<member><function>spl_autoload</function></member>
<member><function>__autoload</function></member>
Expand Down
46 changes: 35 additions & 11 deletions language/oop5/final.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<sect1 xml:id="language.oop5.final" xmlns="http://docbook.org/ns/docbook">
<title>Palabra clave Final</title>
<para>
PHP 5 introduce la nueva palabra clave final, que impide que las clases
PHP introduce la palabra clave final, que impide que las clases
hijas sobrescriban un método, antecediendo su definición con <emphasis>final</emphasis>.
Si la propia clase se define como final, entonces no se podrá heredar de ella.
</para>
Expand Down Expand Up @@ -58,17 +58,41 @@ class ChildClass extends BaseClass {
// Devuelve un error Fatal: Class ChildClass may not inherit from final class (BaseClass)
?>
]]>
</programlisting>
</example>
</para>
<note>
<simpara>
Las propiedades y las constantes no pueden declararse como final. Sólo pueden
las clases y los métodos.
</simpara>
</note>
</sect1>
</programlisting>
</example>
</para>
<para>
<example xml:id="language.oop5.final.example.php81">
<title>Ejemplo de constantes finales a partir de PHP 8.1.0</title>
<programlisting role="php">
<![CDATA[
<?php
class Foo
{
final public const X = "foo";
}

class Bar extends Foo
{
public const X = "bar";
}

// Fatal error: Bar::X cannot override final constant Foo::X
?>
]]>
</programlisting>
</example>
</para>

<note>
<simpara>
Las propiedades no pueden declararse como finales: sólo las clases, métodos y constantes (a partir de PHP 8.1.0) pueden declararse como finales.
</simpara>
<simpara>
A partir de PHP 8.0.0, los métodos privados no pueden ser declarados finales excepto el constructor.
</simpara>
</note>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
29 changes: 29 additions & 0 deletions language/oop5/variance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,35 @@
La covarianza permite que el método hijo devuelva un tipo más específico que el tipo de devolución
del método de su padre. Mientras que la contravarianza permite que un tipo de parámetro
sea menos específico en un método hijo, que el de su padre.
</para>
<para>
Una declaración de tipo covarianza se considera más específica en el siguiente caso:
<itemizedlist>
<listitem>
<simpara>
Se elimina un tipo de un
<link linkend="language.types.type-system.composite.union">tipo de unión</link>
</simpara>
</listitem>
<listitem>
<simpara>
Se añade un tipo a un
<link linkend="language.types.type-system.composite.intersection">tipo de intersección</link>
</simpara>
</listitem>
<listitem>
<simpara>
Un tipo de clase se cambia a un tipo de clase hijo
</simpara>
</listitem>
<listitem>
<simpara>
<type>iterable</type> es cambiado a <type>array</type> o <classname>Traversable</classname>
</simpara>
</listitem>
</itemizedlist>

Una clase de tipo se considera menos específica si ocurre lo contrario.
</para>

<sect2 xml:id="language.oop5.variance.covariance">
Expand Down
111 changes: 23 additions & 88 deletions language/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,94 +8,22 @@
<sect1 xml:id="language.types.intro">
<title>Introducción</title>

<simpara>
PHP admite diez tipos primitivos.
</simpara>

<para>
Cuatro tipos escalares:
Cada expresión en PHP tiene uno de los siguientes
tipos incorporados dependiendo de su valor:
<itemizedlist>
<listitem><simpara><type>null</type></simpara></listitem>
<listitem><simpara><type>bool</type></simpara></listitem>
<listitem><simpara><type>int</type></simpara></listitem>
<listitem><simpara><type>float</type> (número de punto flotante, también conocido como <type>double</type>)</simpara></listitem>
<listitem><simpara><type>string</type></simpara></listitem>
<listitem><simpara><type>array</type></simpara></listitem>
<listitem><simpara><type>object</type></simpara></listitem>
<listitem><simpara><type>callable</type></simpara></listitem>
<listitem><simpara><type>resource</type></simpara></listitem>
</itemizedlist>
</para>

<itemizedlist>

<listitem>
<simpara>
<type>boolean</type>
</simpara>
</listitem>

<listitem>
<simpara>
<type>integer</type>
</simpara>
</listitem>

<listitem>
<simpara>
<type>float</type> (número de punto flotante, también conocido como <type>double</type>)
</simpara>
</listitem>

<listitem>
<simpara>
<type>string</type>
</simpara>
</listitem>

</itemizedlist>

<para>
Cuatro tipos compuestos:
</para>

<itemizedlist>

<listitem>
<simpara>
<type>array</type>
</simpara>
</listitem>

<listitem>
<simpara>
<type>object</type>
</simpara>
</listitem>

<listitem>
<simpara>
<type>callable</type>
</simpara>
</listitem>

<listitem>
<simpara>
<type>iterable</type>
</simpara>
</listitem>

</itemizedlist>

<para>
Y finalmente dos tipos especiales:
</para>

<itemizedlist>

<listitem>
<simpara>
<type>resource</type>
</simpara>
</listitem>

<listitem>
<simpara>
<type>NULL</type>
</simpara>
</listitem>

</itemizedlist>

<simpara>
Puede que existan aún algunas referencias al tipo "double" en el manual. Considere
al tipo double como float; los dos nombres existen sólo por razones históricas.
Expand Down Expand Up @@ -126,7 +54,7 @@
<programlisting role="php">
<![CDATA[
<?php
$un_bool = TRUE; // un valor booleano
$un_bool = true; // un valor booleano
$un_str = "foo"; // una cadena de caracteres
$un_str2 = 'foo'; // una cadena de caracteres
$un_int = 12; // un número entero
Expand Down Expand Up @@ -166,17 +94,24 @@ if (is_string($un_bool)) {
</simpara>
</sect1>

&language.types.type-system;
&language.types.null;
&language.types.boolean;
&language.types.integer;
&language.types.float;
&language.types.string;
&language.types.numeric-strings;
&language.types.array;
&language.types.iterable;
&language.types.object;
&language.types.enumerations;
&language.types.resource;
&language.types.null;
&language.types.callable;
&language.types.mixed;
&language.types.void;
&language.types.never;
&language.types.relative-class-types;
&language.types.value;
&language.types.iterable;
&language.types.declarations;
&language.types.type-juggling;

Expand Down
Loading
Loading