Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale functions may fail and return null or false #883

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions reference/intl/locale/accept-from-http.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<methodsynopsis>
<modifier>public</modifier>
<modifier>static</modifier>
<type>string</type>
<type class="union"><type>string</type><type>false</type></type>
<methodname>Locale::acceptFromHttp</methodname>
<methodparam><type>string</type><parameter>header</parameter></methodparam>
</methodsynopsis>
<para>
&style.procedural;
</para>
<methodsynopsis>
<type>string</type>
<type class="union"><type>string</type><type>false</type></type>
<methodname>locale_accept_from_http</methodname>
<methodparam><type>string</type><parameter>header</parameter></methodparam>
</methodsynopsis>
Expand Down Expand Up @@ -55,6 +55,10 @@
<para>
The corresponding locale identifier.
</para>
<para>
Returns &false; when the length of <parameter>header</parameter> exceeds
<constant>INTL_MAX_LOCALE_LEN</constant>.
</para>
</refsect1>

<refsect1 role="examples">
Expand Down
12 changes: 9 additions & 3 deletions reference/intl/locale/canonicalize.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <modifier>static</modifier> <type>string</type><methodname>Locale::canonicalize</methodname>
<modifier>public</modifier> <modifier>static</modifier>
<type class="union"><type>string</type><type>null</type></type>
<methodname>Locale::canonicalize</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
<para>
Expand All @@ -29,7 +31,7 @@
<term><parameter>locale</parameter></term>
<listitem>
<para>

</para>
</listitem>
</varlistentry>
Expand All @@ -39,7 +41,11 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>

Canonicalized locale string.
</para>
<para>
Returns &null; when the length of <parameter>locale</parameter> exceeds
<constant>INTL_MAX_LOCALE_LEN</constant>.
</para>
</refsect1>

Expand Down
18 changes: 11 additions & 7 deletions reference/intl/locale/filter-matches.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<methodsynopsis>
<modifier>public</modifier>
<modifier>static</modifier>
<type>bool</type>
<type class="union"><type>bool</type><type>null</type></type>
<methodname>Locale::filterMatches</methodname>
<methodparam><type>string</type><parameter>langtag</parameter></methodparam>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
Expand All @@ -25,7 +25,7 @@
&style.procedural;
</para>
<methodsynopsis>
<type>bool</type>
<type class="union"><type>bool</type><type>null</type></type>
<methodname>locale_filter_matches</methodname>
<methodparam><type>string</type><parameter>langtag</parameter></methodparam>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
Expand Down Expand Up @@ -62,7 +62,7 @@
<listitem>
<para>
If true, the arguments will be converted to canonical form before
matching.
matching.
</para>
</listitem>
</varlistentry>
Expand All @@ -76,6 +76,10 @@
<para>
&true; if $locale matches $langtag &false; otherwise.
</para>
<para>
Returns &null; when the length of <parameter>locale</parameter> exceeds
<constant>INTL_MAX_LOCALE_LEN</constant>.
</para>
</refsect1>

<refsect1 role="examples">
Expand All @@ -85,9 +89,9 @@
<programlisting role="php">
<![CDATA[
<?php
echo (locale_filter_matches('de-DEVA','de-DE', false)) ? "Matches" : "Does not match";
echo (locale_filter_matches('de-DEVA','de-DE', false)) ? "Matches" : "Does not match";
echo '; ';
echo (locale_filter_matches('de-DE_1996','de-DE', false)) ? "Matches" : "Does not match";
echo (locale_filter_matches('de-DE_1996','de-DE', false)) ? "Matches" : "Does not match";
?>
]]>
</programlisting>
Expand All @@ -97,9 +101,9 @@ echo (locale_filter_matches('de-DE_1996','de-DE', false)) ? "Matches" : "Does no
<programlisting role="php">
<![CDATA[
<?php
echo (Locale::filterMatches('de-DEVA','de-DE', false)) ? "Matches" : "Does not match";
echo (Locale::filterMatches('de-DEVA','de-DE', false)) ? "Matches" : "Does not match";
echo '; ';
echo (Locale::filterMatches('de-DE-1996','de-DE', false)) ? "Matches" : "Does not match";
echo (Locale::filterMatches('de-DE-1996','de-DE', false)) ? "Matches" : "Does not match";
?>
]]>
</programlisting>
Expand Down
10 changes: 7 additions & 3 deletions reference/intl/locale/get-all-variants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<methodsynopsis>
<modifier>public</modifier>
<modifier>static</modifier>
<type>array</type>
<type class="union"><type>array</type><type>null</type></type>
<methodname>Locale::getAllVariants</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
<para>
&style.procedural;
</para>
<methodsynopsis>
<type>array</type>
<type class="union"><type>array</type><type>null</type></type>
<methodname>locale_get_all_variants</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
Expand Down Expand Up @@ -52,9 +52,13 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The <type>array</type> containing the list of all variants subtag for the locale
The <type>array</type> containing the list of all variants subtag for the locale
or &null; if not present
</para>
<para>
Returns &null; when the length of <parameter>locale</parameter> exceeds
<constant>INTL_MAX_LOCALE_LEN</constant>.
</para>
</refsect1>

