ReflectionClass PHP Class Code Examples

This page contains top rated real world PHP examples of class ReflectionClass extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: CommandTask.php Project: gbdeboer/letterbox-backend
2
 /**
  * Return a list of subcommands for a given command
  *
  * @param string $commandName
  * @return array
  */
 public function subCommands($commandName)
 {
     $Shell = $this->getShell($commandName);
     if (!$Shell) {
         return array();
     }
     $taskMap = TaskCollection::normalizeObjectArray((array) $Shell->tasks);
     $return = array_keys($taskMap);
     $return = array_map('Inflector::underscore', $return);
     $ShellReflection = new ReflectionClass('AppShell');
     $shellMethods = $ShellReflection->getMethods(ReflectionMethod::IS_PUBLIC);
     $shellMethodNames = array('main', 'help');
     foreach ($shellMethods as $method) {
         $shellMethodNames[] = $method->getName();
     }
     $Reflection = new ReflectionClass($Shell);
     $methods = $Reflection->getMethods(ReflectionMethod::IS_PUBLIC);
     $methodNames = array();
     foreach ($methods as $method) {
         $methodNames[] = $method->getName();
     }
     $return += array_diff($methodNames, $shellMethodNames);
     sort($return);
     return $return;
 }
Example #2
Show file File: TranslationFinder.php Project: bnu/BazingaJsTranslationBundle
1
 /**
  * Gets translation files location.
  *
  * @return array
  */
 protected function getLocations()
 {
     $locations = array();
     if (class_exists('Symfony\\Component\\Validator\\Validation')) {
         $r = new \ReflectionClass('Symfony\\Component\\Validator\\Validation');
         $locations[] = dirname($r->getFilename()) . '/Resources/translations';
     }
     if (class_exists('Symfony\\Component\\Form\\Form')) {
         $r = new \ReflectionClass('Symfony\\Component\\Form\\Form');
         $locations[] = dirname($r->getFilename()) . '/Resources/translations';
     }
     if (class_exists('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException')) {
         $r = new \ReflectionClass('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException');
         if (file_exists($dir = dirname($r->getFilename()) . '/../../Resources/translations')) {
             $locations[] = $dir;
         } else {
             // Symfony 2.4 and above
             $locations[] = dirname($r->getFilename()) . '/../Resources/translations';
         }
     }
     $overridePath = $this->kernel->getRootDir() . '/Resources/%s/translations';
     foreach ($this->kernel->getBundles() as $bundle => $class) {
         $reflection = new \ReflectionClass($class);
         if (is_dir($dir = dirname($reflection->getFilename()) . '/Resources/translations')) {
             $locations[] = $dir;
         }
         if (is_dir($dir = sprintf($overridePath, $bundle))) {
             $locations[] = $dir;
         }
     }
     if (is_dir($dir = $this->kernel->getRootDir() . '/Resources/translations')) {
         $locations[] = $dir;
     }
     return $locations;
 }
Example #3
Show file File: Manager.php Project: mheydt/scalr
1
 public static function getScriptingBuiltinVariables()
 {
     if (!self::$BUILTIN_VARIABLES_LOADED) {
         $ReflectEVENT_TYPE = new ReflectionClass("EVENT_TYPE");
         $event_types = $ReflectEVENT_TYPE->getConstants();
         foreach ($event_types as $event_type) {
             if (class_exists("{$event_type}Event")) {
                 $ReflectClass = new ReflectionClass("{$event_type}Event");
                 $retval = $ReflectClass->getMethod("GetScriptingVars")->invoke(null);
                 if (!empty($retval)) {
                     foreach ($retval as $k => $v) {
                         if (!self::$BUILTIN_VARIABLES[$k]) {
                             self::$BUILTIN_VARIABLES[$k] = array("PropName" => $v, "EventName" => "{$event_type}");
                         } else {
                             if (!is_array(self::$BUILTIN_VARIABLES[$k]['EventName'])) {
                                 $events = array(self::$BUILTIN_VARIABLES[$k]['EventName']);
                             } else {
                                 $events = self::$BUILTIN_VARIABLES[$k]['EventName'];
                             }
                             $events[] = $event_type;
                             self::$BUILTIN_VARIABLES[$k] = array("PropName" => $v, "EventName" => $events);
                         }
                     }
                 }
             }
         }
         foreach (self::$BUILTIN_VARIABLES as $k => $v) {
             self::$BUILTIN_VARIABLES["event_{$k}"] = $v;
         }
         self::$BUILTIN_VARIABLES_LOADED = true;
     }
     return self::$BUILTIN_VARIABLES;
 }
