alecrabbit/php-sneaky-peek
Private and protected properties and methods accessors. NOT FOR PRODUCTION USE.
Maintainers
0.0.4
2024-03-06 08:30 UTC
Requires
- php: >=8.2
Requires (Dev)
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT f6e1611a6aae30f89c4375abf7a58427fc248f12
This package is auto-updated.
Last update: 2026-06-29 02:16:23 UTC
README
👁 Latest Stable Version
👁 Packagist Pre Release Version
👁 Latest Unstable Version
A function to get a peek at private parts of an object.
Installation
composer require --dev alecrabbit/php-sneaky-peek
This package is intended for DEVELOPMENT purposes only.
Usage
class Awesome { private $secret = '1234'; protected function protectedMethod() { return 'protected'; } protected static function protectedStaticMethod() { return 'protected static'; } } // ... peek(new Awesome())->secret; // '1234' peek(new Awesome())->protectedMethod(); // 'protected'
In case you want to access static properties or methods you can pass FQCN as an argument instead of an object.
peek(Awesome::class)->protectedStaticMethod(); // 'protected static'
How it is different from spatie/invade?
The main difference is invade can work with objects only, while peek can work with both objects and FQCN(class-string).
