Search
 
SCRIPT & CODE EXAMPLE
 

PHP

phpdoc @method

/** @method string greet(string $who) Hello that guy */
class MyClass
{
  public function __call(string $name, array $args): string
  {
    if( $name === 'greet' )
      return "Hello {$args[0]}!";
    return '';
  }
}
Comment

phpdoc example

/**
 * @property	MyClass	$self_ref			Reference to myself
 * @method		string	greet(string $who)	Hello that guy
 */
class MyClass
{
  /**
   * @param		string		 $name	Name of pseudo-property do invoke
   * @returns	MyClass|null 		Reference to instance or null if 
   *									no name provided.
   */
  public function __get(string $name): ?MyClass
  {
    if( $name === 'self_ref' )
      return $this;
   	return null;
  }
  
  /**
   * @param		string	$name	Name of implicit function to call.
   * @param		array	$args	Array of arguments passed to call.
   * @returns	string			The greeting string or null if no name.
   */
  public function __call(string $name, array $args): string
  {
    if( $name === 'greet' )
    {
      /** @var string $guy The name of the guy to greet */
      $guy = $args[0] ?? 'everyone';
      return "Hello {$guy}!";
    }
    return '';
  }
}
Comment

PREVIOUS NEXT
Code Example
Php :: define function in php 
Php :: php variables examples 
Php :: php exceptions 
Php :: get the value without setter method laravel 
Php :: how to truncate all tables laravel 
Php :: strpos() expects parameter 1 to be string, object given 
Php :: displaying dates using php code 
Php :: laravel set env to production 
Php :: woocommerce_product_query 
Php :: how to write php in script file 
Php :: laravel run command 
Php :: In PackageManifest.php line 122: Undefined index: name 
Php :: self vs this in php 
Php :: pusher 
Php :: @can in laravel 
Php :: php ternary operator good example 
Php :: php loop object keys 
Php :: laravel routes 
Php :: laravel 8 
Php :: a non well formed numeric value encountered laravel 
Php :: php leggere file txt riga per riga 
Php :: php missing ext gd 
Php :: wordpress Simple Membership button name 
Php :: enset laravel session 
Php :: wordpress html classes 
Php :: undefined offset: 7 in d:xamphtdocsphpfunctionfunction.php on line 137 
Php :: PHP detect spam name 
Php :: laravel create event listener 
Php :: wpdb insert or if exists update 
Php :: $name = $name; "Robert" echo; 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =