2017-02-15 121 views
1

當我嘗試創建它時,我會在我的測試類中看到警告。我不想爲測試類創建PHPDoc和更多,但PhpStorm向我顯示警告,因爲PhpStorm無法將測試類標記爲phpcs的排除。PhpStorm phpspec代碼嗅探器忽略測試文件夾

如何我跑我phpcs爲驗證我的類編碼標準:

php bin/phpcs ./src -p --encoding=utf-8 --extensions=php --ignore=Tests --standard=./vendor/escapestudios/symfony2-coding-standard/Symfony2 

如何實現它的PhpStorm 2016年3月2日? 我嘗試創建配置:在PhpStorm

<target name="phpcs-ci" 
     description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server"> 
    <exec executable="phpcs" output="/dev/null"> 
     <arg value="--encoding=utf-8" /> 
     <arg value="--extensions=php" /> 
     <arg value="--ignore=Tests" /> 
     <arg value="--standard=./vendor/escapestudios/symfony2-coding-standard/Symfony2" /> 
     <arg path="${basedir}" /> 
    </exec> 
</target> 

並導入此配置: enter image description here

但我的測試表明我的警告再次: enter image description here

+1

可否請你澄清你在這裏需要什麼。據我瞭解,到目前爲止,您希望禁用代碼嗅探器(PhpStorm集成)爲您的測試文件(無論原因 - 無所謂),但仍然繼續運行它爲您的其他代碼。我對麼? – LazyOne

+0

是的,你是對的。 –

回答

3
  1. Settings/Preferences | Appearance & Behaviour | Scopes

    去那裏並創建一個custom Scope噸帽子會包含這些不需要的文件/文件夾(最簡單的方法 - 導航到樹中的Tests文件夾,然後單擊Include recursively按鈕)。

    注:理論上,這一步可以,如果你與測試,「測試源根」(在項目視圖面板中右鍵單擊並從Mark Directory As子菜單正確類型的標記您的文件夾被跳過;同樣可以做到通過Settings/Preferences | Directories)。

    這樣你可以使用內置的「測試」範圍。

  2. 保存更改(無論是Apply ...或使用OK,並重新打開設置/首再次屏幕)

  3. Settings/Preferences | Editor | Inspections

  4. 查找PHP | PHP Code Sniffer validation檢查

  5. 創建新規則最近創建了Scope。

    單擊In All Scopes按鈕(僅當定義了1個規則時,該按鈕)並選擇該範圍。

    enter image description here

  6. 現在只需禁用此檢查該範圍。

    enter image description here

https://www.jetbrains.com/help/phpstorm/2016.3/changing-the-order-of-scopes.html