Skip to content

Conversation

pscheit
Copy link
Contributor

@pscheit pscheit commented Jun 25, 2025

I noticed a few comments about Codestyle in PRs.
To keep maintainer and contributors happy, I'd suggest to automate the codestyle. That way everyone can concentrate on the code(quality) and not on the codestyle.

Of course a code-formatter does not everything 1000% the way one wants. It's just not customizable entirely.

However this leads to a more consistent codestyle (thats why PSR-x was born) throughout different projects - which I think is a good thing.

Used:
https://cs.symfony.com/doc/usage.html

Cause I feel like this has become a defactor-standard.

Based it on PSR-12, but a lot needs customization.
Non "standard" are in this repo:

  • the blank line after the opening class brace
  • the location of the namespace
  • the indentation from chained method calls (this looks almost broken in places?)

Anyway, this is just a suggestion, happy to adjust whatever you want (and we can).

Would probably add this to the pipeline, because otherwise no one runs this, and WHEN someone runs it and wants to contribute everything would be outdated.

Of course we can disable the method chaining rules and leave it in "free"-mode as is right now.

Hope you like it!

Comment on lines 72 to +74
$mismatchDescription->appendText('element ')->appendValue($k)
->appendText(' was ')->appendValue($actual[$k]);
->appendText(' was ')->appendValue($actual[$k])
;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably write it more like:

      $mismatchDescription
          ->appendText('element ')
          ->appendValue($k)
          ->appendText(' was ')
          ->appendValue($actual[$k])
    ;

Comment on lines 57 to +60
$description
->appendText('array with key ')
->appendDescriptionOf($this->_keyMatcher)
;
->appendText('array with key ')
->appendDescriptionOf($this->_keyMatcher)
;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks more concise to me!

Comment on lines 41 to +43
$mismatchDescription->appendText('array was ')
->appendText('[')
;
->appendText('[')
;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

     $mismatchDescription
         ->appendText('array was ')
         ->appendText('[')
     ;

* @param mixed $item the object against which the matcher is evaluated.
*
* @return boolean <code>true</code> if <var>$item</var> matches,
* @return bool <code>true</code> if <var>$item</var> matches,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up for discussion of course, i like it more if its concise (but dont care if its boolean or bool)


public function testMatchesArrayContainingKey()
{
$array = array('a'=>1, 'b'=>2, 'c'=>3);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought about this a lot, but actually Hamcrest itself describes array's with => (with whitespace around the operator) and this is PSR- standard, so would change that

{
assertThat((float) 5.2, floatValue());
assertThat((double) 5.3, doubleValue());
assertThat((float) 5.3, doubleValue());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no difference in PHP. float, double or real are the same datatype.

At the C level, everything is stored as a double.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant