有没有办法记录特定函数调用exit()?
用例是我们有一个函数负责处理重定向(检查已发送的标头、设置响应代码等),然后关键地调用exit(). 不幸的是,PHPStorm 不知道这个特定的函数会终止执行,因此建议进一步警告,好像这个函数已经返回,但实际上它永远不会返回。
我有CustomRepository扩展Doctrine\ORM\EntityRepository. 该存储库与许多不同的实体相关联。存储库中有一个方法可以返回关联的实体。
class CustomRepository extends \Doctrine\ORM\EntityRepository
{
function getEntity() { ... } // returns an instance of associated entity
}
/**
* @ORM\Entity(repositoryClass="CustomRepository")
*/
class EntityClass1 { ... }
/**
* @ORM\Entity(repositoryClass="CustomRepository")
*/
class EntityClass2 { ... }
$repo1 = $entityManager->getRepository('Entity1');
$entity1 = $repo1->getEntity(); // will return an instance of EntityClass1
$repo2 = $entityManager->getRepository('Entity2');
$entity2 = $repo1->getEntity(); // will return an instance of EntityClass2
Run Code Online (Sandbox Code Playgroud)
我使用 Symfony 2 插件,它正确地将继承方法实体返回的类检测为find.
有没有办法通知插件该方法返回一个关联实体?
在 IntelliJ IDEA 和基于它的 IDE PhpStorm 中,是否有键盘快捷键可以将水平列表转换为垂直列表,反之亦然?例如我有数组
$arr = [
'test',
'a' => 'b',
];
Run Code Online (Sandbox Code Playgroud)
我希望把它单行,我可以选择文本和使用Ctrl+ Shift+ J,我得到
$arr = ['test', 'a' => 'b', ];
Run Code Online (Sandbox Code Playgroud)
这几乎是好的,我可以,手动删除最后一个。但是如何做相反的事情:将水平列表转换为垂直列表?这不仅与数组有关,此问题也与函数签名有关,例如
public function test($arg1, $arg2, $arg3, $arg4)
Run Code Online (Sandbox Code Playgroud)
和函数调用
test($arg1, $arg2, $arg3, $arg4);
Run Code Online (Sandbox Code Playgroud)
有时字符串变得太长,需要将其拆分以提高可读性,如下所示:
test(
$arg1,
$arg2,
$arg3,
$arg4
);
Run Code Online (Sandbox Code Playgroud)
请注意,这个问题与代码折叠无关,我想真正更改格式,而不仅仅是为我显示隐藏。
当我使用 top 语句时,PhpStorm 为我提供了完整的 IntelliSense。例如:
use Framework\MVC\Route;
Route::setRoutes($routes);
Run Code Online (Sandbox Code Playgroud)
但是,我使用的class_alias是 [甚至不适用于同一个文件]:
class_alias("Framework\\MVC\\Route", "Route");
Run Code Online (Sandbox Code Playgroud)
现在,当我写作时,Route::我没有获得智能感知。事实上,它甚至显示了一些警告说 unknown class Route。我怎样才能解决这个问题?
我刚刚安装了 PHPStorm 并在我的 XAMPP php.ini 中配置了 xDebug:
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "C:\xampp\tmp"
Run Code Online (Sandbox Code Playgroud)
重新启动 apache,在 PHPStorm 中单击“调试”,控制台中出现此错误:
C:\xampp\php\php.exe -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 C:/Users/Myuser/AppData/Local/Temp/ide-phpunit.php --no-configuration C:\pwt\pwt-new
Testing started at 2:17 PM ...
Process finished with exit code 255
Run Code Online (Sandbox Code Playgroud)
谷歌搜索说 phpunit 有问题,但我不知道是什么。有任何想法吗 ?
当我尝试在 PHPStorm(10.0.3) 中打开文件时收到以下消息。
phpcs: PHP Fatal error: Call to undefined method PHP_CodeSniffer_File::recordMetric() in /usr/share/php/PHP/CodeSniffer/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php on line 91
Run Code Online (Sandbox Code Playgroud)
有人知道这是什么吗?
我正在使用 JetBrains 的 phpstorm 和 IdeaVim 插件。
我想知道是否可以将正常模式下的键绑定到编辑器操作。
例如,我曾经将Ctrl+映射B到 Navigate > Declaration。然而Ctrl+B是一个向后翻一页的 vi 动作,这没关系。
我知道我可以配置一个键盘快捷方式不同的地方,如Ctrl+ Shift+ B,但让事情变得更简单的我想有映射到功能ideavim的命令模式,例如关键;。
所以,紧迫; 在命令模式下会触发Declarationwitin phpstorm的动作。
我怎样才能做到这一点?
我来自一种严格类型化的编程语言,它有一个名为“ANY”的类型。
因为 PHP 是松散耦合的,所以我的 PhpDoc 需要某种类型的提示,说明变量、参数或返回值可以是任何类型。目前我必须写一些类似的东西:
@var string|int|bool|array|object $someVariable
如果我可以这样写,它会让我的生活更轻松,代码也会更容易阅读:
@var any $someVariable
我实际上在很多情况下都遇到了这个问题 - 在过去的几个月里,到目前为止已经超过 20-30 次,因为我使用 PhpStorm,它向我显示警告,某些方法需要其他类型的参数类型,要么是因为我忘记了将它明确地放在类型列表中,或者因为我使用的是在 Eclipse 中编写的代码,它没有对我自称的“任何”类型显示任何警告。
我的问题:有没有办法告诉 PhpStorm,当我说any我的意思时,string|any|bool|array|object或者是否有其他类型的提示可以这么说?我也很好奇我是否是唯一一个遇到这个问题的人,或者是否还有其他人像这样工作。
我知道您可以使用以下方式从 Symfony 分析器或异常文件链接打开文件project/app/config.yml:
framework:
ide: "phpstorm://open?file=%%f&line=%%l"
Run Code Online (Sandbox Code Playgroud)
更多信息:http : //developer.happyr.com/open-files-in-phpstorm-from-you-symfony-application
但是,当我使用 vagrant 时,服务器的文件路径与我的主机不匹配。
我已经使用正确的路径映射在 PHPStorm 中创建了一个 PHP Web 应用程序服务器,但仍然无法正常工作。
有任何想法吗?
谢谢
PhpStorm 正在对齐数组中的括号。
DB::table('something')->create([
'title' => 'John',
'description' => 'Doe',
]); // I don't want to align it this way...
DB::table('something')->create([
'title' => 'John',
'description' => 'Doe',
]); // But this way...
Run Code Online (Sandbox Code Playgroud)
我在哪里改变这个Settings/Preferences > Editor > Code Style > PHP?
phpstorm ×10
php ×5
phpdoc ×2
symfony ×2
doctrine-orm ×1
ideavim ×1
type-hinting ×1
vim ×1
xampp ×1