overtrue / easy-sms

📲 一款满足你的多种发送需求的短信发送组件
MIT License
3.13k stars 545 forks source link

用户系统中有可能真的存在[Aliyun]这个类 #167

Closed zhangv closed 5 years ago

zhangv commented 5 years ago

https://github.com/overtrue/easy-sms/blob/322dd21fb37d47d47a19a07209416c7f63ae77b7/src/EasySms.php#L264

overtrue commented 5 years ago

https://github.com/overtrue/easy-sms/commit/639d1cdf842258de72b593dcc35f69d7c315ea2b

zhangv commented 5 years ago

貌似没有解决。可能是我没说清楚。 比如,我的系统里本身有 \Aliyun 这个class或者trait 而如果我在easysms里配置了aliyun的网关,那么就会造成class_exists('aliyun') === true,就会直接返回了我系统定义的 \Aliyun, 而不是 \Overtrue\EasySms\Gateways\AliyunGateway 。

overtrue commented 5 years ago

你试试先,根本走不到下一个逻辑。

V notifications@github.com于2019年3月23日 周六上午10:01写道:

貌似没有解决。可能是我没说清楚。 比如,我的系统里本身有 \Aliyun 这个class或者trait 而如果我在easysms里配置了aliyun的网关,那么就会造成class_exists('aliyun') === true,就会直接返回了我系统定义的 \Aliyun, 而不是 \Overtrue\EasySms\Gateways\AliyunGateway 。

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/overtrue/easy-sms/issues/167#issuecomment-475829968, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ3YHffjNO71GU_oRbsy3nAkrQpTxuVks5vZYr9gaJpZM4cCryo .

zhangv commented 5 years ago

你试试先,根本走不到下一个逻辑。 V notifications@github.com于2019年3月23日 周六上午10:01写道: 貌似没有解决。可能是我没说清楚。 比如,我的系统里本身有 \Aliyun 这个class或者trait 而如果我在easysms里配置了aliyun的网关,那么就会造成class_exists('aliyun') === true,就会直接返回了我系统定义的 \Aliyun, 而不是 \Overtrue\EasySms\Gateways\AliyunGateway 。 — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#167 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ3YHffjNO71GU_oRbsy3nAkrQpTxuVks5vZYr9gaJpZM4cCryo .

就是使用过程中发现的。class_exists 改成 \class_exists 似乎没有解决这个问题 - 我在app里测试过。 貌似两个都还是在全局的namespace里查找class。

overtrue commented 5 years ago

找到类和这个影响这个模块使用没关系吧?

V notifications@github.com于2019年3月23日 周六下午4:50写道:

你试试先,根本走不到下一个逻辑。 V notifications@github.com于2019年3月23日 周六上午10:01写道: … <#m4180592358390532314> 貌似没有解决。可能是我没说清楚。 比如,我的系统里本身有 \Aliyun 这个class或者trait 而如果我在easysms里配置了aliyun的网关,那么就会造成class_exists('aliyun') === true,就会直接返回了我系统定义的 \Aliyun, 而不是 \Overtrue\EasySms\Gateways\AliyunGateway 。 — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#167 (comment) https://github.com/overtrue/easy-sms/issues/167#issuecomment-475829968>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ3YHffjNO71GU_oRbsy3nAkrQpTxuVks5vZYr9gaJpZM4cCryo .

就是使用过程中发现的。class_exists 改成 \class_exists 似乎没有解决这个问题 - 我在app里测试过。 貌似两个都还是在全局的namespace里查找class。

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/overtrue/easy-sms/issues/167#issuecomment-475852707, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ3YIY6INQwFiZ2O5QbP4G3ZAfilQkRks5vZerpgaJpZM4cCryo .

zhangv commented 5 years ago

使用是没有关系。但产生了不必要的依赖(dependency)。 如果某个人的app中有定义了一个 \Aliyun 就会影响使用easysms模块。

overtrue commented 5 years ago

为啥会影响?我还是没懂?能不能结合代码说明一下?

V notifications@github.com于2019年3月23日 周六下午10:05写道:

使用是没有关系。但产生了不必要的依赖(dependency)。 如果某个人的app中有定义了一个 \Aliyun 就会影响使用easysms模块。

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/overtrue/easy-sms/issues/167#issuecomment-475872542, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ3YF1tyU8hD_p0aOIxHz1iqoHj0Glqks5vZjS7gaJpZM4cCryo .

zhangv commented 5 years ago

比如,我的系统里本身有 \Aliyun 这个class或者trait --就是用户的app里定义了一个类, 叫 Aliyun

同时,如果我引入了easysms并配置了aliyun的网关,那么就会造成class_exists('aliyun') === true,就会直接返回了我系统定义的 \Aliyun, 而不是 easysms里的 AliyunGateway 类。

你的模块不能也不应该限制用户(这里就是我)的命名空间管理(不管这种定义合不合理)。