Example #4
Show file File: Logger.php Project: SebFav/ApplicationInternet2
1
 /**
  * This is the publicly accessible API for notifying the system that a
  * deprecated feature has been used.
  *
  * If it is run via a TestRunner and the test extends
  * PHPUnit_Framework_TestCase, then this will inject the result into the
  * test runner for display, if not, it will throw the notice to STDERR.
  *
  * @param string $message
  * @param int|bool $backtraceDepth
  */
 public static function log($message, $backtraceDepth = 2)
 {
     if ($backtraceDepth !== FALSE) {
         $trace = debug_backtrace(FALSE);
         if (is_int($backtraceDepth)) {
             $traceItem = $trace[$backtraceDepth];
         }
         if (!isset($traceItem['file'])) {
             $reflectionClass = new ReflectionClass($traceItem['class']);
             $traceItem['file'] = $reflectionClass->getFileName();
         }
         if (!isset($traceItem['line']) && isset($traceItem['class']) && isset($traceItem['function'])) {
             if (!isset($reflectionClass)) {
                 $reflectionClass = new ReflectionClass($traceItem['class']);
             }
             $method = $reflectionClass->getMethod($traceItem['function']);
             $traceItem['line'] = '(between ' . $method->getStartLine() . ' and ' . $method->getEndLine() . ')';
         }
     }
     $deprecatedFeature = new PHPUnit_Util_DeprecatedFeature($message, $traceItem);
     if (self::$currentTest instanceof PHPUnit_Framework_TestCase) {
         $result = self::$currentTest->getTestResultObject();
         $result->addDeprecatedFeature($deprecatedFeature);
     } else {
         file_put_contents('php://stderr', $deprecatedFeature);
     }
 }
Example #5
Show file File: class-gf-addon.php Project: fjbeteiligung/development
1
 public static function get_deprecated_protected_methods_for_base_class($base_class_name, $add_on_class_name = '')
 {
     $deprecated = array();
     if (!class_exists($base_class_name)) {
         return $deprecated;
     }
     $base_class_names = array('GFAddOn', 'GFFeedAddOn', 'GFPaymentAddOn');
     $base_class = new ReflectionClass($base_class_name);
     $classes = empty($add_on_class_name) ? get_declared_classes() : array($add_on_class_name);
     foreach ($classes as $class) {
         if (!is_subclass_of($class, $base_class_name) || in_array($class, $base_class_names)) {
             continue;
         }
         $add_on_class = new ReflectionClass($class);
         $add_on_methods = $add_on_class->getMethods(ReflectionMethod::IS_PROTECTED);
         foreach ($add_on_methods as $method) {
             $method_name = $method->getName();
             $base_has_method = $base_class->hasMethod($method_name);
             $is_declared_by_base_class = $base_has_method && $base_class->getMethod($method_name)->getDeclaringClass()->getName() == $base_class_name;
             $is_overridden = $method->getDeclaringClass()->getName() == $class;
             if ($is_declared_by_base_class && $is_overridden) {
                 $deprecated[] = $class . '::' . $method_name;
             }
         }
     }
     return $deprecated;
 }
