Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Set const value to class const #73

Answered by mabar
pilot114 asked this question in Q&A
Discussion options

is it possible to use a constant as a value?

example:

$class
 ->addConstant('TYPE', '\Foo\Bar::class') // not string ???
 ->setVisibility('protected');

generated:
protected const TYPE = '\Foo\Bar::class';
i need:
protected const TYPE = \Foo\Bar::class;

You must be logged in to vote
$class
 ->addConstant('TYPE', new \Nette\PhpGenerator\Literal('\Foo\Bar::class'))
 ->setVisibility('protected');

Replies: 2 comments

Comment options

$class
 ->addConstant('TYPE', new \Nette\PhpGenerator\Literal('\Foo\Bar::class'))
 ->setVisibility('protected');
You must be logged in to vote
0 replies
Answer selected by dg
Comment options

thx!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #73 on December 26, 2020 19:17.

AltStyle によって変換されたページ (->オリジナル) /