-
Notifications
You must be signed in to change notification settings - Fork 105
/
incompatible.xml
1532 lines (1450 loc) · 56.7 KB
/
incompatible.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 61374bbe228e8e9c55a24aba59a1e2bb2a871148 Maintainer: avenger Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<sect1 xml:id="migration80.incompatible" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>不向后兼容的变更</title>
<sect2 xml:id="migration80.incompatible.core">
<title>PHP 核心中不向后兼容的变更</title>
<sect3 xml:id="migration80.incompatible.core.string-number-comparision">
<title>字符串与数字的比较</title>
<para>
数字与非数字形式的字符串之间的非严格比较现在将首先将数字转为字符串,然后比较这两个字符串。
数字与数字形式的字符串之间的比较仍然像之前那样进行。
请注意,这意味着 <code>0 == "not-a-number"</code> 现在将被认为是 false 。
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>比较</entry>
<entry>之前</entry>
<entry>之后</entry>
</row>
</thead>
<tbody>
<row>
<entry><code>0 == "0"</code></entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><code>0 == "0.0"</code></entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><code>0 == "foo"</code></entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><code>0 == ""</code></entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><code>42 == " 42"</code></entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><code>42 == "42foo"</code></entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<!-- RFC: https://wiki.php.net/rfc/string_to_number_comparison -->
</para>
</sect3>
<sect3 xml:id="migration80.incompatible.core.other">
<title>其它不向后兼容的变更</title>
<itemizedlist>
<listitem>
<para>
<literal>match</literal> 现在是一个保留字。
</para>
</listitem>
<listitem>
<para>
断言(Assertion)失败现在默认抛出异常。如果想要改回之前的行为,可以在 INI 设置中设置
<code>assert.exception=0</code> 。
</para>
</listitem>
<listitem>
<para>
<literal>mixed</literal> 现在是保留字,所以不能用于类,接口或者
trait,也禁止在命名空间中使用。
</para>
</listitem>
<listitem>
<para>
与类名相同的方法名将不再被当做构造方法。应该使用 <link linkend="object.construct">__construct()</link>
来取代它。
</para>
</listitem>
<listitem>
<para>
不再允许通过静态调用的方式去调用非静态方法。因此 <function>is_callable</function> 在检查一个类名与非静态方法时将返回失败(应当检查一个类的实例)。
</para>
</listitem>
<listitem>
<para>
<code>(real)</code> 和 <code>(unset)</code> 转换已被移除。
</para>
</listitem>
<listitem>
<para>
移除 <link linkend="ini.track-errors">track_errors</link> 执行。这意味着不能再用 <varname>php_errormsg</varname>。可以改用
<function>error_get_last</function> 函数。
</para>
</listitem>
<listitem>
<para>
移除定义不区分大小写的常量功能。<function>define</function> 的第三个参数可能不再为 &true;。
</para>
</listitem>
<listitem>
<para>
移除使用 <function>__autoload</function> 函数指定自动加载器的功能。应该改用 <function>spl_autoload_register</function>。
</para>
</listitem>
<listitem>
<para>
<parameter>errcontext</parameter> 参数将不再传递给使用 <function>set_error_handler</function> 设置的自定义错误处理程序。
</para>
</listitem>
<listitem>
<para>
移除 <function>create_function</function>。应该改用匿名函数。
</para>
</listitem>
<listitem>
<para>
移除 <function>each</function>。应该改用 &foreach; 或者 <classname>ArrayIterator</classname>。
</para>
</listitem>
<listitem>
<para>
移除在方法中使用 <methodname>Closure::fromCallable</methodname> 或 <methodname>ReflectionMethod::getClosure</methodname>
创建的匿名函数中解绑 <varname>this</varname> 的能力。
</para>
</listitem>
<listitem>
<para>
移除了从包含 <varname>this</varname> 使用的正常闭包中解绑 <varname>this</varname> 的能力。
</para>
</listitem>
<listitem>
<para>
移除对对象使用 <function>array_key_exists</function> 的能力。应该改用 <function>isset</function> 或 <function>property_exists</function>。
</para>
</listitem>
<listitem>
<para>
<function>array_key_exists</function> 中 <parameter>key</parameter> 参数类型的行为已经和 <function>isset</function> 和正常数组访问一致。所有的
key 类型现在使用通用的强制转换,数组/对象 key 会抛出 <classname>TypeError</classname>。
</para>
</listitem>
<listitem>
<para>
任意一个数组,将数字 <replaceable>n</replaceable> 作为第一个数字 key,下一个隐式键将会是 <replaceable>n+1</replaceable>。即使
<replaceable>n</replaceable> 为负数也是如此。
<!-- RFC: https://wiki.php.net/rfc/negative_array_index -->
</para>
</listitem>
<listitem>
<para>
error_reporting 默认级别现在是 <constant>E_ALL</constant>。之前排除 <constant>E_NOTICE</constant> 和 <constant>E_DEPRECATED</constant>。
</para>
</listitem>
<listitem>
<para>
现在默认启用 <link linkend="ini.display-startup-errors">display_startup_errors</link>。
</para>
</listitem>
<listitem>
<para>
在没有父级的类中使用 <type>parent</type> 将会导致 fatal compile-time 错误。
</para>
</listitem>
<listitem>
<para>
<literal>@</literal> 操作将不再屏蔽 fatal
错误(<constant>E_ERROR</constant>、<constant>E_CORE_ERROR</constant>、<constant>E_COMPILE_ERROR</constant>、<constant>E_USER_ERROR</constant>、<constant>E_RECOVERABLE_ERROR</constant>、<constant>E_PARSE</constant>)。当使用
<literal>@</literal> 时,接受 error_reporting 为 <literal>0</literal> 的错误处理程序,应该调整为使用位掩码检查:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
// 之前
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
if (error_reporting() == 0) {
return false;
}
// ...
}
// 现在
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
if (!(error_reporting() & $err_no)) {
return false;
}
// ...
}
?>
]]>
</programlisting>
</para>
<para>
此外,应注意在生产环境中不显示错误消息,这可能会导致信息泄露。确保 <code>display_errors=Off</code> 与错误记录一起使用。
</para>
</listitem>
<listitem>
<para>
<literal>#[</literal> 不再解释为注释的开头,因为此语法现在用于注解。
<!-- RFC: https://wiki.php.net/rfc/shorter_attribute_syntax_change -->
</para>
</listitem>
<listitem>
<para>
由于不兼容的方法签名(违反 LSP)导致的继承错误现在将始终生成致命错误。以前在某些情况下会生成警告。
<!-- RFC: https://wiki.php.net/rfc/lsp_errors -->
</para>
</listitem>
<listitem>
<para>
相对于位移、加法还有减法,连接运算符的优先级已经更改。
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
echo "Sum: " . $a + $b;
// 之前解释为:
echo ("Sum: " . $a) + $b;
// 现在解释为:
echo "Sum:" . ($a + $b);
?>
]]>
</programlisting>
<!-- RFC: https://wiki.php.net/rfc/concatenation_precedence -->
</para>
</listitem>
<listitem>
<para>
在运行时默认值解析为 &null; 的参数,将不在默默将参数类型标记为可为 null。必须改用指定可为 null 类型或者默认值为 &null;。
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
// 之前:
function test(int $arg = CONST_RESOLVING_TO_NULL) {}
// 之后:
function test(?int $arg = CONST_RESOLVING_TO_NULL) {}
// 或者是
function test(int $arg = null) {}
?>
]]>
</programlisting>
</para>
</listitem>
<listitem>
<para>
一些警告已转换为 <classname>Error</classname> 异常:
</para>
<para>
<simplelist>
<member>
尝试向非对象写入属性。之前会默默的为 null、false 和空字符串创建 stdClass 对象。
</member>
<member>
尝试追加元素到已使用 PHP_INT_MAX 作为 key 的数组。
</member>
<member>
尝试使用无效类型(array 或 object)作为数组的 key 或者字符串的 offset。
</member>
<member>尝试向标量值写入数组索引。</member>
<member>尝试解包非数组或 Traversable。</member>
<member>
尝试访问未定义的常量,之前,访问未定义的常量将会导致警告并解释为字符串。
</member>
<member>
传递错误的参数数量到非可变参数内置函数将引发 <classname>ArgumentCountError</classname>。
</member>
<member>
传递无效的可数的类型到 <function>count</function> 将抛出 <classname>TypeError</classname>。
</member>
</simplelist>
</para>
<para>
一些通知已转换为警告:
</para>
<para>
<simplelist>
<member>尝试读取未定义的变量。</member>
<member>尝试读取未定义的属性。</member>
<member>尝试读取未定义的数组 key。</member>
<member>尝试读取非对象的属性。</member>
<member>尝试读取非数组的数组索引。</member>
<member>尝试转换数组为字符串。</member>
<member>尝试使用资源作为数组 key。</member>
<member>尝试使用 null、bool、float 作为字符串 offset。</member>
<member>尝试读取越界的字符串 offset。</member>
<member>尝试将空字符串分配给字符串 offset。</member>
</simplelist>
<!-- RFC: https://wiki.php.net/rfc/engine_warnings -->
</para>
</listitem>
<listitem>
<para>
尝试将多字节字符串分配给字符串 offset 现在将发出警告。
</para>
</listitem>
<listitem>
<para>
源文件中的异常字符(比如字符串边界外的 NUL 字节)现在将导致 <classname>ParseError</classname> 异常而不是编译警告。
</para>
</listitem>
<listitem>
<para>
未捕获异常现在会经过“clean shutdown”,这意味着未捕获的异常之后调用析构方法。
</para>
</listitem>
<listitem>
<para>
编译时 fatal error“Only variables can be passed by reference”已延迟到运行时,并转换为“Argument cannot be passed by reference”<classname>Error</classname> 异常。
</para>
</listitem>
<listitem>
<para>
一些“Only variables should be passed by reference”通知已转换为“Argument
cannot be passed by reference”异常。
</para>
</listitem>
<listitem>
<para>
匿名类生成的名称已经发生了改变。现在生成的名称将包括第一个父类或接口的名称:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
new class extends ParentClass {};
// -> ParentClass@anonymous
new class implements FirstInterface, SecondInterface {};
// -> FirstInterface@anonymous
new class {};
// -> class@anonymous
?>
]]>
</programlisting>
</para>
<para>
上面显示的名称仍然后跟 NUL 字节和唯一的后缀。
</para>
</listitem>
<listitem>
<para>
trait 别名适配中的非绝对 trait 方法引用现在必须明确:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
class X {
use T1, T2 {
func as otherFunc;
}
function func() {}
}
?>
]]>
</programlisting>
</para>
<para>
如果同时存在 <code>T1::func()</code> 和 <code>T2::func()</code>,以前此代码会默默接受,并且 func 指向
<code>T1::func</code>。现在则会生成 fatal error,必须明确编写 <code>T1::func</code> or <code>T2::func</code>。
</para>
</listitem>
<listitem>
<para>
trait 中定义的 abstract 方法签名现在会检查类中实现的方法:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
trait MyTrait {
abstract private function neededByTrait(): string;
}
class MyClass {
use MyTrait;
// 错误,因为返回类型不匹配。
private function neededByTrait(): int { return 42; }
}
?>
]]>
</programlisting>
<!-- RFC: https://wiki.php.net/rfc/abstract_trait_method_validation -->
</para>
</listitem>
<listitem>
<para>
现在将禁用的函数视为不存在的函数,调用禁用函数将报告未知,并且现在可以重新定义已禁用的函数。
</para>
</listitem>
<listitem>
<para>
<literal>data://</literal> 流封装协议不在可写,这与文档中的行为相匹配。
</para>
</listitem>
<listitem>
<para>
算术和位操作符 <literal>+</literal>、<literal>-</literal>、<literal>*</literal>、<literal>/</literal>、<literal>**</literal>、<literal>%</literal>、<literal><<</literal>、<literal>>></literal>、<literal>&</literal>、<literal>|</literal>、<literal>^</literal>、<literal>~</literal>、<literal>++</literal>、<literal>--</literal>
的其中一个操作符是 &array;、&resource; 或非重载 &object; 时,现在将始终抛出
<classname>TypeError</classname>。唯一的例外是仍然支持 array <literal>+</literal> array 的合并操作。
<!-- RFC: https://wiki.php.net/rfc/arithmetic_operator_type_checks -->
</para>
</listitem>
<listitem>
<para>
浮点数到字符串的强制转换现在始终不会受到独立 locale 的影响。
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
setlocale(LC_ALL, "de_DE");
$f = 3.14;
echo $f, "\n";
// Previously: 3,14
// Now: 3.14
?>
]]>
</programlisting>
</para>
<para>
参阅 <function>printf</function>、<function>number_format</function> 和
<methodname>NumberFormatter</methodname> 了解自定义数字格式的方法。
<!-- RFC: https://wiki.php.net/rfc/locale_independent_float_to_string -->
</para>
</listitem>
<listitem>
<para>
已经移除对使用大括号(花括号)进行偏移量访问的弃用支持。
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
// 将:
$array{0};
$array{"key"};
// 改为:
$array[0];
$array["key"];
?>
]]>
</programlisting>
<!-- RFC: https://wiki.php.net/rfc/deprecate_curly_braces_array_access -->
</para>
</listitem>
<listitem>
<para>
在私有方法上应用 final 修饰符现在将产生警告,除非该方法是构造方法。
<!-- FC: https://wiki.php.net/rfc/inheritance_private_methods -->
</para>
</listitem>
<listitem>
<para>
如果对象的构造方法 <function>exit</function>,那么将不再调用对象的析构方法,这与构造方法抛出异常时的行为相匹配。
</para>
</listitem>
<listitem>
<para>
命名空间名不能再包含空格:<code>Foo\Bar</code> 将识别为命名空间名称,而 <code>Foo \ Bar</code>
则不能。相反,保留关键字现在允许作为命名空间片段,这可能也会改变代码的解释:<code>new\x</code> 现在与
<code>constant('new\x')</code> 相同,而不是 <code>new \x()</code>。
<!-- RFC: https://wiki.php.net/rfc/namespaced_names_as_token -->
</para>
</listitem>
<listitem>
<para>
嵌套的三元表达式现在需要的括号。
<!-- RFC: https://wiki.php.net/rfc/ternary_associativity -->
</para>
</listitem>
<listitem>
<para>
<function>debug_backtrace</function> 和 <methodname>Exception::getTrace</methodname> 将不再提供对参数的引用。通过回溯将不可能更改函数参数。
</para>
</listitem>
<listitem>
<para>
数字字符串的处理方式已经更改,以便更直观和更少出错。现在允许在数字字符串中使用尾随空格,以便与起始空格的处理方式保持一致。这主要影响:
</para>
<para>
<simplelist>
<member><function>is_numeric</function> 函数</member>
<member>字符串间的比较</member>
<member>类型声明</member>
<member>递增/减操作</member>
</simplelist>
</para>
<para>
“前置数字字符串”的概念已删除大部分;仍然存在的目的是为了简化迁移。发出 <constant>E_NOTICE</constant>“A non well-formed numeric value
encountered”的字符串现在将发出 <constant>E_WARNING</constant>“A non-numeric value encountered”,并且所有发出
<constant>E_WARNING</constant>“A non-numeric value encountered”的字符串现在将抛出 <classname>TypeError</classname>。这主要会影响:
</para>
<para>
<simplelist>
<member>算术运算</member>
<member>位运算</member>
</simplelist>
</para>
<para>
<constant>E_WARNING</constant> 到 <classname>TypeError</classname> 的变更也影响了 <constant>E_WARNING</constant>“Illegal string
offset 'string'”的非法字符串偏移。从字符串到 int/float 的明确强制转换的行为没有改变。
<!-- RFC: https://wiki.php.net/rfc/saner-numeric-strings -->
</para>
</listitem>
<listitem>
<para>
如果魔术方法声明了参数和返回类型,那么它们现在将会检查这些。签名应该与以下列表匹配:
</para>
<para>
<simplelist>
<member><code>__call(string $name, array $arguments): mixed</code></member>
<member><code>__callStatic(string $name, array $arguments): mixed</code></member>
<member><code>__clone(): void</code></member>
<member><code>__debugInfo(): ?array</code></member>
<member><code>__get(string $name): mixed</code></member>
<member><code>__invoke(mixed $arguments): mixed</code></member>
<member><code>__isset(string $name): bool</code></member>
<member><code>__serialize(): array</code></member>
<member><code>__set(string $name, mixed $value): void</code></member>
<member><code>__set_state(array $properties): object</code></member>
<member><code>__sleep(): array</code></member>
<member><code>__unserialize(array $data): void</code></member>
<member><code>__unset(string $name): void</code></member>
<member><code>__wakeup(): void</code></member>
</simplelist>
<!-- RFC: https://wiki.php.net/rfc/magic-methods-signature -->
</para>
</listitem>
<listitem>
<para>
<function>call_user_func_array</function> 数组的键现在将解释为参数名,而不是默默忽略。
</para>
</listitem>
<listitem>
<para>
不再允许在命名空间内声明名为 <literal>assert()</literal> 的函数,并发出 <constant>E_COMPILE_ERROR</constant>。<function>assert</function>
函数受引擎的特殊处理,当定义具有相同名称的命名空间函数时,可能会导致不一致的行为。
</para>
</listitem>
</itemizedlist>
</sect3>
</sect2>
<sect2 xml:id="migration80.incompatible.resource2object">
<title>迁移资源到对象</title>
<para>
一些 &resource; 已经迁移到了 &object;。返回值检测从使用 <function>is_resource</function> 替换为是否是 &false;。
</para>
<itemizedlist>
<listitem>
<para>
<function>curl_init</function> 现在将返回 <classname>CurlHandle</classname> 对象而不是 &resource;。<function>curl_close</function>
函数不再有作用,相反,如果不再引用,<classname>CurlHandle</classname> 实例将自动销毁。
</para>
</listitem>
<listitem>
<para>
<function>curl_multi_init</function> 现在将返回 <classname>CurlMultiHandle</classname> 对象而不是 &resource;。<function>curl_multi_close</function>
函数不再有作用,相反,如果不再引用,<classname>CurlMultiHandle</classname> 实例将自动销毁。
</para>
</listitem>
<listitem>
<para>
<function>curl_share_init</function> 现在将返回 <classname>CurlShareHandle</classname> 对象而不是 &resource;。<function>curl_share_close</function>
函数不再有作用,相反,如果不再引用,<classname>CurlShareHandle</classname> 实例将自动销毁。
</para>
</listitem>
<listitem>
<para>
<function>enchant_broker_init</function> 现在将返回 <classname>EnchantBroker</classname> 对象而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
<function>enchant_broker_request_dict</function> 和
<function>enchant_broker_request_pwl_dict</function> 现在将返回
<classname>EnchantDictionary</classname> 对象而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
GD 扩展现在使用 <classname>GdImage</classname> 对象作为图像的底层数据结构,而不是 &resource;。<function>imagedestroy</function>
函数不再有作用,相反,如果不再引用,<classname>GdImage</classname> 实例将自动销毁。
</para>
</listitem>
<listitem>
<para>
<function>openssl_x509_read</function> 和 <function>openssl_csr_sign</function> 现在将返回 <classname>OpenSSLCertificate</classname>
对象而不是 &resource;。弃用 <function>openssl_x509_free</function> 函数且不再起作用,相反,如果不再引用,<classname>OpenSSLCertificate</classname>
实例将自动销毁。
</para>
</listitem>
<listitem>
<para>
<function>openssl_csr_new</function> 现在将返回
<classname>OpenSSLCertificateSigningRequest</classname> 对象而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
<function>openssl_pkey_new</function> 现在将返回 <classname>OpenSSLAsymmetricKey</classname> 对象而不是 &resource;。弃用
<function>openssl_pkey_free</function> 函数且不再起作用,相反,如果不再引用,<classname>OpenSSLAsymmetricKey</classname>
实例将自动销毁。
</para>
</listitem>
<listitem>
<para>
<function>shmop_open</function> 现在将返回 <classname>Shmop</classname> 对象而不是 &resource;。弃用
<function>shmop_close</function> 函数且不再起作用,相反,如果不再引用,<classname>Shmop</classname> 实例将自动销毁。
</para>
</listitem>
<listitem>
<para>
<function>socket_create</function>、<function>socket_create_listen</function>、<function>socket_accept</function>、<function>socket_import_stream</function>、<function>socket_addrinfo_connect</function>、<function>socket_addrinfo_bind</function>
和 <function>socket_wsaprotocol_info_import</function> 现在将返回 <classname>Socket</classname> 对象而不是
&resource;。<function>socket_addrinfo_lookup</function> 现在将返回 <classname>AddressInfo</classname> 对象组成的数组,而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
<function>msg_get_queue</function> 现在将返回 <classname>SysvMessageQueue</classname>
对象而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
<function>sem_get</function> 现在将返回 <classname>SysvSemaphore</classname>
对象而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
<function>shm_attach</function> 现在将返回 <classname>SysvSharedMemory</classname>
对象而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
<function>xml_parser_create</function> 和 <function>xml_parser_create_ns</function> 现在将返回 <classname>XMLParser</classname>
对象而不是 &resource;。<function>xml_parser_free</function> 函数不再有作用,相反,如果不再引用,<classname>XmlParser</classname> 实例将自动销毁。
</para>
</listitem>
<listitem>
<para>
<link linkend="book.xmlwriter">XMLWriter</link> 函数现在分别接受和返回 <classname>XMLWriter</classname> 对象而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
<function>inflate_init</function> 现在将返回 <classname>InflateContext</classname> 对象而不是 &resource;。
</para>
</listitem>
<listitem>
<para>
<function>deflate_init</function> 现在将返回 <classname>DeflateContext</classname> 对象而不是 &resource;。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.com">
<title>COM 和 .Net (Windows)</title>
<para>
移除从类型库导入不区分大小写常量的功能。<function>com_load_typelib</function> 的第二个参数不再是 false;不再禁用 <link
linkend="ini.com.autoregister-casesensitive">com.autoregister_casesensitive</link>;忽略 <link
linkend="ini.com.typelib-file">com.typelib_file</link> 中的不区分大小写标记。
</para>
</sect2>
<sect2 xml:id="migration80.incompatible.curl">
<title>CURL</title>
<para>
<constant>CURLOPT_POSTFIELDS</constant> 不再接受对象作为数组。要将对象解释为数组,手动执行 <code>(array)</code> 转换。这同样适用于接受数组的其它选项。
</para>
</sect2>
<sect2 xml:id="migration80.incompatible.datetime">
<title>日期和时间</title>
<para>
<function>mktime</function> 和 <function>gmmktime</function> 现在强制需要至少一个参数。<function>time</function> 可以用来获取当前时间戳。
</para>
</sect2>
<sect2 xml:id="migration80.incompatible.dom">
<title>DOM</title>
<para>
已移除 DOM 扩展中无行为和包含测试数据的的未实现类。这些类也已在最新版本的 DOM 标准中移除:
</para>
<para>
<simplelist>
<member><classname>DOMNameList</classname></member>
<member><classname>DomImplementationList</classname></member>
<member><classname>DOMConfiguration</classname></member>
<member><classname>DomError</classname></member>
<member><classname>DomErrorHandler</classname></member>
<member><classname>DOMImplementationSource</classname></member>
<member><classname>DOMLocator</classname></member>
<member><classname>DOMUserDataHandler</classname></member>
<member><classname>DOMTypeInfo</classname></member>
<member><classname>DOMStringExtend</classname></member>
</simplelist>
</para>
<para>
已移除 DOM 扩展中没有实现行为的方法:
</para>
<para>
<simplelist>
<member><methodname>DOMNamedNodeMap::setNamedItem</methodname></member>
<member><methodname>DOMNamedNodeMap::removeNamedItem</methodname></member>
<member><methodname>DOMNamedNodeMap::setNamedItemNS</methodname></member>
<member><methodname>DOMNamedNodeMap::removeNamedItemNS</methodname></member>
<member><methodname>DOMText::replaceWholeText</methodname></member>
<member><methodname>DOMNode::compareDocumentPosition</methodname></member>
<member><methodname>DOMNode::isEqualNode</methodname></member>
<member><methodname>DOMNode::getFeature</methodname></member>
<member><methodname>DOMNode::setUserData</methodname></member>
<member><methodname>DOMNode::getUserData</methodname></member>
<member><methodname>DOMDocument::renameNode</methodname></member>
</simplelist>
</para>
</sect2>
<sect2 xml:id="migration80.incompatible.enchant">
<title>Enchant</title>
<itemizedlist>
<listitem>
<para>
<function>enchant_broker_list_dicts</function>、<function>enchant_broker_describe</function> 和
<function>enchant_dict_suggest</function> 现在将返回空数组而不是 &null;。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.exif">
<title>Exif</title>
<para>
已移除 <function>read_exif_data</function>;应该使用 <function>exif_read_data</function> 替代。
</para>
</sect2>
<sect2 xml:id="migration80.incompatible.filter">
<title>Filter</title>
<itemizedlist>
<listitem>
<para>
已移除 <constant>FILTER_VALIDATE_URL</constant> 过滤中的 <constant>FILTER_FLAG_SCHEME_REQUIRED</constant> 和
<constant>FILTER_FLAG_HOST_REQUIRED</constant> flag。<literal>scheme</literal>
和 <literal>host</literal> 始终(并且一直)必需。
</para>
</listitem>
<listitem>
<para>
<function>filter_input</function> 等函数的 <constant>INPUT_REQUEST</constant> 和 <constant>INPUT_SESSION</constant>
源码已经移除。这些从未实现过,并且使用它们将始终生成警告。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.gd">
<title>GD</title>
<itemizedlist>
<listitem>
<para>
移除弃用函数 <function>image2wbmp</function>。
<!-- RFC: https://wiki.php.net/rfc/image2wbmp -->
</para>
</listitem>
<listitem>
<para>
移除弃用函数 <function>png2wbmp</function> 和 <function>jpeg2wbmp</function>。
<!-- RFC: https://wiki.php.net/rfc/deprecate-png-jpeg-2wbmp -->
</para>
</listitem>
<listitem>
<para>
<function>imagecropauto</function> 的 <parameter>mode</parameter> 参数默认不再接受
<literal>-1</literal>。而是应该使用 <constant>IMG_CROP_DEFAULT</constant>。
</para>
</listitem>
<listitem>
<para>
Windows 上,<filename>php_gd2.dll</filename> 已经重命名为 <filename>php_gd.dll</filename>。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.gmp">
<title>GMP</title>
<para>
已经移除 <function>gmp_random</function>。应该使用 <function>gmp_random_range</function> 或
<function>gmp_random_bits</function>。
</para>
</sect2>
<sect2 xml:id="migration80.incompatible.iconv">
<title>Iconv</title>
<para>
不再支持在发生错误时没有正确设置 <varname>errno</varname> 的 iconv 实现。
</para>
</sect2>
<sect2 xml:id="migration80.incompatible.imap">
<title>IMAP</title>
<itemizedlist>
<listitem>
<para>
<function>imap_headerinfo</function> 已移除未使用的 <parameter>default_host</parameter> 参数。
</para>
</listitem>
<listitem>
<para>
已移除 <function>imap_headerinfo</function> 的别名函数 <function>imap_header</function>。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.intl">
<title>国际化函数</title>
<itemizedlist>
<listitem>
<para>
已移除弃用常量 <constant>INTL_IDNA_VARIANT_2003</constant>。
<!-- RFC: https://wiki.php.net/rfc/deprecate-and-remove-intl_idna_variant_2003 -->
</para>
</listitem>
<listitem>
<para>
移除弃用常量 <constant>Normalizer::NONE</constant>。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.ldap">
<title>LDAP</title>
<itemizedlist>
<listitem>
<para>
移除弃用函数 <function>ldap_sort</function>、<function>ldap_control_paged_result</function>
和 <function>ldap_control_paged_result_response</function>。
</para>
</listitem>
<listitem>
<para>
<function>ldap_set_rebind_proc</function> 的接口已修改;<parameter>callback</parameter>
不再接受空字符串;应该使用 &null; 代替。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.mbstring">
<title>MBString</title>
<itemizedlist>
<listitem>
<para>
已移除 <link linkend="ini.mbstring.func-overload">mbstring.func_overload</link> 指令。与其相关的
<constant>MB_OVERLOAD_MAIL</constant>、<constant>MB_OVERLOAD_STRING</constant> 和 <constant>MB_OVERLOAD_REGEX</constant>
常量也已移除。最后,<function>mb_get_info</function> 中的 <literal>"func_overload"</literal> 和
<literal>"func_overload_list"</literal> 条目也已移除。
</para>
</listitem>
<listitem>
<para>
使用 <function>mb_parse_str</function> 时必须指定结果数组。
</para>
</listitem>
<listitem>
<para>
一些弃用的的 mbregex 别名已移除。请参阅下面的列表,以了解应该使用哪些函数:
</para>
<para>
<simplelist>
<member><function>mbregex_encoding</function> → <function>mb_regex_encoding</function></member>
<member><function>mbereg</function> → <function>mb_ereg</function></member>
<member><function>mberegi</function> → <function>mb_eregi</function></member>
<member><function>mbereg_replace</function> → <function>mb_ereg_replace</function></member>
<member><function>mberegi_replace</function> → <function>mb_eregi_replace</function></member>
<member><function>mbsplit</function> → <function>mb_split</function></member>
<member><function>mbereg_match</function> → <function>mb_ereg_match</function></member>
<member><function>mbereg_search</function> → <function>mb_ereg_search</function></member>
<member><function>mbereg_search_pos</function> → <function>mb_ereg_search_pos</function></member>
<member><function>mbereg_search_regs</function> → <function>mb_ereg_search_regs</function></member>
<member><function>mbereg_search_init</function> → <function>mb_ereg_search_init</function></member>
<member><function>mbereg_search_getregs</function> → <function>mb_ereg_search_getregs</function></member>
<member><function>mbereg_search_getpos</function> → <function>mb_ereg_search_getpos</function></member>
<member><function>mbereg_search_setpos</function> → <function>mb_ereg_search_setpos</function></member>
</simplelist>
</para>
</listitem>
<listitem>
<para>
<function>mb_ereg_replace</function> 已移除 <literal>e</literal> 修饰符。应该使用 <function>mb_ereg_replace_callback</function> 代替。
</para>
</listitem>
<listitem>
<para>
<function>mb_ereg_replace</function> 的非字符串模式参数现在将解释为字符串而不是 ASCII 码点。可以通过调用 <function>chr</function> 来恢复以前的行为。
</para>
</listitem>
<listitem>
<para>
<function>mb_strpos</function>、<function>mb_strrpos</function>、<function>mb_stripos</function>、<function>mb_strripos</function>、<function>mb_strstr</function>、<function>mb_stristr</function>、<function>mb_strrchr</function>
和 <function>mb_strrichr</function> 的 <parameter>needle</parameter> 参数现在可以为空。
</para>
</listitem>
<listitem>
<para>
已移除 <function>mb_decode_numericentity</function> 内部不使用的 <parameter>is_hex</parameter> 参数。
</para>
</listitem>
<listitem>
<para>
<function>mb_strrpos</function> 函数的第三个参数传递编码而不是偏移量的遗留行为已经移除;应该将带编码的 <literal>0</literal>
偏移量作为第四个参数提供。
</para>
</listitem>
<listitem>
<para>
<literal>ISO_8859-*</literal> 字符编码的别名已替换为 <literal>ISO8859-*</literal> 别名,以便与 iconv 扩展实现更好的互操作性。带下划线的 mbregex ISO 8859
别名(<literal>ISO_8859_*</literal> 和 <literal>ISO8859_*</literal>)也已移除。
</para>
</listitem>
<listitem>
<para>
<function>mb_ereg</function> 和 <function>mb_eregi</function> 现在将在匹配成功时返回布尔值 &true;。之前,如果未传递
<parameter>matches</parameter>,则返回整数 <literal>1</literal>;如果传递了 <parameter>matches</parameter>,则返回
<code>max(1, strlen($matches[0]))</code>。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.oci8">
<title>OCI8</title>
<itemizedlist>
<listitem>
<para>
<classname>OCI-Lob</classname> 类现在叫做 <classname>OCILob</classname>,<classname>OCI-Collection</classname> 类现在叫做
<classname>OCICollection</classname>,以实现 PHP 8 arginfo 类型注释工具强制执行的名称合规。
</para>
</listitem>
<listitem>
<para>
多个别名函数已标记为已弃用。
</para>
</listitem>
<listitem>
<para>
<function>oci_internal_debug</function> 及其 <function>ociinternaldebug</function> 已移除。
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.incompatible.odbc">
<title>ODBC</title>
<itemizedlist>
<listitem>
<para>
<function>odbc_connect</function> 不再重用连接。
</para>