Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract property hook bodies properly #172

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xHeaven
Copy link

@xHeaven xHeaven commented Jan 23, 2025

This PR aims to fix this issue: tempestphp/tempest-framework#866

Reproduction:

$printer = new Printer();
$from = ClassType::from(Foo::class, withBodies: true);
$fromCode = ClassType::fromCode(file_get_contents(__DIR__ . '/Foo.php'));
echo $printer->printClass($from) . PHP_EOL;
echo $printer->printClass($fromCode);

// Foo.php
class Foo
{
    public $bar {
        get => 'test string';
    }
}

Output before:

class Foo
{
	public $bar {
		get {
		}
	}
}

class Foo
{
	public $bar {
		get => 'test string';
	}
}

Output after:

class Foo
{
	public $bar {
		get => 'test string';
	}
}

class Foo
{
	public $bar {
		get => 'test string';
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant