Skip to content

Introdce a safe_class_exists #110

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

Closed
wants to merge 3 commits into from
Closed

Introdce a safe_class_exists #110

wants to merge 3 commits into from

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Aug 17, 2018

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #107
Documentation
License MIT

What's in this PR?

A workaround to make it work with Magento.

This solution to introduce a functions.php is inspired by Guzzle/PSR7. Now when Im done with the implementation I think it may be overkill.

<?php

// Don't redefine the functions if included multiple times.
if (!function_exists('Http\Discovery\safe_class_exists')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not require_once?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this allows you to override... Im not sure. I just did it the "guzzle" way.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah that allows to override by hijacking the namespace. sounds like either horrible situations or really bad design but i guess it does not hurt too much.

also will be quite some issue with having things loaded in the right order. but if its helpful to people to have it, i guess the overhad is insignificant so lets do it this way.

@@ -27,7 +27,8 @@
"autoload": {
"psr-4": {
"Http\\Discovery\\": "src/"
}
},
"files": ["src/functions_include.php"]
Copy link
Contributor

Choose a reason for hiding this comment

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

is there no autoloading for functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think only classes are autoloaded.

Copy link
Contributor

Choose a reason for hiding this comment

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

right, otherwise we would need a naming scheme for function to filename...

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

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

thanks.

can you check why the tests are failing?

@Nyholm
Copy link
Member Author

Nyholm commented Aug 23, 2018

Can you also check the alternative implementation for this feature: #111

@dbu
Copy link
Contributor

dbu commented Aug 23, 2018

ah, now i know why i was confused. i prefer #111 over the function, it seems less complicated infrastructure to me.

@Nyholm
Copy link
Member Author

Nyholm commented Aug 23, 2018

Yeah, I agree with you.

@Nyholm Nyholm closed this Aug 23, 2018
@Nyholm Nyholm deleted the patch-107 branch August 23, 2018 12:52
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.

Composer dependency missing?
3 participants