Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monish-khatri/8019a4e2138c59d3f68cef8b9d869a70 to your computer and use it in GitHub Desktop.
Save monish-khatri/8019a4e2138c59d3f68cef8b9d869a70 to your computer and use it in GitHub Desktop.
<?php
// Before
class BeforeTest {
private string $name = 'Monish';
public function getName() {
return $this->name;
}
}
echo (new BeforeTest)->getName(); // Output: Monish
// After
class AfterTest {
private string $name = 'Monish';
}
echo (fn() => $this->name)->call(new AfterTest); // Output: Monish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment