@@ -35,18 +35,18 @@ class BufferedReader extends Reader {
3535 private $ bufferSize = 0 ;
3636 private $ buffer = null ;
3737 private $ bufferPos = 0 ;
38-
38+
3939 /**
4040 * The Reader we are buffering for.
4141 */
4242 private $ in ;
43-
43+
4444 /**
45- *
45+ *
4646 * @param object $reader The reader (e.g. FileReader).
4747 * @param integer $buffsize The size of the buffer we should use for reading files.
4848 * A large buffer ensures that most files (all scripts?) are parsed in 1 buffer.
49- */
49+ */
5050 function __construct (Reader $ reader , $ buffsize = 65536 ) {
5151 $ this ->in = $ reader ;
5252 $ this ->bufferSize = $ buffsize ;
@@ -57,53 +57,53 @@ function __construct(Reader $reader, $buffsize = 65536) {
5757 * @return mixed buffer or -1 if EOF.
5858 */
5959 function read ($ len = null ) {
60- // ignore $len param, not sure how to hanlde it, since
60+ // ignore $len param, not sure how to hanlde it, since
6161 // this should only read bufferSize amount of data.
6262 if ($ len !== null ) {
6363 $ this ->currentPosition = ftell ($ this ->fd );
6464 }
65-
65+
6666 if ( ($ data = $ this ->in ->read ($ this ->bufferSize )) !== -1 ) {
67-
67+
6868 // not all files end with a newline character, so we also need to check EOF
6969 if (!$ this ->in ->eof ()) {
70-
70+
7171 $ notValidPart = strrchr ($ data , "\n" );
7272 $ notValidPartSize = strlen ($ notValidPart );
73-
73+
7474 if ( $ notValidPartSize > 1 ) {
7575 // Block doesn't finish on a EOL
7676 // Find the last EOL and forgot all following stuff
7777 $ dataSize = strlen ($ data );
7878 $ validSize = $ dataSize - $ notValidPartSize + 1 ;
79-
79+
8080 $ data = substr ($ data , 0 , $ validSize );
81-
81+
8282 // Rewind to the begining of the forgotten stuff.
8383 $ this ->in ->skip (-$ notValidPartSize +1 );
8484 }
85-
85+
8686 } // if !EOF
8787 }
8888 return $ data ;
8989 }
90-
90+
9191 function skip ($ n ) {
9292 return $ this ->in ->skip ($ n );
9393 }
94-
94+
9595 function reset () {
9696 return $ this ->in ->reset ();
9797 }
98-
98+
9999 function close () {
100100 return $ this ->in ->close ();
101101 }
102-
102+
103103 function open () {
104104 return $ this ->in ->open ();
105105 }
106-
106+
107107 /**
108108 * Read a line from input stream.
109109 */
@@ -122,12 +122,12 @@ function readLine() {
122122
123123 return $ line ;
124124 }
125-
125+
126126 /**
127127 * Reads a single char from the reader.
128128 * @return string single char or -1 if EOF.
129129 */
130- function readChar () {
130+ function readChar () {
131131
132132 if ( $ this ->buffer === null ) {
133133 // Buffer is empty, fill it ...
@@ -138,11 +138,11 @@ function readChar() {
138138 $ this ->buffer = $ read ;
139139 return $ this ->readChar (); // recurse
140140 }
141- } else {
141+ } else {
142142 // Get next buffered char ...
143143 // handle case where buffer is read-in, but is empty. The next readChar() will return -1 EOF,
144144 // so we just return empty string (char) at this point. (Probably could also return -1 ...?)
145- $ ch = ($ this ->buffer !== "" ) ? $ this ->buffer { $ this ->bufferPos } : '' ;
145+ $ ch = ($ this ->buffer !== "" ) ? $ this ->buffer [ $ this ->bufferPos ] : '' ;
146146 $ this ->bufferPos ++;
147147 if ( $ this ->bufferPos >= strlen ($ this ->buffer ) ) {
148148 $ this ->buffer = null ;
@@ -152,19 +152,19 @@ function readChar() {
152152
153153 return $ ch ;
154154 }
155-
155+
156156 /**
157157 * Returns whether eof has been reached in stream.
158158 * This is important, because filters may want to know if the end of the file (and not just buffer)
159159 * has been reached.
160160 * @return boolean
161- */
161+ */
162162 function eof () {
163163 return $ this ->in ->eof ();
164164 }
165165
166166 function getResource () {
167167 return $ this ->in ->getResource ();
168- }
168+ }
169169}
170170?>
0 commit comments