From d5558e935b3e96fc8c09368f077e3be040b56898 Mon Sep 17 00:00:00 2001 From: DrewAPicture Date: Thu, 7 Jun 2018 09:49:59 -0600 Subject: [PATCH 01/11] Update composer.lock. --- composer.lock | 90 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 28 deletions(-) diff --git a/composer.lock b/composer.lock index 8cb5c5e..9b80220 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "7f8182189ed845514079dae0bb6fbc34", + "hash": "9df3212f8845d8c2e01a6b58618c6944", "content-hash": "50b4965030469f5686192ba48645cb3e", "packages": [ { "name": "composer/installers", - "version": "v1.1.0", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/composer/installers.git", - "reference": "a3595c5272a6f247228abb20076ed27321e4aae9" + "reference": "049797d727261bf27f2690430d935067710049c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/a3595c5272a6f247228abb20076ed27321e4aae9", - "reference": "a3595c5272a6f247228abb20076ed27321e4aae9", + "url": "https://api.github.com/repos/composer/installers/zipball/049797d727261bf27f2690430d935067710049c2", + "reference": "049797d727261bf27f2690430d935067710049c2", "shasum": "" }, "require": { @@ -30,7 +30,7 @@ }, "require-dev": { "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "4.1.*" + "phpunit/phpunit": "^4.8.36" }, "type": "composer-plugin", "extra": { @@ -60,11 +60,17 @@ "keywords": [ "Craft", "Dolibarr", + "Eliasis", "Hurad", "ImageCMS", + "Kanboard", + "Lan Management System", "MODX Evo", "Mautic", + "Maya", "OXID", + "Plentymarkets", + "Porto", "RadPHP", "SMF", "Thelia", @@ -72,57 +78,76 @@ "agl", "aimeos", "annotatecms", + "attogram", "bitrix", "cakephp", "chef", + "cockpit", "codeigniter", "concrete5", "croogo", "dokuwiki", "drupal", + "eZ Platform", "elgg", "expressionengine", "fuelphp", "grav", "installer", + "itop", "joomla", "kohana", "laravel", + "lavalite", "lithium", "magento", + "majima", "mako", "mediawiki", "modulework", + "modx", "moodle", + "osclass", "phpbb", "piwik", "ppi", "puppet", + "pxcms", + "reindex", "roundcube", "shopware", "silverstripe", + "sydes", "symfony", "typo3", "wordpress", + "yawik", "zend", "zikula" ], - "time": "2016-07-05 06:18:20" + "time": "2017-12-29 09:13:20" }, { "name": "erusev/parsedown", - "version": "1.6.0", + "version": "1.7.1", "source": { "type": "git", "url": "https://github.com/erusev/parsedown.git", - "reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7" + "reference": "92e9c27ba0e74b8b028b111d1b6f956a15c01fc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/erusev/parsedown/zipball/3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7", - "reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/92e9c27ba0e74b8b028b111d1b6f956a15c01fc1", + "reference": "92e9c27ba0e74b8b028b111d1b6f956a15c01fc1", "shasum": "" }, + "require": { + "ext-mbstring": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35" + }, "type": "library", "autoload": { "psr-0": { @@ -146,7 +171,7 @@ "markdown", "parser" ], - "time": "2015-10-04 16:44:32" + "time": "2018-03-08 01:11:30" }, { "name": "nikic/php-parser", @@ -249,16 +274,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", + "version": "2.0.5", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e6a969a640b00d8daa3c66518b0405fb41ae0c4b", + "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b", "shasum": "" }, "require": { @@ -294,26 +319,34 @@ "email": "mike.vanriel@naenius.com" } ], - "time": "2015-02-03 12:10:50" + "time": "2016-01-25 08:17:30" }, { "name": "psr/log", - "version": "1.0.0", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", "shasum": "" }, + "require": { + "php": ">=5.3.0" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { - "psr-0": { - "Psr\\Log\\": "" + "psr-4": { + "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", @@ -327,12 +360,13 @@ } ], "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", "keywords": [ "log", "psr", "psr-3" ], - "time": "2012-12-21 11:40:51" + "time": "2016-10-10 12:19:37" }, { "name": "scribu/lib-posts-to-posts", @@ -340,12 +374,12 @@ "source": { "type": "git", "url": "https://github.com/scribu/wp-lib-posts-to-posts.git", - "reference": "baefe121458b5d4d333b29e0c0b8cb8fad0fa4a2" + "reference": "a695438e455587fa228e993d05b4431cde99af1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/scribu/wp-lib-posts-to-posts/zipball/baefe121458b5d4d333b29e0c0b8cb8fad0fa4a2", - "reference": "baefe121458b5d4d333b29e0c0b8cb8fad0fa4a2", + "url": "https://api.github.com/repos/scribu/wp-lib-posts-to-posts/zipball/a695438e455587fa228e993d05b4431cde99af1b", + "reference": "a695438e455587fa228e993d05b4431cde99af1b", "shasum": "" }, "require": { @@ -363,7 +397,7 @@ ], "description": "A library for many-to-many relationships in WordPress", "homepage": "https://github.com/scribu/wp-lib-posts-to-posts", - "time": "2015-08-19 09:04:19" + "time": "2016-02-15 12:08:59" }, { "name": "scribu/scb-framework", From fcc8e2dc4d82bdd68ae06d43724daa997a037320 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 15:32:11 -0600 Subject: [PATCH 02/11] Composer lock. --- composer.lock | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/composer.lock b/composer.lock index 9b80220..0cd9b19 100644 --- a/composer.lock +++ b/composer.lock @@ -1,24 +1,23 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "9df3212f8845d8c2e01a6b58618c6944", "content-hash": "50b4965030469f5686192ba48645cb3e", "packages": [ { "name": "composer/installers", - "version": "v1.5.0", + "version": "v1.6.0", "source": { "type": "git", "url": "https://github.com/composer/installers.git", - "reference": "049797d727261bf27f2690430d935067710049c2" + "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/049797d727261bf27f2690430d935067710049c2", - "reference": "049797d727261bf27f2690430d935067710049c2", + "url": "https://api.github.com/repos/composer/installers/zipball/cfcca6b1b60bc4974324efb5783c13dca6932b5b", + "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b", "shasum": "" }, "require": { @@ -125,7 +124,7 @@ "zend", "zikula" ], - "time": "2017-12-29 09:13:20" + "time": "2018-08-27T06:10:37+00:00" }, { "name": "erusev/parsedown", @@ -171,7 +170,7 @@ "markdown", "parser" ], - "time": "2018-03-08 01:11:30" + "time": "2018-03-08T01:11:30+00:00" }, { "name": "nikic/php-parser", @@ -216,7 +215,7 @@ "parser", "php" ], - "time": "2014-07-23 18:24:17" + "time": "2014-07-23T18:24:17+00:00" }, { "name": "phpdocumentor/reflection", @@ -270,7 +269,7 @@ "reflection", "static analysis" ], - "time": "2014-11-14 11:43:04" + "time": "2014-11-14T11:43:04+00:00" }, { "name": "phpdocumentor/reflection-docblock", @@ -319,7 +318,7 @@ "email": "mike.vanriel@naenius.com" } ], - "time": "2016-01-25 08:17:30" + "time": "2016-01-25T08:17:30+00:00" }, { "name": "psr/log", @@ -366,7 +365,7 @@ "psr", "psr-3" ], - "time": "2016-10-10 12:19:37" + "time": "2016-10-10T12:19:37+00:00" }, { "name": "scribu/lib-posts-to-posts", @@ -397,7 +396,7 @@ ], "description": "A library for many-to-many relationships in WordPress", "homepage": "https://github.com/scribu/wp-lib-posts-to-posts", - "time": "2016-02-15 12:08:59" + "time": "2016-02-15T12:08:59+00:00" }, { "name": "scribu/scb-framework", @@ -438,7 +437,7 @@ "keywords": [ "wordpress" ], - "time": "2015-10-25 20:19:41" + "time": "2015-10-25T20:19:41+00:00" } ], "packages-dev": [], From 871ae0412c42d2c629c52ba7a6bbb9e2510b0914 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:27:42 -0600 Subject: [PATCH 03/11] Register the wp-parser-constant post type and add taxonomy support. --- lib/class-plugin.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/class-plugin.php b/lib/class-plugin.php index 5fe7f95..1325b46 100644 --- a/lib/class-plugin.php +++ b/lib/class-plugin.php @@ -28,7 +28,7 @@ public function on_load() { } /** - * Register the function and class post types + * Register the post types. */ public function register_post_types() { @@ -116,6 +116,24 @@ public function register_post_types() { ) ); } + + if ( ! post_type_exists( 'wp-parser-constant' ) ) { + + register_post_type( + 'wp-parser-constant', + array( + 'has_archive' => 'constants', + 'label' => __( 'Constants', 'wp-parser' ), + 'public' => true, + 'rewrite' => array( + 'feeds' => false, + 'slug' => 'constant', + 'with_front' => false, + ), + 'supports' => $supports, + ) + ); + } } /** @@ -123,7 +141,7 @@ public function register_post_types() { */ public function register_taxonomies() { - $object_types = array( 'wp-parser-class', 'wp-parser-method', 'wp-parser-function', 'wp-parser-hook' ); + $object_types = array( 'wp-parser-class', 'wp-parser-method', 'wp-parser-function', 'wp-parser-hook', 'wp-parser-constant' ); if ( ! taxonomy_exists( 'wp-parser-source-file' ) ) { From 4dfe8ccbf9de5251150459d76f996f5afd5a19f4 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:28:05 -0600 Subject: [PATCH 04/11] Add Constant post type support to the Importer class. --- lib/class-importer.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/class-importer.php b/lib/class-importer.php index b83e597..d236b17 100644 --- a/lib/class-importer.php +++ b/lib/class-importer.php @@ -69,6 +69,13 @@ class Importer implements LoggerAwareInterface { */ public $post_type_hook; + /** + * Post type name for constants + * + * @var string + */ + public $post_type_constant; + /** * Handy store for meta about the current item being imported * @@ -100,6 +107,7 @@ public function __construct( array $args = array() ) { 'post_type_method' => 'wp-parser-method', 'post_type_function' => 'wp-parser-function', 'post_type_hook' => 'wp-parser-hook', + 'post_type_constant' => 'wp-parser-constant', 'taxonomy_file' => 'wp-parser-source-file', 'taxonomy_namespace' => 'wp-parser-namespace', 'taxonomy_package' => 'wp-parser-package', From 79e9a5899706d1025cf62cf861f0ca2615fe0c5e Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:28:28 -0600 Subject: [PATCH 05/11] Add Constant support to the missing post type error logger. --- lib/class-importer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-importer.php b/lib/class-importer.php index d236b17..9c9dc6b 100644 --- a/lib/class-importer.php +++ b/lib/class-importer.php @@ -155,7 +155,7 @@ public function import( array $data, $skip_sleep = false, $import_ignored_functi delete_option( 'wp_parser_root_import_dir' ); // Sanity check -- do the required post types exist? - if ( ! post_type_exists( $this->post_type_class ) || ! post_type_exists( $this->post_type_function ) || ! post_type_exists( $this->post_type_hook ) ) { + if ( ! post_type_exists( $this->post_type_class ) || ! post_type_exists( $this->post_type_function ) || ! post_type_exists( $this->post_type_hook ) || ! post_type_exists( $this->post_type_constant ) ) { $this->logger->error( sprintf( 'Missing post type; check that "%1$s", "%2$s", and "%3$s" are registered.', $this->post_type_class, $this->post_type_function, $this->post_type_hook ) ); exit; } From 1528e53a14147b02e28e3945851e49bc194ad6b6 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:29:07 -0600 Subject: [PATCH 06/11] Introduce an import_constant() helper, retrieve all constants from the current file and loop through to import them. --- lib/class-importer.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/class-importer.php b/lib/class-importer.php index 9c9dc6b..11c2861 100644 --- a/lib/class-importer.php +++ b/lib/class-importer.php @@ -314,6 +314,7 @@ public function import_file( array $file, $skip_sleep = false, $import_ignored = 'functions' => array(), 'classes' => array(), 'hooks' => array(), + 'constants' => array(), ), $file ); $count = 0; @@ -345,6 +346,15 @@ public function import_file( array $file, $skip_sleep = false, $import_ignored = } } + foreach ( $file['constants'] as $constant ) { + $this->import_constant( $constant, $import_ignored ); + $count ++; + + if ( ! $skip_sleep && 0 == $count % 10 ) { + sleep( 3 ); + } + } + if ( 'wp-includes/version.php' === $file['path'] ) { $this->import_version( $file ); } @@ -413,6 +423,20 @@ public function import_hook( array $data, $parent_post_id = 0, $import_ignored = return $hook_id; } + /** + * Create a post for a constant + * + * @param array $data Constant. + * @param int $parent_post_id Optional; post ID of the parent (file, class, or function) this item belongs to. + * Defaults to zero (no parent). + * @param bool $import_ignored Optional; defaults to false. If true, constants marked `@ignore` will be imported. + * + * @return bool|int Post ID of this constant, false if any failure. + */ + public function import_constant( array $data, $parent_post_id = 0, $import_ignored = false ) { + $constant_id = $this->import_item( $data, $parent_post_id, $import_ignored, array( 'post_type' => $this->post_type_constant ) ); + } + /** * Create a post for a class * From f8beece72de1ddbbc147ebedd00ca53f533e4ca1 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:29:51 -0600 Subject: [PATCH 07/11] Ensure arguments aren't sought for constants during import. --- lib/class-importer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-importer.php b/lib/class-importer.php index 11c2861..549c796 100644 --- a/lib/class-importer.php +++ b/lib/class-importer.php @@ -762,7 +762,7 @@ public function import_item( array $data, $parent_post_id = 0, $import_ignored = $data['doc']['tags']['deprecated'] = $this->file_meta['deprecated']; } - if ( $post_data['post_type'] !== $this->post_type_class ) { + if ( ! in_array( $post_data['post_type'], array( $this->post_type_class, $this->post_type_constant ) ) ) { $anything_updated[] = update_post_meta( $post_id, '_wp-parser_args', $data['arguments'] ); } From 52e98dd49f1acc169bc0ccc7a2508815719d4039 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:30:13 -0600 Subject: [PATCH 08/11] Add a constant-specific message placeholder for STDOUT. --- lib/class-importer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/class-importer.php b/lib/class-importer.php index 549c796..d2eca0d 100644 --- a/lib/class-importer.php +++ b/lib/class-importer.php @@ -801,6 +801,10 @@ public function import_item( array $data, $parent_post_id = 0, $import_ignored = $this->logger->info( "\t\t" . sprintf( '%1$s method "%2$s"', $action, $ns_name ) ); break; + case $this->post_type_constant: + $this->logger->info( "\t\t" . sprintf( '%1$s constant "%2$s"', $action, $ns_name ) ); + break; + default: $this->logger->info( "\t" . sprintf( '%1$s function "%2$s"', $action, $ns_name ) ); } From 4a5f536b76e3862ca56157bc85b94f84b244ac87 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:30:53 -0600 Subject: [PATCH 09/11] Ensure the end_line and doc attributes are set while looping through constants for each file. --- lib/runner.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/runner.php b/lib/runner.php index cacbec2..0c9e7e0 100644 --- a/lib/runner.php +++ b/lib/runner.php @@ -76,9 +76,11 @@ function parse_files( $files, $root ) { foreach ( $file->getConstants() as $constant ) { $out['constants'][] = array( - 'name' => $constant->getShortName(), - 'line' => $constant->getLineNumber(), - 'value' => $constant->getValue(), + 'name' => $constant->getShortName(), + 'line' => $constant->getLineNumber(), + 'value' => $constant->getValue(), + 'end_line' => $constant->getNode()->getAttribute( 'endLine' ), + 'doc' => export_docblock( $constant ), ); } From fcf035eea854ecbcb0ee53353a1f9e29b8ce1764 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:32:24 -0600 Subject: [PATCH 10/11] Introduce an assertConstantHasDocs() helper for Export_Testcase tests. --- tests/phpunit/includes/export-testcase.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/phpunit/includes/export-testcase.php b/tests/phpunit/includes/export-testcase.php index b3fe845..a0da34b 100644 --- a/tests/phpunit/includes/export-testcase.php +++ b/tests/phpunit/includes/export-testcase.php @@ -433,6 +433,18 @@ protected function assertHookHasDocs( $hook, $docs ) { $this->assertEntityHasDocs( $hook, $docs ); } + /** + * Asserts that a constant has a DocBlock. + * + * @param string $constant Constant name. + * @param array $docs The expected data for the constant's DocBlock. + */ + protected function assertConstantHasDocs( $constant, $docs ) { + + $constant = $this->find_entity_data_in( $this->export_data, 'constants', $constant ); + $this->assertEntityHasDocs( $constant, $docs ); + } + /** * Find the exported data for an entity. * From ae039326b9921392f5c2fcf034e909bc1f7927f4 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 31 Oct 2018 17:33:24 -0600 Subject: [PATCH 11/11] Define single undocumented and documented constants and a test for each, respectively. DocBlock templates are not yet supported in phpDocumentor 2.x --- tests/phpunit/tests/export/docblocks.inc | 9 ++++++++ tests/phpunit/tests/export/docblocks.php | 27 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/tests/phpunit/tests/export/docblocks.inc b/tests/phpunit/tests/export/docblocks.inc index 05686f5..03f0cbb 100644 --- a/tests/phpunit/tests/export/docblocks.inc +++ b/tests/phpunit/tests/export/docblocks.inc @@ -88,3 +88,12 @@ do_action( 'undocumented_hook' ); * A reference array action. */ do_action_ref_array( 'test_ref_array_action', array( &$var ) ); + +define( 'TEST_UNDOCUMENTED_CONST', true ); + +/** + * Documented constant. + * + * @since 5.0 + */ +define ('TEST_CONST', true ); diff --git a/tests/phpunit/tests/export/docblocks.php b/tests/phpunit/tests/export/docblocks.php index 0d49b15..5b56e9a 100644 --- a/tests/phpunit/tests/export/docblocks.php +++ b/tests/phpunit/tests/export/docblocks.php @@ -142,4 +142,31 @@ public function test_property_docblocks() { , array( 'description' => 'This is a docblock for a class property.' ) ); } + + /** + * Test the constant docs are exported. + */ + public function test_constant_docblocks() { + + $this->assertConstantHasDocs( + 'TEST_CONST' + , array( + 'description' => 'Documented constant.', + ) + ); + } + + /** + * Test that constants that aren't documented don't receive docs from another node. + */ + public function test_undocumented_constant() { + + $this->assertConstantHasDocs( + 'TEST_UNDOCUMENTED_CONST' + , array( + 'description' => '', + ) + ); + } + }