Example #6
Show file File: Object.php Project: jacobbuck/silverstripe-framework
0
 /**
  * Get the value of a static property of a class, even in that property is declared protected (but not private),
  * without any inheritance, merging or parent lookup if it doesn't exist on the given class.
  *
  * @static
  * @param $class - The class to get the static from
  * @param $name - The property to get from the class
  * @param null $default - The value to return if property doesn't exist on class
  * @return any - The value of the static property $name on class $class, or $default if that property is not
  *               defined
  */
 public static function static_lookup($class, $name, $default = null)
 {
     if (is_subclass_of($class, 'Object')) {
         if (isset($class::${$name})) {
             $parent = get_parent_class($class);
             if (!$parent || !isset($parent::${$name}) || $parent::${$name} !== $class::${$name}) {
                 return $class::${$name};
             }
         }
         return $default;
     } else {
         // TODO: This gets set once, then not updated, so any changes to statics after this is called the first
         // time for any class won't be exposed
         static $static_properties = array();
         if (!isset($static_properties[$class])) {
             $reflection = new ReflectionClass($class);
             $static_properties[$class] = $reflection->getStaticProperties();
         }
         if (isset($static_properties[$class][$name])) {
             $value = $static_properties[$class][$name];
             $parent = get_parent_class($class);
             if (!$parent) {
                 return $value;
             }
             if (!isset($static_properties[$parent])) {
                 $reflection = new ReflectionClass($parent);
                 $static_properties[$parent] = $reflection->getStaticProperties();
             }
             if (!isset($static_properties[$parent][$name]) || $static_properties[$parent][$name] !== $value) {
                 return $value;
             }
         }
     }
     return $default;
 }
