Skip to content

Conversation

@abolabo
Copy link

@abolabo abolabo commented Dec 25, 2018

just added phpdoc comments and added changes related to readability of code

@antonkomarev
Copy link
Contributor

It's so much different types of changes you've done within one PR. Very hard to review it.

composer.json Outdated
@@ -1,5 +1,5 @@
{
"name": "craftcamp/php-abac",
"name": "abolabo/php-abac",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? 😭

Copy link
Author

Choose a reason for hiding this comment

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

oh.. sorry.. mistake.. please revert

Copy link
Collaborator

@Kern046 Kern046 left a comment

Choose a reason for hiding this comment

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

Hi ! Thanks for your interest in this library and for your contribution ! I'm glad to have such interactions with the community !

However, I removed on purpose the PHPdoc blocks in the methods, as I find it quite useless since PHP7 introduces strict typing which serves also as documentation. I'm not very fond of putting it back.

I would've liked to discuss it first within an opened issue instead debating already-done work ! The fault is mine as I didn't set a proper contributing policy for this repo. I will write it soon enough.

If you have further modifications to propose, I suggest you open an issue first, so we can discuss it without a chance to do unmerged work !

private $policyRuleManager;
/** @var AttributeManager **/
/**
* @var AttributeManager|AttributeManagerInterface
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not useful to set the Manager in PHPdoc if the interface is present. You can remove it :)

Copy link
Author

Choose a reason for hiding this comment

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

hm.. i think you are not right. Phpdoc comments used by IDE such as PhpStorm to show relations between different code. All logic of code-inspectors based on phpdocumentor comments. So if you will run inspector it will show a lot of errors "unknown classes" etc.
Anyway relations of code is important thing if you decided to rename (refactor) some of class.
(Or in case when you call some class not directly, dynamically)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry I wasn't precise enough. I just said that you could do:

/** @var AttributeManagerInterface **/ and not mention `AttributeManager`` since the purpose to set interfaces instead of classes directly is to remove the dependency to a precise class.

I have no doubts on the utility of PHPdoc comments to declare properties type. It's just for methods where I suggest that PHP7 type-hinting is enough for modern IDEs

Copy link
Author

Choose a reason for hiding this comment

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

oh, yes. But in this case IDE will not hint methods of some sibling class of interface.
I mean quick jump to class method from call by ide shortcut ( ctrl+click ). If i describe parameter only as interface class ide jumps into interface class, not child.
Anyway it's your code, your rules :-)

Copy link
Contributor

@antonkomarev antonkomarev Dec 27, 2018

Choose a reason for hiding this comment

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

There is no need to specify all siblings in DocBlock. Only interfaces is fine.
After redirecting in IDE to interface you can choose on what sibling you want to redirect further.

Copy link
Contributor

@antonkomarev antonkomarev Dec 27, 2018

Choose a reason for hiding this comment

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

It's good practice to have FQCN (Fully Qualified Class Names) in DocBlocks.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@abolabo The matter in open-source is not whose code it is, but what is the best way to code this library, and I'm totally open to changes even the ones I wouldn't do myself if it is the best thing according to conventions etc...

Your PR is good, it is totally right to apply SOLID principles here. You did transform the class type-hint into interfaces to remove hard dependencies between classes and it is essential to allow overriding of the library components. To be coherent with this change, the PHPdoc must also be updated, but must not keep the old hard dependency to the classes such as AttributeManager.

In the meantime, you can remove the classes use statements which would become useless with the replacement by interfaces.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand your concern about jumps in IDE but if someone overrides AttributeManager and set it as Abac dependency, it would be wrong that the IDE jumps to the native AttributeManager instead of the extended one. Jumping to the interface seems to be more coherent

{

/**
* Abac constructor.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it really useful to say that this is the class constructor ?

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.

3 participants