PHPUnit\Runner\CleverAndSmart\Util::setInvisibleProperty PHP Метод

setInvisibleProperty() публичный статический Метод

Set an invisible property from an object (private or protected)
public static setInvisibleProperty ( object $object, string $propertyName, mixed $value, string $methodName = null )
$object object
$propertyName string
$value mixed
$methodName string
    public static function setInvisibleProperty($object, $propertyName, $value, $methodName = null)
    {
        if (method_exists($object, $methodName)) {
            $object->{$methodName}($value);
            return;
        }
        static::getPropertyReflection($object, $propertyName)->setValue($object, $value);
    }

Usage Example

 private function sortTestSuite(TestSuite $suite)
 {
     $tests = $suite->tests();
     $testsOrderResult = array(static::SORT_NONE, null);
     foreach ($tests as $test) {
         if ($test instanceof TestCase && Util::getInvisibleProperty($test, 'dependencies', 'hasDependencies')) {
             return $testsOrderResult;
         }
     }
     $orderedTests = new SegmentedQueue($tests);
     $orderedTests->setMergeMode($this->mergeMode);
     foreach ($tests as $position => $test) {
         list($testOrderResult, $time) = $this->sortTest($test, $position, $orderedTests);
         if ($testsOrderResult[0] < $testOrderResult) {
             $testsOrderResult = array($testOrderResult, $time);
         }
     }
     $groups = Util::getInvisibleProperty($suite, 'groups', 'getGroupDetails');
     $groupsOrderResult = array(static::SORT_NONE, null);
     foreach ($groups as $groupName => $group) {
         $groupOrderResult = array(static::SORT_NONE, null);
         $orderedGroup = new SegmentedQueue($group);
         $orderedGroup->setMergeMode($this->mergeMode);
         foreach ($group as $position => $test) {
             list($testOrderResult, $time) = $this->sortTest($test, $position, $orderedGroup);
             if ($groupOrderResult[0] < $testOrderResult) {
                 $groupOrderResult = array($testOrderResult, $time);
             }
         }
         if ($groupOrderResult[0] > static::SORT_NONE) {
             $groups[$groupName] = iterator_to_array($orderedGroup);
             if ($groupsOrderResult[0] < $groupOrderResult[0]) {
                 $groupsOrderResult = $groupOrderResult;
             }
         }
     }
     if ($testsOrderResult[0] > static::SORT_NONE) {
         Util::setInvisibleProperty($suite, 'tests', iterator_to_array($orderedTests), 'setTests');
     }
     if ($groupsOrderResult) {
         Util::setInvisibleProperty($suite, 'groups', $groups, 'setGroupDetails');
     }
     return $testsOrderResult[0] > $groupsOrderResult[0] ? $testsOrderResult : $groupsOrderResult;
 }
All Usage Examples Of PHPUnit\Runner\CleverAndSmart\Util::setInvisibleProperty