From 987ad41765e085ed3c1ac89fdf72d01548b3bd99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sun, 1 Feb 2026 02:01:37 +0800 Subject: [PATCH] fix: Add .php-cs-fixer.php and update many files Add PHP CS Fixer configuration (.php-cs-fixer.php) to enforce coding style and apply corresponding updates across the codebase. Numerous plugins (think-library and many think-plugs-*) and core config files (cache, database, phinx, worker) were updated along with controllers, services, models, storage adapters, helpers and tests to conform to style fixes and minor compatibility/refactors. --- .php-cs-fixer.php | 120 + app/index/controller/Index.php | 30 +- composer.json | 6 +- config/cache.php | 69 +- config/database.php | 91 +- config/phinx.php | 33 +- config/worker.php | 58 +- plugin/think-library/src/Builder.php | 488 ++-- plugin/think-library/src/Command.php | 87 +- plugin/think-library/src/Controller.php | 162 +- plugin/think-library/src/Exception.php | 45 +- plugin/think-library/src/Helper.php | 104 +- plugin/think-library/src/Library.php | 72 +- plugin/think-library/src/Model.php | 111 +- plugin/think-library/src/Plugin.php | 152 +- plugin/think-library/src/Queue.php | 70 +- plugin/think-library/src/Service.php | 56 +- plugin/think-library/src/Storage.php | 131 +- plugin/think-library/src/common.php | 234 +- .../src/contract/StorageInterface.php | 72 +- .../src/contract/StorageUsageTrait.php | 87 +- .../src/contract/StreamInterface.php | 42 +- .../think-library/src/extend/CodeExtend.php | 103 +- .../think-library/src/extend/DataExtend.php | 66 +- .../think-library/src/extend/ExcelExtend.php | 53 +- .../src/extend/FaviconExtend.php | 91 +- .../think-library/src/extend/HttpExtend.php | 84 +- .../think-library/src/extend/ImageVerify.php | 136 +- .../src/extend/JsonRpcClient.php | 71 +- .../src/extend/JsonRpcServer.php | 85 +- plugin/think-library/src/extend/JwtExtend.php | 206 +- .../think-library/src/extend/PhinxExtend.php | 318 +-- .../think-library/src/extend/ToolsExtend.php | 158 +- .../think-library/src/extend/VirtualModel.php | 56 +- .../think-library/src/helper/DeleteHelper.php | 66 +- .../think-library/src/helper/FormHelper.php | 64 +- .../think-library/src/helper/PageHelper.php | 167 +- .../think-library/src/helper/QueryHelper.php | 274 ++- .../think-library/src/helper/SaveHelper.php | 51 +- .../think-library/src/helper/TokenHelper.php | 64 +- .../src/helper/ValidateHelper.php | 61 +- plugin/think-library/src/lang/en-us.php | 155 +- plugin/think-library/src/lang/zh-tw.php | 135 +- plugin/think-library/src/model/SystemAuth.php | 66 +- plugin/think-library/src/model/SystemBase.php | 63 +- .../think-library/src/model/SystemConfig.php | 38 +- plugin/think-library/src/model/SystemData.php | 39 +- plugin/think-library/src/model/SystemFile.php | 50 +- plugin/think-library/src/model/SystemMenu.php | 45 +- plugin/think-library/src/model/SystemNode.php | 40 +- .../think-library/src/model/SystemOplog.php | 41 +- .../think-library/src/model/SystemQueue.php | 56 +- plugin/think-library/src/model/SystemUser.php | 79 +- .../src/service/AdminService.php | 207 +- .../src/service/CaptchaService.php | 239 +- .../src/service/ExpressService.php | 164 +- .../src/service/InterfaceService.php | 104 +- .../think-library/src/service/MenuService.php | 121 +- .../src/service/MessageService.php | 192 +- .../src/service/ModuleService.php | 78 +- .../think-library/src/service/NodeService.php | 169 +- .../src/service/ProcessService.php | 142 +- .../src/service/QueueService.php | 219 +- .../src/service/RuntimeService.php | 110 +- .../src/service/SystemService.php | 274 +-- .../src/service/ZtSmsService.php | 134 +- .../src/storage/AliossStorage.php | 395 ++-- .../src/storage/AlistStorage.php | 255 +-- .../src/storage/LocalStorage.php | 119 +- .../src/storage/QiniuStorage.php | 170 +- .../src/storage/TxcosStorage.php | 392 ++-- .../src/storage/UpyunStorage.php | 329 ++- .../think-library/src/storage/bin/mimes.php | 2023 +++++++++-------- plugin/think-library/src/support/Route.php | 37 +- plugin/think-library/src/support/Url.php | 128 +- .../src/support/command/Database.php | 70 +- .../src/support/command/Package.php | 79 +- .../src/support/command/Publish.php | 82 +- .../src/support/command/Queue.php | 286 +-- .../src/support/command/Replace.php | 64 +- .../src/support/command/Sysmenu.php | 84 +- .../src/support/middleware/JwtSession.php | 74 +- .../src/support/middleware/MultAccess.php | 144 +- .../src/support/middleware/RbacAccess.php | 47 +- plugin/think-library/tests/CodeTest.php | 24 +- plugin/think-library/tests/JwtTest.php | 24 +- plugin/think-library/tests/ModelTest.php | 24 +- plugin/think-library/tests/StorageTest.php | 36 +- plugin/think-library/tests/bootstrap.php | 27 +- plugin/think-plugs-account/src/Service.php | 41 +- .../src/controller/Device.php | 58 +- .../src/controller/Master.php | 52 +- .../src/controller/Message.php | 79 +- .../src/controller/api/Auth.php | 60 +- .../src/controller/api/Login.php | 115 +- .../src/controller/api/Wechat.php | 100 +- .../src/controller/api/Wxapp.php | 169 +- .../src/controller/api/auth/Center.php | 99 +- plugin/think-plugs-account/src/lang/en-us.php | 173 +- plugin/think-plugs-account/src/model/Abs.php | 56 +- .../src/model/PluginAccountAuth.php | 42 +- .../src/model/PluginAccountBind.php | 50 +- .../src/model/PluginAccountMsms.php | 40 +- .../src/model/PluginAccountUser.php | 42 +- .../src/service/Account.php | 212 +- .../src/service/Message.php | 99 +- .../src/service/contract/AccountAccess.php | 279 +-- .../src/service/contract/AccountInterface.php | 111 +- .../src/service/contract/MessageInterface.php | 52 +- .../service/contract/MessageUsageTrait.php | 56 +- .../src/service/message/Alisms.php | 151 +- ...20241010000005_install_account20241010.php | 47 +- .../think-plugs-account/tests/AccountTest.php | 28 +- .../think-plugs-account/tests/bootstrap.php | 27 +- plugin/think-plugs-admin/src/Service.php | 42 +- .../think-plugs-admin/src/controller/Auth.php | 79 +- .../think-plugs-admin/src/controller/Base.php | 99 +- .../src/controller/Config.php | 83 +- .../think-plugs-admin/src/controller/File.php | 98 +- .../src/controller/Index.php | 122 +- .../src/controller/Login.php | 66 +- .../think-plugs-admin/src/controller/Menu.php | 182 +- .../src/controller/Oplog.php | 82 +- .../src/controller/Queue.php | 93 +- .../think-plugs-admin/src/controller/User.php | 118 +- .../src/controller/api/Plugs.php | 48 +- .../src/controller/api/Queue.php | 115 +- .../src/controller/api/System.php | 141 +- .../src/controller/api/Upload.php | 136 +- plugin/think-plugs-admin/src/lang/en-us.php | 539 ++--- plugin/think-plugs-admin/src/route/demo.php | 35 +- plugin/think-plugs-admin/src/view/error.php | 20 +- .../20241010000001_install_admin20241010.php | 67 +- .../20241010000002_install_admin20241011.php | 59 +- plugin/think-plugs-center/src/Service.php | 44 +- .../src/controller/Index.php | 98 +- plugin/think-plugs-center/src/helper.php | 38 +- plugin/think-plugs-center/src/lang/en-us.php | 21 +- .../think-plugs-center/src/route/router.php | 35 +- .../think-plugs-center/src/service/Plugin.php | 95 +- .../20241010000004_install_center20241010.php | 26 +- .../think-plugs-helper/src/DbBackupStruct.php | 43 +- .../think-plugs-helper/src/DbIndexStruct.php | 37 +- .../think-plugs-helper/src/DbModelStruct.php | 62 +- .../src/DbRestoreStruct.php | 43 +- plugin/think-plugs-helper/src/Service.php | 32 +- plugin/think-plugs-payment/src/Service.php | 35 +- .../src/controller/Balance.php | 56 +- .../src/controller/Config.php | 185 +- .../src/controller/Integral.php | 56 +- .../src/controller/Record.php | 68 +- .../src/controller/Refund.php | 41 +- .../src/controller/api/auth/Address.php | 90 +- .../src/controller/api/auth/Balance.php | 26 +- .../src/controller/api/auth/Integral.php | 26 +- plugin/think-plugs-payment/src/lang/en-us.php | 231 +- .../src/model/PluginPaymentAddress.php | 25 +- .../src/model/PluginPaymentBalance.php | 31 +- .../src/model/PluginPaymentConfig.php | 30 +- .../src/model/PluginPaymentIntegral.php | 40 +- .../src/model/PluginPaymentRecord.php | 78 +- .../src/model/PluginPaymentRefund.php | 47 +- .../think-plugs-payment/src/queue/Recount.php | 48 +- .../src/service/Balance.php | 110 +- .../src/service/Integral.php | 123 +- .../src/service/Payment.php | 332 +-- .../src/service/contract/PaymentInterface.php | 41 +- .../src/service/contract/PaymentResponse.php | 51 +- .../service/contract/PaymentUsageTrait.php | 356 +-- .../src/service/payment/AliPayment.php | 109 +- .../src/service/payment/BalancePayment.php | 59 +- .../src/service/payment/CouponPayment.php | 53 +- .../src/service/payment/EmptyPayment.php | 54 +- .../src/service/payment/IntegralPayment.php | 59 +- .../src/service/payment/JoinPayment.php | 98 +- .../src/service/payment/VoucherPayment.php | 56 +- .../src/service/payment/WechatPayment.php | 58 +- .../payment/wechat/WechatPaymentV2.php | 115 +- .../payment/wechat/WechatPaymentV3.php | 112 +- ...20241010000006_install_payment20241010.php | 77 +- .../think-plugs-payment/tests/BalanceTest.php | 24 +- .../think-plugs-payment/tests/PaymentTest.php | 24 +- plugin/think-plugs-static/stc/class/Index.php | 18 +- plugin/think-plugs-static/stc/config/app.php | 65 +- .../think-plugs-static/stc/config/cache.php | 69 +- .../think-plugs-static/stc/config/cookie.php | 43 +- .../stc/config/database.php | 91 +- plugin/think-plugs-static/stc/config/lang.php | 49 +- plugin/think-plugs-static/stc/config/log.php | 65 +- .../think-plugs-static/stc/config/phinx.php | 33 +- .../think-plugs-static/stc/config/route.php | 69 +- .../think-plugs-static/stc/config/session.php | 39 +- plugin/think-plugs-static/stc/config/view.php | 55 +- .../think-plugs-static/stc/public/index.php | 33 +- .../think-plugs-static/stc/public/router.php | 38 +- .../stc/public/static/admin.js | 12 - .../stc/public/static/login.js | 12 - .../stc/public/static/plugs/admin/excel.js | 12 - .../stc/public/static/plugs/admin/queue.js | 12 - .../stc/public/static/plugs/admin/validate.js | 12 - .../stc/public/static/theme/css/_config.less | 12 - .../stc/public/static/theme/css/_custom.less | 12 - .../stc/public/static/theme/css/_display.less | 12 - .../stc/public/static/theme/css/_layout.less | 12 - .../public/static/theme/css/_layout_1.less | 12 - .../static/theme/css/_layout_1_black.less | 12 - .../static/theme/css/_layout_1_blue.less | 12 - .../static/theme/css/_layout_1_green.less | 12 - .../static/theme/css/_layout_1_red.less | 12 - .../public/static/theme/css/_layout_2.less | 12 - .../static/theme/css/_layout_2_black.less | 12 - .../static/theme/css/_layout_2_blue.less | 12 - .../static/theme/css/_layout_2_green.less | 12 - .../static/theme/css/_layout_2_red.less | 12 - .../static/theme/css/_layout_white.less | 12 - .../stc/public/static/theme/css/console.less | 12 - .../stc/public/static/theme/css/iconfont.less | 12 - .../stc/public/static/theme/css/login.less | 12 - .../stc/public/static/theme/css/mobile.less | 12 - plugin/think-plugs-static/stc/think | 33 +- .../src/AuthService.php | 132 +- .../src/ConfigService.php | 87 +- .../src/RegisterService.php | 42 +- .../src/command/Wechat.php | 59 +- .../src/controller/Config.php | 48 +- .../src/controller/Wechat.php | 51 +- .../src/controller/api/Client.php | 71 +- .../src/controller/api/Push.php | 139 +- .../src/handle/PublishHandle.php | 67 +- .../src/handle/ReceiveHandle.php | 74 +- .../src/lang/en-us.php | 121 +- .../src/model/WechatAuth.php | 39 +- ...0000009_install_wechat_service20241010.php | 24 +- plugin/think-plugs-wechat/src/Service.php | 48 +- .../think-plugs-wechat/src/command/Auto.php | 98 +- .../think-plugs-wechat/src/command/Clear.php | 50 +- .../think-plugs-wechat/src/command/Fans.php | 161 +- .../src/controller/Auto.php | 122 +- .../src/controller/Config.php | 109 +- .../src/controller/Fans.php | 79 +- .../src/controller/Keys.php | 112 +- .../src/controller/Menu.php | 128 +- .../src/controller/News.php | 97 +- .../src/controller/api/Js.php | 58 +- .../src/controller/api/Login.php | 51 +- .../src/controller/api/Push.php | 232 +- .../src/controller/api/Test.php | 112 +- .../src/controller/api/View.php | 65 +- .../src/controller/payment/Record.php | 69 +- .../src/controller/payment/Refund.php | 49 +- plugin/think-plugs-wechat/src/lang/en-us.php | 153 +- .../src/model/WechatAuto.php | 40 +- .../src/model/WechatFans.php | 39 +- .../src/model/WechatFansTags.php | 39 +- .../src/model/WechatKeys.php | 40 +- .../src/model/WechatMedia.php | 39 +- .../src/model/WechatNews.php | 39 +- .../src/model/WechatNewsArticle.php | 39 +- .../src/model/WechatPaymentRecord.php | 61 +- .../src/model/WechatPaymentRefund.php | 51 +- .../src/service/AutoService.php | 46 +- .../src/service/FansService.php | 55 +- .../src/service/LoginService.php | 66 +- .../src/service/MediaService.php | 117 +- .../src/service/PaymentService.php | 268 ++- .../src/service/WechatService.php | 205 +- .../20241010000003_install_wechat20241010.php | 56 +- .../20241011000001_install_wechat20241011.php | 51 +- plugin/think-plugs-wemall/src/Service.php | 89 +- .../think-plugs-wemall/src/command/Clear.php | 242 +- .../think-plugs-wemall/src/command/Trans.php | 257 +-- .../think-plugs-wemall/src/command/Users.php | 64 +- .../src/controller/api/Auth.php | 57 +- .../src/controller/api/Data.php | 83 +- .../src/controller/api/Goods.php | 123 +- .../src/controller/api/auth/Cart.php | 54 +- .../src/controller/api/auth/Center.php | 65 +- .../src/controller/api/auth/Checkin.php | 131 +- .../src/controller/api/auth/Coupon.php | 98 +- .../src/controller/api/auth/Order.php | 366 +-- .../src/controller/api/auth/Rebate.php | 61 +- .../src/controller/api/auth/Refund.php | 112 +- .../src/controller/api/auth/Spread.php | 70 +- .../src/controller/api/auth/Transfer.php | 90 +- .../controller/api/auth/action/Collect.php | 46 +- .../controller/api/auth/action/History.php | 60 +- .../src/controller/api/auth/action/Search.php | 50 +- .../src/controller/api/help/Feedback.php | 48 +- .../src/controller/api/help/Problem.php | 39 +- .../src/controller/api/help/Question.php | 76 +- .../src/controller/base/Agent.php | 147 +- .../src/controller/base/Config.php | 66 +- .../src/controller/base/Design.php | 60 +- .../src/controller/base/Discount.php | 101 +- .../src/controller/base/Level.php | 143 +- .../src/controller/base/Notify.php | 103 +- .../src/controller/base/Poster.php | 123 +- .../src/controller/base/Report.php | 56 +- .../src/controller/base/express/Company.php | 70 +- .../src/controller/base/express/Template.php | 104 +- .../src/controller/help/Feedback.php | 169 +- .../src/controller/help/Problem.php | 86 +- .../src/controller/help/Question.php | 111 +- .../src/controller/shop/Goods.php | 294 +-- .../src/controller/shop/Order.php | 119 +- .../src/controller/shop/Refund.php | 188 +- .../src/controller/shop/Reply.php | 62 +- .../src/controller/shop/Sender.php | 139 +- .../src/controller/shop/goods/Cate.php | 155 +- .../src/controller/shop/goods/Mark.php | 64 +- .../src/controller/user/Admin.php | 195 +- .../src/controller/user/Checkin.php | 45 +- .../src/controller/user/Coupon.php | 53 +- .../src/controller/user/Create.php | 158 +- .../src/controller/user/Rebate.php | 60 +- .../src/controller/user/Recharge.php | 145 +- .../src/controller/user/Transfer.php | 128 +- .../src/controller/user/coupon/Config.php | 103 +- .../src/controller/user/rebate/Config.php | 98 +- plugin/think-plugs-wemall/src/helper.php | 43 +- plugin/think-plugs-wemall/src/lang/en-us.php | 535 ++--- .../think-plugs-wemall/src/model/AbsUser.php | 51 +- .../src/model/PluginWemallConfigAgent.php | 52 +- .../src/model/PluginWemallConfigCoupon.php | 55 +- .../src/model/PluginWemallConfigDiscount.php | 58 +- .../src/model/PluginWemallConfigLevel.php | 56 +- .../src/model/PluginWemallConfigNotify.php | 39 +- .../src/model/PluginWemallConfigPoster.php | 95 +- .../src/model/PluginWemallConfigRebate.php | 50 +- .../src/model/PluginWemallExpressCompany.php | 40 +- .../src/model/PluginWemallExpressTemplate.php | 71 +- .../src/model/PluginWemallGoods.php | 98 +- .../src/model/PluginWemallGoodsCate.php | 79 +- .../src/model/PluginWemallGoodsItem.php | 106 +- .../src/model/PluginWemallGoodsMark.php | 40 +- .../src/model/PluginWemallGoodsStock.php | 39 +- .../src/model/PluginWemallHelpFeedback.php | 53 +- .../src/model/PluginWemallHelpProblem.php | 39 +- .../src/model/PluginWemallHelpQuestion.php | 48 +- .../src/model/PluginWemallHelpQuestionX.php | 47 +- .../src/model/PluginWemallOrder.php | 114 +- .../src/model/PluginWemallOrderCart.php | 46 +- .../src/model/PluginWemallOrderItem.php | 74 +- .../src/model/PluginWemallOrderRefund.php | 53 +- .../src/model/PluginWemallOrderSender.php | 50 +- .../model/PluginWemallUserActionCollect.php | 42 +- .../model/PluginWemallUserActionComment.php | 55 +- .../model/PluginWemallUserActionHistory.php | 42 +- .../model/PluginWemallUserActionSearch.php | 39 +- .../src/model/PluginWemallUserCheckin.php | 43 +- .../src/model/PluginWemallUserCoupon.php | 65 +- .../src/model/PluginWemallUserCreate.php | 46 +- .../src/model/PluginWemallUserRebate.php | 49 +- .../src/model/PluginWemallUserRecharge.php | 41 +- .../src/model/PluginWemallUserRelation.php | 99 +- .../src/model/PluginWemallUserTransfer.php | 50 +- .../src/service/ConfigService.php | 78 +- .../src/service/ExpressService.php | 117 +- .../src/service/GoodsService.php | 89 +- .../src/service/PosterService.php | 151 +- .../src/service/UserAction.php | 92 +- .../src/service/UserAgent.php | 79 +- .../src/service/UserCoupon.php | 102 +- .../src/service/UserCreate.php | 233 +- .../src/service/UserOrder.php | 200 +- .../src/service/UserRebate.php | 315 +-- .../src/service/UserRefund.php | 56 +- .../src/service/UserReward.php | 71 +- .../src/service/UserTransfer.php | 59 +- .../src/service/UserUpgrade.php | 138 +- .../20241010000007_install_wemall20241010.php | 276 ++- .../20241010000008_fix_wemall_constraints.php | 86 +- plugin/think-plugs-worker/src/Script.php | 37 +- plugin/think-plugs-worker/src/Server.php | 75 +- plugin/think-plugs-worker/src/Service.php | 39 +- .../think-plugs-worker/src/command/Worker.php | 119 +- .../src/support/HttpServer.php | 57 +- .../src/support/ThinkApp.php | 57 +- .../src/support/ThinkCookie.php | 47 +- .../src/support/ThinkRequest.php | 105 +- .../src/support/ThinkResponseFile.php | 191 +- plugin/think-plugs-worker/stc/worker.php | 32 +- plugin/think-plugs-wuma/src/Query.php | 41 +- plugin/think-plugs-wuma/src/Script.php | 45 +- plugin/think-plugs-wuma/src/Service.php | 38 +- .../think-plugs-wuma/src/command/Create.php | 86 +- .../think-plugs-wuma/src/controller/Code.php | 94 +- .../src/controller/Warehouse.php | 93 +- .../src/controller/api/Auth.php | 31 +- .../src/controller/api/Base.php | 87 +- .../src/controller/api/Coder.php | 59 +- .../src/controller/api/Login.php | 59 +- .../src/controller/sales/Config.php | 71 +- .../src/controller/sales/History.php | 68 +- .../src/controller/sales/Level.php | 102 +- .../src/controller/sales/Order.php | 60 +- .../src/controller/sales/Stock.php | 62 +- .../src/controller/sales/User.php | 135 +- .../src/controller/scaner/Notify.php | 97 +- .../src/controller/scaner/Protal.php | 158 +- .../src/controller/scaner/Query.php | 49 +- .../src/controller/source/Assign.php | 191 +- .../src/controller/source/Blockchain.php | 154 +- .../src/controller/source/Certificate.php | 119 +- .../src/controller/source/Produce.php | 108 +- .../src/controller/source/Template.php | 123 +- .../src/controller/warehouse/Batch.php | 128 +- .../src/controller/warehouse/History.php | 62 +- .../src/controller/warehouse/Inter.php | 188 +- .../src/controller/warehouse/Outer.php | 148 +- .../src/controller/warehouse/Relation.php | 66 +- .../src/controller/warehouse/Replace.php | 48 +- .../src/controller/warehouse/Stock.php | 59 +- .../src/controller/warehouse/User.php | 99 +- plugin/think-plugs-wuma/src/lang/en-us.php | 107 +- .../src/model/AbstractPrivate.php | 43 +- .../src/model/PluginWumaCodeRule.php | 124 +- .../src/model/PluginWumaCodeRuleRange.php | 42 +- .../src/model/PluginWumaSalesOrder.php | 68 +- .../src/model/PluginWumaSalesOrderData.php | 38 +- .../model/PluginWumaSalesOrderDataMins.php | 38 +- .../model/PluginWumaSalesOrderDataNums.php | 38 +- .../src/model/PluginWumaSalesUser.php | 65 +- .../src/model/PluginWumaSalesUserLevel.php | 56 +- .../src/model/PluginWumaSalesUserStock.php | 75 +- .../src/model/PluginWumaSourceAssign.php | 59 +- .../src/model/PluginWumaSourceAssignItem.php | 66 +- .../src/model/PluginWumaSourceBlockchain.php | 42 +- .../src/model/PluginWumaSourceCertificate.php | 53 +- .../src/model/PluginWumaSourceProduce.php | 82 +- .../src/model/PluginWumaSourceQuery.php | 39 +- .../src/model/PluginWumaSourceQueryNotify.php | 39 +- .../src/model/PluginWumaSourceQueryVerify.php | 39 +- .../src/model/PluginWumaSourceTemplate.php | 44 +- .../src/model/PluginWumaWarehouse.php | 51 +- .../src/model/PluginWumaWarehouseOrder.php | 89 +- .../model/PluginWumaWarehouseOrderData.php | 51 +- .../PluginWumaWarehouseOrderDataMins.php | 51 +- .../PluginWumaWarehouseOrderDataNums.php | 39 +- .../src/model/PluginWumaWarehouseRelation.php | 47 +- .../model/PluginWumaWarehouseRelationData.php | 39 +- .../src/model/PluginWumaWarehouseReplace.php | 39 +- .../src/model/PluginWumaWarehouseStock.php | 97 +- .../src/model/PluginWumaWarehouseUser.php | 39 +- .../src/service/CertService.php | 60 +- .../src/service/CodeService.php | 309 +-- .../src/service/RelationService.php | 205 +- .../src/service/RemoveService.php | 113 +- .../src/service/WhCoderService.php | 205 +- .../src/service/WhExportService.php | 165 +- .../src/service/WhImportService.php | 127 +- .../20241010000008_install_wuma20241010.php | 145 +- plugin/think-plugs-wuma/tests/CodeTest.php | 28 +- 453 files changed, 22143 insertions(+), 20383 deletions(-) create mode 100644 .php-cs-fixer.php diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 000000000..a3a6c1335 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,120 @@ +setRiskyAllowed(true)->setParallelConfig(new ParallelConfig(8, 24)); +$finder = Finder::create()->in(__DIR__)->exclude(['vendor', 'public', 'runtime']); +return $config->setFinder($finder)->setUsingCache(false)->setRules([ + '@PSR2' => true, + '@Symfony' => true, + '@DoctrineAnnotation' => true, + '@PhpCsFixer' => true, + 'header_comment' => [ + 'comment_type' => 'PHPDoc', + 'header' => $header, + 'separate' => 'none', + 'location' => 'after_declare_strict', + ], + 'array_syntax' => [ + 'syntax' => 'short', + ], + 'list_syntax' => [ + 'syntax' => 'short', + ], + 'blank_line_before_statement' => [ + 'statements' => [ + 'declare', + ], + ], + 'general_phpdoc_annotation_remove' => [ + 'annotations' => [ + 'author', + ], + ], + 'ordered_imports' => [ + 'imports_order' => [ + 'class', 'function', 'const', + ], + 'sort_algorithm' => 'alpha', + ], + 'single_line_comment_style' => [ + 'comment_types' => [ + ], + ], + 'yoda_style' => [ + 'always_move_variable' => false, + 'equal' => false, + 'identical' => false, + ], + 'phpdoc_align' => [ + 'align' => 'left', + ], + 'multiline_whitespace_before_semicolons' => [ + 'strategy' => 'no_multi_line', + ], + 'constant_case' => [ + 'case' => 'lower', + ], + 'encoding' => true, // PHP代码必须只使用没有BOM的UTF-8 + 'line_ending' => true, // 所有的PHP文件编码必须一致 + 'single_quote' => true, // 简单字符串应该使用单引号代替双引号 + 'no_empty_statement' => true, // 不应该存在空的结构体 + 'standardize_not_equals' => true, // 使用 <> 代替 != + 'blank_line_after_namespace' => true, // 命名空间之后空一行 + 'no_empty_phpdoc' => true, // 不应该存在空的 phpdoc + 'no_empty_comment' => true, // 不应该存在空注释 + 'no_singleline_whitespace_before_semicolons' => true, // 禁止在关闭分号前使用单行空格 + 'concat_space' => ['spacing' => 'one'], // 连接字符是否需要空格,可选配置项 none:不需要 one:一个空格 + 'no_leading_import_slash' => true, // use 语句中取消前置斜杠 + 'cast_spaces' => ['space' => 'none'], + 'class_attributes_separation' => true, + 'combine_consecutive_unsets' => true, + 'declare_strict_types' => true, + 'lowercase_static_reference' => true, + 'linebreak_after_opening_tag' => true, + 'multiline_comment_opening_closing' => true, + 'no_useless_else' => true, + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => false, + 'not_operator_with_space' => false, + 'ordered_class_elements' => true, + 'php_unit_strict' => false, + 'phpdoc_separation' => false, +]); diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 2f5fbf79c..ab6fdaffd 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -1,18 +1,22 @@ env('CACHE_TYPE', 'file'), // 缓存连接配置 - 'stores' => [ - 'file' => [ + 'stores' => [ + 'file' => [ // 驱动方式 - 'type' => 'File', + 'type' => 'File', // 缓存保存目录 - 'path' => '', + 'path' => '', // 缓存名称前缀 - 'prefix' => '', + 'prefix' => '', // 缓存有效期 0 表示永久缓存 - 'expire' => 0, + 'expire' => 0, // 缓存标签前缀 'tag_prefix' => 'tag:', // 序列化机制 - 'serialize' => [], + 'serialize' => [], ], - 'safe' => [ + 'safe' => [ // 驱动方式 - 'type' => 'File', + 'type' => 'File', // 缓存保存目录 - 'path' => syspath('safefile/cache/'), + 'path' => syspath('safefile/cache/'), // 缓存名称前缀 - 'prefix' => '', + 'prefix' => '', // 缓存有效期 0 表示永久缓存 - 'expire' => 0, + 'expire' => 0, // 缓存标签前缀 'tag_prefix' => 'tag:', // 序列化机制 - 'serialize' => [], + 'serialize' => [], ], 'redis' => [ // 驱动方式 - 'type' => 'redis', - 'host' => env('CACHE_REDIS_HOST', '127.0.0.1'), - 'port' => env('CACHE_REDIS_PORT', 6379), - 'select' => env('CACHE_REDIS_SELECT', 0), + 'type' => 'redis', + 'host' => env('CACHE_REDIS_HOST', '127.0.0.1'), + 'port' => env('CACHE_REDIS_PORT', 6379), + 'select' => env('CACHE_REDIS_SELECT', 0), 'password' => env('CACHE_REDIS_PASSWORD', ''), - ] + ], ], -]; \ No newline at end of file +]; diff --git a/config/database.php b/config/database.php index ea58c067d..280a49dec 100644 --- a/config/database.php +++ b/config/database.php @@ -1,83 +1,86 @@ env('DB_TYPE', 'sqlite'), + 'default' => env('DB_TYPE', 'sqlite'), // 自定义时间查询规则 'time_query_rule' => [], // 自动写入时间戳字段 - 'auto_timestamp' => true, + 'auto_timestamp' => true, // 时间字段取出后的默认时间格式 'datetime_format' => 'Y-m-d H:i:s', // 数据库连接配置信息 - 'connections' => [ - 'mysql' => [ + 'connections' => [ + 'mysql' => [ // 数据库类型 - 'type' => 'mysql', + 'type' => 'mysql', // 服务器地址 - 'hostname' => env('DB_MYSQL_HOST', '127.0.0.1'), + 'hostname' => env('DB_MYSQL_HOST', '127.0.0.1'), // 服务器端口 - 'hostport' => env('DB_MYSQL_PORT', '3306'), + 'hostport' => env('DB_MYSQL_PORT', '3306'), // 数据库名 - 'database' => env('DB_MYSQL_DATABASE', 'thinkadmin'), + 'database' => env('DB_MYSQL_DATABASE', 'thinkadmin'), // 用户名 - 'username' => env('DB_MYSQL_USERNAME', 'root'), + 'username' => env('DB_MYSQL_USERNAME', 'root'), // 密码 - 'password' => env('DB_MYSQL_PASSWORD', ''), + 'password' => env('DB_MYSQL_PASSWORD', ''), // 数据库连接参数 - 'params' => [], + 'params' => [], // 数据库表前缀 - 'prefix' => env('DB_MYSQL_PREFIX', ''), + 'prefix' => env('DB_MYSQL_PREFIX', ''), // 数据库编码默认采用 utf8mb4 - 'charset' => env('DB_MYSQL_CHARSET', 'utf8mb4'), + 'charset' => env('DB_MYSQL_CHARSET', 'utf8mb4'), // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) - 'deploy' => 0, + 'deploy' => 0, // 数据库读写是否分离 主从式有效 - 'rw_separate' => false, + 'rw_separate' => false, // 读写分离后 主服务器数量 - 'master_num' => 1, + 'master_num' => 1, // 指定从服务器序号 - 'slave_no' => '', + 'slave_no' => '', // 检查字段是否存在 - 'fields_strict' => true, + 'fields_strict' => true, // 是否需要断线重连 'break_reconnect' => false, // 监听SQL执行日志 - 'trigger_sql' => true, + 'trigger_sql' => true, // 开启字段类型缓存 - 'fields_cache' => isOnline(), + 'fields_cache' => isOnline(), ], 'sqlite' => [ // 数据库类型 - 'type' => 'sqlite', + 'type' => 'sqlite', // 数据库文件 - 'database' => syspath('database/sqlite.db'), + 'database' => syspath('database/sqlite.db'), // 数据库编码默认采用 utf8 - 'charset' => 'utf8', + 'charset' => 'utf8', // 监听执行日志 'trigger_sql' => true, // 其他参数字段 - 'deploy' => 0, - 'suffix' => '', - 'prefix' => '', - 'hostname' => '', - 'hostport' => '', - 'username' => '', - 'password' => '', + 'deploy' => 0, + 'suffix' => '', + 'prefix' => '', + 'hostname' => '', + 'hostport' => '', + 'username' => '', + 'password' => '', ], ], ]; diff --git a/config/phinx.php b/config/phinx.php index a9ee86682..d6b34b457 100644 --- a/config/phinx.php +++ b/config/phinx.php @@ -1,19 +1,22 @@ [], @@ -21,4 +24,4 @@ return [ 'tables' => [], // 备份数据表,填写表名 'backup' => [], -]; \ No newline at end of file +]; diff --git a/config/worker.php b/config/worker.php index 974fe2415..a99b6457f 100644 --- a/config/worker.php +++ b/config/worker.php @@ -1,52 +1,52 @@ '127.0.0.1', + 'host' => '127.0.0.1', // 服务监听端口 - 'port' => 2346, + 'port' => 2346, // 套接字上下文选项 - 'context' => [], + 'context' => [], // 高级自定义服务类 - 'classes' => '', + 'classes' => '', // 消息请求回调处理 'callable' => null, // 服务进程参数配置 - 'worker' => [ - 'name' => 'ThinkAdmin', + 'worker' => [ + 'name' => 'ThinkAdmin', 'count' => 4, ], // 监控文件变更重载,仅 Debug 模式有效 - 'files' => [ + 'files' => [ // 监控检测间隔(单位秒,零不监控) 'time' => 3, // 文件监控目录(默认监控 app+config 目录) 'path' => [], // 文件监控后缀(默认监控 所有 文件) - 'exts' => ['*'] + 'exts' => ['*'], ], // 监控内存超限重载,仅 Debug 模式有效 - 'memory' => [ + 'memory' => [ // 监控检测间隔(单位秒,零不监控) - 'time' => 60, + 'time' => 60, // 限制内存大小(可选单位有 G M K ) - 'limit' => '1G' + 'limit' => '1G', ], -]; \ No newline at end of file +]; diff --git a/plugin/think-library/src/Builder.php b/plugin/think-library/src/Builder.php index d9fa17023..3a9b28fe7 100644 --- a/plugin/think-library/src/Builder.php +++ b/plugin/think-library/src/Builder.php @@ -1,20 +1,22 @@ '; + $html .= "\n\t\t\t" . sprintf('%s%s', empty($attrs['required']) ? '' : 'label-required-prev', $title, $substr); + $html .= "\n\t\t\t" . sprintf('', $name, $this->_attrs($attrs), $title, $this->variable, $name); + if ($remark) { + $html .= "\n\t\t\t" . sprintf('%s', $remark); + } + $this->fields[] = "{$html}\n\t\t"; + return $this; + } + + /** + * 创建 Text 输入. + * @param string $name 字段名称 + * @param string $title 字段标题 + * @param string $substr 字段子标题 + * @param string $remark 字段备注 + * @param bool $required 是否必填 + * @param ?string $pattern 验证规则 + * @param array $attrs 附加属性 + * @return $this + */ + public function addTextInput(string $name, string $title, string $substr = '', bool $required = false, string $remark = '', ?string $pattern = null, array $attrs = []): Builder + { + $attrs['vali-name'] = $title; + if ($required) { + $attrs['required'] = 'required'; + } + if (is_string($pattern)) { + $attrs['pattern'] = $pattern; + } + return $this->addInput($name, $title, $substr, $remark, $attrs); + } + + /** + * 创建密钥输入框. + * @param string $name 字段名称 + * @param string $title 字段标题 + * @param string $substr 字段子标题 + * @param string $remark 字段备注 + * @param bool $required 是否必填 + * @param ?string $pattern 验证规则 + * @param array $attrs 附加属性 + * @return $this + */ + public function addPassInput(string $name, string $title, string $substr = '', bool $required = false, string $remark = '', ?string $pattern = null, array $attrs = []): Builder + { + $attrs['type'] = 'password'; + return $this->addTextInput($name, $title, $substr, $required, $remark, $pattern, $attrs); + } + + /** + * 添加取消按钮. + * @param string $name 按钮名称 + * @param string $confirm 确认提示 + * @return $this + */ + public function addCancelButton(string $name = '取消编辑', string $confirm = '确定要取消编辑吗?'): Builder + { + return $this->addButton($name, $confirm, 'button', 'layui-btn-danger', ['data-close' => null]); + } + + /** + * 添加提交按钮. + * @param string $name 按钮名称 + * @param string $confirm 确认提示 + * @return $this + */ + public function addSubmitButton(string $name = '保存数据', string $confirm = ''): Builder + { + return $this->addButton($name, $confirm, 'submit'); + } + + /** + * 添加上传单图字段. + * @param string $name 字段名称 + * @param string $title 字段标题 + * @param string $substr 字段子标题 + * @param bool $required 必填字段 + * @param array $attrs 附加属性 + * @return $this + */ + public function addUploadOneImage(string $name, string $title, string $substr = '', bool $required = false, array $attrs = []): Builder + { + if ($required) { + $attrs['required'] = 'required'; + } + return $this->_addUploadOneView($name, $title, $substr, $attrs); + } + + /** + * 添加上传视频字段. + * @param string $name 字段名称 + * @param string $title 字段标题 + * @param string $substr 字段子标题 + * @param bool $required 必填字段 + * @param array $attrs 附加属性 + * @return $this + */ + public function addUploadOneVideo(string $name, string $title, string $substr = '', bool $required = false, array $attrs = []): Builder + { + if ($required) { + $attrs['required'] = 'required'; + } + return $this->_addUploadOneView($name, $title, $substr, $attrs, 'video'); + } + + /** + * 创建上传多图字段. + * @param string $name 字段名称 + * @param string $title 字段标题 + * @param string $substr 字段子标题 + * @param bool $required 必填字段 + * @param array $attrs 附加属性 + * @return $this + */ + public function addUploadMulImage(string $name, string $title, string $substr = '', bool $required = false, array $attrs = []): Builder + { + if ($required) { + $attrs['required'] = 'required'; + } + $attrs = array_merge($attrs, ['type' => 'hidden', 'placeholder' => "请上传{$title} ( 多图 )"]); + $html = "\n\t\t" . '
'; + $html .= "\n\t\t\t" . sprintf('%s%s', empty($attrs['required']) ? '' : 'label-required-prev ', $title, $substr); + $html .= "\n\t\t\t" . '
'; + $html .= "\n\t\t\t\t" . sprintf('', $name, $this->_attrs($attrs), $this->variable, $name); + $html .= "\n\t\t\t" . '
' . "\n\t\t" . '
'; + $html .= "\n\t\t" . sprintf('', $name); + $this->fields[] = $html; + return $this; + } + + /** + * 创建复选框字段. + * @param string $name 字段名称 + * @param string $title 字段标题 + * @param string $substr 字段子标题 + * @param string $vname 变量名称 + * @param bool $required 是否必选 + * @param array $attrs 附加属性 + * @return $this + */ + public function addCheckInput(string $name, string $title, string $substr, string $vname, bool $required = false, array $attrs = [], string $type = 'checkbox'): Builder + { + if ($required) { + $attrs['required'] = 'required'; + } + $attrs = array_merge($attrs, ['type' => $type, 'lay-ignore' => null, 'name' => $name . ($type === 'checkbox' ? '[]' : '')]); + $html = "\n\t\t" . '
'; + $html .= "\n\t\t\t" . sprintf('%s%s', empty($attrs['required']) ? '' : ' label-required-prev', $title, $substr); + $html .= "\n\t\t\t" . '
'; + $html .= "\n\t\t\t\t" . sprintf('', $vname); + $html .= "\n\t\t\t\t" . sprintf(''; + $html .= "\n\t\t\t\t" . ''; + $this->fields[] = $html . "\n\t\t\t
\n\t\t
"; + return $this; + } + + /** + * 添加单选框架字段. + * @param string $name 字段名称 + * @param string $title 字段标题 + * @param string $substr 字段子标题 + * @param string $vname 变量名称 + * @param bool $required 是否必选 + * @param array $attrs 附加属性 + * @return $this + */ + public function addRadioInput(string $name, string $title, string $substr, string $vname, bool $required = false, array $attrs = []): Builder + { + return $this->addCheckInput($name, $title, $substr, $vname, $required, $attrs, 'radio'); + } + + /** + * 显示模板内容. + * @return mixed + */ + public function fetch(array $vars = []) + { + $html = ''; + $type = "{$this->type}.{$this->mode}"; + if ($type === 'form.page') { + $html = $this->_buildFormPage(); + } elseif ($type === 'form.modal') { + $html = $this->_buildFormModal(); + } + foreach ($this->class as $k => $v) { + $vars[$k] = $v; + } + throw new HttpResponseException(display($html, $vars)); + } + + /** + * 增加输入表单元素. * @param string $name 字段名称 * @param string $title 字段标题 * @param string $subtitle 字段子标题 @@ -126,80 +335,26 @@ class Builder $html = "\n\t\t" . '"; return $this; } /** - * 创建文本输入框架 - * @param string $name 字段名称 - * @param string $title 字段标题 - * @param string $substr 字段子标题 - * @param array $attrs 附加属性 - * @return $this - */ - public function addTextArea(string $name, string $title, string $substr = '', bool $required = false, $remark = '', array $attrs = []): Builder - { - if ($required) $attrs['required'] = 'required'; - $html = "\n\t\t" . '