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

PHP < 5.4.0 compatibility for "--dump-schema" #109

Merged
merged 1 commit into from
Mar 31, 2015

Conversation

siwinski
Copy link
Contributor

JSON_PRETTY_PRINT available since PHP 5.4.0

@bighappyface
Copy link
Collaborator

+1

@bighappyface
Copy link
Collaborator

@hakre would you mind reviewing this as well? Thanks for the help 🍻

@bighappyface
Copy link
Collaborator

@keradus this would be a good PR to bundle in with #139 and others. Would you please review?

@@ -218,7 +218,8 @@ $refResolver = new JsonSchema\RefResolver($retriever);
$refResolver->resolve($schema, $urlSchema);

if (isset($arOptions['--dump-schema'])) {
echo json_encode($schema, JSON_PRETTY_PRINT) . "\n";
$options = version_compare(PHP_VERSION, '5.4.0', '>=') ? JSON_PRETTY_PRINT : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't do that

Copy link
Contributor

Choose a reason for hiding this comment

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

You want to check if sth you want to use is available for you.
Therefore please check that sth, not sth other. When you want to have JSON_PRETTY_PRINT you should test for it, not for some PHP_VERSION. Remember that one may want to run it under hhvm, and it has it's own problem with constants (they forgot to create some of them).

Ref: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/1.7/Symfony/CS/Utils.php#L30

Copy link
Contributor

Choose a reason for hiding this comment

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

and, btw, PHP_VERSION_ID is hell faster than calling version_comapre ;)

@keradus
Copy link
Contributor

keradus commented Mar 27, 2015

here you go!

@siwinski
Copy link
Contributor Author

@keradus Thanks for the feedback and changing my thought process for things like this! I have made the update to check if the constant is defined instead of checking the PHP version.

@hakre
Copy link
Contributor

hakre commented Mar 30, 2015

@siwinski: I suggest you rebase your branch on top of master. Let me know if you need help with that. Otherwise go into your branch and type:

git rebase master

In case you run into a conflict you don't want to fix / fear, you can always type in then

git rebase --abort

to touch safe ground again. And even if you mess things up greater than that there is always the git reflog as a safety net.

Rebasing will put your changes on top of master as if you've been doing your work on the latest version. This keeps conflicts low and the PR small. Ping me if you've got any questions.

@siwinski siwinski force-pushed the pr-php-lt-5-4-0-compat branch from fb78dad to aaa9ada Compare March 30, 2015 20:33
@siwinski
Copy link
Contributor Author

@hakre LOL... I had originally done that but then couldn't remember if GitHub would close out this original PR or lost the original inline comments so I went with the merge. Rebased.

@hakre
Copy link
Contributor

hakre commented Mar 30, 2015

@siwinski: Cheers! Have you seen the comment on the FULL STOP vs. COMMA operator I just created with much love? Or is it lost now?

Edit: Just in case, I found a link to it: siwinski@fb78dad#commitcomment-10476310

@siwinski siwinski force-pushed the pr-php-lt-5-4-0-compat branch from aaa9ada to 1fc065c Compare March 30, 2015 20:41
@siwinski
Copy link
Contributor Author

@hakre I'm so used to my internal team's process of keeping all commits instead of squashing and merging instead of rebasing that I forgot how to deal with things "outside" :) I've done it plenty and pushed the squash up.

@siwinski
Copy link
Contributor Author

@hakre Regarding fb78dad#commitcomment-10476310 , I can make that change if you would like but I was originally changing only what needed to be changed.

@hakre
Copy link
Contributor

hakre commented Mar 30, 2015

@siwinski: Well if I would have bothered so much and as it's on the same line and really superfluous, I would have done that. In the sense of care-taking and as we've got the luxury of an extensive review here at this moment in time. But it's no show-stopper. Your PR, your choice. I won't run gaga if you wouldn't . Thanks for the fix btw.

bighappyface added a commit that referenced this pull request Mar 31, 2015
PHP < 5.4.0 compatibility for "--dump-schema"
@bighappyface bighappyface merged commit 1235d2e into jsonrainbow:master Mar 31, 2015
@siwinski
Copy link
Contributor Author

siwinski commented Apr 1, 2015

@hakre sorry... I meant to come back and make that change but then this PR got accepted

@hakre
Copy link
Contributor

hakre commented Apr 1, 2015

@siwinski: nothing to feel sorry for. And also you can make a new PR if you like.

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

Successfully merging this pull request may close these issues.

4 participants