diff --git a/src/Jeeves/Generators/Crud/Interfaces/Model.php b/src/Jeeves/Generators/Crud/Interfaces/Model.php index 2e0b118..77d6513 100644 --- a/src/Jeeves/Generators/Crud/Interfaces/Model.php +++ b/src/Jeeves/Generators/Crud/Interfaces/Model.php @@ -17,6 +17,7 @@ public function genModelInterface( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { + $hasTypedConst = $this->hasTypedConst($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Api\Data'); $interface = $namespace->addInterface($className); @@ -27,7 +28,10 @@ public function genModelInterface( if ($cacheTag !== null) { $namespace->addUse('\Magento\Framework\DataObject\IdentityInterface'); $interface->setExtends('\Magento\Framework\DataObject\IdentityInterface'); - $interface->addConstant('CACHE_TAG', $cacheTag)->setVisibility('public'); + $ctag = $interface->addConstant('CACHE_TAG', $cacheTag)->setVisibility('public'); + if ($hasTypedConst) { + $ctag->setType('string'); + } } if ($withStore) { @@ -48,7 +52,10 @@ public function genModelInterface( if (isset($value['identity']) && $value['identity'] === true) { $generated = true; } - $interface->addConstant(strtoupper($name), strtolower($name))->setPublic(); + $c = $interface->addConstant(strtoupper($name), strtolower($name))->setPublic(); + if ($hasTypedConst) { + $c->setType('string'); + } $method = $this->snakeCaseToUpperCamelCase($name); $get = $interface->addMethod('get' . $method) ->setVisibility('public'); diff --git a/test/Expectations/Crud/83/v1/Api/Data/CardInterface.php b/test/Expectations/Crud/83/v1/Api/Data/CardInterface.php index 111e604..0ba7398 100644 --- a/test/Expectations/Crud/83/v1/Api/Data/CardInterface.php +++ b/test/Expectations/Crud/83/v1/Api/Data/CardInterface.php @@ -9,13 +9,13 @@ */ interface CardInterface extends IdentityInterface { - public const CACHE_TAG = 'samp_card'; - public const CARD_ID = 'card_id'; - public const TITLE = 'title'; - public const CODE = 'code'; - public const CATEGORY_ID = 'category_id'; - public const IS_ACTIVE = 'is_active'; - public const STORE_ID = 'store_id'; + public const string CACHE_TAG = 'samp_card'; + public const string CARD_ID = 'card_id'; + public const string TITLE = 'title'; + public const string CODE = 'code'; + public const string CATEGORY_ID = 'category_id'; + public const string IS_ACTIVE = 'is_active'; + public const string STORE_ID = 'store_id'; /** * Get card id diff --git a/test/Expectations/Crud/83/v1/Api/Data/CartItemInterface.php b/test/Expectations/Crud/83/v1/Api/Data/CartItemInterface.php index ca9f252..a1c43de 100644 --- a/test/Expectations/Crud/83/v1/Api/Data/CartItemInterface.php +++ b/test/Expectations/Crud/83/v1/Api/Data/CartItemInterface.php @@ -4,16 +4,16 @@ interface CartItemInterface { - public const CART_ID = 'cart_id'; - public const IS_ACTIVE = 'is_active'; - public const DELIVERY_DATE = 'delivery_date'; - public const CITY = 'city'; - public const CUSTOMER_GROUP = 'customer_group'; - public const DESCRIPTION = 'description'; - public const CREATED_AT = 'created_at'; - public const UPDATED_AT = 'updated_at'; - public const DISCOUNT = 'discount'; - public const PRICE = 'price'; + public const string CART_ID = 'cart_id'; + public const string IS_ACTIVE = 'is_active'; + public const string DELIVERY_DATE = 'delivery_date'; + public const string CITY = 'city'; + public const string CUSTOMER_GROUP = 'customer_group'; + public const string DESCRIPTION = 'description'; + public const string CREATED_AT = 'created_at'; + public const string UPDATED_AT = 'updated_at'; + public const string DISCOUNT = 'discount'; + public const string PRICE = 'price'; /** * Get cart id diff --git a/test/Expectations/Crud/83/v1/Api/Data/ColumnsInterface.php b/test/Expectations/Crud/83/v1/Api/Data/ColumnsInterface.php index c405527..e9b3745 100644 --- a/test/Expectations/Crud/83/v1/Api/Data/ColumnsInterface.php +++ b/test/Expectations/Crud/83/v1/Api/Data/ColumnsInterface.php @@ -4,17 +4,17 @@ interface ColumnsInterface { - public const ID = 'id'; - public const IS_ACTIVE = 'is_active'; - public const HAS_FLAG = 'has_flag'; - public const MERGE_DATE = 'merge_date'; - public const DISCOUNT = 'discount'; - public const COST = 'cost'; - public const PRICE = 'price'; - public const NAME = 'name'; - public const DESCRIPTION = 'description'; - public const CREATED_AT = 'created_at'; - public const UPDATED_AT = 'updated_at'; + public const string ID = 'id'; + public const string IS_ACTIVE = 'is_active'; + public const string HAS_FLAG = 'has_flag'; + public const string MERGE_DATE = 'merge_date'; + public const string DISCOUNT = 'discount'; + public const string COST = 'cost'; + public const string PRICE = 'price'; + public const string NAME = 'name'; + public const string DESCRIPTION = 'description'; + public const string CREATED_AT = 'created_at'; + public const string UPDATED_AT = 'updated_at'; /** * Get id diff --git a/test/Expectations/Crud/83/v1/Api/Data/PosterInterface.php b/test/Expectations/Crud/83/v1/Api/Data/PosterInterface.php index f2cc4fb..41836d2 100644 --- a/test/Expectations/Crud/83/v1/Api/Data/PosterInterface.php +++ b/test/Expectations/Crud/83/v1/Api/Data/PosterInterface.php @@ -9,13 +9,13 @@ */ interface PosterInterface extends IdentityInterface { - public const CACHE_TAG = 'samp_poster'; - public const ID = 'id'; - public const NAME = 'name'; - public const SUBNAME = 'subname'; - public const FAMILY = 'family'; - public const IS_ACTIVE = 'is_active'; - public const PRODUCT_ID = 'product_id'; + public const string CACHE_TAG = 'samp_poster'; + public const string ID = 'id'; + public const string NAME = 'name'; + public const string SUBNAME = 'subname'; + public const string FAMILY = 'family'; + public const string IS_ACTIVE = 'is_active'; + public const string PRODUCT_ID = 'product_id'; /** * Get id diff --git a/test/Expectations/Crud/83/v1/Api/Data/TicketInterface.php b/test/Expectations/Crud/83/v1/Api/Data/TicketInterface.php index 1326fa3..3ea0569 100644 --- a/test/Expectations/Crud/83/v1/Api/Data/TicketInterface.php +++ b/test/Expectations/Crud/83/v1/Api/Data/TicketInterface.php @@ -4,9 +4,9 @@ interface TicketInterface { - public const TICKET_ID = 'ticket_id'; - public const NAME = 'name'; - public const IS_ACTIVE = 'is_active'; + public const string TICKET_ID = 'ticket_id'; + public const string NAME = 'name'; + public const string IS_ACTIVE = 'is_active'; /** * Get ticket id