Commit Graph

1384 Commits

Author SHA1 Message Date
Máté Kocsis
54e2ef0b81
Fix return type of UConverter::fromUCallback() and UConverter::toUCallback()
Closes GH-6950
2021-05-07 15:21:58 +02:00
Nikita Popov
26860c6b6a Fix -Wmaybe-uninitialized warning in intl uchar
This variable can indeed be uninitialized when passed to convert_cp,
though it will not actually be used if uninitialized. This is
still UB though, so let's fix it.
2021-05-07 12:20:16 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
331eddadc8 Make date/time type arguments of IntlDateFormatter ctor optional
Default them to IntlDateFormatter:FULL, which has value 0, which
was what you would get if you passed null to these arguments in
weak typing mode. The documentation called this ICU's default
date/time type.
2021-04-27 23:58:38 +02:00
Nikita Popov
b8942b8313 Fix test for older ICU versions
Apply the change that was done for variant7 to the other variants
as well.
2021-04-15 15:20:17 +02:00
Christoph M. Becker
b074e3b52b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80763: msgfmt_format() does not accept DateTime references
2021-02-17 17:31:47 +01:00
Christoph M. Becker
553a0c52b1 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80763: msgfmt_format() does not accept DateTime references
2021-02-17 17:30:47 +01:00
Christoph M. Becker
84b6152842 Fix #80763: msgfmt_format() does not accept DateTime references
`intl_zval_to_millis()` needs to cater to references.

Closes GH-6707.
2021-02-17 17:26:48 +01:00
Máté Kocsis
bf0f6aaf18
Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Nikita Popov
c91ea947b2 Use typed proprety for Transliterator::$id
This is a read-only property for which Transliterator internally
assigns a string value.

Also clean up the code handling this property a bit.
2021-02-15 12:27:25 +01:00
Nikita Popov
b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.
2021-02-11 21:46:13 +01:00
Máté Kocsis
45fa7596dc
Add missing classes to stubs 2021-02-09 22:38:06 +01:00
Nikita Popov
9d54609a19 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use E_ERROR to report arginfo/zpp mismatch
  Make NumberFormatter ctor $pattern nullable
  Make IntlDateFormatter ctor $pattern nullable
2021-02-09 14:37:41 +01:00
Nikita Popov
f5768eaa2e Make NumberFormatter ctor $pattern nullable
Whether the pattern is needed depends on the used style. If no
pattern is needed, null is a more sensible value than an empty
string.

fixup
2021-02-09 14:36:41 +01:00
Nikita Popov
186f9bab45 Make IntlDateFormatter ctor $pattern nullable
The implementation already made this argument nullable, but it
was not reflected in the stub.
2021-02-09 14:25:30 +01:00
Máté Kocsis
c6723728df
Generate ext/intl class entries from stubs
Closes GH-6670
2021-02-09 13:37:24 +01:00
Máté Kocsis
99b08ac281
Implicitly enable function entry generation when class entry generation is enabled
Closes GH-6675
2021-02-09 13:37:24 +01:00
Máté Kocsis
1954e59758
Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
Nikita Popov
8c3d279cb3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80644: ResourceBundle::get() doesn't reset error state
2021-01-19 15:21:09 +01:00
Nikita Popov
05d168013a Fixed bug #80644: ResourceBundle::get() doesn't reset error state 2021-01-19 15:20:55 +01:00
Nikita Popov
49e030d551 Merge branch 'PHP-8.0'
* PHP-8.0:
  Sync datefmt_get_calendar_object signature
  Sync intlcal_create_instance() and IntlCalendar::createInstance()
  Sync date_diff and DateTime::diff return type
