Remove friendsofphp/php-cs-fixer for nightly builds
Move Ocular fetch to before_script
Move PHPUnit run to script
Cache Composer downloaded files
Use case
Allow maintainer and contributors to have a consistent reference point, and automated compliance with, code style and layout
Usage
As discussed, once fully implemented this will allow a developer to not have to focus at all on code style, while maintaining a consistent base for future contribution.
Fixes to code style can be performed in one of two ways.
As a composer script that runs across all files:
composer lint
Running directly to update a single file (or directory):
This is the part that almost certainly makes this PR a work in progress.
I have based this on Symfony's standards, as it seemed closest to what was in use now. I have no firm opinion either way, as long as there is a reference point, I'll just run the fixer and comply with what is desired :smile:
PHP 7, and especially post-7.1, remove the need & use of a lot of PHPDoc. For example:
/**
* ClientFactory constructor.
*
* @param ConnectionInterface $connection
*/
public function __construct(ConnectionInterface $connection) {}
/**
* @param int $method
* @param string $password
* @param string $username
*
* @return ClientFactory
*/
public function withAuthentication(int $method, string $username, string $password): self {}
All parameters are type-hinted, and visually and IDE recognisable without PHPDoc. Removing those lowers maintenance overhead on both developers and contributors as the code base grows and evolves.
The obvious exception is where a mixed variable is expected, at which point that should be expected to be defined by an @param entry. Obviously mixed data variables are highly undesirable anyway, so well maintained code … well, the point should appear :wink:
NOTE: If this is considered desirable, it should be carried out prior to using the CS fixer to create an updated branch.
Changes
Use case
Usage
As discussed, once fully implemented this will allow a developer to not have to focus at all on code style, while maintaining a consistent base for future contribution.
Fixes to code style can be performed in one of two ways.
As a composer script that runs across all files:
Running directly to update a single file (or directory):
Ruleset
This is the part that almost certainly makes this PR a work in progress.
I have based this on Symfony's standards, as it seemed closest to what was in use now. I have no firm opinion either way, as long as there is a reference point, I'll just run the fixer and comply with what is desired :smile:
Notable results:
@param
variables@param
and other PHPDoc elements, etc@packge
is discouraged/droppedPoints for further discussion:
Are above results acceptable? See example branch results
Unnecessary PHPDoc removal:
PHP 7, and especially post-7.1, remove the need & use of a lot of PHPDoc. For example:
All parameters are type-hinted, and visually and IDE recognisable without PHPDoc. Removing those lowers maintenance overhead on both developers and contributors as the code base grows and evolves.
The obvious exception is where a
mixed
variable is expected, at which point that should be expected to be defined by an@param
entry. Obviously mixed data variables are highly undesirable anyway, so well maintained code … well, the point should appear :wink:NOTE: If this is considered desirable, it should be carried out prior to using the CS fixer to create an updated branch.