Download the PHP package daveross/phpoverloading without Composer

On this page you can find all versions of the php package daveross/phpoverloading. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpoverloading

PHP Overloading Build Status Latest Stable Version Total Downloads License

PHP trait providing a form of method overloading in PHP. Useful when porting code from languages which support method overloading, and that's about the only time you should seriously consider using this library.

Seriously, if you're thinking of using it for new PHP code, ask yourself why. There's no reason to add this kind of overhead, not to mention the cognitive load of weird method names, just to overload methods. PHP has gone this long without native method overloading. It can go longer without it.

Just stop. Think of the children.

License

MIT

See why I contribute to open source software.

Buy me a coffee

Contributing

Pull requests are welcome. Unit tests are encouraged but not required.

Installation

Using composer

Put the require statement for phpoverloading in your composer.json file and run composer install or php composer.phar install:

Manually

Include the file in the src directory, or individual files as needed:

Using

Begin by applying the trait to your class by having inside the class body.

Supported parameter types

All of PHP's native types are recognized:

In addition, the trait recognizes class names and class hierarchies.

A note on method naming

PHP doesn't allow functions or methods to have the same name. That's probably the biggest obstacle to actual method overloading. So you'll need to append the parameter types to each function's name.

For example, if you had two methods named , one taking a string and one taking an array, you'd name them and , but when you called then you'd just reference and pass a string or array and magic happens.

If a method takes more than one parameter, their types are concatenated together in the function name, separated by underscores as in . Overloaded methods can take different numbers of parameters.

Constructors are like any other functions. You can have and if you want. But there's also a suffix (i.e. ) for a default constructor, called when there aren't any parameters passed to the constructor.

The class hierarchy

Say you have these classes:

If you call Foo's constructor and pass an instance of class B, the trait won't find a matching function, so it'll follow the object hierarchy and call instead, passing the instance of B.

If there wasn't a method, it would look for as a fallback.

Constructor overloading

Method overloading


All versions of phpoverloading with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package daveross/phpoverloading contains the following files

Loading the files please wait ....