Skip to content

Commit

Permalink
Create CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Feb 17, 2024
1 parent 08b0150 commit 0d5b938
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Vibes:
======
Generally-useful extensions are great, custom extensions and themes just for one specific DIY site
are welcome too. I (Shish) will probably only actively maintain and add features to the extensions
which I personally use, but if you submit some code of your own I will try to keep it updated and
compatible with any API changes that come along. If your code comes with unit tests, this type of
maintenance is much more likely to be successful :)

Testing:
========
Github Actions will be running three sets of automated tests, all of which you can run for yourself:

- `./vendor/bin/php-cs-fixer fix` - keeping a single style for the whole project
- `./vendor/bin/phpunit --config tests/phpunit.xml` - unit testing
- `./vendor/bin/phpstan analyse --memory-limit 1G -c tests/phpstan.neon` - type checking

The `main` branch is locked down so it can't accept pull requests that don't pass these

Testing FAQs:
=============

## What the heck is "Method XX::YY() return type has no value type specified in iterable type array."?

PHP arrays are very loosely defined - they can be lists or maps, with integer or string
(or non-continuous integer) keys, with any type of object (or multiple types of object).
This isn't great for type safety, so PHPStan is a bit stricter, and requires you to
specify what type of array it is and what it contains. You can do this with PHPdoc comments,
like:

```php
/**
* @param array<string, Cake> $cakes -- a mapping like ["sponge" => new Cake()]
* @return array<Ingredient> -- a list like [new Ingredient("flour"), new Ingredient("egg")]
*/
function get_ingredients(array $cakes, string $cake_name): array {
return $cakes[$cake_name]->ingredients;
}
```

0 comments on commit 0d5b938

Please sign in to comment.