Is there any way to suppress particular types of errors in PHPDoc, or direct it not to check for some elements?
I don't need a DocBlock for both the file and the class. My typical layout is as follows:
<?php
/**
* Registration service
*
* Coordinates the registration actions for users. These are ...
*
* #version a.4.2
* #author My Name <me at example.com>
*/
namespace MyProject\Service;
use Other\Namespace;
class Registration extends AbstractService
{
// ...
In this case, PHPDoc complains that I have no class summary. I can remedy the problem by copying the DocBlock and pasting it immediately above the class declaration, but I'm hoping for a better solution.
If I'm not mistaken, and I didn't test this, you could do something like this:
<?php
namespace MyProject\Service;
use Other\Namespace;
/**
* Registration service
*
* Coordinates the registration actions for users. These are ...
*
* #version a.4.2
* #author My Name <me at example.com>
*/
class Registration extends AbstractService
{
// ...
At least the docblock should now be recognised as a class doc instead of a file doc, which is more accurate in this particular example.
To try and answer your original question, actually suppressing the error, you could try this answer (it describes using the command line --packageoutput argument).
Related
I am having a lot of trouble getting PHPStan to see the FuelPHP core classes. It would appear this sort of thing causes it grief:
namespace Fuel\Core;
/**
* Template Controller class
*
* A base controller for easily creating templated output.
*
* #package Fuel
* #category Core
* #author Fuel Development Team
*/
abstract class Controller_Template extends \Controller
{
/**
* #var string page template
*/
public $template = 'template';
Where Controller is also in the Fuel\Core namespace:
namespace Fuel\Core;
abstract class Controller
{
/**
* #var Request The current Request object
*/
public $request;
It looks like PHPStan can's find Controller because it is looking in the root namespace. FuelPHP gets around this (magic? autoloading? aliasing?). Is there a way to get PHPStan to jump on the same bandwagon, or do I need to stub out all the core classes I'm using?
Did you try to follow this guide? PHPStan: Discovering symbols
I helped set up FuelCMS analysis in the past. What worked for that user was this phpstan.neon:
parameters:
scanDirectories:
- core/classes
bootstrapFiles:
- core/classes/autoloader.php
There's an example repository that works: https://github.com/ondrejmirtes/phpstan_problem/tree/fix
For some reason the phpstan.neon is buried in app/classes/controller while it should definitely be in the root directory. But otherwise it works.
I have namespaced PHP classes documented as such:
<?php
namespace container;
/**
* Description of Stuff
*
* \xrefitem wpaction "Actions" "Actions Wordpress" init
*/
class Stuff {}
Other example:
<?php
namespace container;
/**
* Description of Things
*
* \xrefitem wpaction "Actions" "Actions Wordpress" admin
*/
class Things {}
They are cross-referenced in the page defined as such:
/**
* \page wpaction Wordpress actions
*
* All Wordpress actions used by ACME software.
*/
The problem is that, instead of class names, only the container namespace appears in the Doxygen generated cross-reference page:
container\Stuff and container\Things should appear instead.
Is this a bug or am I doing something wrong? How can I fix this?
(I use ALIASES to shorten calls to \xrefitem in production code, but I omitted it in this test case to narrow down the problem.)
I'm working on a project that uses the Lithium (http://li3.me/) framework and they document their classes like this:
class Controller extends \lithium\core\Object {
/**
* Contains an instance of the `Request` object with all the details of the HTTP request that
* was dispatched to the controller object. Any parameters captured in routing, such as
* controller or action name are accessible as properties of this object, i.e.
* `$this->request->controller` or `$this->request->action`.
*
* #see lithium\action\Request
* #var object
*/
public $request = null;
I've always used fully qualified class names in the #var and Eclipse seems to do a good job with that for generating content assist. However they seem to document class names using #see tags instead, and content assist is not available. Is there a way to configure PDT to use the information in the #see tag as a class name for the purposes of content assist?
It's not possible without own plugin. #see tag should be used for links only.
I integrated PHPUnit into netbeans and now want to generate tests for my code.
<?php
/**
* Action User
*
* user api
*
* #link http://getfrapi.com
* #author Frapi <frapi#getfrapi.com>
* #link rsmobile/user/:id
*/
class Action_User extends Frapi_Action implements Frapi_Action_Interface
{
}
?>
I tried to do that by right clicking and selecting Tools->Create PHPUnit Tests. But it gave this error :
Fatal error: Class 'Frapi_Action' not found in /Users/username/Documents/.../src/
frapi/custom/Action/User.php on line 12
Then I added dummy Frapi_Action class in file User.php and then it generated skeleton class.
<?php
/**
* Action User
*
* user api
*
* #link http://getfrapi.com
* #author Frapi <frapi#getfrapi.com>
* #link rsmobile/user/:id
*/
class Frapi_Action {}
class Action_User extends Frapi_Action implements Frapi_Action_Interface
{
}
?>
Why it gave that Class not found error? How do I solve it?
I solved it by adding path of the file containing Frapi_Action class.
require_once 'path/of/file';
Your class is not in the source code in the original example. You either need to include/require the external file containing the class (recommended) or have the class in this code.
PHPDocumenter keeps telling me that my page-level docblock is not present in my file, i read several pages of documentation online to make this work but still doesn't work, anyone know whats wrong?
<?php
namespace Activis\Catalog\Model;
/**
* This file represents the factory for the domain object Product for the Activis catalog.
*
* For now, this factory is simple and abstract but will slowly change into a non-static set of factory functions
* The domain model for this object is \Activis\Catalog\Model\Product
*
* #category Domain model factory
* #package Activis.Catalog.Model
* #author Mathieu Dumoulin
* #license LGPL v3
* #link http://activis.ca/
* #todo Change the methods in the factory to not be abstract and require an instance of this class
*/
/**
* Declares the catalog's product's domain model factory
*
* #abstract
* #static
*/
abstract class ProductFactory
{
}
Page-level docblock should be placed on top of file, before namespace declarations