Skip to content

Commit

Permalink
Add missing ZEND constants and descriptions of their PHP aliases (php…
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored Jan 7, 2024
1 parent 2998456 commit 9a0bab1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 25 deletions.
28 changes: 25 additions & 3 deletions appendices/reserved.constants.core.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: 37280533a76693adac626a37ffc8daa2276400ce Maintainer: avenger Status: ready -->
<!-- EN-Revision: 140689d2196c7ce0b7cb6a3d822915eb8df8f51f Maintainer: avenger Status: ready -->
<!-- CREDITS: Luffy -->
<sect2 xml:id="reserved.constants.core" xmlns="http://docbook.org/ns/docbook">
<title>内核预定义常量</title>
Expand Down Expand Up @@ -75,14 +75,36 @@
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.zend-thread-safe">
<term>
<constant>ZEND_THREAD_SAFE</constant>
(<type>bool</type>)
</term>
<listitem>
<simpara>
Indicates whether the current build of PHP is thread safe.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.zend-debug-build">
<term>
<constant>ZEND_DEBUG_BUILD</constant>
(<type>bool</type>)
</term>
<listitem>
<simpara>
表示当前 PHP 版本是否为调试版本。
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.php-zts">
<term>
<constant>PHP_ZTS</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>

表示 PHP 的当前版本是否为线程安全版本。
</simpara>
</listitem>
</varlistentry>
Expand All @@ -93,7 +115,7 @@
</term>
<listitem>
<simpara>

表示当前 PHP 版本是否为调试版本。
</simpara>
</listitem>
</varlistentry>
Expand Down
44 changes: 22 additions & 22 deletions language/enumerations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
enum Suit
{
Expand All @@ -58,7 +58,7 @@ enum Suit
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
function pick_a_card(Suit $suit) { ... }
Expand Down Expand Up @@ -90,7 +90,7 @@ pick_a_card('Spades');
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
$a = Suit::Spades;
$b = Suit::Spades;
Expand Down Expand Up @@ -123,7 +123,7 @@ $a instanceof Suit; // true
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
print Suit::Spades->name;
// 输出 "Spades"
Expand Down Expand Up @@ -153,7 +153,7 @@ print Suit::Spades->name;
<para>按以下语法,定义标量形式的枚举:</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
enum Suit: string
{
Expand Down Expand Up @@ -196,7 +196,7 @@ enum Suit: string
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
print Suit::Clubs->value;
// 输出 "C"
Expand All @@ -211,7 +211,7 @@ print Suit::Clubs->value;
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
$suit = Suit::Clubs;
$ref = &$suit->value;
Expand Down Expand Up @@ -248,7 +248,7 @@ $ref = &$suit->value;
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
$record = get_stuff_from_database($id);
print $record['suit'];
Expand Down Expand Up @@ -278,7 +278,7 @@ print $suit->value;
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
interface Colorful
{
Expand Down Expand Up @@ -328,7 +328,7 @@ print Suit::Diamonds->shape(); // 输出 "Rectangle"
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
interface Colorful
{
Expand Down Expand Up @@ -375,7 +375,7 @@ enum Suit: string implements Colorful
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
interface Colorful
{
Expand Down Expand Up @@ -430,7 +430,7 @@ final class Suit implements UnitEnum, Colorful
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
enum Size
{
Expand Down Expand Up @@ -469,7 +469,7 @@ enum Size
<para>枚举常量可以引用枚举条目:</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
enum Size
{
Expand All @@ -494,7 +494,7 @@ enum Size
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
interface Colorful
{
Expand Down Expand Up @@ -546,7 +546,7 @@ enum Suit implements Colorful
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
// 这是完全合法的 Enum 定义
enum Direction implements ArrayAccess
Expand Down Expand Up @@ -627,7 +627,7 @@ $x = Direction::Up['short'];
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
$clovers = new Suit();
// Error: Cannot instantiate enum Suit
Expand All @@ -649,7 +649,7 @@ $horseshoes = (new ReflectionClass(Suit::class))->newInstanceWithoutConstructor(
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
Suit::cases();
// 产生: [Suit::Hearts, Suit::Diamonds, Suit::Clubs, Suit::Spades]
Expand All @@ -672,7 +672,7 @@ Suit::cases();
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
Suit::Hearts === unserialize(serialize(Suit::Hearts));
Expand All @@ -698,7 +698,7 @@ print serialize(Suit::Hearts);
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
enum Foo {
case Bar;
Expand Down Expand Up @@ -825,7 +825,7 @@ fot(MoreErrorCode::PEBKAC);
<example>
<title>值受限的基本用法</title>
<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
enum SortOrder
{
Expand All @@ -852,7 +852,7 @@ function query($fields, $filter, SortOrder $order = SortOrder::Asc) { ... }
<title>值排他的高级用法</title>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
enum UserStatus: string
{
Expand Down Expand Up @@ -889,7 +889,7 @@ enum UserStatus: string
</para>

<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
foreach (UserStatus::cases() as $case) {
printf('<option value="%s">%s</option>\n', $case->value, $case->label());
Expand Down

0 comments on commit 9a0bab1

Please sign in to comment.