Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 1.85 KB

CONTRIBUTING.md

File metadata and controls

56 lines (36 loc) · 1.85 KB

Contributing

Setup

composer install

Generating an Args Definition

You can generate an Args definition for an array parameter of a function or method given its file name, its fully qualified symbol name, and the parameter name. The generated definition serves as a starting point and you'll need to manually correct things like union types, improve the docblock formatting, add PHPStan constraints as necessary, and generally make sure the properties are valid and correct.

The command looks like this for class methods:

composer generate -- --file=<file> --method=<method> --param=<param>

and this for functions:

composer generate -- --file=<file> --function=<function> --param=<param>

A copy of WordPress is available in vendor/wordpress/wordpress.

Examples

composer generate -- --file=vendor/wordpress/wordpress/wp-includes/class-wp-query.php --method="\WP_Query::parse_query()" --param=query
composer generate -- --file=vendor/wordpress/wordpress/wp-includes/post.php --function="\register_post_type()" --param=args

Tests

Add a corresponding entry to the extra.args-shapes property in composer.json using the existing entries as a guide.

Updating args for a new WordPress release

  1. Switch the roots/wordpress-full dependency to dev-main or an RC, such as x.y-RC3
  2. Run composer test
  3. Address any new, updated, or removed args in changed files in tests/shapes
  4. Re-run the tests until they all pass

Running the Tests

The tests in the tests directory are there mainly to check the types of the properties of a given Args definition. They're not real tests and they only test the happy path (it's not possible to ensure that a given value cannot be used, for example). That said, they've allowed me to catch a few bugs so they are somewhat useful.

Running the tests:

composer test