summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-02-15 12:25:55 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-02-15 12:27:25 +0100
commitc91ea947b201435428f9f7d67a83a210b9af2621 (patch)
treef39b23ec0c57fd418dfd9ee4d4335f603e6cfee6
parent2ccf6309176d8bcba0245da16a4ab497ece24719 (diff)
downloadphp-git-c91ea947b201435428f9f7d67a83a210b9af2621.tar.gz
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.
-rw-r--r--ext/intl/transliterator/transliterator.stub.php3
-rw-r--r--ext/intl/transliterator/transliterator_arginfo.h6
-rw-r--r--ext/intl/transliterator/transliterator_class.c33
3 files changed, 11 insertions, 31 deletions
diff --git a/ext/intl/transliterator/transliterator.stub.php b/ext/intl/transliterator/transliterator.stub.php
index c893e111f0..e8e147ac8e 100644
--- a/ext/intl/transliterator/transliterator.stub.php
+++ b/ext/intl/transliterator/transliterator.stub.php
@@ -4,8 +4,7 @@
class Transliterator
{
- /** @var string|null */
- public $id;
+ public string $id;
final private function __construct() {}
diff --git a/ext/intl/transliterator/transliterator_arginfo.h b/ext/intl/transliterator/transliterator_arginfo.h
index 0e5249493f..1cf928b7b8 100644
--- a/ext/intl/transliterator/transliterator_arginfo.h
+++ b/ext/intl/transliterator/transliterator_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 2ea0ba060d9b3cb9a7e8ca4a5932c755bf8df7d0 */
+ * Stub hash: c34871965e0d58bb15beda1787b7cdd0754bb28f */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Transliterator___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
@@ -59,9 +59,9 @@ zend_class_entry *register_class_Transliterator()
class_entry = zend_register_internal_class_ex(&ce, NULL);
zval property_id_default_value;
- ZVAL_NULL(&property_id_default_value);
+ ZVAL_UNDEF(&property_id_default_value);
zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, 1);
- zend_declare_property_ex(class_entry, property_id_name, &property_id_default_value, ZEND_ACC_PUBLIC, NULL);
+ zend_declare_typed_property(class_entry, property_id_name, &property_id_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
zend_string_release(property_id_name);
return class_entry;
diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c
index 9959be91c1..0ca4fda755 100644
--- a/ext/intl/transliterator/transliterator_class.c
+++ b/ext/intl/transliterator/transliterator_class.c
@@ -189,19 +189,10 @@ err:
/* {{{ get_property_ptr_ptr handler */
static zval *Transliterator_get_property_ptr_ptr( zend_object *object, zend_string *name, int type, void **cache_slot )
{
- zval *retval;
-
- if(zend_binary_strcmp( "id", sizeof( "id" ) - 1,
- ZSTR_VAL( name ), ZSTR_LEN( name ) ) == 0 )
- {
- retval = NULL; /* fallback to read_property */
+ if (zend_string_equals_literal(name, "id")) {
+ return NULL; /* fallback to read_property */
}
- else
- {
- retval = zend_std_get_property_ptr_ptr( object, name, type, cache_slot );
- }
-
- return retval;
+ return zend_std_get_property_ptr_ptr( object, name, type, cache_slot );
}
/* }}} */
@@ -210,15 +201,10 @@ static zval *Transliterator_read_property( zend_object *object, zend_string *nam
{
zval *retval;
- if( ( type != BP_VAR_R && type != BP_VAR_IS ) &&
- ( zend_binary_strcmp( "id", sizeof( "id" ) - 1,
- ZSTR_VAL( name ), ZSTR_LEN( name ) ) == 0 ) )
- {
+ if ((type != BP_VAR_R && type != BP_VAR_IS) && zend_string_equals_literal(name, "id")) {
zend_throw_error(NULL, "Transliterator::$id is read-only");
retval = &EG( uninitialized_zval );
- }
- else
- {
+ } else {
retval = zend_std_read_property( object, name, type, cache_slot, rv );
}
@@ -238,14 +224,9 @@ static zval *Transliterator_write_property( zend_object *object, zend_string *na
} else {
scope = zend_get_executed_scope();
}
- if( ( scope != Transliterator_ce_ptr ) &&
- ( zend_binary_strcmp( "id", sizeof( "id" ) - 1,
- ZSTR_VAL( name ), ZSTR_LEN( name ) ) == 0 ) )
- {
+ if ((scope != Transliterator_ce_ptr) && zend_string_equals_literal(name, "id")) {
zend_throw_error(NULL, "Transliterator::$id is read-only");
- }
- else
- {
+ } else {
value = zend_std_write_property( object, name, value, cache_slot );
}