Skip to content

Commit

Permalink
Merge pull request #4373 from ampproject/4342-add-php-stan-analysis
Browse files Browse the repository at this point in the history
Add PHP-Stan static analysis
  • Loading branch information
westonruter authored Mar 12, 2020
2 parents 9196aa9 + 6b0841b commit d077842
Show file tree
Hide file tree
Showing 54 changed files with 7,745 additions and 552 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ jobs:
after_success:
- npx sizereport --config

- stage: analyze
name: Static analysis (PHP)
php: "7.3"
install:
- composer install
script:
- composer analyze

- stage: test
name: JavaScript unit tests
php: "7.3"
Expand Down Expand Up @@ -150,6 +158,7 @@ jobs:

- name: Libraries that are meant to be externalized (5.6)
php: "5.6"
env: TEST_SKIP_PHPSTAN=1
install:
- composer --working-dir=lib/common install
- composer --working-dir=lib/optimizer install
Expand Down
8 changes: 1 addition & 7 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,7 @@ function _amp_xdebug_admin_notice() {
add_action( 'admin_notices', '_amp_xdebug_admin_notice' );
}

require_once AMP__DIR__ . '/includes/class-amp-autoloader.php';
AMP_Autoloader::register();

require_once AMP__DIR__ . '/back-compat/back-compat.php';
require_once AMP__DIR__ . '/includes/amp-helper-functions.php';
require_once AMP__DIR__ . '/includes/admin/functions.php';
require_once AMP__DIR__ . '/includes/deprecated.php';
require_once AMP__DIR__ . '/vendor/autoload.php';

register_activation_hook( __FILE__, 'amp_activate' );

Expand Down
31 changes: 27 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
"sabberworm/php-css-parser": "dev-master#134f4e6"
},
"require-dev": {
"civicrm/composer-downloads-plugin": "^2.1",
"dealerdirect/phpcodesniffer-composer-installer": "0.6.2",
"mikey179/vfsstream": "1.6.8",
"php-stubs/wordpress-stubs": "^5.3.2",
"phpcompatibility/phpcompatibility-wp": "2.1.0",
"roave/security-advisories": "dev-master",
"sirbrillig/phpcs-variable-analysis": "2.8.1",
"wp-cli/wp-cli": "2.4.1",
"wp-coding-standards/wpcs": "2.2.1",
"xwp/wp-dev-lib": "1.5.0"
},
Expand All @@ -41,6 +42,13 @@
"sort-packages": true
},
"extra": {
"downloads": {
"phpstan": {
"url": "https://github.com/phpstan/phpstan/releases/download/0.12.14/phpstan.phar",
"path": "vendor/bin/phpstan",
"type": "phar"
}
},
"patches": {
"sabberworm/php-css-parser": {
"Fix parsing CSS selectors which contain commas <https://github.com/sabberworm/PHP-CSS-Parser/pull/138>": "https://github.com/sabberworm/PHP-CSS-Parser/commit/fa139f65c5b098ae652c970b25e6eb03fc495eb4.diff",
Expand All @@ -52,12 +60,24 @@
"autoload": {
"psr-4": {
"AmpProject\\AmpWP\\": "src/"
}
},
"classmap": [
"includes/"
],
"files": [
"back-compat/back-compat.php",
"includes/amp-helper-functions.php",
"includes/admin/functions.php",
"includes/deprecated.php"
]
},
"autoload-dev": {
"psr-4": {
"AmpProject\\AmpWP\\Tests\\": "tests/php/src/"
}
},
"classmap": [
"tests/php/validation/"
]
},
"repositories": [
{
Expand All @@ -81,5 +101,8 @@
}
],
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"scripts": {
"analyze": "if [ -z $TEST_SKIP_PHPSTAN ]; then phpstan analyze --ansi; fi"
}
}
Loading

0 comments on commit d077842

Please sign in to comment.