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
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.
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).
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.
My code looks like this:
/**
* #package Test
*/
require_once('foo.php');
/**
* Main class
*/
class Test{
}
/**
* Generic exception
*/
class Test_Excepcion extends Exception{
}
I want the first docblock to be a file level block, but ApiGen seems to link it to the require statement and my classes show up in the "None" namespace. It gets fixed if I do e.g. this:
/**
* #package Test
*/
//
require_once('foo.php');
Is this the intended behaviour? Do I need to add a bogus comment after the file level block? What are the precise rules?
The #package tag is not necessarily a file-level block. You can specify the #package tag for each class in your file. Like this:
/**
* Main class
* #package Test
*/
class Test{}
I'm looking for a way to make PHPStorm hide some methods from code completion. I've tried to annotate the DocBlocks with #access private but that does not hide them from view.
Is there any way to hide private API, short of writing/generating a stub file with a limited interface and referencing that in my project?
for example:
Lets say the library has this in it:
<?php
interface IDoABunchOfStuff
{
/**
* My library users use this
*/
public function doFoo();
/**
* My Library needs this but requires that my users don't see it.
*
* #access private
* #visibility none
* #package mylib
* #internal
*/
public function doBar();
}
class Foo extends Something implements IDoABunchOfStuff
{
/**
* does foo
*/
public function doFoo()
{
// ...
}
/**
* does bar. for internal use only
*
* #access private
* #visibility none
* #package mylib
* #internal
*/
public function _doBar()
{
// ...
}
}
And my library user is typing:
<?php
myAwesomeFunction(IDoABunchOfStuff $aFoo)
{
if($->$oFoo->[CTRL+SPACE] // invoking code completion...
Is it possible to (and if it is how do I) make it so that my user never sees _doBar?
Neither of the different annotations i've tried seem to have the desired effect.
P.S. I'm using PHPStorm 4.0.3
additional:
In this case I am implementing ArrayAccess and I don't want offsetGet, offsetSet, offsetExists and offsetUnset cluttering up my code completion window but I've had similar problems elsewhere enough to warrant asking a more generalized question.
Nope -- you cannot do such thing in current version of PhpStorm.
There is a ticket on Issue Tracker that suggests using #access tag for this purpose, but currently it is not scheduled to be implemented for any particular version: http://youtrack.jetbrains.com/issue/WI-5788
Feel free to vote/comment/etc and maybe it will be implemented sooner.