Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions internal/jennies/php/rawtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ func (jenny RawTypes) Generate(context languages.Context) (codejen.Files, error)
files := make(codejen.Files, 0, len(context.Schemas))

jenny.shaper = &shape{context: context}
jenny.tmpl = jenny.tmpl.Funcs(templateHelpers(templateDeps{
config: jenny.config,
context: context,
}))
jenny.tmpl = jenny.tmpl.
Funcs(templateHelpers(templateDeps{
config: jenny.config,
context: context,
})).
Funcs(common.TypesTemplateHelpers(context))

// generate typehints with a compiler pass
context.Schemas, err = (&AddTypehintsComments{config: jenny.config}).Process(context.Schemas)
Expand Down
2 changes: 1 addition & 1 deletion internal/jennies/php/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (formatter *typeFormatter) constantRefValue(def ast.ConstantReferenceType)
return formatter.formatEnumValue(obj, def)
}
if obj.Type.IsScalar() {
return formatter.config.fullNamespaceRef(formatPackageName(def.ReferredPkg) + "\\" + formatObjectName(def.ReferredType))
return formatter.config.fullNamespaceRef(formatPackageName(def.ReferredPkg) + "\\Constants::" + formatConstantName(def.ReferredType))
}

return "unknown"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class MyStruct implements \JsonSerializable

public function __construct()
{
$this->aString = \Grafana\Foundation\ConstantReferenceAsDefault\ConstantRefString;
$this->optString = \Grafana\Foundation\ConstantReferenceAsDefault\ConstantRefString;
$this->aString = \Grafana\Foundation\ConstantReferenceAsDefault\Constants::CONSTANT_REF_STRING;
$this->optString = \Grafana\Foundation\ConstantReferenceAsDefault\Constants::CONSTANT_REF_STRING;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GridLayoutUsingValue implements \JsonSerializable
*/
public function __construct(?string $gridLayoutProperty = null)
{
$this->kind = \Grafana\Foundation\ConstantReferenceDiscriminator\GridLayoutKindType;
$this->kind = \Grafana\Foundation\ConstantReferenceDiscriminator\Constants::GRID_LAYOUT_KIND_TYPE;
$this->gridLayoutProperty = $gridLayoutProperty ?: "";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GridLayoutWithoutValue implements \JsonSerializable
*/
public function __construct(?string $gridLayoutProperty = null)
{
$this->kind = \Grafana\Foundation\ConstantReferenceDiscriminator\GridLayoutKindType;
$this->kind = \Grafana\Foundation\ConstantReferenceDiscriminator\Constants::GRID_LAYOUT_KIND_TYPE;
$this->gridLayoutProperty = $gridLayoutProperty ?: "";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RowsLayoutUsingValue implements \JsonSerializable
*/
public function __construct(?string $rowsLayoutProperty = null)
{
$this->kind = \Grafana\Foundation\ConstantReferenceDiscriminator\RowsLayoutKindType;
$this->kind = \Grafana\Foundation\ConstantReferenceDiscriminator\Constants::ROWS_LAYOUT_KIND_TYPE;
$this->rowsLayoutProperty = $rowsLayoutProperty ?: "";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RowsLayoutWithoutValue implements \JsonSerializable
*/
public function __construct(?string $rowsLayoutProperty = null)
{
$this->kind = \Grafana\Foundation\ConstantReferenceDiscriminator\RowsLayoutKindType;
$this->kind = \Grafana\Foundation\ConstantReferenceDiscriminator\Constants::ROWS_LAYOUT_KIND_TYPE;
$this->rowsLayoutProperty = $rowsLayoutProperty ?: "";
}

Expand Down