2021-01-18 14:39:51 +01:00
Nikita Popov
ebf461a025 Sync datefmt_get_calendar_object signature
In this case, it's only a matter of using the same type order
in both cases.
2021-01-18 14:39:32 +01:00
Nikita Popov
39077deea5 Sync intlcal_create_instance() and IntlCalendar::createInstance()
Remove the explicit mention of IntlGregorianCalendar in the latter.
It is a subclass of IntlCalendar, and as such covered if only
IntlCalendar is used as the return type.
2021-01-18 14:39:32 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
422d1665a2 Make convert_to_*_ex simple aliases of convert_to_*
Historically, the _ex variants separated the zval first, if a
conversion was necessary. This distinction no longer makes sense
since PHP 7.

The only difference that was still left is that _ex checked whether
the type is the same first, but the usage of these macros did not
actually distinguish on whether such an inlined check is valuable
or not in a given context.

Also drop the unused convert_to_explicit_type macros.
2021-01-14 12:11:11 +01:00
Nikita Popov
c61390cfb4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80425
2020-11-27 10:03:21 +01:00
Nikita Popov
5240f8391f Fixed bug #80425
Rename the methods in MessageFormatAdapter to make sure they don't
clash with anything defined by icu itself, which may be a problem
if icu is linked statically.
2020-11-27 10:02:00 +01:00
Nikita Popov
975735c027 Use true/false instead of TRUE/FALSE in intl
And drop the U_DEFINE_TRUE_AND_FALSE flag.
2020-11-09 14:44:11 +01:00
Christoph M. Becker
49ca191667 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Split tests for compatibility with ICU 68.1
2020-11-06 17:44:51 +01:00
Christoph M. Becker
77b6e95d92 Split tests for compatibility with ICU 68.1 2020-11-06 17:42:39 +01:00
Máté Kocsis
d6264b0966
Verify parameter names of function aliases
Closes GH-6335
2020-10-16 10:56:33 +02:00
Nikita Popov
5e34744fd9 Initialize calendar_long variable
As reported by cmb, this results a VC runtime warning. I don't
believe there's a problem here, as we only use calendar_long if
both calendar_is_null and calendar_obj are not set, but it doesn't
hurt to initialize it either...
2020-10-14 11:57:05 +02:00
Máté Kocsis
186612e4d7
Improve parameter names in ext/intl
Closes GH-6309
2020-10-12 18:06:45 +02:00
Nikita Popov
6edad1716d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  intl: report more information about message pattern parse errors
2020-10-12 16:44:18 +02:00
Philip Hofstetter
74cf2eb83f intl: report more information about message pattern parse errors
The message patterns can be pretty complex, so reporting a generic
U_PARSE_ERROR without any additional information makes it needlessly
hard to fix erroneous patterns.

This commit makes use of the additional UParseError* parameter to
umsg_open to retrieve more details about the parse error to report that
to the user via intl_get_error_message()

Additional improve error reporting from the IntlMessage constructor.
Previously, all possible failures when calling IntlMessage::__construct()
would be masked away with a generic "Constructor failed" message.
This would include invalid patterns.

This commit makes sure that the underlying error that caused the
constructor failure is reported as part of the IntlException error
message.

Closes GH-6325.
2020-10-12 16:42:41 +02:00
Máté Kocsis
503999910b
More precise type information for datefmt_format() 2020-10-09 11:05:42 +02:00
Nikita Popov
f82414e935 Fix out of bounds offset handling with empty needle
For strrpos with positive out of bounds offsets was not detected.
2020-10-01 16:41:51 +02:00
Christian Schneider
7af24eaedd Allow empty needle in grapheme_str*pos, grapheme_str*str
For consistency with str* and mb_str* functions.

Closes GH-6245.
Closes php/php-tasks#20.
2020-10-01 16:33:58 +02:00
Matteo Beccati
43ce7846d2 Skip test with ICU version < 58 2020-09-26 10:47:56 +02:00
George Peter Banyard
a91cb2f48c Promote warning to ValueError for Spoofchecker::setRestrictionLevel()
Closes GH-6197
2020-09-25 17:55:31 +01:00
Nikita Popov
13b791c79c Normalize substr() behavior
Make the behavior of substr(), mb_substr(), iconv_substr() and
grapheme_substr() consistent when it comes to the handling of
out of bounds offsets. substr() will now always clamp out of
bounds offsets to the string boundary. Cases that previously
returned false will now return an empty string. This means that
substr() itself *always* returns a string now (like mb_substr()
already did before.)

