Skip to content
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
1 change: 1 addition & 0 deletions language-snippets.ent
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ xmlns="http://docbook.org/ns/docbook"><simpara> 该函数自 PHP 8.1
<!ENTITY example.outputs.84.similar '<simpara xmlns="http://docbook.org/ns/docbook">上述示例在 PHP 8.4 中的输出类似于:</simpara>'>

<!ENTITY example.outputs.85.similar '<simpara xmlns="http://docbook.org/ns/docbook">上述示例在 PHP 8.5 中的输出类似于:</simpara>'>
<!ENTITY example.outputs.86.similar '<simpara xmlns="http://docbook.org/ns/docbook">上述示例在 PHP 8.6 中的输出类似于:</simpara>'>

<!ENTITY example.outputs.32bit '<simpara xmlns="http://docbook.org/ns/docbook">以上示例在 32 位机器上的输出:</simpara>'>

Expand Down
47 changes: 33 additions & 14 deletions language/predefined/attributes/allowdynamicproperties.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 603435cd84951fc720eded819c62ef2466d21b5c Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 822b0828562580aac0327eb2d84e8e6e06e51a98 Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<reference xml:id="class.allowdynamicproperties" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>AllowDynamicProperties 注解</title>
Expand All @@ -20,14 +20,21 @@
也同样允许动态属性。
</simpara>
</note>
<note>
<simpara>
此注解于 PHP 8.2.0 引入,是显式启用动态属性的方式。若类未使用此注解,且未实现
<link linkend="object.get">__get()</link> 或 <link linkend="object.set">__set()</link>,
则在该类上创建动态属性会被弃用。
</simpara>
</note>
</section>

<section xml:id="allowdynamicproperties.synopsis">
&reftitle.classsynopsis;

<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\Attribute]</modifier>
<modifier role="attribute">#[\Attribute(\Attribute::TARGET_CLASS)]</modifier>
<modifier>final</modifier>
<classname>AllowDynamicProperties</classname>
</ooclass>
Expand All @@ -40,31 +47,43 @@

<section>
&reftitle.examples;
<simpara>
从 PHP 8.2.0 起弃用动态属性,因此在不使用此注解标记类的情况下使用动态属性将发出弃用通知。
</simpara>
<example>
<title>AllowDynamicProperties 与不存在的属性</title>
<title>AllowDynamicProperties 与动态属性</title>
<simpara>
若要启用动态属性,请添加 <literal>#[\AllowDynamicProperties]</literal>。
</simpara>
<programlisting role="php">
<![CDATA[
<?php
class DefaultBehaviour { }

#[\AllowDynamicProperties]
class ClassAllowsDynamicProperties { }
class ValidExample { }

$o1 = new DefaultBehaviour();
$o2 = new ClassAllowsDynamicProperties();
$obj = new ValidExample();
$obj->myDynamicProp = 1234;
?>
]]>
</programlisting>
</example>

$o1->nonExistingProp = true;
$o2->nonExistingProp = true;
<example>
<title>AllowDynamicProperties 与不存在的属性</title>
<simpara>
自 PHP 8.2.0 起,除非类使用此注解,否则必须显式声明属性。在此类上创建未声明的属性会发出弃用通知。
</simpara>
<programlisting role="php">
<![CDATA[
<?php
class InvalidExample { }

$obj = new InvalidExample();
$obj->myUnknownProperty = 1234;
?>
]]>
</programlisting>
&example.outputs.82;
<screen>
<![CDATA[
Deprecated: Creation of dynamic property DefaultBehaviour::$nonExistingProp is deprecated in file on line 10
Deprecated: Creation of dynamic property InvalidExample::$myUnknownProperty is deprecated in file on line 5
]]>
</screen>
</example>
Expand Down
7 changes: 5 additions & 2 deletions language/predefined/attributes/attribute.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 603435cd84951fc720eded819c62ef2466d21b5c Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 8dc5bef8981ffd33c8c51f7f33414fcf5c03767a Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<reference xml:id="class.attribute" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Attribute 属性</title>
<titleabbrev>Attribute</titleabbrev>
Expand All @@ -18,7 +19,7 @@

