PHP code example of grikdotnet / z-unfinal

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

    

grikdotnet / z-unfinal example snippets


use ZEngine\Core;
use ZEngine\Reflection\ReflectionClass;

Core::init();

// Get reflection for a final class
$reflectionClass = new ReflectionClass(FinalClass::class);

// Remove the final flag
$reflectionClass->setFinal(false);

// Now you can extend the class in your tests
class ExtendedClass extends FinalClass {
    // Test-specific functionality
}

use ZEngine\Core;
use ZEngine\Reflection\ReflectionClass;

Core::init();

$reflectionClass = new ReflectionClass(AbstractClass::class);
$reflectionClass->setAbstract(false);

// Now you can create an instance of the abstract class
$instance = new AbstractClass();

use ZEngine\Core;
use ZEngine\Reflection\ReflectionClass;

Core::init();

$reflectionClass = new ReflectionClass(TargetClass::class);
$reflectionClass->addTraits(SomeTrait::class);

// Now TargetClass has all methods from SomeTrait
(new TestClass())->traitMethod()