Closes GH-6182.
2020-09-25 09:58:21 +02:00
Nikita Popov
73631e517f Try to fix test 2020-09-22 17:04:06 +02:00
Nikita Popov
6436ddbfc8 Handle out-of-bounds offset consistently in grapheme_* API
Make sure we throw the same kind of error regardless of whether
the offset is out-of-bounds in the fast path or in the slow
path.
2020-09-22 17:01:06 +02:00
Nikita Popov
1312c417de Fix grapheme out of bounds check
An offset equal to the string length is not out of bounds.
2020-09-22 16:38:53 +02:00
George Peter Banyard
ddd99a7005 Drop -1 mode for collator_is_numeric()
It is used only once with allow_errors enabled
2020-09-21 16:29:10 +01:00
George Peter Banyard
2b6f5eec6c Drop Hex support in numeric strings for Intl collator
Support for this was removed in PHP 7.0.

See: https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings
2020-09-21 16:29:10 +01:00
Máté Kocsis
e950ca13ea
Consolidate the usage of "either" and "one of" in error messages
Closes GH-6173
2020-09-20 19:41:47 +02:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Máté Kocsis
c76910cd96
Display types in stubs more uniformly
In preparation for generating method signatures for the manual.

This change gets rid of bogus false|null return types, a few unnecessary trailing backslashes, and settles on using ? when possible for nullable types.
2020-09-16 21:19:36 +02:00
Máté Kocsis
46c0c82a0f
Declare array|int and object-of-class|int types in stubs
Closes GH-6081

Co-Authored-By: Nikita Popov <nikic@php.net>
2020-09-14 11:59:32 +02:00
Máté Kocsis
c98d47696f
Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Máté Kocsis
9975986b7e
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +02:00
Máté Kocsis
fd0b39905c
Promote warnings to exceptions in ext/intl
Closes GH-5972
2020-09-07 19:46:55 +02:00
Máté Kocsis
8107a1da5a
Use ZPP instead of custom type checks
We can add these types as a native type declaration to stubs as a side-effect. Closes GH-6068
2020-09-04 14:32:34 +02:00
Máté Kocsis
f7fbc6333f
Add more precise type info for stubs
Closes GH-6005
2020-09-01 16:35:56 +02:00
Nikita Popov
f593019819 Prevent ResourceBundle double-construction 2020-08-26 10:25:15 +02:00
Nikita Popov
6b554251f7 Prevent double-construction of NumberFormatter 2020-08-26 10:25:09 +02:00
Nikita Popov
72eaf509d3 Prevent double-construction of IntlGregorianCalendar 2020-08-26 10:24:57 +02:00
Nikita Popov
f6e5cc3391 Prevent double-construction of IntlRuleBasedBreakIterator 2020-08-26 10:03:28 +02:00
Nikita Popov
647fb38d58 Ensure RuleBasedBreakIterator constructor throws on failure
Constructors must throw on failure indepdendent of the configured
intl error mode.
2020-08-25 15:28:58 +02:00
Nikita Popov
259d050a39 Clean up BreakIterator create_object handler
Use standard zend_object_alloc() function and fix the
object_init_properties() call (which works out okay because there
are no properties).
2020-08-25 13:11:43 +02:00
Nikita Popov
da0a0a13be Fixed bug #79946
Declare __STDC_CONSTANT_MACROS and __STDC_FORMAT_MACROS via -D
to make sure they are declared before the first stdint.h include.
We also define these in php_stdint.h, but don't always include that
file first.

