PHPackages                             jorisvanw/mocker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. jorisvanw/mocker

ActiveLibrary[Testing &amp; Quality](/categories/testing)

jorisvanw/mocker
================

Mock class constructor args based on the reflection class

v1.2.3(11mo ago)060↓100%1MITPHP

Since Jun 4Pushed 11mo agoCompare

[ Source](https://github.com/JorisvanW/mocker)[ Packagist](https://packagist.org/packages/jorisvanw/mocker)[ Docs](https://github.com/reecem/mocker)[ Fund](https://www.paypal.me/iexistin3d)[ GitHub Sponsors](https://github.com/reecem)[ RSS](/packages/jorisvanw-mocker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (1)

Reflection Mocker
=================

[](#reflection-mocker)

[ ![](https://camo.githubusercontent.com/773fa681c0f6e20aac83b9ede9e33f173e63f98f22651c20dc867b1cb1fe8de0/68747470733a2f2f636f6465636f762e696f2f67682f52656563654d2f6d6f636b65722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/ReeceM/mocker)[ ![](https://camo.githubusercontent.com/b18aaf932657346c971b3a7f1ee80c3814a0f1e65981e222e85202e9f058910f/68747470733a2f2f7472617669732d63692e636f6d2f52656563654d2f6d6f636b65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/ReeceM/mocker)[![Latest Stable Version](https://camo.githubusercontent.com/8230d179648d8dd59d9fe6c9e203f1d7c9ed212e9585ab2bd1be33b4a9319596/68747470733a2f2f706f7365722e707567782e6f72672f72656563656d2f6d6f636b65722f762f737461626c65)](https://packagist.org/packages/reecem/mocker)[![License](https://camo.githubusercontent.com/6bc32a7a33944b3efdee9bc4bf3369b1fbc2a1ff121a2f3037a0e0608c884aca/68747470733a2f2f706f7365722e707567782e6f72672f72656563656d2f6d6f636b65722f6c6963656e7365)](https://packagist.org/packages/reecem/mocker)[![Downloads](https://camo.githubusercontent.com/111b517c52722bc6e4d6e11a58f235af61b46004b6aa643d5a8d39387c15c6ab/68747470733a2f2f706f7365722e707567782e6f72672f72656563656d2f6d6f636b65722f646f776e6c6f616473)](https://packagist.org/packages/reecem/mocker)

This package is initially made to for an issue on the MailEclipse package, but improvements are welcome. It currently is probably stupid simple, but deals with the one job of reading a file and mocking it.

> Generate a mocked instance of the un-typed params in a \_\_construct() method

This searches the file retrieved from the reflection class and looks for all object like arrow calls; ie:

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

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require reecem/mocker
```

Requirements
------------

[](#requirements)

- Laravel ^5.6 (min)

Usage
-----

[](#usage)

```
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"]'
```

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [ReeceM](https://github.com/ReeceM)
- [All Contributors](../../contributors)

todo
----

[](#todo)

- Add functionality to account for `$this->internal = $param;` searching so it works later on in the code
- Add a translation file for mocked values when testing to give a translated result for previews

Support
-------

[](#support)

Consider supporting some code if it is useful to you 😄

- [MailEclipse](https://github.com/Qoraiche/laravel-mail-editor) "just a small donation from Laravel mail editor owner, thanks for your contributions"

[![Buy Me a Coffee at ko-fi.com](https://camo.githubusercontent.com/c66a3b97bd969f336e4089211ab1a116386b434dfd7f3d793b1248986e7778d2/68747470733a2f2f617a3734333730322e766f2e6d7365636e642e6e65742f63646e2f6b6f6669342e706e673f763d32)](http://bit.ly/2J4ZPBM)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Sponsors
--------

[](#sponsors)

    [ ![](https://user-images.githubusercontent.com/15586492/96636404-2c18dd00-1315-11eb-9520-736dffaaf0a7.png) ](https://www.jetbrains.com/?from=maileclipse)

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance52

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 92.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

339d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61791473a04a2f1535d7cb64d69b6d7f1d715535e64da8a62ec70b6370cdedbb?d=identicon)[JorisvanW](/maintainers/JorisvanW)

---

Top Contributors

[![ReeceM](https://avatars.githubusercontent.com/u/2767904?v=4)](https://github.com/ReeceM "ReeceM (70 commits)")[![blakehooks](https://avatars.githubusercontent.com/u/2652600?v=4)](https://github.com/blakehooks "blakehooks (2 commits)")[![JorisvanW](https://avatars.githubusercontent.com/u/11089853?v=4)](https://github.com/JorisvanW "JorisvanW (2 commits)")[![Qoraiche](https://avatars.githubusercontent.com/u/15586492?v=4)](https://github.com/Qoraiche "Qoraiche (2 commits)")

---

Tags

testinglaravelhelpermockerymockerreecem

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jorisvanw-mocker/health.svg)

```
[![Health](https://phpackages.com/badges/jorisvanw-mocker/health.svg)](https://phpackages.com/packages/jorisvanw-mocker)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M54](/packages/timacdonald-log-fake)[laracasts/testdummy

Easy test stubs

4671.4M35](/packages/laracasts-testdummy)[davestewart/sketchpad

An innovative front-end environment for interactive Laravel development

29512.9k1](/packages/davestewart-sketchpad)[srlabs/laravel-testing-utilities

Helper utilities for testing Laravel Applications

1011.9k](/packages/srlabs-laravel-testing-utilities)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
