Bug #64800 [NEW]: Example 1 appears incorrect
From: bsasser at sindtech dot net
Operating system: n/a
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Bug
Bug description:Example 1 appears incorrect
Description:
------------
The comments for Example 1 at
http://www.php.net/manual/en/language.oop5.interfaces.php
appear to be
technically incorrect.
The comment states:
"// Fatal error: Class BadTemplate contains 1 abstract methods
// and must therefore be declared abstract (iTemplate::getHtml)"
When I copy & paste the entire example into a text editor and 'Search' for
the word 'abstract', the only two places it appears are in the comment as
noted above.
This also means iTemplate::getHtml is not declared 'abstract'.
Declaration of Template::getHtml:
public function getHtml($template)
The only way it seems the comments can be correct are if declaring an
interface automatically makes those functions or methods, abstract. There
is no such mention of this, that I could find, at the specified URL.
Test script:
---------------
URL: http://www.php.net/manual/en/language.oop5.interfaces.php
// This will not work
// Fatal error: Class BadTemplate contains 1 abstract methods
// and must therefore be declared abstract (iTemplate::getHtml)
class BadTemplate implements iTemplate
{
private $vars = array();
public function setVariable($name, $var)
{
$this->vars[$name] = $var;
}
}
?>
Expected result:
----------------
// This will work
// No error: because there is no method or function explicitly declared
'abstract' in this example.
{
private $vars = array();
public function setVariable($name, $var)
{
$this->vars[$name] = $var;
}
}
?>
--
Edit bug report at https://bugs.php.net/bug.php?id=64800&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64800&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64800&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64800&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64800&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64800&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64800&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64800&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64800&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64800&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64800&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64800&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64800&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64800&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64800&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64800&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64800&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64800&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64800&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64800&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64800&r=mysqlcfg
Thread (2 messages)
- bsasser at sindtech dot net