BingAds / BingAds-PHP-SDK

Other
56 stars 45 forks source link

Codestyle fixes. Adding missed phpDoc. className -> static in methods… #29

Open ValeriyMaslenikov opened 6 years ago

ValeriyMaslenikov commented 6 years ago

… which returns $this.

Hi guys. To use correct autocomplete and type highlighting in IDE, like PhpStorm let's use static keyword instead of class name in @return block.

In this case IDE will notify us that methodFromB() doesn't exist, because it will expect that method iWillReturnThis returns class A:

class A {
 /**
  * @return A
  */
  public function iWillReturnThis() { 
    return $this; 
  }
} 

class B extends A {
  public function methodFromB() { }
}

(new B())->iWillReturnThis()->methodFromB()

In this case it works well:

class A {
 /**
  * @return static
  */
  public function iWillReturnThis() { 
    return $this; 
  }
} 
...

And to make fluent interface highlighting works well with public properties, let's use phpDoc @var near property declaration, like:

class A {
  /** @var B */
  public $B;
}
class B {
  public function method();
}

(new A())->B->method()
eric-urban commented 6 years ago

@ValeriyMaslenikov thanks for the suggestions! We will keep these in mind for a future release.

eric-urban commented 4 years ago

@ValeriyMaslenikov thanks again for the feedback. We resolved most PHP doc issues in version 13.0.1.