Example #7
Show file File: FrameworkExtensionTest.php Project: d3ancole1995/symfony
0
 public function testTranslator()
 {
     $container = $this->createContainerFromFile('full');
     $this->assertTrue($container->hasDefinition('translator.default'), '->registerTranslatorConfiguration() loads translation.xml');
     $this->assertEquals('translator.default', (string) $container->getAlias('translator'), '->registerTranslatorConfiguration() redefines translator service from identity to real translator');
     $resources = array();
     foreach ($container->getDefinition('translator.default')->getMethodCalls() as $call) {
         if ('addResource' == $call[0]) {
             $resources[] = $call[1];
         }
     }
     $files = array_map(function ($resource) {
         return realpath($resource[1]);
     }, $resources);
     $ref = new \ReflectionClass('Symfony\\Component\\Validator\\Validator');
     $this->assertContains(strtr(dirname($ref->getFileName()) . '/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Validator translation resources');
     $ref = new \ReflectionClass('Symfony\\Component\\Form\\Form');
     $this->assertContains(strtr(dirname($ref->getFileName()) . '/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Form translation resources');
     $ref = new \ReflectionClass('Symfony\\Component\\Security\\Core\\SecurityContext');
     $ref = dirname($ref->getFileName());
     if (!file_exists($ref . '/composer.json')) {
         $ref = dirname($ref);
     }
     $this->assertContains(strtr($ref . '/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Security translation resources');
     $calls = $container->getDefinition('translator.default')->getMethodCalls();
     $this->assertEquals(array('fr'), $calls[0][1][0]);
 }
Example #8
Show file File: Container.php Project: tuneyourserver/components
0
 /**
  * Create instance of desired class.
  *
  * @param string           $class
  * @param array            $parameters     Constructor parameters.
  * @param string|null      $context
  * @param \ReflectionClass $reflection     Instance of reflection associated with class,
  *                                         reference.
  * @return object
  * @throws ContainerException
  */
 private function createInstance($class, array $parameters, $context = null, \ReflectionClass &$reflection = null)
 {
     try {
         $reflection = new \ReflectionClass($class);
     } catch (\ReflectionException $exception) {
         throw new ContainerException($exception->getMessage(), $exception->getCode(), $exception);
     }
     //We have to construct class using external injector
     if (empty($parameters) && $this->hasInjector($reflection)) {
         //Creating class using injector/factory
         $instance = $this->getInjector($reflection)->createInjection($reflection, $context);
         if (!$reflection->isInstance($instance)) {
             throw new InjectionException("Invalid injector response.");
         }
         //todo: potentially to be replaced with direct call logic (when method is specified
         //todo: instead of class/binding name)
         return $instance;
     }
     if (!$reflection->isInstantiable()) {
         throw new ContainerException("Class '{$class}' can not be constructed.");
     }
     if (!empty($constructor = $reflection->getConstructor())) {
         //Using constructor with resolved arguments
         $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters));
     } else {
         //No constructor specified
         $instance = $reflection->newInstance();
     }
     return $instance;
 }
Example #9
Show file File: ClientTest.php Project: OlivierBarbier/google-api-php-client
0
 public function testApplicationDefaultCredentialsWithSubject()
 {
     $sub = 'sub123';
     $client = new Google_Client();
     $client->setAuthConfig(__DIR__ . '/../config/application-default-credentials.json');
     $client->setSubject($sub);
     $http = new Client();
     $client->authorize($http);
     $listeners = $http->getEmitter()->listeners('before');
     $this->assertEquals(1, count($listeners));
     $this->assertEquals(2, count($listeners[0]));
     $this->assertInstanceOf('Google\\Auth\\AuthTokenFetcher', $listeners[0][0]);
     // access the protected $fetcher property
     $class = new ReflectionClass(get_class($listeners[0][0]));
     $property = $class->getProperty('fetcher');
     $property->setAccessible(true);
     $fetcher = $property->getValue($listeners[0][0]);
     $this->assertInstanceOf('Google\\Auth\\ServiceAccountCredentials', $fetcher);
     // access the protected $auth property
     $class = new ReflectionClass(get_class($fetcher));
     $property = $class->getProperty('auth');
     $property->setAccessible(true);
     $auth = $property->getValue($fetcher);
     $this->assertEquals($sub, $auth->getSub());
 }
Example #10
Show file File: HuluDistributionPlugin.php Project: DBezemer/server
0
 /**
  * @param string $baseClass
  * @param string $enumValue
  * @param array $constructorArgs
  * @return object
  */
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     // client side apps like batch and admin console
     if (class_exists('KalturaClient') && $enumValue == KalturaDistributionProviderType::HULU) {
         if ($baseClass == 'IDistributionEngineCloseDelete') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineCloseSubmit') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineCloseUpdate') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineDelete') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineReport') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineSubmit') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineUpdate') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineEnable') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineDisable') {
             return new HuluDistributionEngine();
         }
         if ($baseClass == 'KalturaDistributionProfile') {
             return new KalturaHuluDistributionProfile();
         }
         if ($baseClass == 'KalturaDistributionJobProviderData') {
             return new KalturaHuluDistributionJobProviderData();
         }
     }
     if (class_exists('Kaltura_Client_Client') && $enumValue == Kaltura_Client_ContentDistribution_Enum_DistributionProviderType::HULU) {
         if ($baseClass == 'Form_ProviderProfileConfiguration') {
             $reflect = new ReflectionClass('Form_HuluProfileConfiguration');
             return $reflect->newInstanceArgs($constructorArgs);
         }
     }
     if ($baseClass == 'KalturaDistributionJobProviderData' && $enumValue == self::getDistributionProviderTypeCoreValue(HuluDistributionProviderType::HULU)) {
         $reflect = new ReflectionClass('KalturaHuluDistributionJobProviderData');
         return $reflect->newInstanceArgs($constructorArgs);
     }
     if ($baseClass == 'kDistributionJobProviderData' && $enumValue == self::getApiValue(HuluDistributionProviderType::HULU)) {
         $reflect = new ReflectionClass('kHuluDistributionJobProviderData');
         return $reflect->newInstanceArgs($constructorArgs);
     }
     if ($baseClass == 'KalturaDistributionProfile' && $enumValue == self::getDistributionProviderTypeCoreValue(HuluDistributionProviderType::HULU)) {
         return new KalturaHuluDistributionProfile();
     }
     if ($baseClass == 'DistributionProfile' && $enumValue == self::getDistributionProviderTypeCoreValue(HuluDistributionProviderType::HULU)) {
         return new HuluDistributionProfile();
     }
     return null;
 }
