PHP code example of automattic / jetpack-analyzer

1. Go to this page and download the library: Download automattic/jetpack-analyzer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

automattic / jetpack-analyzer example snippets


$declarations = new Automattic\Jetpack\Analyzer\Declarations();

// single file
$declarations->scan( $base_path . '/class.jetpack.php' );

// OR recursively scan a directory
$exclude = array( '.git', 'vendor', 'tests', 'docker', 'bin', 'scss', 'images', 'docs', 'languages', 'node_modules' );
$declarations->scan( $base_path, $exclude );

// print the declarations
$declarations->print();

// save the declarations as CSV
$declarations->save( 'path/to/jetpack-master.csv' );

// load some other declarations
$jp74_declarations->load( 'path/to/jetpack-branch-7.4.csv' );

// load declarations from a file, or scan using ->scan()
$master_declarations->load( 'path/to/codebase-1.0.csv' );
$other_declarations->load( 'path/to/codebase-2.0.csv' );
// OR
$master_declarations->scan( 'path/to/master_branch', array( '.git', 'node_modules' ) );
$other_declarations->scan( 'path/to/other_branch', array( '.git', 'node_modules' ) );

$differences = new Automattic\Jetpack\Analyzer\Differences();
$differences->find( $master_declarations, $jp74_declarations );
$differences->print();

$invocations = new Automattic\Jetpack\Analyzer\Invocations();
$invocations->scan( 'path/to/example.php' ); // can be a file or directory
// OR
$invocations->scan( 'path/to/repo', array( '.git', '.gitmodules', 'assets' ) );

$invocations->print();

// assumes `$differences` and `$invocations` have already been generated as per above
$warnings = new Automattic\Jetpack\Analyzer\Warnings();
$warnings->generate( $invocations, $differences );
$warnings->print();