-
Notifications
You must be signed in to change notification settings - Fork 7.9k
RFC: Constructor behaviour of internal classes #1178
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
Closed
Closed
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b00cd68
Fixed PDORow behaviour and message.
Danack 043a026
Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter.
Danack a519838
Fixed ReflectionExtension and ReflectionProperty.
Danack c57bde7
Fixed SplFixedArray and tests.
Danack 99dae96
Converted intl extension to use IntlException in constructors.
Danack 0922eca
Made Phar throw exception on bad constructor.
Danack 78ebf83
Fixed fileinfo behaviour.
Danack d3267d0
Fixed PDO constructor to not return null.
Danack 9803fcc
Made UConverter throw an exception if the constructor fails.
Danack 6b23264
Reverted change to function name and added note of why it is differen…
Danack 910a324
Fixed indentation. Fixed comment style. Fixed commented out code.
Danack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ extern "C" { | |
#include "dateformat_helpers.h" | ||
|
||
/* {{{ */ | ||
static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) | ||
static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor) | ||
{ | ||
zval *object; | ||
|
||
|
@@ -64,8 +64,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) | |
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll|zzs", | ||
&locale_str, &locale_len, &date_type, &time_type, &timezone_zv, | ||
&calendar_zv, &pattern_str, &pattern_str_len) == FAILURE) { | ||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: " | ||
"unable to parse input parameters", 0); | ||
intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: " | ||
"unable to parse input parameters", 0, is_constructor); | ||
Z_OBJ_P(return_value) = NULL; | ||
return; | ||
} | ||
|
@@ -79,6 +79,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) | |
DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; | ||
|
||
if (DATE_FORMAT_OBJECT(dfo) != NULL) { | ||
// This is __construct being called on an instance - it is not | ||
// a constructor. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C++ comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, | ||
"datefmt_create: cannot call constructor twice", 0); | ||
return; | ||
|
@@ -110,8 +112,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) | |
pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo)); | ||
if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { | ||
/* object construction -> only set global error */ | ||
intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: " | ||
"error converting pattern to UTF-16", 0); | ||
intl_error_set_ex(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: " | ||
"error converting pattern to UTF-16", 0, is_constructor); | ||
goto error; | ||
} | ||
} | ||
|
@@ -139,8 +141,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) | |
df->adoptTimeZone(timezone); | ||
} | ||
} else { | ||
intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date " | ||
"formatter creation failed", 0); | ||
intl_error_set_ex(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date " | ||
"formatter creation failed", 0, is_constructor); | ||
goto error; | ||
} | ||
|
||
|
@@ -175,7 +177,7 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) | |
U_CFUNC PHP_FUNCTION( datefmt_create ) | ||
{ | ||
object_init_ex( return_value, IntlDateFormatter_ce_ptr ); | ||
datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); | ||
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) { | ||
RETURN_NULL(); | ||
} | ||
|
@@ -192,7 +194,7 @@ U_CFUNC PHP_METHOD( IntlDateFormatter, __construct ) | |
/* return_value param is being changed, therefore we will always return | ||
* NULL here */ | ||
return_value = getThis(); | ||
datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); | ||
|
||
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) { | ||
zend_object_store_ctor_failed(Z_OBJ(orig_this)); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, was spaces instead of tab.