Example #11
Show file File: DrupalKernelTest.php Project: eigentor/tommiblog
0
 /**
  * Tests DIC compilation.
  */
 public function testCompileDIC()
 {
     // @todo: write a memory based storage backend for testing.
     $modules_enabled = array('system' => 'system', 'user' => 'user');
     $request = Request::createFromGlobals();
     $this->getTestKernel($request, $modules_enabled);
     // Instantiate it a second time and we should get the compiled Container
     // class.
     $kernel = $this->getTestKernel($request);
     $container = $kernel->getContainer();
     $refClass = new \ReflectionClass($container);
     $is_compiled_container = !$refClass->isSubclassOf('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $this->assertTrue($is_compiled_container);
     // Verify that the list of modules is the same for the initial and the
     // compiled container.
     $module_list = array_keys($container->get('module_handler')->getModuleList());
     $this->assertEqual(array_values($modules_enabled), $module_list);
     // Get the container another time, simulating a "production" environment.
     $container = $this->getTestKernel($request, NULL)->getContainer();
     $refClass = new \ReflectionClass($container);
     $is_compiled_container = !$refClass->isSubclassOf('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $this->assertTrue($is_compiled_container);
     // Verify that the list of modules is the same for the initial and the
     // compiled container.
     $module_list = array_keys($container->get('module_handler')->getModuleList());
     $this->assertEqual(array_values($modules_enabled), $module_list);
     // Test that our synthetic services are there.
     $class_loader = $container->get('class_loader');
     $refClass = new \ReflectionClass($class_loader);
     $this->assertTrue($refClass->hasMethod('loadClass'), 'Container has a class loader');
     // We make this assertion here purely to show that the new container below
     // is functioning correctly, i.e. we get a brand new ContainerBuilder
     // which has the required new services, after changing the list of enabled
     // modules.
     $this->assertFalse($container->has('service_provider_test_class'));
     // Add another module so that we can test that the new module's bundle is
     // registered to the new container.
     $modules_enabled['service_provider_test'] = 'service_provider_test';
     $this->getTestKernel($request, $modules_enabled);
     // Instantiate it a second time and we should not get a ContainerBuilder
     // class because we are loading the container definition from cache.
     $kernel = $this->getTestKernel($request, $modules_enabled);
     $container = $kernel->getContainer();
     $refClass = new \ReflectionClass($container);
     $is_container_builder = $refClass->isSubclassOf('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $this->assertFalse($is_container_builder, 'Container is not a builder');
     // Assert that the new module's bundle was registered to the new container.
     $this->assertTrue($container->has('service_provider_test_class'), 'Container has test service');
     // Test that our synthetic services are there.
     $class_loader = $container->get('class_loader');
     $refClass = new \ReflectionClass($class_loader);
     $this->assertTrue($refClass->hasMethod('loadClass'), 'Container has a class loader');
     // Check that the location of the new module is registered.
     $modules = $container->getParameter('container.modules');
     $this->assertEqual($modules['service_provider_test'], array('type' => 'module', 'pathname' => drupal_get_filename('module', 'service_provider_test'), 'filename' => NULL));
     // Check that the container itself is not among the persist IDs because it
     // does not make sense to persist the container itself.
     $persist_ids = $container->getParameter('persist_ids');
     $this->assertIdentical(FALSE, array_search('service_container', $persist_ids));
 }
Example #12
Show file File: FtpDistributionPlugin.php Project: DBezemer/server
0
 /**
  * @param string $baseClass
  * @param string $enumValue
  * @param array $constructorArgs
  * @return object
  */
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     // client side apps like batch and admin console
     if (class_exists('KalturaClient') && ($enumValue == KalturaDistributionProviderType::FTP || $enumValue == KalturaDistributionProviderType::FTP_SCHEDULED)) {
         if ($baseClass == 'IDistributionEngineCloseDelete') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineCloseSubmit') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineCloseUpdate') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineDelete') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineReport') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineSubmit') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineUpdate') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineEnable') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'IDistributionEngineDisable') {
             return new FtpDistributionEngine();
         }
         if ($baseClass == 'KalturaDistributionProfile') {
             return new KalturaFtpDistributionProfile();
         }
         if ($baseClass == 'KalturaDistributionJobProviderData') {
             return new KalturaFtpDistributionJobProviderData();
         }
     }
     if (class_exists('Kaltura_Client_Client') && ($enumValue == Kaltura_Client_ContentDistribution_Enum_DistributionProviderType::FTP || $enumValue == Kaltura_Client_ContentDistribution_Enum_DistributionProviderType::FTP_SCHEDULED)) {
         if ($baseClass == 'Form_ProviderProfileConfiguration') {
             $reflect = new ReflectionClass('Form_FtpProfileConfiguration');
             return $reflect->newInstanceArgs($constructorArgs);
         }
     }
     if ($baseClass == 'KalturaDistributionJobProviderData' && ($enumValue == self::getDistributionProviderTypeCoreValue(FtpDistributionProviderType::FTP) || $enumValue == self::getDistributionProviderTypeCoreValue(FtpDistributionProviderType::FTP_SCHEDULED))) {
         $reflect = new ReflectionClass('KalturaFtpDistributionJobProviderData');
         return $reflect->newInstanceArgs($constructorArgs);
     }
     if ($baseClass == 'kDistributionJobProviderData' && ($enumValue == self::getApiValue(FtpDistributionProviderType::FTP) || $enumValue == self::getApiValue(FtpDistributionProviderType::FTP_SCHEDULED))) {
         $reflect = new ReflectionClass('kFtpDistributionJobProviderData');
         return $reflect->newInstanceArgs($constructorArgs);
     }
     if ($baseClass == 'KalturaDistributionProfile' && ($enumValue == self::getDistributionProviderTypeCoreValue(FtpDistributionProviderType::FTP) || $enumValue == self::getDistributionProviderTypeCoreValue(FtpDistributionProviderType::FTP_SCHEDULED))) {
         return new KalturaFtpDistributionProfile();
     }
     if ($baseClass == 'DistributionProfile' && ($enumValue == self::getDistributionProviderTypeCoreValue(FtpDistributionProviderType::FTP) || $enumValue == self::getDistributionProviderTypeCoreValue(FtpDistributionProviderType::FTP_SCHEDULED))) {
         return new FtpDistributionProfile();
     }
     return null;
 }
