Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [inne][PHP]Undefined variable 'object' less - Problem
kriskrkpl
post
Post #1





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 24.08.2015

Ostrzeżenie: (0%)
-----


Witam serdecznie wszystkich na forum (IMG:style_emoticons/default/smile.gif)

Potrzebuje pomocy w zloklizowanu błędu.

Używam PHP Storm, który zwraca mi następujący problem:

Undefined variable 'object' less... (Ctrl+F1)
The inspection can produce two types of warnings:
The definition of the variable can not be found anywhere. ("Undefined variable")
There are one or more pathes to rich the line with the variable usage without defining it. ("Variable might have not been defined")
All variables from files that contain 'include' or 'require' are considered as defined if the option "Ignore 'include' and 'require' statements" is disabled. The inspection is enabled for global space by default.

Z kolej przeglądarka zwraca mi problem

Fatal error: Call to a member function isAccessible() on null in /public_html/Core/Base/Front.php on line 359

O to kod tego pliku :

  1.  
  2. ....( Górna część kodu )
  3. public function dispatch($controller, $action, $params, $moduleCall)
  4. {
  5. $request = $this->getRequest();
  6. $this->setHelpersPathBase();
  7. $response = $this->getResponse();
  8.  
  9. if ($this->getRequest()->getQuery("widget")) {
  10. $module = $this->formatNamespaceName($this->getRequest()->getQuery("widget"));
  11. $isAccessible = (strtolower($module) == "widget" ? true : $object = $this->getApplication()->getModules($module) instanceof Module && $object->isAccessible());
  12.  
  13. if (!$isAccessible) {
  14. return NULL;
  15. }
  16.  
  17. $disableOb = $this->getParam("disableOutputBuffering");
  18. $obLevel = ob_get_level();
  19.  
  20. if ($disableOb) {
  21. }
  22.  
  23. $this->getApplication()->getEvent()->trigger("onBeforeDispatch." . $module);
  24.  
  25. try {
  26. echo Action::getInstance()->widget($this->getRequest()->getQuery("widget"), $this->getRequest()->getQuery("options"));
  27. }
  28. catch (\Core\Exception $e) {
  29. $curObLevel = ob_get_level();
  30.  
  31. ........( dalsza część kodu )


W czym leży problem (IMG:style_emoticons/default/questionmark.gif)

Proszę o pomoc

Ten post edytował kriskrkpl 29.08.2015, 14:04:19
Go to the top of the page
+Quote Post
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


problem masz tutaj:
  1. $object = $this->getApplication()->getModules($module) instanceof Module && $object->isAccessible())


To zwraca Ci:
  1. $object = ($this->getApplication()->getModules($module) instanceof Module && $object->isAccessible())

czyli do $object jest przypisywany wynik logiczny porównania tego:

  1. $this->getApplication()->getModules($module) instanceof Module && $object->isAccessible()


A że w logicznym warunku nie masz zainicjowanej $object to wywala błąd.

Powinno być tak:
  1. $isAccessible = (strtolower($module) == "widget" ? true : ($object = $this->getApplication()->getModules($module) instanceof Module) && $object->isAccessible());
Go to the top of the page
+Quote Post
kriskrkpl
post
Post #3





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 24.08.2015

Ostrzeżenie: (0%)
-----


Dziękuje za odpowiedź , teraz mam taki błąd , więc w sumie dalej coś nie tak

Fatal error: Call to a member function isAccessible() on boolean in /public_html/Core/Base/Front.php on line 359
Go to the top of the page
+Quote Post
Pyton_000
post
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


przesuń nawias z "instanceof Module)" tak: ") instanceof Module"
Go to the top of the page
+Quote Post
kriskrkpl
post
Post #5





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 24.08.2015

Ostrzeżenie: (0%)
-----


Bardzo Tobie dziękuje Działa ! (IMG:style_emoticons/default/smile.gif)

Jeszcze mam tylko ostatnie pytanie (IMG:style_emoticons/default/smile.gif)

Mam taki kod

  1. ( Górna cześć kodu .....)
  2. public function getClassResources($namespace)
  3. {
  4. if (!$this->modules_methods[$namespace]) {
  5. if (version_compare(PHP_VERSION, "5.2.6") === -1) {
  6. $class = new ReflectionObject($namespace . '\Module');
  7. $classMethods = $class->getMethods();
  8. $methodNames = array();
  9.  
  10. foreach ($classMethods as $method ) {
  11. $this->modules_methods[$namespace][] = $method->getName();
  12. }
  13. }
  14. else {
  15. $this->modules_methods[$namespace] = get_class_methods($namespace . '\Module');
  16. }
  17. }
  18.  
  19. return $this->modules_methods[$namespace];
  20. }
  21.  
  22. protected function _loadConfig($file)
  23. {
  24. if (!file_exists($file)) {
  25. throw new \Core\Exception("Missing file '" . $file . "'!");
  26. }
  27.  
  28. $environment = $this->getEnvironment();
  29. $suffix = strtolower(pathinfo($file, PATHINFO_EXTENSION));
  30.  
  31. switch ($suffix) {
  32. case "ini":
  33. require_once ("Config/Ini.php");
  34. $config = new \Core\Config\Ini($file, $environment);
  35. break;
  36. Reszta kodu.....



Oraz taki błąd

Fatal error: Uncaught exception 'Core\Exception' with message 'Missing file ''!' in /public_html/Core/Base/Init.php:753

Proszę o ostatnią pomoc
Go to the top of the page
+Quote Post
Pyton_000
post
Post #6





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


W pliku gdzie wywołujesz _loadConfig() wywołanie tej metody musisz objąć w try{} catch{}
Go to the top of the page
+Quote Post
kriskrkpl
post
Post #7





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 24.08.2015

Ostrzeżenie: (0%)
-----


Problem dalej występuje w tym pliku w którym podałem kod.

Skrypt zwraca mi taki błąd . Problem leży na pewno w pliku init.php

Fatal error: Uncaught exception 'Core\Exception' with message 'Missing file ''!' in /public_html/Core/Base/Init.php:740 Stack trace: #0 /public_html/Core/Base/Init.php(192): Core\Base\Init->_loadConfig(NULL) #1 /public_html/Core/Base/Init.php(157): Core\Base\Init->setOptions(Array) #2 /public_html/Core/Base/Init.php(114): Core\Base\Init->__construct('production', '/home/klient.dh...', NULL, '/home/klient.dh...') #3 /public_html/index.php(21): Core\Base\Init::getInstance('production', '/home/klient.dh...', NULL, '/home/klient.dh...') #4 {main} thrown in /public_html/Core/Base/Init.php on line 740


Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 17:57