首先,我在Dreamweaver的代码视图中严格执行所有编码已有好几年了.我可以在记事本中完成所有编码,但记事本没有任何功能.:)我从未想过要改变因为我已经习惯了Dreamweaver.但现在它开始在这里和那里激怒我.我也想切换到更轻量级的编辑器.
在Dreamweaver中我不喜欢的是标签不能自动更改为空格(非常烦人,也欢迎任何解决方案).它还在各处创造了许多无用的空白.
我喜欢Dreamweaver的html和css自动自动完成功能,这样可以加快我的编码速度,因为我不需要输入每个字符.我已经尝试了其他一些编辑器,但我真的很想念这个功能.Dreamweaver还会自动从标头中包含的css文件中完成css类.
还有其他编辑器有类似的功能吗?免费或许可是免费的.我喜欢Sublime Text(http://www.sublimetext.com/).
谢谢!
IDE(PS-117.65)抱怨某些常量未定义.
我已经在另一个文件的循环中定义了它们.我可以在这个文件的顶部放置一个doc注释来告知它常量吗?通常/** @var和@global语法似乎不适用于常量.
不确定如何提出这个问题.但我使用PhpStorm作为我的IDE.
我创建了一个将处理数据库检索和操作的类.在其中我有这个连接方法:
private function connect() {
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->db;
$options = [
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
];
try {
$this->conn = new PDO($dsn, $this->user, $this->pass, $options);
} catch(PDOException $e) {
$this->error = $e->getMessage();
}
}
Run Code Online (Sandbox Code Playgroud)
该方法工作正常,但当我$this->conn在其他方法中使用时,PhpStorm不会识别$this->conn为PDO对象.
使用此方法:
private function insert() {
$insert = $this->conn->prepare($sql);
$insert->execute();
}
Run Code Online (Sandbox Code Playgroud)
PhpStorm说它无法找到方法prepare或execute.
如果我传入$this->conn方法并在参数上使用PHPDoc块,它工作正常:
/**
* @param $conn pdo
*/
private function insert($conn) {
$insert = …Run Code Online (Sandbox Code Playgroud) PHP 7.1
我目前正在尝试制作一个抽象类,以提供和定义并部分实现其子类的功能。
在这里,我使用以下构造:
abstract class Parent {
public static function fromDB(string $name = '') {
$instance = new static();
if (!empty($name)) {
$instance->setName($name)->read();
}
return $instance;
}
public abstract function read();
public abstract function setName(string $name): self;
}
Run Code Online (Sandbox Code Playgroud)
在这里PHP似乎理解setName($name)返回类型为Object的Object Parent,但是PhpStorm指示read()不能在结果上调用,这将是预期的结果。
错误消息:在主题类中找不到引用的方法。
我不确定这是否是PHP或PhpStorm中的错误,或更可能是我不了解自己在做什么...
我已经阅读了“后期静态绑定”和以下部分讨论此问题的问题,但我不知道如何解决此问题:
感谢您的时间和帮助。
编辑:如下所示,我试图在子类中实现:
public function setName(string $name = null): user {...}
Run Code Online (Sandbox Code Playgroud)
这显然不适用于selfreturn,但(IMO应该)使用static,这是被禁止的。
我正在使用Closure::call(http://php.net/manual/en/closure.call.php)在类上下文中调用外部闭包.
这是一个简单的复制品:
class Foo {
private $bar = 'baz';
/**
* Executes a closure in $this context and returns whatever the closure returns.
*
* @param \Closure $closure
* @return mixed
*/
public function callClosureInThisContext(\Closure $closure) {
return $closure->call($this);
}
}
class Closures {
/**
* @return \Closure
*/
public function getClosureForFoo() : \Closure {
return function () {
// how do I tell my IDE that in this context $this is actually class Foo,
// …Run Code Online (Sandbox Code Playgroud) 我将barryvdh/laravel-ide-helper插件添加到Laravel 5.6的PhpStorm 2017.3.4中。似乎无法正常工作。
路线/api.php
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Run Code Online (Sandbox Code Playgroud)
在Route中找不到方法“中间件”
路线/web.php
Route::get('/', function () {
return view('welcome');
});
Run Code Online (Sandbox Code Playgroud)
这个还可以
route / channels.php
Broadcast::channel('App.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
Run Code Online (Sandbox Code Playgroud)
在广播中找不到方法“频道”
App \ Http \ Controllers \ Auth \ RegisterController.php
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
Run Code Online (Sandbox Code Playgroud)
类Validator存在多个定义
config / app.php
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => …Run Code Online (Sandbox Code Playgroud) 这可能不是什么大问题,但我认为代码应该是一致的,我认为区分大小写对函数调用很重要.他们是一种让PhpStorm识别函数调用是否与其定义具有相同情况的方法吗?
偶尔我会发现updateNote看起来像是updateNOte因为我的右手打字比左边快.我想抓住这些并修复它们.
PhpStorm发现了许多其他语法项,如数据类型等,但我找不到这方面的检查.这样的检查是否存在?
我使用PhpStorm在以下函数中自动添加了返回类型:
/**
* @return \Generator|null
*/
function yieldTest(): ?\Generator
{
yield from [1, 2, 3];
}
Run Code Online (Sandbox Code Playgroud)
我的问题:为什么在null选项旁边添加选项\Generator?
我看不到此方法返回null的方法,所以我想知道我是在忽略工作中的某些东西yield还是这是PhpStorm的怪癖并且可以安全地放弃?
更新:
为了澄清-我问为什么PHPStorm生成的返回类型为?\Generator。
我了解它随后被添加null到了php doc @return标签中,因为在上?。
更新2:
这是生成额外位之前测试文件的完整代码:
class yieldTestClass
{
public function yieldTest()
{
yield from [1, 2, 3];
}
}
Run Code Online (Sandbox Code Playgroud)
这是从方法名称的上下文菜单中选择“声明返回类型”后的代码:
class yieldTestClass
{
public function yieldTest(): ?\Generator
{
yield from [1, 2, 3];
}
}
Run Code Online (Sandbox Code Playgroud)
我不确定这是IDE中的本机功能还是来自插件,但如果是插件,我想它应该是https://plugins.jetbrains.com/plugin/7622-php-inspections-ea-扩展-
不管怎样,同样的问题。
phpstorm ×10
php ×6
console ×1
dreamweaver ×1
editor ×1
html ×1
ide ×1
inheritance ×1
laravel ×1
pdo ×1
phpdoc ×1
symfony ×1
ubuntu-16.04 ×1
xdebug ×1