Example #13
Show file File: ignitiondeck-idf.php Project: christopherreay/freeFreeCrowdfunding_ignitiondeck_crowdfunding
0
/**
 * Action called when a transaction order is updated from iT Exchange
 */
function iditexch_update_order($args)
{
    $transaction_id = $args['ID'];
    // Getting the products involved in the transaction/payment
    $products = it_exchange_get_transaction_products($transaction_id);
    if (is_array($products)) {
        $id_orders = array();
        $count = 1;
        foreach ($products as $cart_id => $data) {
            $product_id = $data['product_id'];
            $qty = $data['count'];
            $price = $data['product_subtotal'];
            $vars = iditexch_payment_vars($transaction_id, $product_id, $price, $count);
            for ($i = 0; $i < $qty; $i++) {
                // Adding order separately for each number of product quantity
                $rc = new ReflectionClass('ID_Order');
                $order = $rc->newInstanceArgs($vars);
                $check = $order->check_new_order($vars['transaction_id'] . "-" . $i);
                if (isset($check)) {
                    $pay_id = $check->id;
                    if (isset($pay_id) && $pay_id > 0) {
                        $vars['id'] = $pay_id;
                        $rc = new ReflectionClass('ID_Order');
                        // Adding quantity number to transaction_id
                        $vars['transaction_id'] = $vars['transaction_id'] . "-" . $i;
                        $order = $rc->newInstanceArgs($vars);
                        $update = $order->update_order();
                    }
                }
            }
            $count++;
        }
    }
}
Example #14
Show file File: TestResult.php Project: trowski/phpunit
0
 /**
  * Returns the class hierarchy for a given class.
  *
  * @param string $className
  * @param bool   $asReflectionObjects
  *
  * @return array
  */
 protected function getHierarchy($className, $asReflectionObjects = false)
 {
     if ($asReflectionObjects) {
         $classes = [new ReflectionClass($className)];
     } else {
         $classes = [$className];
     }
     $done = false;
     while (!$done) {
         if ($asReflectionObjects) {
             $class = new ReflectionClass($classes[count($classes) - 1]->getName());
         } else {
             $class = new ReflectionClass($classes[count($classes) - 1]);
         }
         $parent = $class->getParentClass();
         if ($parent !== false) {
             if ($asReflectionObjects) {
                 $classes[] = $parent;
             } else {
                 $classes[] = $parent->getName();
             }
         } else {
             $done = true;
         }
     }
     return $classes;
 }