PHP code example of netherphp / object

1. Go to this page and download the library: Download netherphp/object 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/ */

    

netherphp / object example snippets


class BaseObject
extends Nether\Object\Prototype {
	public int $ID;
	public string $Name;
}

$RowFromDB = [ 'ID'=> 1, 'Name'=> 'Bob' ];
$Obj = new BaseObject($RowFromDB);

$Data = new Nether\Object\Datastore([
	1, 2, 3,
	4, 5, 6
]);

// strip out odd numbers
// then sort it big to small
// then show me what we got.

print_r(
	$Data
	->Filter(fn(int $Val)=> ($Val % 2) == 0)
	->Sort(fn(int $A, int $B)=> $B <=> $A)
	->Values()
);

// Array
// (
//    [0] => 6
//    [1] => 4
//    [2] => 2
// )

class MyClass {

	use
	Nether\Object\Package\ClassInfoPackage;

}

$ClassInfo = MyClass::GetClassInfo();

print_r($ClassInfo);

class MyClass {

	use
	Nether\Object\Package\MethodInfoPackage;

	public function
	GetID():
	int {

		return 0;
	}

}

$Methods = MyClass::GetMethodIndex();

foreach($Methods as $Method) {
	print_r($Method);
}

class MyClass {

	use
	Nether\Object\Package\PropertyInfoPackage;

	public int
	$ID = 0;

}

$Props = MyClass::GetPropertyIndex();

foreach($Props as $Prop) {
	print_r($Prop);
}