All function braces need to be on new line
This commit is contained in:
13
phpcs.xml
13
phpcs.xml
@@ -15,9 +15,18 @@
|
|||||||
<arg value="s"/>
|
<arg value="s"/>
|
||||||
|
|
||||||
<!-- Use PSR-2 as a base -->
|
<!-- Use PSR-2 as a base -->
|
||||||
<rule ref="PSR2">
|
<rule ref="PSR2"/>
|
||||||
|
|
||||||
|
<!-- Exclusions below are for templates/ folder -->
|
||||||
|
|
||||||
|
<!-- Allow php files without any PHP in them -->
|
||||||
|
<rule ref="Internal.NoCodeFound">
|
||||||
|
<exclude-pattern>templates</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
|
||||||
<!-- Allow braces on same line for named functions -->
|
<!-- Allow braces on same line for named functions -->
|
||||||
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine"/>
|
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
|
||||||
|
<exclude-pattern>templates</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Allow closing braces to be on the same line -->
|
<!-- Allow closing braces to be on the same line -->
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ use Roots\Sage\Template\WrapperInterface;
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @SuppressWarnings(PHPMD.StaticAccess) This is a helper function, so we can suppress this warning
|
* @SuppressWarnings(PHPMD.StaticAccess) This is a helper function, so we can suppress this warning
|
||||||
*/
|
*/
|
||||||
function template_wrap(WrapperInterface $wrapper, $slug = 'base') {
|
function template_wrap(WrapperInterface $wrapper, $slug = 'base')
|
||||||
|
{
|
||||||
WrapperCollection::add($wrapper, $slug);
|
WrapperCollection::add($wrapper, $slug);
|
||||||
return $wrapper->getWrapper();
|
return $wrapper->getWrapper();
|
||||||
}
|
}
|
||||||
@@ -21,7 +22,8 @@ function template_wrap(WrapperInterface $wrapper, $slug = 'base') {
|
|||||||
* @param string $slug
|
* @param string $slug
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function template_unwrap($slug = 'base') {
|
function template_unwrap($slug = 'base')
|
||||||
|
{
|
||||||
return WrapperCollection::get($slug)->getTemplate();
|
return WrapperCollection::get($slug)->getTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +31,8 @@ function template_unwrap($slug = 'base') {
|
|||||||
* @param $filename
|
* @param $filename
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function asset_path($filename) {
|
function asset_path($filename)
|
||||||
|
{
|
||||||
static $manifest;
|
static $manifest;
|
||||||
isset($manifest) || $manifest = new JsonManifest(get_template_directory() . '/' . Asset::$dist . '/assets.json');
|
isset($manifest) || $manifest = new JsonManifest(get_template_directory() . '/' . Asset::$dist . '/assets.json');
|
||||||
return (string) new Asset($filename, $manifest);
|
return (string) new Asset($filename, $manifest);
|
||||||
@@ -39,7 +42,8 @@ function asset_path($filename) {
|
|||||||
* Determine whether to show the sidebar
|
* Determine whether to show the sidebar
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function display_sidebar() {
|
function display_sidebar()
|
||||||
|
{
|
||||||
static $display;
|
static $display;
|
||||||
isset($display) || $display = apply_filters('sage/display_sidebar', true);
|
isset($display) || $display = apply_filters('sage/display_sidebar', true);
|
||||||
return $display;
|
return $display;
|
||||||
@@ -49,7 +53,8 @@ function display_sidebar() {
|
|||||||
* Page titles
|
* Page titles
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function title() {
|
function title()
|
||||||
|
{
|
||||||
if (is_home()) {
|
if (is_home()) {
|
||||||
if ($home = get_option('page_for_posts', true)) {
|
if ($home = get_option('page_for_posts', true)) {
|
||||||
return get_the_title($home);
|
return get_the_title($home);
|
||||||
|
|||||||
@@ -18,17 +18,20 @@ class Asset
|
|||||||
|
|
||||||
protected $dir;
|
protected $dir;
|
||||||
|
|
||||||
public function __construct($file, ManifestInterface $manifest = null) {
|
public function __construct($file, ManifestInterface $manifest = null)
|
||||||
|
{
|
||||||
$this->manifest = $manifest;
|
$this->manifest = $manifest;
|
||||||
$this->asset = basename($file);
|
$this->asset = basename($file);
|
||||||
$this->dir = dirname($file) != '.' ? dirname($file) : '';
|
$this->dir = dirname($file) != '.' ? dirname($file) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString() {
|
public function __toString()
|
||||||
|
{
|
||||||
return $this->getUri();
|
return $this->getUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUri() {
|
public function getUri()
|
||||||
|
{
|
||||||
$file = ($this->manifest ? $this->manifest->get($this->asset) : $this->asset);
|
$file = ($this->manifest ? $this->manifest->get($this->asset) : $this->asset);
|
||||||
return get_template_directory_uri() . self::$dist . '/' . $this->dir . '/' . $file;
|
return get_template_directory_uri() . self::$dist . '/' . $this->dir . '/' . $file;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user