I'm trying to document a sample file:
/**
* ElasticSearch Library
*
* Intended to do some cool stuff
*
*
* #author cmvr
* #subpackage elasticSearch
* #copyright free to use
* #license http://www.gnu.org/copyleft/gpl.html Freely available under GPL
*/
namespace Libs;
/**
* This is the main class of elastic search
*/
class elasticSearch {
protected $dataConnection;
/**
* elastic search setup data connection
* #return boolean
*/
public function setupDataConnection($dataString) {
return true;
}
}
I'm running in the CLI:
phpdoc -f ../../app/libraries/elasticSearch.php -t ../../newDocs
And it's working fine, but when i'm viewing my html ouput here:
newDocs/files/elasticSearch.html
The class and the method setupDataConnection aren't documented at all.
This is the screens i see:
Can anyone explain what am i doing wrong?
Related
I read this and this. But how to setup this in NetBeans IDE in Windows machine?
Yii2 requires PHP 5.4 minimum, so if your IDE supports PHP 5.4 or later then it will show standards for Yii2 too.
You can also check this yii pligin for netbeans http://plugins.netbeans.org/plugin/47246/php-yii-framework-netbeans-phpcc
in root of your project make file with name of autocompletion.php and add this to file.
/**
* Yii bootstrap file.
* Used for enhanced IDE code autocompletion.
* Note: To avoid "Multiple Implementations" PHPStorm warning and make autocomplete faster
* exclude or "Mark as Plain Text" vendor/yiisoft/yii2/Yii.php file
*/
class Yii extends \yii\BaseYii
{
/**
* #var BaseApplication|WebApplication|ConsoleApplication the application instance
*/
public static $app;
}
/**
* Class BaseApplication
* Used for properties that are identical for both WebApplication and ConsoleApplication
*
* #property trntv\filekit\Storage $fileStorage
* #property common\components\keyStorage\KeyStorage $keyStorage
* #property yii\web\UrlManager $urlManagerFrontend UrlManager for frontend application.
* #property yii\web\UrlManager $urlManagerBackend UrlManager for backend application.
* #property yii\web\UrlManager $urlManagerStorage UrlManager for storage application.
* #property trntv\glide\components\Glide $glide
* #property trntv\bus\CommandBus $commandBus
*/
abstract class BaseApplication extends yii\base\Application
{
}
/**
* Class WebApplication
* Include only Web application related components here
*
* #property User $user User component.
*/
class WebApplication extends yii\web\Application
{
}
/**
* Class ConsoleApplication
* Include only Console application related components here
*/
class ConsoleApplication extends yii\console\Application
{
}
/**
* User component
* Include only Web application related components here
*
* #property \common\models\User $identity User model.
* #method \common\models\User getIdentity() returns User model.
*/
class User extends \yii\web\User
{
}
I currently use such order of annotations:
Code 1:
/**
* sets elements for main (top), secondary (sub1) level and tertiary (sub2) level;
* prevents sharing of content with previous instances
*
* #param string $TopElement
* #param string $SubElement1
* #param string $SubElement2
*
* #return void
*
* #throws MarC_Exception if top element was not set
* #throws MarC_Exception if sub1 element was not set
* #throws MarC_Exception if sub2 element was not set
* #throws MarC_Exception if all elements were set the same
*/
public function __construct($TopElement="", $SubElement1="", $SubElement2="")
{
...
}
Code 2:
/**
* elements used for creation of code
*
* #static
* #var array
*/
protected $Elements = array();
Code 3:
/**
* #package ...
*
* #author ...
* #copyright ...
*
* #license ...
*
* generation of advanced select menu
*/
At this time i don't use all annotations (probably all I use you can see in codes above).
And I wonder if in php is any suggested (preffered) order of annotations - or it is free matter of programmer (and then this question will be useless).
TLDR; It's a free matter
PHP coding standards differ on this. The best I can suggest is to pick a coding standard you like and run PHP CodeSniffer (https://github.com/squizlabs/PHP_CodeSniffer) against it and see what it suggest. Some coding standards require they be in a specific order and a specific spacing to your docblock annotations. Others are more relaxed and make no suggestions about docblock annotations what-so-ever.
To get PHP Code Sniffer:
$ curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
$ php phpcs.phar -h
$ php phpcs.phar --standard=[STANDARD_CHOICE] /path/to/project
Some coding standards you might want to consider:
http://www.php-fig.org/psr/psr-2/
http://framework.zend.com/manual/1.12/en/coding-standard.coding-style.html
http://pear.php.net/manual/en/rfc.header-comments.php
If you're worried about a document generators (like phpDocumentor) not being able to parse the docblock annotations, you can always check what annotations they support. I've never had a problem with phpDocumentor complaining about the ordering or formatting though.
As for custom annotations being used by libraries such as Doctrine, Symfony and PHPUnit, I've also never noticed the order having an impact on the parsing and processing.
I've been trying to document my configuration file, following the phpdocumentor documention I started with a simplified config file which looks like this:
/**
* Configuration / Settings file
*
* #package site
* #copyright 2013
* #author Nick
*
*/
/**
* Switch development mode on/off
*/
define('DEV_MODE',true);
The above constant pulls through into the documentation, however all it shows is the constant name (DEV_MODE), not any description.
Then I found this other question on here, which suggests adding #const to define the constant:
/**
* Configuration / Settings file
*
* #package site
* #copyright 2013
* #author Nick
*
*/
/**
* Switch development mode on/off
* #const DEV_MODE
*/
define('DEV_MODE',true);
But this still hasn't done anything different.
Not sure if it matters or not, but I'm using the phar file to run phpDoc.
Can anyone see something I'm doing wrong?
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.
Parse error: syntax error, unexpected T_CLASS in /homepages/1/d160385903/htdocs/etri/libraries/joomla/html/html/behavior.php on line 17
In this script:
<?php
/**
* #version $Id: behavior.php 18130 2010-07-14 11:21:35Z louis $
* #package Joomla.Framework
* #subpackage HTML
* #copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* #license GNU/GPL, see LICENSE.php
*
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('JPATH_BASE') or die();
/**
* JHTML helper class for loading JavaScript behaviors into the document head. This version is
* designed to load MooTools version 1.2 plus the 1.1 compatibility layer.
*
* #package Joomla.Framework
* #subpackage HTML
*
* #since 1.5.19
* #static
*/
class JHTMLBehavior
{
/**
* Method to load the mootools framework and compatibility layer into the document head. If the
* optional debug flag is set then a uncompressed version of the files will be loaded.
*
* #param boolean $debug True to enable debugging mode. If no value is set the value will
* be taken from the application configuration settings.
*
* #return void
*
* #since 1.5.19
* #static
*/
function mootools($debug = null)
{
// Check to see if it has already been loaded.
static $loaded;
if (!empty($loaded)) {
return;
}
// If no debugging value is set, use the setting from the application configuration.
if ($debug === null) {
$debug = JFactory::getConfig()->getValue('config.debug');
}
/*
* Note: Konqueror browser check.
* - If they fix thier issue with compressed javascript we can remove this.
*/
$kcheck = isset($_SERVER['HTTP_USER_AGENT']) ? strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'konqueror') : null;
// If the debugging flag is set or the browser is Konqueror use the uncompressed file.
if ($debug || $kcheck) {
JHTML::script('mootools-uncompressed.js', 'plugins/system/mtupgrade/', false);
}
else {
JHTML::script('mootools.js', 'plugins/system/mtupgrade/', false);
}
Any suggestions?
Thanks!
-M
Method chaining is not available in php 4.
It is available in PHP 5.x
Thats why $debug = JFactory::getConfig()->getValue('config.debug'); is working in PHP 5.x but not in PHP 4.x
This may help you.
Once I close the method and class statements, I don't receive any parse error with PHP 5.3.3. Which version of PHP are you using? And what version of the Joomla installation?