Home » Text » Text_Statistics » Bug #4492
Undefined index for each new word
Details
| Submitted | 2005-05-31 20:07 UTC |
|---|---|
| From | mjohnson at pitsco dot com |
| Assigned | cweiske |
| Status | Closed |
| Package | Text_Statistics |
| PHP Version | Irrelevant |
| OS | NA |
| Roadmaps | (Not assigned) |
Comments
[2005-05-31 20:07 UTC] mjohnson at pitsco dot com
Description:
------------
If error_reporting is set to E_ALL, a notice is issued for each new word, as well as the first access to the $_uniques property.
The easiest solution is to add $_uniques as a variable in the class and using the @ operator on the increment. See reproduce code for a patch. Due to the 20 line restriction, I didn't document $_uniques.
Reproduce code:
---------------
--- Statistics.orig.php 2005-05-31 13:02:31.710024025 -0500
+++ Statistics.x.php 2005-05-31 15:04:37.508227929 -0500
@@ -111,6 +111,8 @@
'/Dr\./i' => 'Doctor',
);
+ var $_uniques = array();
+
/*
* Constructor.
*
@@ -156,7 +158,7 @@
$w_obj = new Text_Word($word);
$this->numSyllables += $w_obj->numSyllables();
$this->numWords++;
- if($this->_uniques[strtolower($word)]++ == 0) {
+ if(@$this->_uniques[strtolower($word)]++ == 0) {
$this->uniqWords++;
}
}