A filter should first call parent::read( $maxlength); to retrieve the data from the previous filter who, ultimately, retrieved it from the stream.
This method is called whenever data is read from the attached stream (such as with fread()). A filter should first call parent::read($maxlength); to retrieve the data from the previous filter who, ultimately, retrieved it from the stream. Your filter may then modify the data as needed and return it. Your filter should never return more than maxlength bytes. Since parent::read($maxlength); will also not return more than maxlength bytes this will ordinarily be a non-issue. However, if your filter increases the size of the data being returned, you should either call parent::read($maxlength-$x); where x is the most your filter will grow the size of the data read. Alternatively, you can build a read-buffer into your class.