php - php在尝试调用方法后输出代码
问题描述
我正在尝试重新创建 laravel 雄辩的 ORM。在我尝试调用一个类的方法后,php 会打印调用背后的代码。我使用作曲家和命名空间。也许知道我使用 xampp 很重要?!
这是我的代码
索引.php
<?
namespace com;
require_once __DIR__ . '/vendor/autoload.php';
use com\config\Conf;
use com\db\Table;
use com\db\dataTypes\INTEGER;
use com\Connectors\MySqlConnector;
$DB_HOST = Conf::$DB_HOST;
$DB_PORT = Conf::$DB_PORT;
$DB_USER = Conf::$DB_USER;
$DB_PASSWORD = Conf::$DB_PASSWORD;
$DB_NAME = Conf::$DB_NAME;
$connector = new MySqlConnector($DB_HOST,$DB_PORT,$DB_USER,$DB_PASSWORD,$DB_NAME);
$t1 = new Table("table1");
$age = new INTEGER("age");
//affected call
$age = $age -> primary() -> unsigned();
$counting = new INTEGER("counting");
$counting = $counting->nullable(false)->defaultValue(18);
$t1->addData($age);
$t1->addData($counting);
$connector->addTable($t1);
$connector->registerTables();
我已经用“//affected call”标记了代码的一部分。
整数.php
<?
namespace com\db\dataTypes;
use com\db\dataTypes\DataType;
use com\config\Conf;
class INTEGER extends DataType{
private int $defaultValue = 0;
private bool $unsigned = false;
function __construct(string $col) {
$this->column = $col;
}
//code
public function primary() : INTEGER {
$this->isPrimaryKey = true;
return $this;
}
public function unsigned() : INTEGER {
$this->unsigned = true;
return $this;
}
//code
}
输出看起来像这样
primary() -> unsigned(); $counting = new INTEGER("counting"); $counting = $counting->nullable(false)->defaultValue(18); $t1->addData($age); $t1->addData($counting); $connector->addTable($t1); $connector->registerTables();
我不知道它是否有帮助,但这是我的composer.json
{
"autoload": {
"psr-4": {
"com\\": "",
"com\\config\\": "config/",
"com\\db\\": "db/",
"com\\db\\dataTypes\\": "db/dataTypes/",
"com\\Connectors\\": "Connectors/"
}
}
}
解决方案
推荐阅读
- node.js - 开玩笑的错误 MongoServerError: E11000 duplicate key 错误收集
- visual-studio-code - VS Code 如何将 IntelliSense 添加到嵌入式语言
- wordpress - wordpress媒体库上传pdf并获取url
- javascript - 如何以编程方式平滑滚动多个容器?
- python - pyspark 将 RDD 转换回 DF
- snowflake-cloud-data-platform - 使用分区 ADLS 复制到
- bash - 运行 bash 脚本空行 $'\r' 时出错:找不到命令
- tkinter - Python`Ошибка无效的命令名“.!canvas”`
- ruby-on-rails - 如果条件 image.url.present,我该如何添加?
- macos - 如何修复 OS X 更新失败?