title: PHPStorm - Method not found in subject class
body: <p>I have a project that I'm working on and I just switched over to PHPStorm because it's starting to get big and I need some refactoring tools. I noticed that since variables aren't declared as types (like they are in Java) PHPStorm doesn't know where to look for method calls on variable names sometimes. Here's my code. </p>
  
  <pre><code>&lt;?php
  
  require_once "autoloader.php";
  
  
  class User {
  
      private $userID;
      private $email;
      private $encryptedPassword;
      private $userDBWriter;
      private $company;
      private $companyInfoChangeRequest;
      private $admin;
      private $accountIsActive;
      private $dealTracker;
      private $changeRequestPending;
  
      function __construct($email, $encryptedPassword) {
          $this-&gt;email = $email;
          $this-&gt;encryptedPassword = $encryptedPassword;
          $this-&gt;userDBWriter = new UserDBWriter();
          $this-&gt;admin = false;
          $this-&gt;dealTracker = new DealTracker($this);
      }
  
      public function addUserToDB() {
          $this-&gt;userDBWriter-&gt;addUserToDB($this);
      }
  
      public function setUserAsAdmin($adminStatus) {
          $this-&gt;admin = (bool) $adminStatus;
      }
  
      public function userAccountActiveStatus($accountStatus) {
          $this-&gt;accountIsActive = (bool) $accountStatus;
      }
  
      public function setUserID($userID) {
          $this-&gt;userID = $userID;
      }
  
      public function getUserID() {
          return $this-&gt;userID;
      }
  
      public function getEmail() {
          return $this-&gt;email;
      }
  
      public function isAdmin() {
          return $this-&gt;admin;
      }
  
      public function isAccountActive() {
          return $this-&gt;accountIsActive;
      }
  
      public function getEncryptedPassword() {
          return $this-&gt;encryptedPassword;
      }
  
      public function toArray() {
          $userArray = array(
              "id"=&gt;$this-&gt;userID,
              "email"=&gt;$this-&gt;email,
              "company_name"=&gt;$this-&gt;getCompanyName(),
              "business_type"=&gt;$this-&gt;getBusinessType(),
              "company_phone"=&gt;$this-&gt;getCompanyPhone(),
              "company_street"=&gt;$this-&gt;getCompanyStreet(),
              "company_city"=&gt;$this-&gt;getCompanyCity(),
              "company_zip"=&gt;$this-&gt;getCompanyZip(),
              "monday_hours"=&gt;$this-&gt;getMondayHours(),
              "tuesday_hours"=&gt;$this-&gt;getTuesdayHours(),
              "wednesday_hours"=&gt;$this-&gt;getWednesdayHours(),
              "thursday_hours"=&gt;$this-&gt;getThursdayHours(),
              "friday_hours"=&gt;$this-&gt;getFridayHours(),
              "saturday_hours"=&gt;$this-&gt;getSaturdayHours(),
              "sunday_hours"=&gt;$this-&gt;getSundayHours(),
              "store_image_path"=&gt;$this-&gt;getStoreImagePath(),
              "shop_description"=&gt;$this-&gt;getShopDescription(),
              "deals"=&gt;$this-&gt;dealTracker-&gt;dealsToArray()
              );
          return $userArray;  
      }
  
      public function addCompany(Company $company) {
          $this-&gt;company = $company;
      }
  
          public function getCompanyName() {
              return $this-&gt;company-&gt;getCompanyName();
          }
  
          public function getBusinessType() {
              return $this-&gt;company-&gt;getBusinessType();
          }
  
          public function getCompanyPhone() {
              return $this-&gt;company-&gt;getCompanyPhone();
          }
  
          public function getCompanyStreet() {
              return $this-&gt;company-&gt;getCompanyStreet();
          }
  
          public function getCompanyCity() {
              return $this-&gt;company-&gt;getCompanyCity();
          }
  
          public function getCompanyState() {
              return $this-&gt;company-&gt;getCompanyState();
          }
  
          public function getCompanyZip() {
              return $this-&gt;company-&gt;getCompanyZip();
          }
  
          public function getMondayHours() {
              return $this-&gt;company-&gt;getMondayHours();
          }
  
          public function getTuesdayHours() {
              return $this-&gt;company-&gt;getTuesdayHours();
          }
  
          public function getWednesdayHours() {
              return $this-&gt;company-&gt;getWednesdayHours();
          }
  
          public function getThursdayHours() {
              return $this-&gt;company-&gt;getThursdayHours();
          }
  
          public function getFridayHours() {
              return $this-&gt;company-&gt;getFridayHours();
          }
  
          public function getSaturdayHours() {
              return $this-&gt;company-&gt;getSaturdayHours();
          }
  
          public function getSundayHours() {
              return $this-&gt;company-&gt;getSundayHours();
          }
  
          public function getStoreImagePath() {
              return $this-&gt;company-&gt;getStoreImagePath();
          }
  
          public function getShopDescription() {
              return $this-&gt;company-&gt;getShopDescription();
          }
  
          public function isBusinessVerified() {
              return $this-&gt;company-&gt;getVerifiedBusiness();
          }
  
      public function setCompanyInfoChangeRequest($company) {
          $this-&gt;companyInfoChangeRequest = $company;
      }
  
      public function submitCompanyInfoChangeRequest($company) {
          $this-&gt;companyInfoChangeRequest = new CompanyInfoChangeRequest($this, $company);
          $this-&gt;companyInfoChangeRequest-&gt;submitCompanyInfoChangeRequest();
      }
  
      public function cancelCompanyInfoChangeRequest() {
          if ($this-&gt;changeRequestPending) {
              $this-&gt;companyInfoChangeRequest-&gt;cancelRequest();
          }
      }
  
      public function isCompanyChangeRequestPending() {
          return $this-&gt;changeRequestPending;
      }
  
      public function approveCompanyInfoChangeRequest($company) {
          $this-&gt;companyInfoChangeRequest-&gt;approveCompanyInfoChangeRequest($this);
      }
  
      public function setChangeRequestPending($isPending) {
          $this-&gt;changeRequestPending = (bool) $isPending;
      }
          public function getChangeRequestCompanyName() {
              return $this-&gt;companyInfoChangeRequest-&gt;getCompanyName();
          }
  
          public function getChangeRequestBusinessType() {
              return $this-&gt;companyInfoChangeRequest-&gt;getBusinessType();
          }
  
          public function getChangeRequestCompanyPhone() {
              return $this-&gt;companyInfoChangeRequest-&gt;getCompanyPhone();
          }
  
          public function getChangeRequestCompanyStreet() {
              return $this-&gt;companyInfoChangeRequest-&gt;getCompanyStreet();
          }
  
          public function getChangeRequestCompanyCity() {
              return $this-&gt;companyInfoChangeRequest-&gt;getCompanyCity();
          }
  
          public function getChangeRequestCompanyState() {
              return $this-&gt;companyInfoChangeRequest-&gt;getCompanyState();
          }
  
          public function getChangeRequestCompanyZip() {
              return $this-&gt;companyInfoChangeRequest-&gt;getCompanyZip();
          }
  
          public function getChangeRequestMondayHours() {
              return $this-&gt;companyInfoChangeRequest-&gt;getMondayHours();
          }
  
          public function getChangeRequestTuesdayHours() {
              return $this-&gt;companyInfoChangeRequest-&gt;getTuesdayHours();
          }
  
          public function getChangeRequestWednesdayHours() {
              return $this-&gt;companyInfoChangeRequest-&gt;getWednesdayHours();
          }
  
          public function getChangeRequestThursdayHours() {
              return $this-&gt;companyInfoChangeRequest-&gt;getThursdayHours();
          }
  
          public function getChangeRequestFridayHours() {
              return $this-&gt;companyInfoChangeRequest-&gt;getFridayHours();
          }
  
          public function getChangeRequestSaturdayHours() {
              return $this-&gt;companyInfoChangeRequest-&gt;getSaturdayHours();
          }
  
          public function getChangeRequestSundayHours() {
              return $this-&gt;companyInfoChangeRequest-&gt;getSundayHours();
          }
  
          public function getChangeRequestStoreImagePath() {
              return $this-&gt;companyInfoChangeRequest-&gt;getStoreImagePath();
          }
  
          public function getChangeRequestShopDescription() {
              return $this-&gt;companyInfoChangeRequest-&gt;getShopDescription();
          }
  
  }
  </code></pre>
  
  <p>Some of the methods with the warning <code>"Method not found in class..."</code> are <code>getCompanyName()</code> <code>getBusinessType()</code> <code>getCompanyPhone()</code> and any other method that calls a method on <code>$this-&gt;company</code> or <code>$this-&gt;companyInfoChangeRequest</code>.</p>
  
  <p>I know why this is happening. It's because PHPStorm doesn't know what the variable is an instance of. I noticed here <a href="https://stackoverflow.com/questions/27787607/method-not-found-in-class">Method not found in class</a> they used a PHPDoc comment to type hint the variable type so PHPStorm knows where to look. <strong>I would like a "non-comment" solution</strong> because if I come across a comment in the future I'm liable to delete it. Sorry about the long class. I'm importing the project into PHPStorm so I can start to do some refactoring. Thanks.</p>