Skip to content
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

Minor improvements #785

Merged
merged 6 commits into from
Aug 28, 2018
Merged

Minor improvements #785

merged 6 commits into from
Aug 28, 2018

Conversation

kinow
Copy link
Collaborator

@kinow kinow commented Aug 27, 2018

Mentioned in another ticket that I had a few minor improvements to submit. All of these were found with PhpStorm, which I have been using for another project (normally use Eclipse). Simply downloaded a copy with my apache e-mail (free 🎉 ), imported the project, and then did an "Inspect Code".

I think it will be easier to review each commit, as I tried to group the enhancements as they appeared in PhpStorm.

Some other interesting entries not included in this commit as I think it would require further analysis:

  • unnecessary \. in JS regex
  • Inconsistent return points: several missing return statement (some functions have a return, but if there is an error, it doesn't return anything, nor throws any exception)
  • Duplicate array keys: In RestController, around line 228, an array with values is created to be returned. But if you look closer, and search for title, you will see that it first is set to rdfs:label, and then set again in the array to dct:title (@osma not in this commit, as I am not sure which one is correct)
  • Void function result used: in controllers, we are using something like return $this->returnError(....), but actually, the returnError does not return. It sets headers and echoes. I think PHP stops the code execution and returns too, being lenient here. But it could change in the future. Will put another ticket for it someday

If we started using a bit more of type setting (e.g. function blabla(): bool, also phpdocs annotations, and those nice @var $ret array, etc) I think we could spot more probable bugs, and make the code simpler. I am working with a senior symfony guy, who is teaching me a few more tricks while helping on a project he recently set up. Might come back later with a few more ideas later :-) 🏃‍♂️

@kinow
Copy link
Collaborator Author

kinow commented Aug 27, 2018

Will wait to see what are the test results in Travis CI. In my environment 5 tests failed, but I suspect due to my PHP 7.2. They failed with "Cannot use stdClass as Object because 'Object' is a special class name", and it looks like it's being fixed right now in JsonLD -> lanthaler/JsonLD#79

@kinow
Copy link
Collaborator Author

kinow commented Aug 27, 2018

Tests that failed in my environment:

  • ConceptTest::testExternalResourceReifications
  • ConceptTest::testProcessExternalResource
  • ModelTest::testGetRDFWithVocidAndURIasJSON
  • ModelTest::testGetResourceFromUri
  • RestControllerTest::testDataAsJson

@osma
Copy link
Member

osma commented Aug 28, 2018

Thanks, all look very reasonable! Just in time for the 2.0 release!

The PHP 7.2 issue is a known problem (see #758).

Regarding the remaining ones: very good points, I suggest you open issues or PRs for each of these so we can investigate further.

Type annotations would be great to have, it's just a non-trivial amount of work to add them. I'm sure adding them would spot new issues as you say.

@osma osma merged commit 28cb9ea into NatLibFi:master Aug 28, 2018
@osma osma added this to the 2.0 milestone Aug 28, 2018
@osma osma added the bug label Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants