Skip to content

Commit

Permalink
Standardise casting spacing (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored Oct 4, 2024
1 parent a145dcb commit c22228b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 50 deletions.
2 changes: 0 additions & 2 deletions chapters/tutorial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->


7 changes: 4 additions & 3 deletions language/operators/bitwise.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 61374bbe228e8e9c55a24aba59a1e2bb2a871148 Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 8859c8b96cd9e80652813f7bcf561432a5e9f934 Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<sect1 xml:id="language.operators.bitwise">
<title>位运算符</title>
<titleabbrev>位</titleabbrev>
Expand Down Expand Up @@ -217,10 +218,10 @@ echo "hallo" ^ "hello"; // 输出 ascii 值 #0 #4 #0 #0 #0
// 'a' ^ 'e' = #4
echo 2 ^ "3"; // 输出 1
// 2 ^ ((int)"3") == 1
// 2 ^ ((int) "3") == 1
echo "2" ^ 3; // 输出 1
// ((int)"2") ^ 3 == 1
// ((int) "2") ^ 3 == 1
?>
]]>
</programlisting>
Expand Down
15 changes: 8 additions & 7 deletions language/operators/comparison.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e50e79746736dbdfbabe9bd3566793b3ddf38f58 Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 8859c8b96cd9e80652813f7bcf561432a5e9f934 Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<sect1 xml:id="language.operators.comparison">
<title>比较运算符</title>
<titleabbrev>比较</titleabbrev>
Expand Down Expand Up @@ -255,11 +256,11 @@ echo $a <=> $b; // 1
<![CDATA[
<?php
// Bool 和 null 总是作为 bool 比较
var_dump(1 == TRUE); // TRUE - same as (bool)1 == TRUE
var_dump(0 == FALSE); // TRUE - same as (bool)0 == FALSE
var_dump(100 < TRUE); // FALSE - same as (bool)100 < TRUE
var_dump(-10 < FALSE);// FALSE - same as (bool)-10 < FALSE
var_dump(min(-100, -10, NULL, 10, 100)); // NULL - (bool)NULL < (bool)-100 is FALSE < TRUE
var_dump(1 == TRUE); // TRUE - same as (bool) 1 == TRUE
var_dump(0 == FALSE); // TRUE - same as (bool) 0 == FALSE
var_dump(100 < TRUE); // FALSE - same as (bool) 100 < TRUE
var_dump(-10 < FALSE);// FALSE - same as (bool) -10 < FALSE
var_dump(min(-100, -10, NULL, 10, 100)); // NULL - (bool) NULL < (bool) -100 is FALSE < TRUE
?>
]]>
</programlisting>
Expand Down Expand Up @@ -401,7 +402,7 @@ echo (true ? 'true' : false ? 't' : 'f');
// 下面是与上面等价的语句,但更清晰
echo ((true ? 'true' : 'false') ? 't' : 'f');
// 这里可以看到第一个表达式的计算结果是 “true”,第二个表达式的计算结果为 (bool)true,
// 这里可以看到第一个表达式的计算结果是 “true”,第二个表达式的计算结果为 (bool) true,
// 因此返回第二个三元表达式的 true 分支。
?>
]]>
Expand Down
5 changes: 3 additions & 2 deletions language/operators/execution.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 43d07782b514d0c7a8487f2c74063739f302df8d Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: ebfd524ef6937b8ca42b05a6b01f43fbd8757244 Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<sect1 xml:id="language.operators.execution">
<title>执行运算符</title>
<titleabbrev>执行</titleabbrev>
<para>
PHP 支持一个执行运算符:反引号(``)。注意这不是单引号!PHP
PHP 支持一个执行运算符:反引号(<literal>``</literal>)。注意这不是单引号!PHP
将尝试将反引号中的内容作为 shell 命令来执行,并将其输出信息返回(即,可以赋给一个变量而不是简单地丢弃到标准输出)。使用反引号运算符“`”的效果与函数
<function>shell_exec</function> 相同。
<informalexample>
Expand Down
4 changes: 2 additions & 2 deletions language/types/array.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: c97d8be813dd0189f2a97359795fbe7173792878 Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: 8859c8b96cd9e80652813f7bcf561432a5e9f934 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: Geogory, dallas, jwj, mowangjuanzi, Luffy -->
<sect1 xml:id="language.types.array">
<title>Array 数组</title>
Expand Down Expand Up @@ -924,7 +924,7 @@ $error_descriptions[8] = "This is just an informal notice";
对于任意 <type>int</type>,<type>float</type>,
<type>string</type>,<type>bool</type> 和 <type>resource</type> 类型,如果将一个值转换为
<type>array</type>,将得到一个仅有一个元素的数组,其下标为
0,该元素即为此标量的值。换句话说,<literal>(array)$scalarValue</literal> 与
0,该元素即为此标量的值。换句话说,<code>(array) $scalarValue</code> 与
<literal>array($scalarValue)</literal> 完全一样。
</para>

Expand Down
43 changes: 11 additions & 32 deletions language/types/integer.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: 161dde4fe721309398dd324edbf02aec409f127b Maintainer: Avenger Status: ready -->
<!-- EN-Revision: 8859c8b96cd9e80652813f7bcf561432a5e9f934 Maintainer: Avenger Status: ready -->
<!-- CREDITS: Gregory, dallas, Altair, mowangjuanzi -->
<sect1 xml:id="language.types.integer">
<title>Integer 整型</title>
Expand Down Expand Up @@ -105,43 +105,22 @@ integer : decimal
</para>

<example>
<title>32 位系统下的整数溢出</title>
<title>整数溢出</title>
<programlisting role="php">
<![CDATA[
<?php
$large_number = 2147483647;
var_dump($large_number); // int(2147483647)
$large_number = 2147483648;
var_dump($large_number); // float(2147483648)
$million = 1000000;
$large_number = 50000 * $million;
var_dump($large_number); // float(50000000000)
?>
]]>
</programlisting>
</example>

<example>
<title>64 位系统下的整数溢出</title>
<programlisting role="php">
<![CDATA[
<?php
$large_number = 9223372036854775807;
var_dump($large_number); // int(9223372036854775807)
$large_number = 9223372036854775808;
var_dump($large_number); // float(9.2233720368548E+18)
$million = 1000000;
$large_number = 50000000000000 * $million;
var_dump($large_number); // float(5.0E+19)
$large_number = 50000000000000000000;
var_dump($large_number); // float(5.0E+19)
var_dump(PHP_INT_MAX + 1); // 32-bit system: float(2147483648)
// 64-bit system: float(9.2233720368548E+18)
?>
]]>
</programlisting>
</example>
</sect2>

<sect2 xml:id="language.types.integer.division">
<title>整数除法</title>
<para>
PHP 没有 <type>int</type> 除法取整运算符,要使用 <function>intdiv</function> 实现。
<literal>1/2</literal> 产生出 <type>float</type>
Expand Down Expand Up @@ -213,7 +192,7 @@ var_dump(foo(8.1)); // 自 PHP 8.1.0 起:“Deprecated: Implicit conversion fr
var_dump(foo(8.1)); // PHP 8.1.0 之前为 8
var_dump(foo(8.0)); // 8 in both cases
var_dump((int)8.1); // 8 in both cases
var_dump((int) 8.1); // 8 in both cases
var_dump(intval(8.1)); // 8 in both cases
?>
]]>
Expand All @@ -229,7 +208,7 @@ var_dump(intval(8.1)); // 8 in both cases

<note>
<para>
NaN 和 Infinity 在转换成 <type>int</type> 时是零。
<literal>NaN</literal>、<literal>Inf</literal><literal>-Inf</literal> 在转换成 <type>int</type> 时是零。
</para>
</note>

Expand Down
5 changes: 3 additions & 2 deletions reference/array/functions/array-merge.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 9e0f03ac354d797d1d16c0fcc1663e5e170f2727 Maintainer: Avenger Status: ready -->
<!-- EN-Revision: 8859c8b96cd9e80652813f7bcf561432a5e9f934 Maintainer: Avenger Status: ready -->
<!-- CREDITS: Luffy -->
<refentry xml:id="function.array-merge" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>array_merge</refname>
Expand Down Expand Up @@ -170,7 +171,7 @@ array(5) {
<?php
$beginning = 'foo';
$end = array(1 => 'bar');
$result = array_merge((array)$beginning, (array)$end);
$result = array_merge((array) $beginning, (array) $end);
print_r($result);
?>
]]>
Expand Down

0 comments on commit c22228b

Please sign in to comment.