reference/datetime/datetimeimmutable/getlasterrors.xml
453f103a69eb2db96a4a162f526fd22dd54843dc
...
...
@@ -1,6 +1,5 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<refentry xml:id="datetimeimmutable.getlasterrors" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>DateTimeImmutable::getLastErrors</refname>
...
...
@@ -9,18 +8,102 @@
9
8

10
9
<refsect1 role="description">
11
10
&reftitle.description;
12
-
<methodsynopsis role="oop">
13
-
<modifier>public</modifier> <modifier>static</modifier> <type>array</type><methodname>DateTimeImmutable::getLastErrors</methodname>
14
-
<void />
11
+
<methodsynopsis role="DateTimeImmutable">
12
+
<modifier>public</modifier> <modifier>static</modifier> <type class="union"><type>array</type><type>false</type></type><methodname>DateTimeImmutable::getLastErrors</methodname>
13
+
<void/>
15
14
</methodsynopsis>
16
15
<para>
17
-
Like <methodname>DateTime::getLastErrors</methodname> but works with
18
-
<classname>DateTimeImmutable</classname>.
16
+
Returns an array of warnings and errors found while parsing
17
+
a date/time string.
19
18
</para>
20
19
</refsect1>
21
20

22
-
</refentry>
21
+
<refsect1 role="parameters">
22
+
&reftitle.parameters;
23
+
&no.function.parameters;
24
+
</refsect1>
25
+

26
+
<refsect1 role="returnvalues">
27
+
&reftitle.returnvalues;
28
+
<para>
29
+
Returns array containing info about warnings and errors, or &false; if there
30
+
are neither warnings nor errors.
31
+
</para>
32
+
</refsect1>
33
+

34
+
<refsect1 role="changelog">
35
+
&reftitle.changelog;
36
+
<para>
37
+
<informaltable>
38
+
<tgroup cols="2">
39
+
<thead>
40
+
<row>
41
+
<entry>&Version;</entry>
42
+
<entry>&Description;</entry>
43
+
</row>
44
+
</thead>
45
+
<tbody>
46
+
<row>
47
+
<entry>8.2.0</entry>
48
+
<entry>
49
+
Before PHP 8.2.0, this function did not return &false;
50
+
when there were no warnings or errors. Instead, it would always
51
+
return the documented array structure.
52
+
</entry>
53
+
</row>
54
+
</tbody>
55
+
</tgroup>
56
+
</informaltable>
57
+
</para>
58
+
</refsect1>
59
+

60
+
<refsect1 role="examples">
61
+
&reftitle.examples;
62
+
<example>
63
+
<title><function>DateTimeImmutable::getLastErrors</function> example</title>
64
+
<programlisting role="php">
65
+
<![CDATA[
66
+
<?php
67
+
try {
68
+
$date = new DateTimeImmutable('asdfasdf');
69
+
} catch (Exception $e) {
70
+
// For demonstration purposes only...
71
+
print_r(DateTimeImmutable::getLastErrors());
72
+

73
+
// The real object-oriented way to do this is
74
+
// echo $e->getMessage();
75
+
}
76
+
?>
77
+
]]>
78
+
</programlisting>
79
+
&examples.outputs;
80
+
<screen>
81
+
<![CDATA[
82
+
Array
83
+
(
84
+
[warning_count] => 1
85
+
[warnings] => Array
86
+
(
87
+
[6] => Double timezone specification
88
+
)
89
+

90
+
[error_count] => 1
91
+
[errors] => Array
92
+
(
93
+
[0] => The timezone could not be found in the database
94
+
)
23
95

96
+
)
97
+
]]>
98
+
</screen>
99
+
<para>
100
+
The indexes 6, and 0 in the example output refer to the character index in the string where the error occurred.
101
+
</para>
102
+
</example>
103
+
</refsect1>
104
+

105
+

106
+
</refentry>
24
107
<!-- Keep this comment at the end of the file
25
108
Local variables:
26
109
mode: sgml
27
110