-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-2124: Ensure that null is still accepted for optional parameters #1347
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ final class ClientEncryption | |
|
||
final public function __construct(array $options) {} | ||
|
||
final public function createDataKey(string $kmsProvider, array $options = []): \MongoDB\BSON\Binary {} | ||
final public function createDataKey(string $kmsProvider, ?array $options = null): \MongoDB\BSON\Binary {} | ||
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. Was it necessary to change the default value from I had used the following for in my proposed changes for #1339:
This satisfied a PHPT test I created with an explicit 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. This was mainly done for consistency, as omitting the parameter and passing an explicit |
||
|
||
#if PHP_VERSION_ID >= 80000 | ||
final public function decrypt(\MongoDB\BSON\Binary $value): mixed {} | ||
|
@@ -51,10 +51,10 @@ final public function decrypt(\MongoDB\BSON\Binary $value) {} | |
#endif | ||
|
||
#if PHP_VERSION_ID >= 80000 | ||
final public function encrypt(mixed $value, array $options = []): \MongoDB\BSON\Binary {} | ||
final public function encrypt(mixed $value, ?array $options = null): \MongoDB\BSON\Binary {} | ||
#else | ||
/** @param mixed $value */ | ||
final public function encrypt($value, array $options = []): \MongoDB\BSON\Binary {} | ||
final public function encrypt($value, ?array $options = null): \MongoDB\BSON\Binary {} | ||
#endif | ||
|
||
final public function __wakeup(): void {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* This is a generated file, edit the .stub.php file instead. | ||
* Stub hash: 516a26c70864397ba986d9855f4f876fe84bceb9 */ | ||
* Stub hash: 4b4373da62f18f2c3ab6aae78a495ed84adbe09b */ | ||
|
||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Manager___construct, 0, 0, 0) | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, uri, IS_STRING, 1, "null") | ||
|
@@ -66,7 +66,7 @@ ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_executeReadCommand, 0, 2, MongoDB\\Driver\\Cursor, 0) | ||
ZEND_ARG_TYPE_INFO(0, db, IS_STRING, 0) | ||
ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0) | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") | ||
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. I was wondering why this diff was smaller than the stub file. Looks like |
||
ZEND_END_ARG_INFO() | ||
|
||
#define arginfo_class_MongoDB_Driver_Manager_executeReadWriteCommand arginfo_class_MongoDB_Driver_Manager_executeReadCommand | ||
|
@@ -102,7 +102,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_sele | |
ZEND_END_ARG_INFO() | ||
|
||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Manager_startSession, 0, 0, MongoDB\\Driver\\Session, 0) | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") | ||
ZEND_END_ARG_INFO() | ||
|
||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Manager___wakeup, 0, 0, IS_VOID, 0) | ||
|
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.
I take it this was always inconsistent, as the constructor has always required 1 parameter and uses
Z_PARAM_STRING
.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.
That is correct - this may be due to me being lazy and using PHPStorm's stubs as base for these and subsequently forgetting to double-check this method: https://github.com/JetBrains/phpstorm-stubs/blob/9d134fcc6c8d4cbb8ffd8e65e25a49fea18a7a0d/mongodb/mongodb.php#L2015