### Install Spatie Invade Source: https://github.com/spatie/invade/blob/main/README.md Installs the Spatie Invade package using Composer. This is the primary method for adding the package to your PHP project. ```bash composer require spatie/invade ``` -------------------------------- ### Run Tests Source: https://github.com/spatie/invade/blob/main/README.md Executes the test suite for the Spatie Invade package using Composer. This command verifies the functionality and stability of the package. ```bash composer test ``` -------------------------------- ### Accessing Private Object Properties and Methods Source: https://github.com/spatie/invade/blob/main/README.md Demonstrates how to use the `invade` function to access and modify private properties, and call private methods on an object instance. It shows reading, writing, and invoking private members. ```php class MyClass { private string $privateProperty = 'private value'; private function privateMethod(): string { return 'private return value'; } } $myClass = new MyClass(); // Get private property echo invade($myClass)->privateProperty; // Set private property invade($myClass)->privateProperty = 'changed value'; echo invade($myClass)->privateProperty; // Call private method echo invade($myClass)->privateMethod(); ``` -------------------------------- ### Accessing Private Static Class Properties and Methods Source: https://github.com/spatie/invade/blob/main/README.md Illustrates how to use the `invade` function with a class name to access and modify private static properties, and call private static methods. This is useful for interacting with class-level private members. ```php class MyClass { private static string $privateStaticProperty = 'privateValue'; private static function privateStaticMethod(string $string, int $int): string { return 'private return value ' . $string . ' ' . $int; } } // Get private static property echo invade(MyClass::class)->get('privateStaticProperty'); // Set private static property invade(MyClass::class)->set('privateStaticProperty', 'changedValue'); echo invade(MyClass::class)->get('privateStaticProperty'); // Call private static method echo invade(MyClass::class) ->method('privateStaticMethod') ->call('foo', 123); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.