@@ -81,6 +81,11 @@ class PHP_CodeCoverage_Report_HTML_Node_File extends PHP_CodeCoverage_Report_HTM
8181 */
8282 protected $ testData ;
8383
84+ /**
85+ * @var boolean
86+ */
87+ protected $ cacheTokens = TRUE ;
88+
8489 /**
8590 * @var boolean
8691 */
@@ -148,11 +153,12 @@ class PHP_CodeCoverage_Report_HTML_Node_File extends PHP_CodeCoverage_Report_HTM
148153 * @param PHP_CodeCoverage_Report_HTML_Node $parent
149154 * @param array $coverageData
150155 * @param array $testData
156+ * @param boolean $cacheTokens
151157 * @param boolean $yui
152158 * @param boolean $highlight
153159 * @throws PHP_CodeCoverage_Exception
154160 */
155- public function __construct ($ name , PHP_CodeCoverage_Report_HTML_Node $ parent , array $ coverageData , array $ testData , $ yui = TRUE , $ highlight = FALSE )
161+ public function __construct ($ name , PHP_CodeCoverage_Report_HTML_Node $ parent , array $ coverageData , array $ testData , $ cacheTokens , $ yui , $ highlight )
156162 {
157163 parent ::__construct ($ name , $ parent );
158164
@@ -166,11 +172,12 @@ public function __construct($name, PHP_CodeCoverage_Report_HTML_Node $parent, ar
166172
167173 $ this ->coverageData = $ coverageData ;
168174 $ this ->testData = $ testData ;
175+ $ this ->cacheTokens = $ cacheTokens ;
169176 $ this ->highlight = $ highlight ;
170177 $ this ->yui = $ yui ;
171178 $ this ->codeLines = $ this ->loadFile ($ path );
172179 $ this ->ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored (
173- $ path
180+ $ path, $ cacheTokens
174181 );
175182
176183 $ this ->calculateStatistics ();
@@ -830,8 +837,14 @@ protected function loadFile($file)
830837
831838 protected function processClasses ()
832839 {
833- $ file = $ this ->getId () . '.html# ' ;
834- $ tokens = PHP_Token_Stream_CachingFactory::get ($ this ->getPath ());
840+ $ file = $ this ->getId () . '.html# ' ;
841+
842+ if ($ this ->cacheTokens ) {
843+ $ tokens = PHP_Token_Stream_CachingFactory::get ($ this ->getPath ());
844+ } else {
845+ $ tokens = new PHP_Token_Stream ($ this ->getPath ());
846+ }
847+
835848 $ classes = $ tokens ->getClasses ();
836849 unset($ tokens );
837850
@@ -870,7 +883,12 @@ protected function processClasses()
870883
871884 protected function processFunctions ()
872885 {
873- $ tokens = PHP_Token_Stream_CachingFactory::get ($ this ->getPath ());
886+ if ($ this ->cacheTokens ) {
887+ $ tokens = PHP_Token_Stream_CachingFactory::get ($ this ->getPath ());
888+ } else {
889+ $ tokens = new PHP_Token_Stream ($ this ->getPath ());
890+ }
891+
874892 $ functions = $ tokens ->getFunctions ();
875893 unset($ tokens );
876894
0 commit comments