如何创建要由fix带选项的命令运行的自定义规则集--rules=@custom?
像@PSR1,@PSR2,@Symfony,@PHP56Migration,@PHP70Migration,@PHP71Migration制成。
php-cs-fixer版本:2.2.3
仅通过插入供应商代码- vendor/friendsofphp/php-cs-fixer/src/RuleSet.php:
private $setDefinitions = array(
'@custom' => [
'some_custom_fixer` => true,
]
)
Run Code Online (Sandbox Code Playgroud)
符合我的预期,但RuleSet确实如此final class。setDefinitions使用自定义配置时,有没有方法可以覆盖或扩展.php_cs?
例如,让我们说我们有这样的事情:
.
??? app
? ??? module1
? ? ??? composer.json
? ??? module2
? ??? composer.json
??? composer.json
Run Code Online (Sandbox Code Playgroud)
在每个composer.json我们都有不同的依赖关系。
如何使用单个命令安装所有需要的软件包?
我正在尝试使用基于存储在数据库中的内容的内容填充我的网页.但是,我想跳过第一项; 我想从第二个项目开始循环.
我怎样才能做到这一点?
@foreach($aboutcontent as $about)
<div class="col-md-4 text-center">
<div class="thumbnail">
<img id="" class="img-responsive" src="images/{{ $about->aboutimg }}" alt="">
<div class="caption">
<h3>{{ $about->aboutname }}</h3>
<p>{{ $about->aboutinfo }}</p>
</div>
</div>
</div>
@endforeach
Run Code Online (Sandbox Code Playgroud) 对于Laravel项目,我使用Travis Ci作为PHP语言选项.除了PHP,我想做一些Node JS测试.Node JS的默认安装版本不符合我的要求.如何在配置文件中指定Node JS的版本?
我尝试了以下内容.但不幸的是,这不起作用.
language: php
php:
- '7.0'
- '7.1'
node_js:
- '6.10'
Run Code Online (Sandbox Code Playgroud) 我正在尝试为使用全局参数(来自YML文件)的服务编写测试。
我正在方法中检索此参数setUp(),但是当我尝试在中使用它们时@dataProvider,会引发错误。
class InterpreterServiceTest extends KernelTestCase
{
private $container;
private $service;
private $citiesMap;
public function setUp()
{
self::bootKernel();
$this->container = self::$kernel->getContainer();
$this->service = $this->container->get('geolocation.interpreter');
$this->citiesMap = $this->container->getParameter("citiesmap");
self::tearDown();
}
/**
* @dataProvider locationsProvider
*/
public function testCompanyCityFromCity($location, $expected)
{
$city = $this->service->getCompanyCityFromCity($location);
$this->assertEquals($expected, $city);
}
public function locationsProvider()
{
$return = array();
foreach ($this->citiesMap as $area) {
$return[] = [
$area['external_service_area'],
$area['company_area']
];
}
return $return;
}
}
Run Code Online (Sandbox Code Playgroud)
为foreach()提供了无效的参数
如果我手动写的返回locationsProvider()它的作品
return [
["Barcelona", "Barcelona"], …Run Code Online (Sandbox Code Playgroud) <p id="p1">
...here is a lot of text (html) mixed with php...
</p>
<button onclick="copyToClipboard('#p1')">Copy to clipboard</button>
------
JS
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}
Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,结果将被复制但没有粗体,下划线,行和其他格式化的东西.我如何复制它,因为它默认显示?
是否有任何选项可以将 phpcs 修复程序结果的输出存储到文件中?
我尝试了下面的
phpcs --standard='Symfony' -a 'path' --report-file='~/Users/uname/Desktop/PHPcs'
Run Code Online (Sandbox Code Playgroud)
但它给出了一个错误:
错误:指定的报告文件路径“~/Users/uname/Desktop/PHPcs”指向不存在的目录
运行“ phpcs --help”获取使用信息
我有一个列表(如字符串,比如$ peoplelist),如下所示:
Name1
Name2
Name3
Run Code Online (Sandbox Code Playgroud)
我想要做的是将整个字符串分成单独的元素(其中每一行对应一个新元素//即元素1是"Name1",元素2是"Name2"等)并将它们放入一个数组中(实际上,使用换行符作为分隔符,并将该字符串拆分为单独的元素,以便放入唯一索引下的数组中).
这是我到目前为止:
# Step 1 - Fetch the list
$peoplelist = file_get_contents('http://domain.tld/file-path/')
//The Contents of $peoplelist is stated at the top of this question.
//(The list of names in blue)
# Step 2 - Split the List, and put into an array
$arrayX = preg_split("/[\r\n]+/", $playerlist);
var_dump($arrayX);
Run Code Online (Sandbox Code Playgroud)
现在,使用上面提到的代码,这就是我得到的(输出):
array(1) { [0]=> string(71) "Name1
Name2
Name3
" }
Run Code Online (Sandbox Code Playgroud)
根据我的输出,(根据我的理解)整个字符串(步骤1中的列表)被放入一个索引下的数组中,这意味着第二步不能有效地完成我打算做的事情.
我的问题是,如何将列表拆分为单独的元素(原始列表中的每个单独的行是一个唯一的元素)并将这些元素放在一个数组中?
编辑: 谢谢大家的帮助!感谢localheinz的解决方案:)
注意:如果将来有人读到这个,请确保列表的源文件包含原始数据 - 我的错误是使用扩展名为.php的文件,其中包含html标记 - 这个html脚本干扰了索引过程.
我已经下载了源代码,我认为代码is_string()已经存在ext/standard/,但我不确定.
我有以下数组:
$name_arr = array('raj','raj','ganesh','rahul','ganesh','mayur','raj','rahul');
Run Code Online (Sandbox Code Playgroud)
我想这样排序:
$final_arr = array('raj','raj','raj','ganesh','ganesh','rahul','rahul','mayur');
Run Code Online (Sandbox Code Playgroud)
我该如何实现?