-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better code analysis with @method tags. #15
Comments
An even cheaper option would be to make the protected /**
* The wrapped field.
*
* @var \File_MARC_Field
*/
public $field; |
Thanks for bringing this up, @rudolfbyker. This is lazyness from my side, I agree that adding And yes, we can also make If you would like to go ahead and prepare a PR, great! |
OK, I'll prepare a PR. Are you using a specific code style or code analysis tool? Regardless, I'll try to make it consistent with the rest of your code. |
Also, what's the oldest PHP version you are targeting? |
Thanks! I'm using phpcs to align with PSR2, see ruleset.xml. I should also probably document this, but if you use overcommit, it will run cs checks and linting before each commit, see .overcommit.yml As for PHP version, this project officially still supports PHP 5.6, but I'm open for changing that to 7.1 or 7.2 if you see the need for it! |
VersionPerfect. I'll stick to PHP5.6 for now, since file_marc is also targeting PHP 5. (For my own projects, I have dropped all support for Code stylePHPCS is great. My IDE actually detected the rules before I realised they are specified in ruleset.xml. ProblemWe have a slight problem with adding the This is a code smell that I won't try to fix in this PR, but we have to decide whether we will annotate the methods of I think we should, and then just add a FIXME note. Alternatively…If this were my project, I would drop the It's still a possibility for a later release, since I'm adding |
(Btw. since you asked about code style etc. I took the opportunity to add a CONTRIBUTING file since this project didn't have one.) |
The idea of this project was to create a more fluent / less verbose interface to File_MARC using some magic, so I think it might defeat the purpose a bit if we enforce a more strict typing scheme. Would it help to add a new |
Yes, I think that would be structurally more sound, but I also think it's a separate issue from this one. Also not sure how one would go about doing that in a backward-compatible manner. Maybe that is something for |
Indeed, it would be something for 3.0, but it could probably be done in a way so that code that doesn't depend on the result being a specific type would not break :) Agree it's a different issue, I created #17 for it. |
Since you are wrapping
File_MARC_Record
and friends inRecord.php
andField.php
, and use__call
to delegate the method calls to them, you should have@method
tags to aid IDE code hinting. Here are examples forRecord.php
andField.php
:Another option would be to get rid of the
__call
magic methods and just let the user use the wrapped object directly, throughgetField
orgetRecord
. That would need proper type documentation, too:This method already exists in
Field.php
but not inRecord.php
. Here is an example of what we need inRecord.php
:We could also do both. I'll even make a PR if you tell me which solution you prefer.
The text was updated successfully, but these errors were encountered: