PHP code example of reecem / mocker

1. Go to this page and download the library: Download reecem/mocker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

reecem / mocker example snippets


...
public function __construct($objectArg, string $arg) 
{
    $this->value    = $objectArg->value; // this will be picked up
    $this->name     = $arg;
}
...


use ReeceM\ReflectionMockery;

/**
 * The class __construct Method is automatically read and args created
 */
$mock = new ReflectionMockery('\App\User');
// or
$mock = new ReflectionMockery(new \ReflectionClass('\App\User'));

// some time later

/**
 * Use call a variable from the class that don't exist
 */
{{ $mock->get('somethingNotInUser') }}
{{ $mock->somethingNotInUser }}

// both would return 

"mock->somethingNotInUser"
// if something was set in user
'mock->somethingNotInUser => ["value that set"]'