草庐IT

fluent-interface

全部标签

php - 从继承接口(interface)的类调用静态方法

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Referringtoastaticmemberofasubclass请查看以下代码以了解我的问题。有没有办法强制抽象returnSomething(),同时保持从抽象“中间人”类中定义的函数调用函数的可能性?对我来说,这似乎是PHP的瓶颈。

php - 接口(interface)和抽象类的优点是什么?

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicates:purposeofinterfaceinclassesWhatisthedifferencebetweenaninterfaceandabstractclass?大家好,我是一名PHP程序员。任何人都可以解释使用接口(interface)和抽象类的优势是什么。

在类 Illuminate\Support\Fluent 中找不到 Phpstorm 9 EAP 方法 "unique"

我正在做一个网站项目,我正在使用Laravel5和PHPStorm9EAP。我创建了一个迁移并使用此代码$table->string('name')->unique();并且IDE突出显示了unique()和显示一条消息Illuminate\Support\Fluent类中未找到“唯一”方法。这是我的迁移:classCreateProductsTableextendsMigration{/***Runthemigrations.**@returnvoid*/publicfunctionup(){Schema::create('products',function(Blueprint$t

类实现接口(interface)时PHP Trait冲突

我有一个实现execute方法接口(interface)的类。接口(interface)强制execute方法有两个带有一些类型提示的参数。我还使用了一个具有execute方法的特征,但具有不同的功能和签名。我通过使用更改特征方法名称:classMyClassimplementsMyInterface{useMyTrait{executeasprotectedcommanderExecute;}publicfunctionexecute(SomeInterface$arg1,SomeInterface2$arg2){//dosomething}}当我尝试运行该应用程序时,它会抛出一个f

php - 类不返回接口(interface)实例 PHP

我在实现接口(interface)的类上遇到奇怪的错误。错误:Catchablefatalerror:Argument1passedtoMyApp\Library\Cache::__construct()mustbeaninstanceofMyApp\Contacts\CacheInterface,instanceofMyApp\Driver\Cache\Filegiven文件类别:namespaceMyApp\Driver\Cache;useMyApp\Library\Config;useMyApp\Contracts\CacheInterface;classFileimplemen

php - 在 PHP 中检测方法链的结尾?

我找不到关于我的上述问题的简单示例:如何检测方法链的结尾?我只是以Zend_Db_Select为例,但我认为这个对于这个简单的问题来说太复杂了。是否有可能在PHP中捕获方法链的“结尾”?谢谢,工厂 最佳答案 没有。这是不可能的。Zend_Db_Select不检测方法链的结尾。您链接的每个方法都只返回$this并且当您停止链接时,您就停止了链接。没有神奇的东西说:嘿,这是链条的末端。例子:$foo=$this->is()->a()->method()->chain();如果所有方法返回$this,那么$foo将包含chain()的结果

php - 尝试测试 UPS "Quantum"接口(interface) - XML 文档格式不正确

我们正在尝试测试联合包裹服务公司(UPS)“Quantum”接口(interface)测试获取订单状态信息。我们的跟踪号API可以正常工作,但在使用QVEvents时遇到了问题。UPS“出境订阅账户”已设置、激活并链接到我的帐号。用户访问QuantumView数据View在用户设置屏幕中被勾选。顺便说一句,我已经使用类似的代码获得了TrackingAPI,因此我认为我可以排除用户名或密码问题。这两个API在操作上有什么不同吗?(例如:SSL要求、HTTPheader设置?)这是对我有用的跟踪API(“TackbyWaybill”)代码:$access$userid$passwdhell

php - Analytics PHP 接口(interface) (GAPI) 用户模拟

我目前在GoogleAnalytics(分析)中拥有大约100个站点,分布在几个不同的Google帐户中,并且一个帐户对每个站点都拥有完全权限。如果可能,我想避免为每个分析配置文件手动添加Google服务帐户的权限。我正在使用GoogleAnalyticsPHPInterface尝试使用$delegate_email参数模拟用户时,出现以下异常:GAPI:Failedtoauthenticateuser.Error:"{"error":"unauthorized_client","error_description":"Unauthorizedclientorscopeinreques

php - 如何在 Yii2 中将接口(interface)注入(inject) Controller 的构造函数

我想注入(inject)接口(interface)app\models\IFooprivate$foo;publicfunction__construct($id,$module,IFoo$foo,array$config=[]){parent::__construct($id,$module,$config);$this->foo=$foo;}我应该如何设置容器以正确解决实现IFoo的具体类app\models\Foo中的依赖关系? 最佳答案 尝试在入口脚本中这样调用它:\Yii::$container->set('app\mod

php - 为什么中间件不实现接口(interface)?

在LaravelIlluminate\Contracts\Routing\Middleware。现在,用artisan创建的中间件不再实现任何东西。和thecontractwasremoved没有解释(除非我弄错了)。有原因吗? 最佳答案 根据laravel5.2升级指南officialdocumentation在弃用部分下:Illuminate\Contracts\Routing\Middleware契约已被弃用。您的中间件不需要契约(Contract)。此外,TerminableMiddleware契约(Contract)也已弃