PHP code example of usmanhalalit / get-set-go

1. Go to this page and download the library: Download usmanhalalit/get-set-go 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/ */

    

usmanhalalit / get-set-go example snippets


Class MyClass{
    use \GetSetGo\SetterGetter;

    protected $foo;
}

$myClass = new MyClass;

$myClass->setFoo('bar');
echo $myClass->getFoo();

/**
 * We can't use setSomeProperty() anymore.
 *
 * @var
 * @setter false
 */
protected $someProperty;

/**
 * We can't use getSomeProperty() anymore.
 *
 * @var \stdClass
 * @getter false
 */
protected $someProperty;

/**
 * We can't use setSomeProperty() or getSomeProperty().
 *
 * @getter false
 * @setter false
 */
protected $someProperty;

/**
 * Should be an instance of stdClass only.
 *
 * @var \stdClass
 */
protected $shouldBeStdClass;

/**
 * Should be an array only.
 *
 * @var Array
 */
protected $shouldBeArray;

/**
 * Should be a string only
 *
 * @var String
 */
protected $shouldBeString;

/**
 * Should be a number only.
 *
 * @var Number
 */
protected $shouldBeNumber;

/**
 * Should be an object only.
 *
 * @var Object
 */
protected $shouldBeObject;