PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Text » Text_Statistics » Bug #4492

Undefined index for each new word

Details

Submitted2005-05-31 20:07 UTC
Frommjohnson at pitsco dot com
Assignedcweiske
StatusClosed
PackageText_Statistics
PHP VersionIrrelevant
OSNA
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++;
}
}