getMethods() public méthode

public getMethods ( $filter ) : Method[]
Résultat Method[]
 /**
  * @param \Nette\DI\Container $dic
  * @throws MemberAccessException
  * @internal
  */
 public function injectComponentFactories(Nette\DI\Container $dic)
 {
     if (!$this instanceof Nette\Application\UI\PresenterComponent && !$this instanceof Nette\Application\UI\Component) {
         throw new MemberAccessException('Trait ' . __TRAIT__ . ' can be used only in descendants of PresenterComponent.');
     }
     $this->autowireComponentFactoriesLocator = $dic;
     $storage = $dic->hasService('autowired.cacheStorage') ? $dic->getService('autowired.cacheStorage') : $dic->getByType('Nette\\Caching\\IStorage');
     $cache = new Nette\Caching\Cache($storage, 'Kdyby.Autowired.AutowireComponentFactories');
     if ($cache->load($presenterClass = get_class($this)) !== NULL) {
         return;
     }
     $ignore = class_parents('Nette\\Application\\UI\\Presenter') + ['ui' => 'Nette\\Application\\UI\\Presenter'];
     $rc = new ClassType($this);
     foreach ($rc->getMethods() as $method) {
         if (in_array($method->getDeclaringClass()->getName(), $ignore, TRUE) || !Strings::startsWith($method->getName(), 'createComponent')) {
             continue;
         }
         foreach ($method->getParameters() as $parameter) {
             if (!($class = $parameter->getClassName())) {
                 // has object type hint
                 continue;
             }
             if (!$this->findByTypeForFactory($class) && !$parameter->allowsNull()) {
                 throw new MissingServiceException("No service of type {$class} found. Make sure the type hint in {$method} is written correctly and service of this type is registered.");
             }
         }
     }
     $files = array_map(function ($class) {
         return ClassType::from($class)->getFileName();
     }, array_diff(array_values(class_parents($presenterClass) + ['me' => $presenterClass]), $ignore));
     $files[] = ClassType::from($this->autowireComponentFactoriesLocator)->getFileName();
     $cache->save($presenterClass, TRUE, [$cache::FILES => $files]);
 }
Exemple #2
0
 protected function loadGettersSetters()
 {
     $methods = [];
     foreach ($this->reflection->getMethods() as $method) {
         $methods[strtolower($method->name)] = $method;
     }
     foreach ($this->metadata->getProperties() as $name => $property) {
         $getter = 'getter' . strtolower($name);
         if (isset($methods[$getter])) {
             $property->hasGetter = TRUE;
         }
         $setter = 'setter' . strtolower($name);
         if (isset($methods[$setter])) {
             $property->hasSetter = TRUE;
         }
     }
 }
 public function startup()
 {
     parent::startup();
     $classReflection = new Nette\Reflection\ClassType('Helpers');
     $methods = $classReflection->getMethods();
     foreach ($methods as $method) {
         $this->template->registerHelper($method->getName(), 'Helpers::' . $method->getName());
     }
     $this->template->kategorie = $this->kategorie->getMenu();
     $this->template->aktuality = $this->clanky->getClanky(5, 0, "aktuality", null, true);
 }
 /**
  * @return array
  */
 public final function getSubscribedEvents()
 {
     $list = [];
     $ref = new ClassType($this);
     foreach ($ref->getMethods() as $method) {
         if ($method->getAnnotation('subscribe')) {
             $list[] = $method->name;
         }
     }
     return $list;
 }
 /**
  * Generates markdown output for a specified class
  * @param string $class e.g. `PDO` or a user class like `diversen\markdownDocs`
  * @return void the method adds to $output
  */
 public function classToMD($class, $options = [])
 {
     $r = new ClassType($class);
     $this->output .= $this->sectionHeader('Class: ' . $r->getName(), 3);
     // Class description
     $this->output .= $r->getDescription() . $this->getNL();
     // Get methods and props
     $methods = $r->getMethods();
     $props = $r->getDefaultProperties();
     // Parse properties
     $this->output .= $this->sectionHeader("Properties");
     $this->generatePropsMD($r, $props, $options);
     // Parse methods
     $this->output .= $this->sectionHeader("Methods");
     $this->generateMethodMD($methods, $options);
 }
Exemple #6
0
 /**
  * Adds task case to be processed when cronner runs. If tasks
  * with name which is already added are given then throws
  * an exception.
  *
  * @param object $tasks
  * @return \stekycz\Cronner\Cronner
  * @throws \stekycz\Cronner\InvalidArgumentException
  */
 public function addTasks($tasks)
 {
     $tasksId = $this->createIdFromObject($tasks);
     if (in_array($tasksId, $this->registeredTaskObjects)) {
         throw new InvalidArgumentException("Tasks with ID '" . $tasksId . "' have been already added.");
     }
     $reflection = new ClassType($tasks);
     $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
     foreach ($methods as $method) {
         if (!Strings::startsWith($method->getName(), '__') && $method->hasAnnotation(Parameters::TASK)) {
             $task = new Task($tasks, $method, $this->timestampStorage);
             if (array_key_exists($task->getName(), $this->tasks)) {
                 throw new DuplicateTaskNameException('Cannot use more tasks with the same name "' . $task->getName() . '".');
             }
             $this->tasks[$task->getName()] = $task;
         }
     }
     $this->registeredTaskObjects[] = $tasksId;
     return $this;
 }