This is necessary for old compilers that use C99 rather than C11
semantics for stdint.h.
2020-08-10 09:52:22 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Máté Kocsis
046cc5e4c2
Add another round of missing parameter types to stubs
Closes GH-5950
2020-08-07 16:48:45 +02:00
Nikita Popov
8b77c58130 Accept zend_object* in zend_update_property 2020-08-07 16:40:27 +02:00
Máté Kocsis
79981a394e
Add a bunch of missing argument types to stubs 2020-08-03 00:45:51 +02:00
George Peter Banyard
f78a091014 Warning to ValueError promotion in Intl extension Part 1
Affects:
- IntlCalendar
- IntlGregorianCalendar
- IntlBreakIterator

Closes GH-5669
2020-07-31 13:27:22 +01:00
Máté Kocsis
0d330e1a02
Add a few missing parameter types in stubs
Related to GH-5627
2020-07-30 14:26:45 +02:00
Nikita Popov
27ad19c3e8 Validate collator earlier during sort
Check this once before the sort, instead of on every compare.
Also directly store the UCollator to make things more obvious.
2020-07-24 11:58:10 +02:00
Nikita Popov
545928e4b8 Fix some clang warnings 2020-07-23 10:35:40 +02:00
Nikita Popov
4ce9571978 Fix UConvert::getErrorMessage() leak on zpp failure 2020-07-21 12:05:44 +02:00
Nikita Popov
4903f7c5fd Fix IntlGregorianCalendar constructor signature
Give these conversative UNKNOWN defaults and no types, as the
overload is something of a mess.
2020-07-17 12:47:25 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00
Nikita Popov
302933daea Remove no_separation flag 2020-07-07 09:30:24 +02:00
Nikita Popov
e93aca7167 Explicitly create references in UConverter callbacks
And don't allow separation.
2020-07-07 09:29:21 +02:00
Máté Kocsis
91fbd12d57
Fix a few comments 2020-07-06 21:23:35 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
312201dce4 Add get_gc handle for object iterators
Optional handler with the same semantics as the object handler.
2020-07-01 15:17:22 +02:00
Máté Kocsis
30067894fc
Update outdated arginfo hashes 2020-06-30 16:02:11 +02:00
George Peter Banyard
892b32d839 Drop non-well numeric string in Intl test 2020-06-28 19:30:07 +02:00
Nikita Popov
ff19ec2df3 Introduce InternalIterator
Userland classes that implement Traversable must do so either
through Iterator or IteratorAggregate. The same requirement does
not exist for internal classes: They can implement the internal
get_iterator mechanism, without exposing either the Iterator or
IteratorAggregate APIs. This makes them usable in get_iterator(),
but incompatible with any Iterator based APIs.

A lot of internal classes do this, because exposing the userland
APIs is simply a lot of work. This patch alleviates this issue by
providing a generic InternalIterator class, which acts as an
adapater between get_iterator and Iterator, and can be easily
used by many internal classes. At the same time, we extend the
requirement that Traversable implies Iterator or IteratorAggregate
to internal classes as well.

Closes GH-5216.
2020-06-24 15:31:41 +02:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
Nikita Popov
15846ff115 Add ZVAL_OBJ_COPY macro
For the common ZVAL_OBJ + GC_ADDREF pattern.
This mirrors the existing ZVAL_STR_COPY API.
2020-06-17 16:36:56 +02:00
Nikita Popov
257dbb0450 Add zend_call_known_function() API family
This adds the following APIs:

void zend_call_known_function(
    zend_function *fn, zend_object *object, zend_class_entry *called_scope,
    zval *retval_ptr, int param_count, zval *params);

void zend_call_known_instance_method(
    zend_function *fn, zend_object *object, zval *retval_ptr, int param_count, zval *params);
void zend_call_known_instance_method_with_0_params(
    zend_function *fn, zend_object *object, zval *retval_ptr);
void zend_call_known_instance_method_with_1_params(
    zend_function *fn, zend_object *object, zval *retval_ptr, zval *param);
void zend_call_known_instance_method_with_2_params(
    zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2);

