PHP code example of neunerlei / container-autowiring-declaration

1. Go to this page and download the library: Download neunerlei/container-autowiring-declaration 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/ */

    

neunerlei / container-autowiring-declaration example snippets


namespace Neunerlei\ContainerAutoWiringDeclaration\Definition;
interface AutoWiringDefinitionProviderInterface {
	
	/**
	 * Adds a new auto wiring definition to the list of registered definitions.
	 *
	 * @param AutoWiringClassInterface $definition
	 *
	 * @return $this
	 */
	public function setAutoWiringDefinition(AutoWiringClassInterface $definition);
	
	/**
	 * Returns a auto wiring definition object for the given class name.
	 *
	 * @param string $className The name of the class to get the definition object for
	 *
	 * @return AutoWiringClassInterface
	 */
	public function getAutoWiringDefinition(string $className): AutoWiringClassInterface;
	
}

namespace Neunerlei\ContainerAutoWiringDeclaration\Definition;
interface AutoWiringClassInterface {
	
	/**
	 * Returns the name of the class described in this definition instance
	 * @return string
	 */
	public function getName(): string;
	
	/**
	 * Returns true if the class should be handled as singleton. Meaning the container should always
	 * return he same instance after it was created once.
	 * @return bool
	 */
	public function isSingleton(): bool;
	
	/**
	 * Returns the list of constructor parameters
	 * @return AutoWiringParameterInterface[]
	 */
	public function getConstructorParams(): array;
	
	/**
	 * Returns the list of inject methods of this class.
	 * This MUST return an empty array if the class does not implement the Injectable interface
	 * @return AutoWiringMethodInterface[]
	 * @see \Neunerlei\ContainerAutoWiringDeclaration\InjectableInterface
	 */
	public function getInjectMethods(): array;

}

namespace Neunerlei\ContainerAutoWiringDeclaration\Definition;
interface AutoWiringMethodInterface {
	
	/**
	 * Returns the auto-wiring class definition
	 * @return \Neunerlei\ContainerAutoWiringDeclaration\Definition\AutoWiringClassInterface
	 */
	public function getClass(): AutoWiringClassInterface;
	
	/**
	 * Returns the name of the method
	 *
	 * @return string
	 */
	public function getName(): string;
	
	/**
	 * Returns the list of parameters that should be set for this method.
	 *
	 * @return AutoWiringParameterInterface[]
	 */
	public function getParameters(): array;
}

namespace Neunerlei\ContainerAutoWiringDeclaration\Definition;
interface AutoWiringParameterInterface {
	
	/**
	 * Returns the auto-wiring method definition
	 * @return \Neunerlei\ContainerAutoWiringDeclaration\Definition\AutoWiringMethodInterface
	 */
	public function getMethod(): AutoWiringMethodInterface;
	
	/**
	 * Returns the name of the parameter
	 *
	 * @return string
	 */
	public function getName(): string;
	
	/**
	 * Returns true if the parameter has a defined type class that can be instantiated
	 * @return bool
	 */
	public function hasType(): bool;
	
	/**
	 * Returns the type of the parameter as a string or null if there is none
	 * @return string|null
	 */
	public function getType(): ?string;
	
	/**
	 * Returns true if this parameter should have a lazy loading proxy
	 * @return bool
	 */
	public function isLazy(): bool;
	
	/**
	 * Returns true if a default value exists, false if not
	 * @return bool
	 */
	public function hasDefaultValue(): bool;
	
	/**
	 * Returns the default value or null if there is none
	 * @return mixed
	 */
	public function getDefaultValue();
}