svn: /phpdoc/pt_BR/trunk/ appendices/ini.core.xml appendices/migration74/new-features.xml appendices/reserved.xml language/functions.xml
[email protected] (Daniel Rodrigues Lima)
| Newsgroups | php.doc.pt-br |
|---|---|
| Message-ID | <[email protected]> |
geekcom Mon, 27 Apr 2020 19:19:25 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=349715
Log:
sync with en version
Changed paths:
U phpdoc/pt_BR/trunk/appendices/ini.core.xml
U phpdoc/pt_BR/trunk/appendices/migration74/new-features.xml
U phpdoc/pt_BR/trunk/appendices/reserved.xml
U phpdoc/pt_BR/trunk/language/functions.xml
svn-diffs-349715.txt
(text/x-diff, 11.3 KB)
Modified: phpdoc/pt_BR/trunk/appendices/ini.core.xml
===================================================================
--- phpdoc/pt_BR/trunk/appendices/ini.core.xml 2020-04-27 08:25:24 UTC (rev 349714)
+++ phpdoc/pt_BR/trunk/appendices/ini.core.xml 2020-04-27 19:19:25 UTC (rev 349715)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- EN-Revision: 349194 Maintainer: ae Status: revision --><!-- CREDITS: ae, fibbarth, fabioluciano, rogeriopradoj, adiel, geekcom -->
+<!-- EN-Revision: 349307 Maintainer: ae Status: revision --><!-- CREDITS: ae, fibbarth, fabioluciano, rogeriopradoj, adiel, geekcom -->
<section xml:id="ini.core" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Descrição das principais diretivas do &php.ini;</title>
@@ -1430,8 +1430,8 @@
arquivos para incluir. Ele irá verificar o primeiro caminho, e se não o encontrar,
verificar o próximo caminho, até que encontre o arquivo incluído ou
retorne com um
- <link linkend="errorfunc.constants.errorlevels.e-warning">warning</link>
- ou um <link linkend="errorfunc.constants.errorlevels.e-error">error</link>.
+ <constant>E_WARNING</constant>
+ ou um <constant>E_ERROR</constant>.
Você pode modificar ou configurar o include_path em tempo de execução usando
<function>set_include_path</function>.
</para>
Modified: phpdoc/pt_BR/trunk/appendices/migration74/new-features.xml
===================================================================
--- phpdoc/pt_BR/trunk/appendices/migration74/new-features.xml 2020-04-27 08:25:24 UTC (rev 349714)
+++ phpdoc/pt_BR/trunk/appendices/migration74/new-features.xml 2020-04-27 19:19:25 UTC (rev 349715)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- EN-Revision: 348891 Maintainer: geekcom Status: ready --><!-- CREDITS: geekcom -->
+<!-- EN-Revision: 349702 Maintainer: geekcom Status: ready --><!-- CREDITS: geekcom -->
<sect1 xml:id="migration74.new-features" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Novos Recursos</title>
@@ -34,8 +34,9 @@
<title>Arrow functions</title>
<para>
- Arrow functions fornecem uma sintaxe abreviada para definir funções
- com ligação implícita por escopo por valor.
+ <link linkend="functions.arrow">Arrow functions</link> fornecem uma
+ sintaxe abreviada para definir funções
+ com ligação implícita por valor de escopo.
<informalexample>
<programlisting role="php">
Modified: phpdoc/pt_BR/trunk/appendices/reserved.xml
===================================================================
--- phpdoc/pt_BR/trunk/appendices/reserved.xml 2020-04-27 08:25:24 UTC (rev 349714)
+++ phpdoc/pt_BR/trunk/appendices/reserved.xml 2020-04-27 19:19:25 UTC (rev 349715)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- EN-Revision: 346864 Maintainer: ae Status: ready --><!-- CREDITS: ae, thiago, AlexAntonio, royopa, lcobucci, fabioluciano, adiel, geekcom -->
+<!-- EN-Revision: 349701 Maintainer: ae Status: ready --><!-- CREDITS: ae, thiago, AlexAntonio, royopa, lcobucci, fabioluciano, adiel, geekcom -->
<appendix xml:id="reserved" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Lista de Palavras Reservadas do PHP</title>
@@ -140,16 +140,19 @@
<link linkend="language.exceptions">finally</link> (a partir do PHP 5.5)
</entry>
<entry>
+ <link linkend="functions.arrow">fn</link> (a partir do PHP 7.4)
+ </entry>
+ <entry>
<link linkend="control-structures.for">for</link>
</entry>
<entry>
&foreach;
</entry>
+ </row>
+ <row>
<entry>
<link linkend="functions.user-defined">function</link>
</entry>
- </row>
- <row>
<entry>
<link linkend="language.variables.scope">global</link>
</entry>
@@ -162,11 +165,11 @@
<entry>
<link linkend="language.oop5.interfaces">implements</link>
</entry>
+ </row>
+ <row>
<entry>
<function>include</function>
</entry>
- </row>
- <row>
<entry>
<function>include_once</function>
</entry>
@@ -179,11 +182,11 @@
<entry>
<link linkend="language.oop5.interfaces">interface</link>
</entry>
+ </row>
+ <row>
<entry>
<function>isset</function>
</entry>
- </row>
- <row>
<entry>
<function>list</function>
</entry>
@@ -196,11 +199,11 @@
<entry>
<link linkend="language.operators.logical">or</link>
</entry>
+ </row>
+ <row>
<entry>
<function>print</function>
</entry>
- </row>
- <row>
<entry>
<link linkend="language.oop5.visibility">private</link>
</entry>
@@ -213,11 +216,11 @@
<entry>
<function>require</function>
</entry>
+ </row>
+ <row>
<entry>
<function>require_once</function>
</entry>
- </row>
- <row>
<entry>
<function>return</function>
</entry>
@@ -230,11 +233,11 @@
<entry>
<link linkend="language.exceptions">throw</link>
</entry>
+ </row>
+ <row>
<entry>
<link linkend="language.oop5.traits">trait</link> (a partir do PHP 5.4)
</entry>
- </row>
- <row>
<entry>
<link linkend="language.exceptions">try</link>
</entry>
@@ -247,11 +250,11 @@
<entry>
<link linkend="language.oop5.properties">var</link>
</entry>
+ </row>
+ <row>
<entry>
<link linkend="control-structures.while">while</link>
</entry>
- </row>
- <row>
<entry>
<link linkend="language.operators.logical">xor</link>
</entry>
@@ -263,8 +266,6 @@
</entry>
<entry>
</entry>
- <entry>
- </entry>
</row>
</tbody>
</tgroup>
Modified: phpdoc/pt_BR/trunk/language/functions.xml
===================================================================
--- phpdoc/pt_BR/trunk/language/functions.xml 2020-04-27 08:25:24 UTC (rev 349714)
+++ phpdoc/pt_BR/trunk/language/functions.xml 2020-04-27 19:19:25 UTC (rev 349715)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- EN-Revision: 347269 Maintainer: ae Status: ready --><!-- CREDITS: fabioluciano, ae, geekcom -->
+<!-- EN-Revision: 349700 Maintainer: ae Status: ready --><!-- CREDITS: fabioluciano, ae, geekcom -->
<chapter xml:id="language.functions" xmlns="http://docbook.org/ns/docbook">
<title>Funções</title>
@@ -126,8 +126,8 @@
</simpara>
<note>
<simpara>
- Nomes de funções são insensíveis ao caso, mas é melhor chamar
- as funções da mesma forma que ela aparecem nas declarações.
+ Nomes de funções são case-insensitive para caracteres ASCII <literal>A</literal> até <literal>Z</literal>, mas é melhor chamar
+ as funções da mesma forma que elas aparecem nas declarações.
</simpara>
</note>
<simpara>
@@ -1737,7 +1737,171 @@
</sect2>
</sect1>
+ <sect1 xml:id="functions.arrow">
+ <title>Arrow Functions</title>
+ <simpara>
+ Arrow functions foram introduzidos a partir do PHP 7.4 como uma sintaxe mais concisa para
+ <link linkend="functions.anonymous">funções anônimas</link>.
+ </simpara>
+ <simpara>
+ Funções anônimas e arrow functions são implementadas usando a classe
+ <link linkend="class.closure"><classname>Closure</classname></link>.
+ </simpara>
+
+ <simpara>
+ Arrow functions tem a forma básica
+ <code>fn (argument_list) => expr</code>.
+ </simpara>
+
+ <simpara>
+ Arrow functions possuem a mesmas características das
+ <link linkend="functions.anonymous">funções anônimas</link>,
+ exceto que o uso de variáveis do escopo pai é sempre automático.
+ </simpara>
+
+ <simpara>
+ Quando uma variável usada na expressão é definida no escopo pai
+ ele será implicitamente capturado por valor.
+ No exemplo a seguir, as funções <varname>$fn1</varname> e
+ <varname>$fn2</varname>comportam-se da mesma maneira.
+ </simpara>
+
+ <para>
+ <example>
+ <title>Arrow functions capturam variáveis por valor automaticamente</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$y = 1;
+
+$fn1 = fn($x) => $x + $y;
+// equivalent to using $y by value:
+$fn2 = function ($x) use ($y) {
+ return $x + $y;
+};
+
+var_export($fn1(3));
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+4
+]]>
+ </screen>
+ </example>
+ </para>
+ <simpara>
+ Isso também funciona se as arrow de functions estiverem aninhadas:
+ </simpara>
+ <para>
+ <example>
+ <title>Arrow functions capturam variáveis por valor automaticamente, mesmo quando aninhadas</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$z = 1;
+$fn = fn($x) => fn($y) => $x * $y + $z;
+// Outputs 51
+var_export($fn(5)(10));
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <simpara>
+ Da mesma forma que funções anônimas,
+ a sintaxe das arrow functions permitem assinaturas de função arbitrária,
+ incluindo parâmetros e tipos de retorno, valores padrão, variadics,
+ bem como por referência passando e retornando.
+ Todos os exemplos válidos de arrow functions:
+ </simpara>
+ <para>
+ <example>
+ <title>Examplos de arrow functions</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+fn(array $x) => $x;
+static fn(): int => $x;
+fn($x = 42) => $x;
+fn(&$x) => $x;
+fn&($x) => $x;
+fn($x, ...$rest) => $rest;
+
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <simpara>
+ Arrow functions usam vinculação de variável por valor.
+ Isso é aproximadamente equivalente a realizar um <code>use($x)</code> para cada
+ variável <varname>$x</varname> usada dentro da arrow function.
+ Uma passagem de variável por valor, significa que não é possível modificar quaisquer valores
+ do escopo externo.
+ <link linkend="functions.anonymous">Funções anônimas</link>
+ podem ser usadas em vez disso para passagem de variável por referência.
+ </simpara>
+ <para>
+ <example>
+ <title>Valores do escopo externo não podem ser modificados por arrow functions</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$x = 1;
+$fn = fn() => $x++; // Has no effect
+$fn();
+var_export($x); // Outputs 1
+
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+
+ <sect2 role="changelog">
+ &reftitle.changelog;
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>&Version;</entry>
+ <entry>&Description;</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>7.4.0</entry>
+ <entry>
+ Arrow functions tornou-se disponível.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ </sect2>
+
+ <sect2 role="notes">
+ &reftitle.notes;
+ <note>
+ <simpara>
+ É possível usar <function>func_num_args</function>,
+ <function>func_get_arg</function>, e <function>func_get_args</function>
+ de dentro de uma arrow functions.
+ </simpara>
+ </note>
+ </sect2>
+ </sect1>
+
</chapter>
<!-- Keep this comment at the end of the file