Commit Graph

110 Commits

Author SHA1 Message Date
Máté Kocsis
305b17e85f
Do not include the same stub multiple times
Closes GH-5322
2020-04-03 14:23:54 +02:00
Christoph M. Becker
7d0102dfa7 Revert "Replace @param annotations with type declarations"
This reverts commit c31029f335.
2020-02-17 08:55:18 +01:00
Christoph M. Becker
c31029f335 Replace @param annotations with type declarations 2020-02-16 23:43:38 +01:00
Christoph M. Becker
6ee6097688 Constrain number parameter of numfmt_format to int|float
This is inline with similar changes to the math functions.  Especially,
array to number conversion makes no sense here, and is likely to hide
a programming error.

To make that feasible, we introduce the `n` specifier for classic ZPP
so we can stick with `zend_parse_method_parameters()`.

We also remove a test case, which has been degenerated to a ZPP test.
2020-02-16 16:48:35 +01:00
Máté Kocsis
86780ff79f
Add stubs for NumberFormatter
Closes GH-4827
2020-02-09 22:10:12 +01:00
Christoph M. Becker
aba6937c0a Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79212: NumberFormatter::format() may detect wrong type
2020-02-03 12:30:42 +01:00
Christoph M. Becker
57b9eca83d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79212: NumberFormatter::format() may detect wrong type
2020-02-03 12:29:43 +01:00
Christoph M. Becker
c2935499b1 Fix #79212: NumberFormatter::format() may detect wrong type
We have to convert to number *before* detecting the type, to cater to
internal objects implementing `cast_object`.

We also get rid of the fallback behavior of using `FORMAT_TYPE_INT32`,
because that can no longer happen; after `convert_scalar_to_number_ex`
the type is either `IS_LONG` or `IS_DOUBLE`.  We cater explicitly to
the `IS_ARRAY` case what also avoids triggering a type confusion when
`::TYPE_INT64` is passed as `$type`.
2020-02-03 12:28:32 +01:00
Christoph M. Becker
1468484296 Fix #74063: NumberFormatter fails after retrieval from session
While it would be desireable to actually support unserialization of
NumberFormatter instances, at least we should not allow serialization
for now.

We also remove some doubtful tests, which have been added[1] claiming
that they would crash the intl extension, but apparently no fix has
been applied, and the test cases have not been marked as XFAIL.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=ed793b2a3f857fd49c0c1b036062140da5b3e674>
2020-01-30 10:13:29 +01:00
Máté Kocsis
019e8d438c
Throw exception for unconstructed intl objects
Closes GH-5052
2020-01-05 23:55:14 +01:00
Máté Kocsis
1b93cfee0c
Use RETURN_THROWS() after zend_parse_method_parameters() 2020-01-02 23:01:37 +01:00
Christoph M. Becker
8060a8507f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78912: INTL Support for accounting format
2019-12-09 16:35:45 +01:00
Christoph M. Becker
505cc77cbe Fix #78912: INTL Support for accounting format
We provide `NumberFormatter::CURRENCY_ACCOUNTING` to wrap
`UNUM_CURRENCY_ACCOUNTING `[1].

[1] <https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/unum_8h.html#a4eb4d3ff13bd506e7078b2be4052266dae97cdd7ed612d07d251021c076efb1c5>
2019-12-09 16:34:56 +01:00
Máté Kocsis
969e7a3c8b Cleanup return values for Intl when parameter parsing is unsuccessful
Closes GH-4871.
2019-10-30 13:21:40 +01:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Nikita Popov
f821256d00 Remove unused is_constructor arguments 2019-07-15 12:36:31 +02:00
Dmitry Stogov
e188e4170f Use ZEND_TRY_ASSIGN_REF_... macros for arguments passed to internal function by reference 2019-04-24 18:28:29 +03:00
Dmitry Stogov
2e4686b566 Use ZEND_TRY_ASSIGN_REF_... macros for arguments passed to internal function by reference 2019-04-24 18:16:47 +03:00
Dmitry Stogov
34db07567d Use ZEND_TRA_ASSIGN_REF_... macros for by reference arguments of internal functions. 2019-04-24 16:14:48 +03:00
Nikita Popov
86ef425177 Intl: Don't separately report "bad arguments" errors
zpp will be throwing for these now, don't report them in addition to
that.
2019-03-11 11:32:20 +01:00
Nikita Popov
513b76794b Make zpp failures always throw, independent of strict_types
Previously zend_parse_parameters (and FastZPP) would handle invalid
arguments depending on strict_types: With strict_types=1, a TypeError
is thrown, with strict_types=0 a warning is thrown and (usually) NULL
is returned. Additionally, some functions (constructors always and
other methods sometimes) opt-it to throwing regardless of strict_types.

This commit changes zpp to always generate a TypeError exception in
PHP 8.
2019-03-11 11:32:20 +01:00
Dmitry Stogov
91ef4124e5 Refactor zend_object_handlers API to pass zend_object* and zend_string* insted of zval(s). 2019-02-04 13:20:25 +03:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Nikita Popov
e219ec144e Implement typed properties
RFC: https://wiki.php.net/rfc/typed_properties_v2