<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\Attribute]</modifier>
<modifier role="attribute">#[\Attribute(\Attribute::TARGET_CLASS)]</modifier>
<modifier>final</modifier>
<classname>Attribute</classname>
</ooclass>
Expand Down Expand Up @@ -177,6 +178,8 @@
<entry>8.5.0</entry>
<entry>
新增 <constant>Attribute::TARGET_CONSTANT</constant>。
现在将 <code>#[\Attribute]</code> 应用于抽象类、枚举、接口或 trait 会触发编译时错误;此前只有在调用
<methodname>ReflectionAttribute::newInstance</methodname> 时才会在运行时报告。
</entry>
</row>
</tbody>
Expand Down
31 changes: 29 additions & 2 deletions language/predefined/attributes/deprecated.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 603435cd84951fc720eded819c62ef2466d21b5c Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 8dc5bef8981ffd33c8c51f7f33414fcf5c03767a Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<reference xml:id="class.deprecated" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Deprecated 属性</title>
<titleabbrev>Deprecated</titleabbrev>
Expand All @@ -11,14 +12,17 @@
<simpara>
此属性用于将功能标记为已弃用。使用已弃用的功能将导致发出 <constant>E_USER_DEPRECATED</constant> 错误。
</simpara>
<simpara>
自 PHP 8.5.0 起,此属性也可以应用于 trait 和类外声明的编译时常量。
</simpara>
</section>

<section xml:id="deprecated.synopsis">
&reftitle.classsynopsis;

<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\Attribute]</modifier>
<modifier role="attribute">#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION | \Attribute::TARGET_CLASS_CONSTANT | \Attribute::TARGET_CONSTANT | \Attribute::TARGET_CLASS)]</modifier>
<modifier>final</modifier>
<classname>Deprecated</classname>
</ooclass>
Expand Down Expand Up @@ -95,6 +99,29 @@ This is unsafe
</informalexample>
</section>

<section role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.5.0</entry>
<entry>
<classname>Deprecated</classname> 现在也可以应用于 trait 和类外声明的编译时常量;后者通过新的
<constant>Attribute::TARGET_CONSTANT</constant> 目标实现。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>

<section xml:id="deprecated.seealso">
&reftitle.seealso;
<simplelist>
Expand Down
39 changes: 35 additions & 4 deletions language/predefined/attributes/override.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 603435cd84951fc720eded819c62ef2466d21b5c Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: a65a5e6f1911958433899d22bfe252dedec57b69 Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<reference xml:id="class.override" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Override 注解</title>
Expand All @@ -10,10 +10,10 @@
<section xml:id="override.intro">
&reftitle.intro;
<simpara>
此注解用于表明某个方法或属性意图重写父类中的方法或属性,或实现接口中定义的方法或属性。
此注解用于表明某个方法、属性或类常量(包括枚举 case)意图重写父类中的方法、属性或类常量,或实现接口中定义的方法、属性或类常量。
</simpara>
<simpara>
如果父类或实现的接口中不存在同名方法或属性,则会引发编译时错误。
如果父类或实现的接口中不存在同名的方法、属性或类常量,则会引发编译时错误。
</simpara>
<simpara>
此注解不能用于 <link linkend="object.construct">__construct()</link>
Expand All @@ -26,7 +26,7 @@

<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\Attribute]</modifier>
<modifier role="attribute">#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS_CONSTANT)]</modifier>
<modifier>final</modifier>
<classname>Override</classname>
</ooclass>
Expand All @@ -48,6 +48,12 @@
</row>
</thead>
<tbody>
<row>
<entry>8.6.0</entry>
<entry>
<classname>Override</classname> 可以应用于类常量,包括枚举 case。
</entry>
</row>
<row>
<entry>8.5.0</entry>
<entry>
Expand Down Expand Up @@ -108,6 +114,31 @@ final class Extended extends Base {
<screen>
<![CDATA[
Fatal error: Extended::$boo has #[\Override] attribute, but no matching parent property exists
]]>
</screen>
</example>
<example>
<title>与类常量一起使用</title>
<programlisting role="php">
<![CDATA[
<?php

class Base {
protected const FOO = 'foo';
}

final class Extended extends Base {
#[\Override]
protected const BOO = 'boo';
}

?>
]]>
</programlisting>
&example.outputs.86.similar;
<screen>
<![CDATA[
Fatal error: Extended::BOO has #[\Override] attribute, but no matching parent constant exists
]]>
</screen>
</example>
Expand Down
4 changes: 2 additions & 2 deletions language/predefined/attributes/returntypewillchange.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 52e88759354dd18104d8c067780be9f582f20136 Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 8dc5bef8981ffd33c8c51f7f33414fcf5c03767a Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<reference xml:id="class.returntypewillchange" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>ReturnTypeWillChange 注解</title>
Expand Down Expand Up @@ -45,7 +45,7 @@

<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\Attribute]</modifier>
<modifier role="attribute">#[\Attribute(\Attribute::TARGET_METHOD)]</modifier>
<modifier>final</modifier>
<classname>ReturnTypeWillChange</classname>
</ooclass>
Expand Down
4 changes: 2 additions & 2 deletions language/predefined/attributes/sensitiveparameter.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 603435cd84951fc720eded819c62ef2466d21b5c Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 8dc5bef8981ffd33c8c51f7f33414fcf5c03767a Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<reference xml:id="class.sensitiveparameter" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>SensitiveParameter 注解</title>
Expand All @@ -20,7 +20,7 @@

