question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to access property promotion in php8 ?

See original GitHub issue

for example a class like

final class CurrencyFactory
{
    private $currencyList;

    /**
     * @param array<string, mixed> $currencies
     */
    public function __construct(private array $currencies)
    {
    }
}
  • parser config
const parser = new PhpParser.Engine({
    parser: {
        extractDoc: true,
    },
    ast: {
        withPositions: true
    }
});

the propertystatement only have $currencyList, but how to get $currencies info aswell?

am not sure if this is a bug or am missing a config option, any help is appreciated.

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:6

github_iconTop GitHub Comments

0reactions
ctf0commented, Dec 17, 2022

@deakjahn many many thanks for your help & quick response, deeply appreciate it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PHP 8: Constructor property promotion - Stitcher.io
In short: property promotion allows you to combine class fields, constructor definition and variable assignments all into one syntax, in the ...
Read more >
PHP 8.0: Class constructor property promotion
Constructor Property Promotion is a new syntax in PHP 8 that allows class property declaration and constructor assignment right from the constructor.
Read more >
Constructor property promotion in PHP 8 - Mindsers Blog
PHP 8 provides a solution to this problem through the promotion of constructor properties. The two examples are identical. But watch how promoted...
Read more >
New Features - Manual - PHP
Support for constructor property promotion (declaring properties in the constructor signature) has ... These are the same as %g and %G , but...
Read more >
PHP 8: Constructor property promotion - phpGrid
PHP 8 : Constructor property promotion · The Promoted properties can have default value · It's OK to combine promoted and normal properties...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found