有什么可以阻止我在__construct()括号内键入这样的提示吗?
<?php
class SomeClass extends BaseClass {
public function __construct(array $someArray) {
parent::__construct($someArray);
}
或者我只能这样做?
<?php
class SomeClass extends BaseClass {
public function __construct($some
对于我的laravel应用程序中的一个资源,当字段空白时,我会得到一个错误:
Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, null given, called in /var/www/html/pfladmin/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 309 and defined
我在堆栈跟踪中查找了我编写的一些代码(而不是来自
我有一个在命名空间中创建的程序的测试程序。我遇到的问题是,laravel容器似乎没有解决测试方法依赖关系,也没有解决laravel,.。我在Windows 10上。
PHP代码:
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ACME\SomeClass;
class CLIComman
我正在尝试加载PHP中附带的Google,但是首先,我需要将apiClient类实例传递给另一个类,因为我使用Codeigniter加载apiClient库,但是它没有加载第二个类。
我所做的:
$this->load->library('google/apiClient', NULL, 'apiClient');
echo gettype($this->apiClient); // object
// This class needs the `apiClient` class to be passed to this, but fail
我试图创建一个带有声明的参数类型的函数,以快速检查它们的格式是否正确,但当它返回一个字符串时,会出现以下错误:
Catchable fatal error: Argument 2 passed to myfunction() must be an instance of string, string given, called in path_to_file on line 69 and defined in path_to_file on line 49
示例
function myfunction( array $ARRAY, string $STRING, int $INTEGER )
我正在尝试使用我的路由服务提供商提供的服务。
我已经尝试了我通常在任何控制器中所做的事情
use App\Services\EncryptionService;
class RouteServiceProvider extends ServiceProvider{
..
public function __construct(EncryptionService $encryption) {
$this->encryption = $encryption;
} // end function constructor
..
}
我得到的错误是
我的目标是打印一个整数数组的所有元素,而不管它的长度。我想以Python列表格式打印它,但随后我得到了这个错误。这是我的密码
int measure(int n[])
{
int num=0;
while (n[num]) { num++; }
return num;
}
void show(int n[])
{
int a = measure(n);
for (int i=0; i<a; i++) {
if (i==0) { printf("[%d,",n[i]); }
else if (i==a
我正在使用Laravel 5.4,我试图将一个$order类注入到一个trait中,这个trait将由一个model实现。如下所示:
class Forum extends Model
{
use Orderable;
特征的constructor如下所示:
trait Orderable
{
public $orderInfo;
public function __construct(OrderInterface $orderInfo)
{
$this->orderInfo = $orderInfo;
}
我的服务提供商如下所
我有一个电子商务与Prestashop 1.7.6.9,这往往是一个500错误。
因此,我尝试启用调试,现在Prestashop显示了这个错误:
(1/1) FatalThrowableError
Type error: Argument 2 passed to
PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingPresenter::present()
must be of the type array, boolean given, called in
/home/path
我需要帮助传递我已经初始化的变量,使用__construct()在Laravel中查看。
这是我的控制器代码
protected $profileInfo;
public function __construct(){
$this->profileInfo = Profile::with('address')->where('id', '=', '1')->get();
}
public function index(){
$this->profileInfo;
return view(
在php-8和更高版本中,下面的代码可以工作
class Foo {
public function __construct(string $string = null) {}
}
但是在php-8中,除了属性提升之外,它还引发了一个错误。
class Foo {
public function __construct(private string $string = null) {}
}
致命错误:不能将null用作字符串类型的参数$string的默认值
但是,使字符串可以为空工作。
class Foo {
public function __construc
以下代码:
<?php
class Type {
}
function foo(Type $t) {
}
foo(null);
?>
运行时失败:
PHP Fatal error: Argument 1 passed to foo() must not be null
为什么不允许像其他语言一样传递null?
我在Laravel5.2中创建了一个自定义异常类。它的工作效果很好,直到拉里5.4。
当我试图使用同一个与Laravel5.5相同的自定义异常类时,它会抛出以下错误。
Type error: Argument 1 passed to App\Utility\Exceptions\CustomException::report() must be an instance of Exception, none given, called in /var/www/html/bubbles/vendor/laravel/framework/src/Illuminate/Foundation/Excep
为什么这个不起作用?
Prelude> foldl1 (\a b -> ((snd a) + (snd b))) [(1,2),(3,4)]
<interactive>:1:17:
Occurs check: cannot construct the infinite type: b = (a, b)
Expected type: (a, b)
Inferred type: b
In the expression: ((snd a) + (snd b))
In the first argument of `foldl1&
我在尝试在扩展线程的类中模拟一个方法
class Tclass extends \Threaded
{
public function __construct( $name )
{
$this->name = $name;
}
public function run()
{
$this->mockMePlease("var");
}
public function mockMePlease($var){}
}
class TclassTest extends \Code
我需要以下几点:
function(arg) {
if (undefined was passed explicitly)
//case 1
if (no parameter was passed)
// case 2
}
这有可能吗?接下来的陈述对这些情况没有影响:
typeof args === 'undefined'
args === undefined
args === null
所以我想我应该试着在Laravel里使用这个花哨的IoC容器。我从口香糖开始,但我不能让它开始工作。也许在我的理解上还存在着差距。我真的很感激这里的任何帮助。
所以我有一个连接到RESTful Api的类。下面是其中的一个示例:
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Client;
use GuzzleHttp\Subscriber\Oauth\Oauth1;
class EtApi {
//you can pass in the model if you wanna
我想将一个DateTimeZone对象传递给我的类Test中的方法。我有以下代码: class Test {
function __construct( $timezone_object = new DateTimeZone() ) {
// Do something with the object passed in my function here
}
} 不幸的是,上面的方法不起作用。它给了我一个错误。我知道我可以做以下事情: class Test {
function __construct( $timezone_object = NULL )
我在反抗。据我所知,AutoWrap函数用于调用外部方法,获取/设置属性。
让我们尝试理解调用此函数的代码:
//Make it visible (i.e. app.visible = 1)
{
//parameter preparation
VARIANT x;
x.vt = VT_I4;// type of parameter
x.lVal = 1;// value
AutoWrap(
DISPATCH_PROPERTYPUT, // set property
NULL, // we need no result
<?php
class A
{
public $x=40;
function sum($x)
{
return $this->x + $this->x;
}
public function __construct()
{
echo "The class ".__class__." has been created<br>";
}
function sub($integers)
{
echo 2*$inte
因此,我试图在资源中添加一个新的度量趋势,但始终会收到以下错误:
Too few arguments to function Laravel\Nova\Resource::__construct(), 0 passed in /crm/nova/src/Metrics/Trend.php on line 116 and exactly 1 expected {"userId":1,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0
我刚收到这个致命的错误
可捕获的致命错误:传递给File::__construct()的参数1必须是整数的实例,给定整数,在第9行的/home/radu/php_projects/audio_player/php/File.php中调用,在第7行的/home/radu/php_projects/audio_player/php/File.php中定义
所以,这是一门课
class File{
public $id;
public $name;
public $file_paths;
public funct
我刚刚遇到了一个问题,我无法解释为什么这样做。
我有一个只接受字符串类型参数的函数。
示例类
class A {
public function __construct() {
$data = new \Illuminate\Support\Collection();
// getType($data) => object
$this->make($data);
}
private function make(string $str): string {
// getType($str)
我正在尝试在Java中反射地调用这个方法:
public void setFoo(ArrayList<String> foo) { this.foo = foo; }
问题是我希望将null作为null传递,这样foo就变成了null。
然而,在下面的方法中,它假设没有参数,并且我得到了IllegalArgumentException(wrong number of arguments):
method.invoke(new FooHolder(), null);
// -----------------------------^ - I want null to be passe
我无法通过Laravel注入这些变量:
//...class AllowedUsername implements Rule...
public function __construct(Router $router, Filesystem $files, Repository $config)
{
$this->router = $router;
$this->files = $files;
$this->config = $config;
}
我知道错误:
Type error: Too few arguments to function ..