Download the PHP package rezen/proxyz without Composer
On this page you can find all versions of the php package rezen/proxyz. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package proxyz
Short Description A library to make it easier to change native php functions behaviour
License MIT
Homepage https://github.com/rezen/proxyz
Informations about the package proxyz
proxyz
If you are trying to test a PHP application and want to override file_get_contents
response, you're in for a heap of fun (okay, so not fun). Really, any function that interacts with stateful bits is annoying. PHP has so many functions (not objects) that are in the global namespace that make testing hard. Also if you are writing a plugin for WordPress, you are using functions in the global namespace which you can not overwrite. To mitigate some of this pain, what you need is a method proxy. A method proxy will allow you to override or watch the behaviour of a function in the global namespace effortlessly.
Install
composer require rezen/proxyz
Example
In your app, wherever you init and configure things, add a wrapper
Wherever you need to override the file_get_contents
, import the namespaced function.
Override a class when need be!
Testing
Todo
- Code rewriter for detecting native functions and adding
use
imports - Improve WordPress references
- Currently ~20+ functions have variable references
ag --php '\&\$' --ignore *class* --nofilename | awk '$1=$1' | grep '^function' | grep '_' | grep -v 'tion _' | grep -v sodium | cut -d ' ' -f2 | cut -d'(' -f1 | sort | uniq
- Functions
- add_comment_to_entry
- crypto_generichash_final
- crypto_generichash_update
- feed_start_element
- get_page_hierarchy
- merge_originals_with
- merge_with
- recurse_dirsize
- separate_comments
- translate_entry
- update_page_cache
- update_post_cache
- update_post_caches
- wp_add_id3_tag_data
- wp_cache_get
- wp_get_post_revision
- wp_getimagesize
- wp_handle_sideload
- wp_handle_upload
- wp_handle_upload_error
- wp_kses_attr_check
- wp_parse_str
- Currently ~20+ functions have variable references