phpdoc

How to typehint context in an IDE?

∥☆過路亽.° 提交于 2021-02-08 15:55:28
问题 I am using Closure::call (http://php.net/manual/en/closure.call.php) to call an external closure inside a class context. Here's a simple repro: class Foo { private $bar = 'baz'; /** * Executes a closure in $this context and returns whatever the closure returns. * * @param \Closure $closure * @return mixed */ public function callClosureInThisContext(\Closure $closure) { return $closure->call($this); } } class Closures { /** * @return \Closure */ public function getClosureForFoo() : \Closure {

PHPdoc - defining object properties for an object of stdClass

﹥>﹥吖頭↗ 提交于 2021-02-06 08:00:23
问题 I am trying to figure out if it is possible to use PHPdoc to define the object properties being returned by a function or a object method. Say I have the following class: class SomeClass { public function staffDetails($id){ $object = new stdClass(); $object->type = "person"; $object->name = "dave"; $object->age = "46"; return $object; } } Now, it is easy enough to define input parameters. /** * Get Staff Member Details * * @param string $id staff id number * * @return object */ class

PHPdoc - defining object properties for an object of stdClass

a 夏天 提交于 2021-02-06 07:58:48
问题 I am trying to figure out if it is possible to use PHPdoc to define the object properties being returned by a function or a object method. Say I have the following class: class SomeClass { public function staffDetails($id){ $object = new stdClass(); $object->type = "person"; $object->name = "dave"; $object->age = "46"; return $object; } } Now, it is easy enough to define input parameters. /** * Get Staff Member Details * * @param string $id staff id number * * @return object */ class

PHPdoc - defining object properties for an object of stdClass

风流意气都作罢 提交于 2021-02-06 07:58:12
问题 I am trying to figure out if it is possible to use PHPdoc to define the object properties being returned by a function or a object method. Say I have the following class: class SomeClass { public function staffDetails($id){ $object = new stdClass(); $object->type = "person"; $object->name = "dave"; $object->age = "46"; return $object; } } Now, it is easy enough to define input parameters. /** * Get Staff Member Details * * @param string $id staff id number * * @return object */ class

annotating a local variable in php

陌路散爱 提交于 2021-02-05 14:52:10
问题 I am using Eclipse PDT and I want to annotate a local variable using Phpdoc. All I see is that I can annotate the variables/properties of a class using @var or even @property , but how is this possible for a local variable? How can I do something like this? function foo(){ /** @var Stock $a */ $a->save(); } 回答1: The Phpdoc standard does not cover these annotations (it only cover class properties with the @var tag); however, it is perfectly possible in Eclipse (e.g. PDT): /* @var $variable

annotating a local variable in php

孤者浪人 提交于 2021-02-05 14:50:08
问题 I am using Eclipse PDT and I want to annotate a local variable using Phpdoc. All I see is that I can annotate the variables/properties of a class using @var or even @property , but how is this possible for a local variable? How can I do something like this? function foo(){ /** @var Stock $a */ $a->save(); } 回答1: The Phpdoc standard does not cover these annotations (it only cover class properties with the @var tag); however, it is perfectly possible in Eclipse (e.g. PDT): /* @var $variable

Prevent PHP from parsing non-PHP files such as someFile.php.txt

那年仲夏 提交于 2021-02-04 17:37:07
问题 I just installed phpdocumentor, but received strange errors. I finally tracked down the problem. Phpdocumentor creates various files such as someFile.php.txt which contains PHP code, but aren't meant to be parsed. Turns out, my server is parsing them. I've also tested a file name called someFile.txt, and it isn't being parsed. How do I prevent my PHP server from parsing files such as someFile.php.txt? My server is PHP Version 5.4.20, Apache 2.2.15, and CentOS 6.4. My /etc/httpd/conf.d/php

Why do I get a PHPDoc warning in PhpStorm over this code

家住魔仙堡 提交于 2021-01-21 12:23:09
问题 I can't understand why PhpStorm gives me the following warning PHPDoc comment does not match function or method signature over this method: /** * Create a new instance of the class * @param string $classname Class to instantiate * @return object the instance * @throw FactoryException If the class is not instantiable */ private function newInstance($classname) { $reflectionClass = new \ReflectionClass($classname); if (! $reflectionClass->isInstantiable()) { throw new FactoryException("The