This is a squash of PR #3734, which is a squash of PR #3313.

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
Co-authored-by: Joe Watkins <krakjoe@php.net>
Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2019-01-11 15:49:06 +01:00
Dmitry Stogov
0f7f1498be Use ZEND_THIS macro to hide implementation details in extensions code. 2018-11-15 19:54:19 +03:00
Dmitry Stogov
c6ad0b92b7 Replace getThis() by EX(This), when additional check is not necessary. 2018-11-14 02:44:25 +03:00
Dmitry Stogov
8939c4d96b Get rid of ZEND_ACC_CTOR, ZEND_ACC_DTOR and ZEND_ACC_IMPLEMENTED_ABSTRACT 2018-09-05 13:16:10 +03:00
Christoph M. Becker
3d4fbdade4 Remove needless version checks
As of PHP 5.5.3, we're requiring ICU ≥ 4.0[1] anyway, so there's no
need to check for ICU 3.x.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=8831b00>
2018-08-01 17:53:38 +02:00
Dmitry Stogov
265c3ed6cf Fixed incorrrecr zval_dtor() usage to replace value of argument passed by reference, that may lead to memory leaks. 2018-07-05 10:57:49 +03:00
Dmitry Stogov
f2b4ec4bdc Export standard object handlers, to avoid indirect access 2018-05-31 11:57:22 +03:00
Gabriel Caruso
701437a948
Remove return types from some magic method in protos
__construct, __destruct, __wakeup does not have return types defined.
2018-03-09 12:04:46 +01:00
Christoph M. Becker
a98eb1ec2c [ci skip] Fix reference notation in protos 2018-03-06 13:22:39 +01:00
Gabriel Caruso
b47b3596ef [ci skip] Use float instead of double in proto 2018-03-06 13:16:18 +01:00
Dmitry Stogov
9e709e2fa0 Move constants into read-only data segment 2017-12-14 18:43:44 +03:00
Dmitry Stogov
6a9d2b2190 Cleanup type conversion 2017-12-07 19:24:55 +03:00
Nikita Popov
b72b1a4e4d Add zend_object_alloc() API
Using ecalloc() to create objects is expensive, because the
dynamic-size memset() is unreasonably slow. Make sure we only
zero the main object structure with known size, as the properties
are intialized separately anyway.

Technically we do not need to zero the embedded zend_object
structure either, but as long as the memset argument is constant,
a couple more bytes don't really matter.
2017-11-25 17:12:37 +01:00
Nikita Popov
fc7cfe1c0e Remove superfluous checks of register_internal_class retval 2017-08-25 22:08:59 +02:00
Nikita Popov
29af302395 Remove useless dtor handlers in intl
These are only indirections to the default handler
2016-07-16 23:16:43 +02:00
Dmitry Stogov
323b2733f6 Fixed compilation warnings 2016-06-22 00:40:50 +03:00
Anatol Belski
da15af8b3f fix include order 2016-06-21 18:58:11 +02:00
Dmitry Stogov
1616038698 Added ZEND_ATTRIBUTE_FORMAT to some middind functions.
"%p" replaced by ZEND_LONG_FMT to avoid compilation warnings.
Fixed most incorrect use cases of format specifiers.
2016-06-21 16:00:37 +03:00
Dmitry Stogov
560e4fa393 Removed or simplified incorrect SEPARATE_*() macros usage. 2015-09-29 11:17:43 +03:00
Dmitry Stogov
f7b6de5b5e Cleanup (avoid string reallocations) 2015-07-01 13:26:39 +03:00
Nikita Popov
e74b84a9fe Fix Intl constructor leaks
Drop the Z_OBJ(return_value) = NULL hack and return status code
from ctor function instead.
2015-04-17 10:33:59 +02:00
Nikita Popov
122d759618 Always throw TypeException on throwing zpp failures
Introduces a ZEND_PARSE_PARAMS_THROW flag for zpp, which forces to
report FAILURE errors using a TypeException instead of a Warning,
like it would happen in strict mode.

Adds a zend_parse_parameters_throw() convenience function, which
invokes zpp with this flag.

Converts all cases I could identify, where we currently have
throwing zpp usage in constructors and replaces them with this API.
Error handling is still replaced to EH_THROW in some cases to handle
other, domain-specific errors in constructors.
2015-04-06 11:27:34 +02:00
Dmitry Stogov
1018f462d8 Patch improvement:
Removed the corresponding core code.
Fixed ext/com_dotnet and ext/date.
Refactored ext/intl changes.
Improved ext/fileinfo and ext/pdo changes.
Fixed tests.
2015-03-30 18:53:38 +03:00
Danack
99dae96dc0 Converted intl extension to use IntlException in constructors. 2015-03-15 13:59:48 +00:00
Dmitry Stogov
9e70d7672d Move zend_object->guards into additional slot of zend_object->properties_table[]. As result size of objects without __get/__set/__unset/__isset magic methods is reduced. 2015-02-04 15:24:13 +03:00
Dmitry Stogov
8aa146b810 Fixed use after free 2015-01-26 12:24:33 +03:00
Stanislav Malyshev
b7a7b1a624 trailing whitespace removal 2015-01-10 15:07:38 -08:00