<refsect1 role="examples">
Expand Down
12 changes: 8 additions & 4 deletions reference/intl/locale/get-keywords.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<methodsynopsis>
<modifier>public</modifier>
<modifier>static</modifier>
<type>array</type>
<type class="union"><type>array</type><type>null</type></type>
<methodname>Locale::getKeywords</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
<para>
&style.procedural;
</para>
<methodsynopsis>
<type>array</type>
<type class="union"><type>array</type><type>null</type></type>
<methodname>locale_get_keywords</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
Expand Down Expand Up @@ -54,6 +54,10 @@
<para>
Associative <type>array</type> containing the keyword-value pairs for this locale
</para>
<para>
Returns &null; when the length of <parameter>locale</parameter> exceeds
<constant>INTL_MAX_LOCALE_LEN</constant>.
</para>
</refsect1>

<refsect1 role="examples">
Expand All @@ -66,7 +70,7 @@
$keywords_arr = locale_get_keywords('de_DE@currency=EUR;collation=PHONEBOOK');
if ($keywords_arr) {
foreach ($keywords_arr as $key => $value) {
echo "$key = $value\n";
echo "$key = $value\n";
}
}
?>
Expand All @@ -81,7 +85,7 @@ if ($keywords_arr) {
$keywords_arr = Locale::getKeywords('de_DE@currency=EUR;collation=PHONEBOOK');
if ($keywords_arr) {
foreach ($keywords_arr as $key => $value) {
echo "$key = $value\n";
echo "$key = $value\n";
}
}
?>
Expand Down
10 changes: 7 additions & 3 deletions reference/intl/locale/get-primary-language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<methodsynopsis>
<modifier>public</modifier>
<modifier>static</modifier>
<type>string</type>
<type class="union"><type>string</type><type>null</type></type>
<methodname>Locale::getPrimaryLanguage</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
<para>
&style.procedural;
</para>
<methodsynopsis>
<type>string</type>
<type class="union"><type>string</type><type>null</type></type>
<methodname>locale_get_primary_language</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
Expand Down Expand Up @@ -52,7 +52,11 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The language code associated with the language or &null; in case of error.
The language code associated with the language.
</para>
<para>
Returns &null; when the length of <parameter>locale</parameter> exceeds
<constant>INTL_MAX_LOCALE_LEN</constant>.
</para>
</refsect1>

Expand Down
8 changes: 6 additions & 2 deletions reference/intl/locale/get-region.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<methodsynopsis>
<modifier>public</modifier>
<modifier>static</modifier>
<type>string</type>
<type class="union"><type>string</type><type>null</type></type>
<methodname>Locale::getRegion</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
<para>
&style.procedural;
</para>
<methodsynopsis>
<type>string</type>
<type class="union"><type>string</type><type>null</type></type>
<methodname>locale_get_region</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
Expand Down Expand Up @@ -54,6 +54,10 @@
<para>
The region subtag for the locale or &null; if not present
</para>
<para>
Returns &null; when the length of <parameter>locale</parameter> exceeds
<constant>INTL_MAX_LOCALE_LEN</constant>.
</para>
</refsect1>

<refsect1 role="examples">
Expand Down
14 changes: 9 additions & 5 deletions reference/intl/locale/lookup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<methodsynopsis>
<modifier>public</modifier>
<modifier>static</modifier>
<type>string</type>
<type class="union"><type>string</type><type>null</type></type>
<methodname>Locale::lookup</methodname>
<methodparam><type>array</type><parameter>langtag</parameter></methodparam>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
Expand All @@ -26,17 +26,17 @@
&style.procedural;
</para>
<methodsynopsis>
<type>string</type>
<type class="union"><type>string</type><type>null</type></type>
<methodname>locale_lookup</methodname>
<methodparam><type>array</type><parameter>langtag</parameter></methodparam>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>canonicalize</parameter><initializer>&false;</initializer></methodparam>
<methodparam choice="opt"><type>string</type><parameter>default</parameter></methodparam>
</methodsynopsis>
<para>
Searches the items in <parameter>langtag</parameter> for the best match to
Searches the items in <parameter>langtag</parameter> for the best match to
the language range specified in <parameter>locale</parameter> according to
RFC 4647's lookup algorithm.
RFC 4647's lookup algorithm.
</para>
</refsect1>

Expand All @@ -48,7 +48,7 @@
<term><parameter>langtag</parameter></term>
<listitem>
<para>
An <type>array</type> containing a list of language tags to compare to
An <type>array</type> containing a list of language tags to compare to
<parameter>locale</parameter>. Maximum 100 items allowed.
</para>
</listitem>
Expand Down Expand Up @@ -90,6 +90,10 @@
<para>
The closest matching language tag or default value.
</para>
<para>
Returns &null; when the length of <parameter>locale</parameter> exceeds
<constant>INTL_MAX_LOCALE_LEN</constant>.
</para>
</refsect1>

<refsect1 role="examples">
Expand Down
4 changes: 2 additions & 2 deletions reference/intl/locale/parse-locale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<methodsynopsis>
<modifier>public</modifier>
<modifier>static</modifier>
<type>array</type>
<type class="union"><type>array</type><type>null</type></type>
<methodname>Locale::parseLocale</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
<para>
&style.procedural;
</para>
<methodsynopsis>
<type>array</type>
<type class="union"><type>array</type><type>null</type></type>
<methodname>locale_parse</methodname>
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
</methodsynopsis>
Expand Down