Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

Conversation

@thewilkybarkid
Copy link
Contributor

Investigating whether the required changes are all worthwhile.

@thewilkybarkid thewilkybarkid requested a review from a team as a code owner January 8, 2019 12:38
}

$this->filesystem->dumpFile("{$this->path}/{$id}/{$version->toInt()}.xml", $item->getContent());
$contents = stream_get_contents($item->getContent());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

}

if (!$content = @fopen($file = "{$this->path}/{$id}/{$version->toInt()}.xml", 'rb')) {
$content = @fopen($file = "{$this->path}/{$id}/{$version->toInt()}.xml", 'rb');

Choose a reason for hiding this comment

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

the @ operator is really what sticks out in this line more than the condition/assignment mixing


/**
* @param mixed $resource
* @param ?string $type

Choose a reason for hiding this comment

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

?string cannot be put directly into the signature because it's inherited I guess

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. (Should be string|null here too.)

Copy link
Contributor Author

@thewilkybarkid thewilkybarkid Jan 9, 2019

Choose a reason for hiding this comment

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

Though the parent class defines these so shouldn't be needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reading phpstan/phpstan-strict-rules#51 (comment) {@inheritdoc} is required, but isn't in the next version (just tried and confirmed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

{@inheritdoc} works for ResourceComparator/TraversableComparator but not Loader? 🤔

}

/**
* @param mixed $resource

Choose a reason for hiding this comment

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

the purpose seems to be "declare all types"? But doesn't seem to add information as $resource can be any type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like #18 (comment), this is on the parent so shouldn't be needed.

ignoreErrors:
- '~^.*(?=.* Symfony\\Component\\Config\\Definition\\Builder)(?=.*( |:{2})end\(\)).*$~'
- '~^Call to method PHPUnit\\Framework\\Assert::assertInstanceOf\(\) with .+? and .+? will always evaluate to true\.$~'
- '~^Dynamic call to static method PHPUnit\\Framework\\Assert::assert[A-z]+\(\)\.$~'

Choose a reason for hiding this comment

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

surely there must be a way to disable/enable rules selectively like https://github.com/phpstan/phpstan-strict-rules#enabling-rules-one-by-one?

Copy link

@giorgiosironi giorgiosironi left a comment

Choose a reason for hiding this comment

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

My summary is:

  • code becoming more verbose due to strict checks like booleans for all conditions
  • docblocks with types mandatory for practically everything (even some local variables, no type inference?)
  • indirections over standard library functions
    All of these add a steep learning curve for contributing, but unclear what bugs they are finding. Other opinions?

@stephenwf
Copy link

Looks like theres a lot of good bug-catching rules in the strict ruleset, could enable a subset of them. In my opinion the volume of doc-block looks very PHP 5.4. For simple structures that have a typed constructor, it seems unnecessary.

The strict boolean in conditionals also may be better as a warning, where some cases it may make sense to loosely check for truth-y values. In a perfect world PHP wouldn't return a mixture of false/null/0 from its core functions and throw exceptions more often.

@thewilkybarkid
Copy link
Contributor Author

docblocks with types mandatory for practically everything (even some local variables, no type inference?)

In my opinion the volume of doc-block looks very PHP 5.4. For simple structures that have a typed constructor, it seems unnecessary.

Relates to libero/php-coding-standard#32 (and libero/php-coding-standard#40).

I'm undecided still. I haven't really done it in the past as IDEs/my eyes are generally quite good at type inference. So is PHPStan, but there are cases where it doesn't work. It also helps validate assignment. PHP 7.4 will hopefully have typed properties too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants