PHP code example of iqomp / class-builder
1. Go to this page and download the library: Download iqomp/class-builder 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/ */
iqomp / class-builder example snippets
use Iqomp\ClassBuilder\Builder;
$structure = [ /* ... */ ];
$result = Builder::build($structure);
$structure = [
// the file comments
'comments' => [
'My first library',
'@package vendor/module',
'@version 0.0.1'
],
// the class comment
'class_comments' => [
'@RpcService(name="ClassName")'
],
'namespace' => 'Vendor\\Module',
'type' => 'class', // interface
'name' => 'ClassName',
'extends' => [
'\\Other\\Module\\Class',
// may add more for interface
],
'implements' => [
'\\Other\\Module\\Iface',
// may add more
],
'properties' => [
'first' => [
'static' => false,
'visibility' => 'public',
'type' => 'string',
'attribute' => 'string',
'default' => null // remove to not set the default
],
'second' => [
'visibility' => 'protected',
'type' => '\\Other\\Module\\Class'
]
],
'methods' => [
'getOne' => [
'static' => false,
'visibility' => 'public',
'return' => '?object',
'attribute' => 'string',
'arguments' => [
'first' => [
'type' => 'int'
],
'second' => [
'type' => 'bool',
'default' => 0
]
],
'content' => 'return false;',
'comment' => [
'@param first int first arguments',
'@param second bool second arguments',
'@return bool'
]
]
],
'uses' => [
'App\\Library\\Class' => 'XClass',
'App\\Library\\Awesome' => null
]
];
/**
* My first library
* @package vendor/module
* @version 0.0.1
*/
namespace Vendor\Module;
use App\Library\Class as XClass;
use App\Library\Awesome;
/**
* @RpcService(name="ClassName")
*/
class ClassName extends \Other\Module\Class implements \Other\Module\Iface
{
#[string]
public string $first = null;
protected \Other\Module\Class $second;
/**
* @param first int first arguments
* @param second bool second arguments
* @return bool
*/
#[string]
public function getOne (int $first, bool $second = 0): ?object
{
return false;
}
}