168 $chunkSize = (int)ceil( count( $files ) / 72 );
170 $parser = (
new PhpParser\ParserFactory )->createForVersion( PhpParser\PhpVersion::fromComponents( 7, 0 ) );
171 $traverser =
new PhpParser\NodeTraverser;
173 $traverser->addVisitor( $finder );
175 $fileCount = count( $files );
177 $outputProgress = !defined(
'MW_PHPUNIT_TEST' );
179 for ( $i = 0; $i < $fileCount; $i++ ) {
181 $code = file_get_contents( $file );
183 if ( !str_contains( $code,
'@deprecated' ) ) {
187 $finder->setCurrentFile( substr( $file->getPathname(), strlen(
$IP ) + 1 ) );
188 $nodes = $parser->parse( $code );
189 $traverser->traverse( $nodes );
191 if ( $i % $chunkSize === 0 ) {
192 $percentDone = 100 * $i / $fileCount;
193 if ( $outputProgress ) {
194 fprintf( STDERR,
"\r[%-72s] %d%%", str_repeat(
'#', $i / $chunkSize ), $percentDone );
199 if ( $outputProgress ) {
200 fprintf( STDERR,
"\r[%'#-72s] 100%%\n",
'' );
204 if ( parent::posix_isatty( STDOUT ) ) {
205 $versionFmt =
"\n* Deprecated since \033[37;1m%s\033[0m:\n";
206 $entryFmt =
" %s \033[33;1m%s\033[0m (%s:%d)\n";
208 $versionFmt =
"\n* Deprecated since %s:\n";
209 $entryFmt =
" %s %s (%s:%d)\n";
212 foreach ( $finder->getFoundNodes() as $version => $nodes ) {
213 printf( $versionFmt, $version );
214 foreach ( $nodes as $node ) {
217 $node[
'hard'] ?
'+' :
'-',
224 printf(
"\nlegend:\n -: soft-deprecated\n +: hard-deprecated (via wfDeprecated())\n" );