Jump to content

PHPDoc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Tag: Reverted
Petrux (talk | contribs)
Undid revision 1249629219 by 2607:FEA8:AA99:EB00:6CAC:CA0B:1936:34D (talk) which replaced the relevant examples with junk code
 
Line 7: Line 7:
On August 13, 2013 the PHP Framework Interoperability Group began writing a formal specification (PSR) for PHPDoc.<ref name="psr"/>
On August 13, 2013 the PHP Framework Interoperability Group began writing a formal specification (PSR) for PHPDoc.<ref name="psr"/>


== Example ==

<syntaxhighlight lang="php">
<?php
/**

* Get all image nodes.
# Your solution here!
*

* @param \DOMNode $node The \DOMDocument instance

* @param boolean $strict If the document has to be valid
if($_SERVER["REQUEST_METHOD"]==="POST"){
*
if(isset($_POST['n']) && is_numeric($_POST['n'])){
* @return \DOMNode
$n=filter_input(INPUT_POST,'n',FILTER_VALIDATE_INT);
*/

public function getImageNodes(\DOMNode $node, $strict = true): \DOMNode
if ($n < 1) {
{
echo json_encode(["Error" => "The number must be a positive integer."]);
exit;
// ...
}
}
</syntaxhighlight>

$factors=generateFactors($n);

if(!empty($factors)){
echo "<ol>";
foreach($factors as $result)
echo "<li>$result</li>";
echo "</ol>";
}else{
echo json_encode(["Error" => "Invalid input."]);
}
}
}

function generateFactors($n){
$array=[];
for ($i = 1; $i <= $n / 2; $i++) {
if ($n % $i == 0) {
$array[] = $i; // Add factor
}
}
$array[] = $n; // Always include n as a factor
return $array;
}
?>


==See also==
==See also==

Latest revision as of 06:49, 11 October 2024

PHPDoc is an adaptation of Javadoc format for the PHP programming language. It is still an informal standard for commenting PHP code, but it is in the process of being formalized.[1] It allows external document generators like phpDocumentor, which is the de facto standard implementation,[1] to generate documentation of APIs and helps some IDEs such as Zend Studio, NetBeans, JetBrains PhpStorm, ActiveState Komodo Edit and IDE, PHPEdit and Aptana Studio to interpret variable types and other ambiguities in the loosely typed language and to provide improved code completion, type hinting and debugging.

PHPDoc supports documentation of both object-oriented and procedural code.

On August 13, 2013 the PHP Framework Interoperability Group began writing a formal specification (PSR) for PHPDoc.[1]

Example

[edit]
/**
 * Get all image nodes.
 *
 * @param \DOMNode     $node       The \DOMDocument instance
 * @param boolean      $strict     If the document has to be valid
 *
 * @return \DOMNode
 */
 public function getImageNodes(\DOMNode $node, $strict = true): \DOMNode
 {
     // ...
 }

See also

[edit]

References

[edit]
[edit]