<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\Attribute]</modifier>
<modifier role="attribute">#[\Attribute(\Attribute::TARGET_PARAMETER)]</modifier>
<modifier>final</modifier>
<classname>SensitiveParameter</classname>
</ooclass>
Expand Down
4 changes: 2 additions & 2 deletions reference/curl/functions/curl-close.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 86c8ebd19ed93843f293bdcecc9ce68cb4ab57bc Maintainer: daijie Status: ready -->
<!-- EN-Revision: 8dc5bef8981ffd33c8c51f7f33414fcf5c03767a Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.curl-close" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand All @@ -15,7 +15,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier role="attribute">#[\Deprecated]</modifier>
<modifier role="attribute">#[\Deprecated(since: '8.5', message: "as it has no effect since PHP 8.0")]</modifier>
<type>void</type><methodname>curl_close</methodname>
<methodparam><type>CurlHandle</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
Expand Down
18 changes: 15 additions & 3 deletions reference/curl/functions/curl-share-close.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: fc9a0a8b29a7a099998bdd71fe5350a10b18fe62 Maintainer: duanxiaoqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 8dc5bef8981ffd33c8c51f7f33414fcf5c03767a Maintainer: duanxiaoqiang Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.curl-share-close" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>curl_share_close</refname>
Expand All @@ -15,7 +15,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier role="attribute">#[\Deprecated]</modifier>
<modifier role="attribute">#[\Deprecated(since: '8.5', message: "as it has no effect since PHP 8.0")]</modifier>
<type>void</type><methodname>curl_share_close</methodname>
<methodparam><type>CurlShareHandle</type><parameter>share_handle</parameter></methodparam>
</methodsynopsis>
Expand Down Expand Up @@ -51,6 +51,18 @@
</row>
</thead>
<tbody>
<row>
<entry>8.5.0</entry>
<entry>
此函数已弃用。
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
此函数现在不执行任何操作(NOP)。
</entry>
</row>
&curl.changelog.share-handle-param;
</tbody>
</tgroup>
Expand Down
4 changes: 2 additions & 2 deletions reference/datetime/functions/date-sunrise.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 3a8c3e77df070a046c9d5b56b68926ca2d7e5ee3 Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: 8dc5bef8981ffd33c8c51f7f33414fcf5c03767a Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.date-sunrise" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand All @@ -19,7 +19,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier role="attribute">#[\Deprecated]</modifier>
<modifier role="attribute">#[\Deprecated(since: '8.1', message: 'use date_sun_info() instead')]</modifier>
<type class="union"><type>string</type><type>int</type><type>float</type><type>false</type></type><methodname>date_sunrise</methodname>
<methodparam><type>int</type><parameter>timestamp</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>returnFormat</parameter><initializer><constant>SUNFUNCS_RET_STRING</constant></initializer></methodparam>
Expand Down
4 changes: 2 additions & 2 deletions reference/datetime/functions/date-sunset.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 3a8c3e77df070a046c9d5b56b68926ca2d7e5ee3 Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: 8dc5bef8981ffd33c8c51f7f33414fcf5c03767a Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.date-sunset" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand All @@ -21,7 +21,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier role="attribute">#[\Deprecated]</modifier>
<modifier role="attribute">#[\Deprecated(since: '8.1', message: 'use date_sun_info() instead')]</modifier>
<type class="union"><type>string</type><type>int</type><type>float</type><type>false</type></type><methodname>date_sunset</methodname>
<methodparam><type>int</type><parameter>timestamp</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>returnFormat</parameter><initializer><constant>SUNFUNCS_RET_STRING</constant></initializer></methodparam>
Expand Down
Loading
Loading