johnpbloch / invade
A copy of the invade function from Livewire
Installs: 11 116
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >7.4.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-12-11 23:47:45 UTC
README
Invade is a utility library shamelessly stolen from Livewire for Laravel. Using invade()
, you can easily access all private and protected properties and methods of a class. This is nothing revolutionary or complicated, but it is terribly convenient. I created this as its own package for two reasons:
- I wanted to be able to require this function as a dev dependency, since I don't love the idea of this function being available in non-dev installations
- I wanted to use it in non-Laravel codebases
Installation
composer require --dev johnpbloch/invade
Usage
# supposing there is a class like this: class StateManager { private $dataYouAreDebugging = []; /* ... */ } # and supposing you have an instance of StateManager and you need to see that data: /** @var StateManager $instance */ \var_dump(\invade($instance)->dataYouAreDebugging);
invade()
will also give you the ability to set non-public properties and to call non-public methods.