filename
stringlengths
11
137
content
stringlengths
6
292k
projects/packages/assets/tests/php/test-assets.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName /** * Tests for Automattic\Jetpack\Assets methods * * @package automattic/jetpack-assets */ namespace Automattic\Jetpack; use Automattic\Jetpack\Constants as Jetpack_Constants; use Brain\Monkey; use Brain\Monkey\Filters; use Brain\Monkey\Function...
projects/packages/assets/tests/php/test-assets-files/js-and-css.asset.php
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'ver-from-js-and-css');
projects/packages/assets/tests/php/test-assets-files/everything.asset.php
<?php return array('dependencies' => array('wp-polyfill', 'wp-components', 'wp-i18n'), 'version' => 'ver-from-everything');
projects/packages/assets/tests/php/test-assets-files/i18n-map.php
<?php return array( 'domain' => 'target', 'type' => 'plugins', 'packages' => array( 'foo' => array( 'path' => 'path/to/foo', 'ver' => '1.2.3', ), 'bar' => '4.5.6', ), );
projects/packages/assets/src/class-assets.php
<?php /** * Jetpack Assets package. * * @package automattic/jetpack-assets */ namespace Automattic\Jetpack; use Automattic\Jetpack\Assets\Semver; use Automattic\Jetpack\Constants as Jetpack_Constants; use InvalidArgumentException; /** * Class Assets */ class Assets { /** * Holds all the scripts handles tha...
projects/packages/assets/src/class-semver.php
<?php /** * Simple semver version handling. * * We use this instead of something like `composer/semver` to avoid * plugins needing to include yet-another dependency package. The * amount of code we need here is pretty small. * * We use this instead of PHP's `version_compare()` because that doesn't * handle prer...
projects/packages/my-jetpack/tests/php/class-sample-module-product.php
<?php /** * Testing class * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; /** * Sample Module Product for testing */ class Sample_Module_Product extends Module_Product { /** * The product slug * * @var string */ public static $slug = 'sample-module-product'; /** * The Jetpack m...
projects/packages/my-jetpack/tests/php/test-videopress-product.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Tokens; use Automattic\Jetpack\My_Jetpack\Products\Videopress; use Jetpack_Options; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDBless_Options; use WorDBless\U...
projects/packages/my-jetpack/tests/php/test-product-search-stats.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\My_Jetpack\Products\Search_Stats; use PHPUnit\Framework\TestCase; /** * Unit tests for Search_Stats. * * @package automattic/my-jetpack */ class Test_Search_Stats extends TestCase {...
projects/packages/my-jetpack/tests/php/test-search-product.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Tokens; use Automattic\Jetpack\My_Jetpack\Products\Search; use Jetpack_Options; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDBless_Options; use WorDBless\Users...
projects/packages/my-jetpack/tests/php/test-hybrid-product.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Tokens; use Automattic\Jetpack\My_Jetpack\Products\Backup; use Jetpack_Options; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDBless_Options; use WorDBless\Users...
projects/packages/my-jetpack/tests/php/test-backup-product.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Tokens; use Automattic\Jetpack\My_Jetpack\Products\Backup; use Automattic\Jetpack\Redirect; use Jetpack_Options; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDB...
projects/packages/my-jetpack/tests/php/bootstrap.php
<?php /** * Bootstrap. * * @package automattic/ */ /** * Include the composer autoloader. */ require_once __DIR__ . '/../../vendor/autoload.php'; define( 'WP_DEBUG', true ); define( 'JETPACK_ENABLE_MY_JETPACK', true ); \WorDBless\Load::load();
projects/packages/my-jetpack/tests/php/class-broken-product.php
<?php /** * Testing class * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; /** * Broken product for testing */ class Broken_Product extends Module_Product { /** * Product slug * * @var string */ public static $slug = 'broken'; /** * Get the product name * * @return string ...
projects/packages/my-jetpack/tests/php/test-wpcom-products.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Tokens; use Automattic\Jetpack\Constants; use Jetpack_Options; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDBless_Options; use WorDBless\Users as WorDBless_Use...
projects/packages/my-jetpack/tests/php/test-products-rest.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Tokens; use Jetpack_Options; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDBless_Options; use WorDBless\Users as WorDBless_Users; use WP_REST_Request; use WP_RE...
projects/packages/my-jetpack/tests/php/test-products.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use PHPUnit\Framework\TestCase; require_once __DIR__ . '/assets/mock-classes.php'; /** * Unit tests for the REST API endpoints. * * @package automattic/my-jetpack * @see \Automattic\Jetpack\My_Jetpack\Re...
projects/packages/my-jetpack/tests/php/test-social-product.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Tokens; use Automattic\Jetpack\My_Jetpack\Products\Social; use Jetpack_Options; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDBless_Options; use WorDBless\Users...
projects/packages/my-jetpack/tests/php/test-jetpack-manage.php
<?php /** * Test the Jetpack Manage features in My Jetpack. * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use WorDBless\BaseTestCase; class Test_Jetpack_Manage extends BaseTestCase { /** * Admin user id * * @var int */ protected $admin_id; /** * Editor user id * ...
projects/packages/my-jetpack/tests/php/test-module-product.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Tokens; use Jetpack_Options; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDBless_Options; use WorDBless\Users as WorDBless_Users; require_once __DIR__ . '/clas...
projects/packages/my-jetpack/tests/php/test-activitylog.php
<?php /** * Test the Activity Log features in My Jetpack. * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use WorDBless\BaseTestCase; class Test_Activitylog extends BaseTestCase { /** * Admin user id * * @var int */ protected $admin_id; /** * Editor user id * * @v...
projects/packages/my-jetpack/tests/php/test-product-multiple-filenames.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\My_Jetpack\Products\Backup; use PHPUnit\Framework\TestCase; use WorDBless\Options as WorDBless_Options; /** * Unit tests for the REST API endpoints. * * @package automattic/my-jetpac...
projects/packages/my-jetpack/tests/php/assets/mock-classes.php
<?php // phpcs:disable namespace Automattic\Jetpack\My_Jetpack; class Mock_Boost_Child extends Products\Boost { public static function get_name() { return 'Child Boost'; } } class Mock_Boost_Invalid { public static function get_name() { return 'Child Boost'; } }
projects/packages/my-jetpack/src/class-rest-ai.php
<?php /** * Sets up the AI REST API endpoints. * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Jetpack_Options; use WP_Error; /** * Registers the REST routes for AI. */ ...
projects/packages/my-jetpack/src/class-products.php
<?php /** * Class for manipulating products * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; /** * A class for everything related to product handling in My Jetpack */ class Products { /** * Get the list of Products classes * * Here's where all the existing Products are regi...
projects/packages/my-jetpack/src/class-jetpack-manage.php
<?php /** * Tools to manage things related to "Jetpack Manage" * - Add Jetpack Manage menu item. * - Check if user is an agency (used by the Jetpack Manage banner) * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Admin_UI\Admin_Menu; use Automattic\Jetpack\Co...
projects/packages/my-jetpack/src/class-rest-zendesk-chat.php
<?php /** * Sets up the Zendesk Chat REST API endpoints. * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Client; /** * Registers the REST routes for Zendesk Chat. */ class REST_Zendesk_Chat { const TRANSIENT_EXPIRY = 1 * MINUTE_IN_SECONDS * 60...
projects/packages/my-jetpack/src/class-wpcom-products.php
<?php /** * Fetches and store the list of Jetpack products available in WPCOM * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Status\Visitor; use Jetpack_Options; use WP_Error; /** * Stores the list of products availa...
projects/packages/my-jetpack/src/class-rest-products.php
<?php /** * Sets up the Products REST API endpoints. * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use WP_Error; /** * Registers the REST routes for Products. */ class REST_Products { /** * Constructor. */ public function __construct() { register_rest_route( 'my-jetp...
projects/packages/my-jetpack/src/class-rest-purchases.php
<?php /** * Sets up the Purchases REST API endpoints. * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Connection\Manager as Connection_Manager; /** * Registers the REST routes for Purchases. */ class REST_Purchases ...
projects/packages/my-jetpack/src/class-initializer.php
<?php /** * WP Admin page with information and configuration shared among all Jetpack stand-alone plugins * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Admin_UI\Admin_Menu; use Automattic\Jetpack\Assets; use Automattic\Jetpack\Boost_Speed_Score\Jetpack_Boost...
projects/packages/my-jetpack/src/class-rest-product-data.php
<?php /** * Sets up the Product Data REST API endpoints. * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Client; use WP_Error; /** * Registers the REST routes for Product Data */ class REST_Product_Data { /** * Constructor. */ public functi...
projects/packages/my-jetpack/src/class-activitylog.php
<?php /** * Manage the display of an "Activity Log" menu item. * * @package automattic/my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Admin_UI\Admin_Menu; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\Redirect; /** * Activity Log features ...
projects/packages/my-jetpack/src/products/class-product.php
<?php /** * Base product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\Plugins_Installer; use Jetpack_Options; use WP_Error; /** * Class responsible for handlin...
projects/packages/my-jetpack/src/products/class-security.php
<?php /** * Security product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Module_Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; use WP_Error; /** * Class responsible for handling the Security product */ class Security extends Module_...
projects/packages/my-jetpack/src/products/class-crm.php
<?php /** * Boost product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; /** * Class responsible for handling the CRM product */ class Crm extends Product { /** * The product slug * ...
projects/packages/my-jetpack/src/products/class-module-product.php
<?php /** * Base Module product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Jetpack; use WP_Error; /** * Class responsible for handling the Module products * * Module products are those that are a Jetpack module behind the scenes. * * They require Jetpack plugin and will then act...
projects/packages/my-jetpack/src/products/class-social.php
<?php /** * Search product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Hybrid_Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; use Automattic\Jetpack\Status\Host; /** * Class responsible for handling the Social product */ class Social...
projects/packages/my-jetpack/src/products/class-videopress.php
<?php /** * VideoPress product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Hybrid_Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; /** * Class responsible for handling the VideoPress product */ class Videopress extends Hybrid_Product ...
projects/packages/my-jetpack/src/products/class-starter.php
<?php /** * Starter plan * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Module_Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; use WP_Error; /** * Class responsible for handling the Starter plan */ class Starter extends Module_Product {...
projects/packages/my-jetpack/src/products/class-stats.php
<?php /** * Jetpack Stats product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Initializer; use Automattic\Jetpack\My_Jetpack\Module_Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; use Automattic\Jetpack\Status\Host; use Jetpack_Options;...
projects/packages/my-jetpack/src/products/class-anti-spam.php
<?php /** * Anti_Spam product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; /** * Class responsible for handling the Anti_Spam product */ class Anti_Spam extends Product { /** * The p...
projects/packages/my-jetpack/src/products/class-search-stats.php
<?php /** * Get search stats for use in the wp-admin dashboard. * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\Connection\Client; use Jetpack_Options; /** * Search stats (e.g. post count, post type breakdown) */ class Search_Stats { const EXCLUDED_POST_TYPE...
projects/packages/my-jetpack/src/products/class-search.php
<?php /** * Search product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Constants; use Automattic\Jetpack\My_Jetpack\Hybrid_Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; use Automattic\Jetpack\Search\Modu...
projects/packages/my-jetpack/src/products/class-jetpack-ai.php
<?php /** * AI product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\My_Jetpack\Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; /** * Class responsible for handling the Jetpack AI pr...
projects/packages/my-jetpack/src/products/class-backup.php
<?php /** * Boost product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\My_Jetpack\Hybrid_Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; use Automattic\Jetpack\Redirect; use Jetpack_Options; use WP_Error; ...
projects/packages/my-jetpack/src/products/class-boost.php
<?php /** * Boost product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; /** * Class responsible for handling the Boost product */ class Boost extends Product { const FREE_TIER_SLUG ...
projects/packages/my-jetpack/src/products/class-hybrid-product.php
<?php /** * Base product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack; use Automattic\Jetpack\Modules; use Automattic\Jetpack\Plugins_Installer; use WP_Error; /** * Class responsible for handling the hybrid products * * Hybrid products are those that may work both as a stand-alone plugin...
projects/packages/my-jetpack/src/products/class-extras.php
<?php /** * Extras product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Product; /** * Class responsible for handling the Extras product. * Extras, so far, could be considered as Jetpack plugin bridge. */ class Extras extends Product { /** ...
projects/packages/my-jetpack/src/products/class-protect.php
<?php /** * Protect product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\My_Jetpack\Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; use Jetpack_Options; use WP_Error; /** * Class responsible for handling ...
projects/packages/my-jetpack/src/products/class-creator.php
<?php /** * Creator product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\My_Jetpack\Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; /** * Class responsible for handling the Creator product */ class Creator extends Product { const FREE_TIER_SLU...
projects/packages/my-jetpack/src/products/class-scan.php
<?php /** * Scan product * * @package my-jetpack */ namespace Automattic\Jetpack\My_Jetpack\Products; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\My_Jetpack\Module_Product; use Automattic\Jetpack\My_Jetpack\Wpcom_Products; use Automattic\Jetpack\Redirect; use Jetpack_Options; use WP_Error; /...
projects/packages/error/tests/php/test-error.php
<?php /** * Testing the Error package. * * @package automattic/jetpack-error */ use Automattic\Jetpack\Error; use PHPUnit\Framework\TestCase; /** * Class Test_Error */ class Test_Error extends TestCase { /** * Test Jetpack Error. */ public function test_jetpack_error() { $error = new Error(); $this->a...
projects/packages/error/tests/php/bootstrap.php
<?php /** * Bootstrap. * * @package automattic/jetpack-error */ /** * Load Composer autoloader. */ require_once __DIR__ . '/../../vendor/autoload.php';
projects/packages/error/src/class-error.php
<?php /** * Jetpack Error - a wrapper around WP_Error. * * @see https://codex.wordpress.org/Class_Reference/WP_Error * * @package automattic/jetpack-error */ namespace Automattic\Jetpack; /** * Class Automattic\Jetpack\Error */ class Error extends \WP_Error {}
projects/packages/analyzer/scripts/jetpack-svn.php
<?php /** * This script can be used as such to check some codebase against latest changes in Jetpack plugin. * * It only pulls from wp.org svn tags. It defaults to use `trunk` as the latest version, and * finds the next non-beta version as latest stable. * * It requires one parameter, which is the path to the cod...
projects/packages/analyzer/scripts/core-calls.php
<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName /** * Function call finder script. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer; use Composer\Script\Event; /** * This class holds the callback for the WordPress API function analyzer. */ class CoreCalls { ...
projects/packages/analyzer/scripts/jetpack-example.php
<?php /** * Example usage script. * * @package automattic/jetpack-analyzer */ /** * This script is meant to run outside of typical WordPress environments and only by knowledgeable folks. * Disabling some phpcs scripts: * * phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec * phpcs:disable W...
projects/packages/analyzer/scripts/jp-warnings-job.php
<?php require dirname( __DIR__ ) . '/vendor/autoload.php'; // ini_set( 'memory_limit', '512M' ); $folder_name = $argv[1]; $excludes = array( '.git', 'vendor', 'tests', 'docker', 'bin', 'scss', 'images', 'docs', 'languages', 'node_modules' ); $differences = Automattic\Jetpack\Analyzer\Scripts::load_differences(...
projects/packages/analyzer/scripts/jp-analyze-parallel.php
<?php ini_set( 'memory_limit', '512M' ); require dirname( __DIR__ ) . '/vendor/autoload.php'; use Automattic\Jetpack\Analyzer\Locker; use Automattic\Jetpack\Analyzer\Model; use Automattic\Jetpack\Analyzer\PluginDownloader; use Automattic\Jetpack\Analyzer\Scripts; $slurper_path = dirname( __DIR__ ) . '/slurper/plugi...
projects/packages/analyzer/scripts/jetpack-slurper.php
#!/usr/bin/env php -d memory_limit=2048M <?php /** * A script to scan the entire WordPress.org plugins directory for breaking changes between * two different versions of Jetpack. * * @package automattic/jetpack-analyzer */ /** * This script is meant to run outside of typical WordPress environments and only by kn...
projects/packages/analyzer/scripts/core-definitions.php
<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName /** * Function definition finder script. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer; use Composer\Script\Event; /** * This class holds the callback for the WordPress API function definition finder. */ clas...
projects/packages/analyzer/scripts/example.php
<?php /** * Example usage script. * * @package automattic/jetpack-analyzer */ /** * This script is meant to run outside of typical WordPress environments and only by knowledgeable folks. * Disabling some phpcs scripts: * * phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec * phpcs:disable W...
projects/packages/analyzer/data/example-external.php
<?php /** * This file is not meant to be run. It is used as example input to the compatibility checker script. * * @package automattic/jetpack-analyzer */ // phpcs:disable // valid signature initialization with missing class. $sig = new Jetpack_Signature( 'abcd1234', 12345 ); // static method. Jetpack_Tracks_Cli...
projects/packages/analyzer/src/class-warnings.php
<?php /** * Warnings class. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer; /** * Class Warnings */ class Warnings extends PersistentList { /** * Generates if a invocation is due to a difference. * * @param object $invocations The invocations. * @param object $differe...
projects/packages/analyzer/src/class-PersistentList.php
<?php namespace Automattic\Jetpack\Analyzer; /** * Handy class for persisting a list of objects that support the to_csv_array method */ class PersistentList { private $items; function __construct() { $this->items = array(); } public function get() { return $this->items; } public function add( $item ) {...
projects/packages/analyzer/src/class-utils.php
<?php namespace Automattic\Jetpack\Analyzer; use PhpParser\Node; /** * Shared code that probably should be a trait */ class Utils { /** * parses the node used to describe parameter defaults into a string for easy comparison */ static function get_param_default_as_string( $default, $current_class ) { if ( $...
projects/packages/analyzer/src/class-dependencies.php
<?php /** * This collects dependencies of invocations in Codebase A to declarations in codebase B. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer; /** * This collects dependencies of invocations in Codebase A to declarations in codebase B */ class Dependencies extends Persiste...
projects/packages/analyzer/src/diff-generator.php
<?php namespace Automattic\Jetpack\Analyzer; class Scripts { static function get_differences( $new_path, $old_path ) { $excludes = array( '.git', 'vendor', 'tests', 'docker', 'bin', 'scss', 'images', 'docs', 'languages', 'node_modules' ); $new_out_path = dirname( __DIR__ ) . '/output/differences/new_...
projects/packages/analyzer/src/class-declarations.php
<?php namespace Automattic\Jetpack\Analyzer; use PhpParser\NodeTraverser; use PhpParser\NodeVisitor\NameResolver; use PhpParser\ParserFactory; class Declarations extends PersistentList { private $parser; function __construct() { $this->parser = ( new ParserFactory() )->create( ParserFactory::PREFER_PHP7 ); p...
projects/packages/analyzer/src/class-invocations.php
<?php namespace Automattic\Jetpack\Analyzer; use PhpParser\NodeTraverser; use PhpParser\NodeVisitor\NameResolver; use PhpParser\ParserFactory; /** * TODO: share this file loading code w/ Declarations */ class Invocations extends PersistentList { private $parser; function __construct() { $this->parser = ( new ...
projects/packages/analyzer/src/class-differences.php
<?php namespace Automattic\Jetpack\Analyzer; class Differences extends PersistentList { private function slashit( $path ) { $path .= ( substr( $path, -1 ) == '/' ? '' : '/' ); return $path; } /** * Find differences between two sets of declarations. * * @param Declarations $new_declarations List of new...
projects/packages/analyzer/src/Invocations/class-static-const.php
<?php namespace Automattic\Jetpack\Analyzer\Invocations; use Automattic\Jetpack\Analyzer\Declarations\Class_Const; use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem; /** * Instantiation of a class * * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )` */ ...
projects/packages/analyzer/src/Invocations/class-depends-on.php
<?php /** * Interface for Depends_On. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer\Invocations; interface Depends_On { /** * Interface for identifying declarations that are depended upon. * * @param \Automattic\Jetpack\Analyzer\Declarations $declaration Declaration of c...
projects/packages/analyzer/src/Invocations/class-static-call.php
<?php namespace Automattic\Jetpack\Analyzer\Invocations; use Automattic\Jetpack\Analyzer\Declarations\Class_Method; use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem; /** * Instantiation of a class * * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )` */...
projects/packages/analyzer/src/Invocations/class-visitor.php
<?php namespace Automattic\Jetpack\Analyzer\Invocations; use Automattic\Jetpack\Analyzer\Utils; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; class Visitor extends NodeVisitorAbstract { private $invocations; private $file_path; /** * PrettyPrinter class. * * @var \PhpParser\PrettyPrinter\Standard ...
projects/packages/analyzer/src/Invocations/class-function-call.php
<?php namespace Automattic\Jetpack\Analyzer\Invocations; use Automattic\Jetpack\Analyzer\Declarations\Function_; use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem; /** * Invocations of a function * * TODO: detect dynamic invocations like `$function_name( 'hi' )` */ class Function_Call ext...
projects/packages/analyzer/src/Invocations/class-new.php
<?php namespace Automattic\Jetpack\Analyzer\Invocations; use Automattic\Jetpack\Analyzer\Declarations\Class_; use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem; /** * Instantiation of a class * * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )` */ class...
projects/packages/analyzer/src/Invocations/class-static-property.php
<?php namespace Automattic\Jetpack\Analyzer\Invocations; use Automattic\Jetpack\Analyzer\Declarations\Class_Property; use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem; /** * Instantiation of a class * * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )` ...
projects/packages/analyzer/src/Dependencies/class-dependency.php
<?php namespace Automattic\Jetpack\Analyzer\Dependencies; use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem; class Dependency extends PersistentListItem { public $invocation; public $declaration; public $invocation_root; function __construct( $invocation, $declaration, $invocation_root =...
projects/packages/analyzer/src/Declarations/class-visitor.php
<?php namespace Automattic\Jetpack\Analyzer\Declarations; use Automattic\Jetpack\Analyzer\Utils; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; class Visitor extends NodeVisitorAbstract { private $current_class; private $declarations; private $current_relative_path; public function __construct( $current...
projects/packages/analyzer/src/Declarations/class-class-method.php
<?php namespace Automattic\Jetpack\Analyzer\Declarations; /** * We only log public class methods, whether they are static, and their parameters */ class Class_Method extends Declaration { public $class_name; public $method_name; public $params; public $static; public $deprecated; function __construct( $path,...
projects/packages/analyzer/src/Declarations/class-class-property.php
<?php namespace Automattic\Jetpack\Analyzer\Declarations; /** * We only log public class variables */ class Class_Property extends Declaration { public $class_name; public $prop_name; public $static; function __construct( $path, $line, $class_name, $prop_name, $static ) { $this->class_name = $class_name; $...
projects/packages/analyzer/src/Declarations/class-function.php
<?php namespace Automattic\Jetpack\Analyzer\Declarations; /** * We only log public class methods, whether they are static, and their parameters */ class Function_ extends Declaration { public $func_name; public $params; public $deprecated; function __construct( $path, $line, $func_name, $deprecated = false ) {...
projects/packages/analyzer/src/Declarations/class-class-const.php
<?php namespace Automattic\Jetpack\Analyzer\Declarations; /** * We only log public class variables */ class Class_Const extends Declaration { public $class_name; public $const_name; function __construct( $path, $line, $class_name, $const_name ) { $this->class_name = $class_name; $this->const_name = $const_n...
projects/packages/analyzer/src/Declarations/class-declaration.php
<?php namespace Automattic\Jetpack\Analyzer\Declarations; use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem; abstract class Declaration extends PersistentListItem { public $path; public $line; function __construct( $path, $line ) { $this->path = $path; $this->line = $line; } functi...
projects/packages/analyzer/src/Declarations/class-class.php
<?php namespace Automattic\Jetpack\Analyzer\Declarations; class Class_ extends Declaration { public $class_name; function __construct( $path, $line, $class_name ) { $this->class_name = $class_name; parent::__construct( $path, $line ); } function to_csv_array() { return array( $this->type(), $this->p...
projects/packages/analyzer/src/api/class-status-controller.php
<?php namespace Automattic\Jetpack\Analyzer; class Status_Controller extends Controller { public function get() { return $this->model->get_status(); } public function post() { return 'Status_Controller post'; } }
projects/packages/analyzer/src/api/class-controller.php
<?php namespace Automattic\Jetpack\Analyzer; /** * Abstract-ish controller class. */ class Controller { protected $model; protected $params; public function __construct() { $this->model = new Model(); $this->params = New Params(); } public function process() { $out = array( 'result' => 'OK' ); $data ...
projects/packages/analyzer/src/api/class-analyze-controller.php
<?php namespace Automattic\Jetpack\Analyzer; class Analyze_Controller extends Controller { public function get() { try { Locker::lock(); } catch ( \Throwable $th ) { // TODO: extend default Exception class, and use instance_of instead. if ( 'Locked already' === $th->getMessage() ) { return $this->mod...
projects/packages/analyzer/src/api/class-router.php
<?php namespace Automattic\Jetpack\Analyzer; /** * Router class. App entry point */ class Router { private $status; private $analyze; private $params; public function __construct() { $this->status = new Status_Controller(); $this->analyze = new Analyze_Controller(); $this->params = new Params(); } p...
projects/packages/analyzer/src/api/class-model.php
<?php namespace Automattic\Jetpack\Analyzer; class Model { private $db_file; private $content; public function __construct() { $this->db_file = dirname( __DIR__ ) . '/data-store.json'; } public function get_status() { $this->load(); return $this->content; } public function toggle_status() { $this->lo...
projects/packages/analyzer/src/api/class-plugin-downloader.php
<?php namespace Automattic\Jetpack\Analyzer; use Automattic\Jetpack\Analyzer\Scripts; class PluginDownloader { private $type; public function __construct($type) { $this->type = $type; $this->output_dir = realpath( dirname( __DIR__ ) . '/../output' ) . '/'; } public function get_version($version) { echo '...
projects/packages/analyzer/src/api/class-params.php
<?php namespace Automattic\Jetpack\Analyzer; /** * Params class */ class Params { public function get_params() { parse_str($_SERVER['QUERY_STRING'], $params); return $params; } public function get_param( $param ) { $params = $this->get_params(); if( array_key_exists( $param, $params ) ) { return $para...
projects/packages/analyzer/src/PersistentList/class-item.php
<?php /** * PersistentList Item abstract. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer\PersistentList; /** * Class Item */ abstract class Item { /** * Return array of declaration items. * * @return array */ abstract public function to_csv_array(); }
projects/packages/analyzer/src/Differences/class-class-property-moved.php
<?php /** * Class propery moved checker. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer\Differences; use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? /** * Class Class_Property_Moved */ class Class_Property_Moved extends Differences_List_Item implements...
projects/packages/analyzer/src/Differences/class-function-missing.php
<?php /** * Function Missing checker * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer\Differences; use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? /** * Class Function_Missing */ class Function_Missing extends Differences_List_Item implements Invocation_...
projects/packages/analyzer/src/Differences/class-class-method-missing.php
<?php /** * Class Method Missing Warner. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer\Differences; use Automattic\Jetpack\Analyzer\Invocations\Static_Call; use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? /** * Class Class_Method_Missing */ class Clas...
projects/packages/analyzer/src/Differences/class-class-property-missing.php
<?php /** * Class Property Missing check. * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer\Differences; use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? /** * Class Class_Property_Missing */ class Class_Property_Missing extends Differences_List_Item imple...
projects/packages/analyzer/src/Differences/class-class-const-missing.php
<?php /** * Class Constant Missing * * @package automattic/jetpack-analyzer */ namespace Automattic\Jetpack\Analyzer\Differences; use Automattic\Jetpack\Analyzer\Invocations\Static_Const; use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? /** * Class Class_Const_Missing */ class Class_Cons...