These are used to perform a call if you already have the
zend_function you want to call. zend_call_known_function()
is the base API, the rest are just really thin wrappers around
it for the common case of instance method calls.

Closes GH-5692.
2020-06-09 16:21:54 +02:00
Máté Kocsis
596561009c
Fix some UNKNOWN default values
In ext/ffi, ext/intl, ext/mysqli, and ext/pcntl
2020-06-09 09:46:51 +02:00
Máté Kocsis
aa9b0ccda8
Add tests to check mismatching function signatures
Closes GH-5666
2020-06-06 09:23:34 +02:00
George Peter Banyard
4c6ecc820b Refactor IntlBreakIterator::next() handling 2020-06-05 22:16:33 +02:00
George Peter Banyard
7af0466044 Convert code path which should never happen to assertion 2020-06-05 22:11:06 +02:00
Christoph M. Becker
46d2a981dd Update intl test suite for ICU 67.1
Cherry-picked from c915c60171.
2020-06-05 10:51:51 +02:00
George Peter Banyard
97757e759d Fix weird zend_bool usage in Intl Calendar::roll() method
This code really needs to be review as it's convoluted for no good reason.
2020-06-04 22:56:10 +02:00
Christoph M. Becker
864fb0ec23 Implement #47074: phpinfo() reports "On" as 1 for the some extensions
What is modified as boolean, should also be displayed as boolean.
2020-06-04 11:25:45 +02:00
Máté Kocsis
fbe30592d6
Improve type error messages when an object is given
From now on, we always display the given object's type instead of just reporting "object".
Additionally, make the format of return type errors match the format of argument errors.

Closes GH-5625
2020-05-26 19:06:19 +02:00
George Peter Banyard
ea8686540a Fix [-Wundef] warning in INTL extension 2020-05-20 18:22:10 +02:00
George Peter Banyard
1f05966a41 Use new Fast ZPP macros for string|int parar types
Closes GH-5512
2020-05-13 12:07:02 +02:00
Nikita Popov
28af364d2a Deprecate old ReflectionParameter type declaration APIs
This deprecates:

    ReflectionParameter::isArray()
    ReflectionParameter::isCallable()
    ReflectionParameter::getClass()

These APIs have been superseded by ReflectionParameter::getType()
since PHP 7.0. Types introduced since that time are not available
through the old APIs, and their behavior is getting increasingly
confusing. This is how they interact with PHP 8 union types:

 * isArray() will return true if the type is array or ?array,
   but not any other union type
 * Same for isCallable().
 * getClass() will return a class for T|int etc, as long as the
   union only contains a single type. T1|T2 will return null.

This behavior is not particularly reasonable or useful, and will
get more confusing as new type system extensions are added.

Closes GH-5209.
2020-05-11 17:01:40 +02:00
Máté Kocsis
4a816584a4
Make float to string casts locale-independent
From now on, float to string casting will always behave locale-independently.
RFC: https://wiki.php.net/rfc/locale_independent_float_to_string
Closes GH-5224

Co-authored-by: George Peter Banyard <girgias@php.net>
2020-05-08 10:52:23 +02:00
Christoph M. Becker
c915c60171 Update intl test suite for ICU 67.1 2020-04-24 11:24:44 +02:00
vibhutisawant
481caf17bc Fix Bug #79431 Various compiler warnings on Big endian architecture with GCC 5.4.0
Fix [-Werror=maybe-uninitialized] compilation warnings on big endian system

Closes GH-5373
2020-04-15 23:30:06 +02:00
George Peter Banyard
04ab4d09be Add Intl resource bundle files for big-endian architecture.
Little and Big endian files have their own designated folder.
Both use the ASCII charset family.
We may want to add a big-endian/EBCDIC charset family resource bundle in the future.

The build script is currently left untouched as it seems to mostly be for Windows.
2020-04-14 15:30:01 +02:00
Máté Kocsis
f00bcfbb7d
Generate method entries for ext/intl
Closes GH-5370
2020-04-14 13:39:00 +02:00