Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jclaveau/php-visibility-violator
Library to violate the defined visibility of methods and properties for testing purpose
https://github.com/jclaveau/php-visibility-violator
Last synced: 2 days ago
JSON representation
Library to violate the defined visibility of methods and properties for testing purpose
- Host: GitHub
- URL: https://github.com/jclaveau/php-visibility-violator
- Owner: jclaveau
- License: mit
- Created: 2017-10-05T23:48:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-20T01:56:31.000Z (almost 6 years ago)
- Last Synced: 2024-12-20T08:03:44.088Z (3 days ago)
- Language: PHP
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP Visibility Violator
=============================This class provides simple helpers uppon basic features of the [Reflection API](https://secure.php.net/manual/en/book.reflection.php) to violate the [visibility](http://php.net/manual/en/language.oop5.visibility.php) of properties and methods:
+ Modify or access privates properties of classes and instances
+ Call privates or protected methods## Quality
[![Build Status](https://travis-ci.org/jclaveau/php-logical-filter.png?branch=master)](https://travis-ci.org/jclaveau/php-visibility-violator)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jclaveau/php-visibility-violator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/jclaveau/php-visibility-violator/?branch=master)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/jclaveau/php-visibility-violator/issues)
[![Viewed](http://hits.dwyl.com/jclaveau/php-visibility-violator.svg)](http://hits.dwyl.com/jclaveau/php-visibility-violator)## Installation
The Visibility Violator is available via composer```
composer require jclaveau/php-visibility-violator
```## Usage
```php
use JClaveau\VisibilityViolator\VisibilityViolator;$value = VisibilityViolator::getHiddenProperty($instance, 'property');
$value = VisibilityViolator::getHiddenProperty(MyClass::class, 'static_property');VisibilityViolator::setHiddenProperty($instance, 'property', 'new value');
VisibilityViolator::setHiddenProperty(MyClass::class, 'static_property', 'new value');$return = VisibilityViolator::callHiddenMethod($instance, 'method', $arguments);
$return = VisibilityViolator::callHiddenMethod(MyClass::class, 'staticMethod', ['argument 1', 'argument 2']);
```## Documentation
+ [API Reference](docs)
+ [PHP Visibility Documentation](http://php.net/manual/en/language.oop5.visibility.php)
+ [PHP Reflection Documentation](https://secure.php.net/manual/en/book.reflection.php)
+ [Tests](tests/unit/VisibilityViolatorTest.php)