public
Last active

Using PHP_CompatInfo on WordPress source

  • Download Gist
compat.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
<?php
 
require 'c:\UniServer\home\us_pear\pear\Bartlett\PHP\CompatInfo.php';
 
$source = 'c:\server\resources\wordpress';
 
$options = array(
'cacheOptions' => array( 'save_path' => 'c:\Temp\\' ),
'recursive' => true,
);
 
try {
$phpci = new PHP_CompatInfo($options);
$phpci->parse( $source );
 
$allResultsAtOnce = $phpci->toArray();
 
} catch ( PHP_CompatInfo_Exception $e ) {
die ('PHP_CompatInfo Exception : ' . $e->getMessage() . PHP_EOL);
}
 
$output = '';
$extensions = wp_list_pluck( $allResultsAtOnce, 'extensions' );
 
$extensions_output = array();
 
foreach ( $extensions as $node ) {
 
foreach ( $node as $name => $extension ) {
 
if ( ! isset($extensions_output[$name]) )
$extensions_output[$name] = array( 'uses' => 0,
'sources' => array() );
 
$extensions_output[$name]['uses'] += $extension['uses'];
 
// var_dump($extension['sources']);
 
if ( ! in_array( $extension['sources'], $extensions_output[$name]['sources'] ) )
$extensions_output[$name]['sources'][] = array_shift( str_replace( 'c:\server\resources\wordpress\\', '', $extension['sources'] ) );
}
 
}
 
unset($extensions_output['Core']);
unset($extensions_output['standard']);
//unset( $extensions_output['date'] );
//unset( $extensions_output['pcre'] );
//ksort( $extensions_output );
uksort( $extensions_output, 'strnatcasecmp' );
var_dump( $extensions_output );
 
foreach ( $extensions_output as $name => $extension ) {
 
$output .= "{$name}\t{$extension['uses']} uses\n";
 
$count = count( $extension['sources'] );
 
if ( 20 < $count ) {
 
$output .= "\n\t{$count} files";
}
else {
 
$output .= "\n";
 
foreach ( $extension['sources'] as $source ) {
 
$output .= "\t{$source}\n";
}
 
}
 
$output .= "\n---\n";
}
 
preprint( $output );
 
$output = '';
 
foreach ( $extensions_output as $name => $extension ) {
 
$output .= " - {$name}\n";
}
 
preprint( $output );
//var_dump($allResultsAtOnce);
//var_dump( $output );

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.