diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..5c6d710
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,48 @@
+version: 2.1
+
+orbs:
+ default:
+ executors:
+ node-10:
+ docker:
+ - image: 'circleci/node:10-stretch'
+ php-73:
+ docker:
+ - image: 'circleci/php:7.3-stretch'
+ jobs:
+ build-php:
+ executor: php-73
+ steps:
+ - run: php -v
+ - checkout
+ - restore_cache:
+ keys:
+ - composer-v1-{{ checksum "composer.lock" }}
+ - composer-v1-
+ - run: composer install -n --prefer-dist --no-scripts --no-suggest
+ - run: composer lint
+ - save_cache:
+ key: composer-v1-{{ checksum "composer.lock" }}
+ paths:
+ - vendor
+ build-node:
+ executor: node-10
+ steps:
+ - run: yarn versions
+ - checkout
+ - restore_cache:
+ keys:
+ - node-v1-{{ checksum "yarn.lock" }}
+ - node-v1-
+ - run: yarn install --frozen-lockfile
+ - run: yarn run docs:build
+ - save_cache:
+ key: node-v1-{{ checksum "yarn.lock" }}
+ paths:
+ - node_modules
+
+workflows:
+ build:
+ jobs:
+ - default/build-node
+ - default/build-php
diff --git a/composer.json b/composer.json
index 88f75a5..4fc6109 100644
--- a/composer.json
+++ b/composer.json
@@ -27,6 +27,14 @@
]
},
"require": {
- "php": ">=7.1"
+ "php": ">=7.1.3"
+ },
+ "scripts": {
+ "lint": [
+ "phpcs --ignore=vendor,tests --extensions=php --standard=PSR12 ."
+ ]
+ },
+ "require-dev": {
+ "squizlabs/php_codesniffer": "^3.4"
}
}
diff --git a/composer.lock b/composer.lock
index cd35006..04cafe7 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,16 +4,68 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "ae05741702892f571ada339e3e14f69f",
+ "content-hash": "c9cec73fd4cddad2d2ed3f15db4953ce",
"packages": [],
- "packages-dev": [],
+ "packages-dev": [
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "3.4.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
+ "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8",
+ "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8",
+ "shasum": ""
+ },
+ "require": {
+ "ext-simplexml": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
+ },
+ "bin": [
+ "bin/phpcs",
+ "bin/phpcbf"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "lead"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
+ "keywords": [
+ "phpcs",
+ "standards"
+ ],
+ "time": "2019-04-10T23:49:02+00:00"
+ }
+ ],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": ">=7.0"
+ "php": ">=7.1.3"
},
"platform-dev": []
}
diff --git a/src/Directives.php b/src/Directives.php
index e4a3a4c..6f7ddc7 100644
--- a/src/Directives.php
+++ b/src/Directives.php
@@ -2,13 +2,6 @@
namespace Log1x\SageDirectives;
-/**
- * Return if Directives already exists.
- */
-if (class_exists('Directives')) {
- return;
-}
-
/**
* Directives
*/
@@ -50,7 +43,7 @@ public function __construct()
*/
protected function get($name)
{
- if (file_exists($directives = __DIR__.'/Directives/'.$name.'.php')) {
+ if (file_exists($directives = __DIR__ . '/Directives/' . $name . '.php')) {
return require_once($directives);
}
}
@@ -89,6 +82,8 @@ protected function blade()
}
}
+// phpcs:disable
if (function_exists('add_action')) {
new Directives();
}
+// phpcs:enable
diff --git a/src/Directives/ACF.php b/src/Directives/ACF.php
index ea4d0e1..4fd860d 100644
--- a/src/Directives/ACF.php
+++ b/src/Directives/ACF.php
@@ -23,11 +23,11 @@
if (str_contains($expression, ',')) {
$expression = Util::parse($expression);
- return "get(0)}, {$expression->get(1)})) : ?>".
+ return "get(0)}, {$expression->get(1)})) : ?>" .
"get(0)}, {$expression->get(1)})) : the_row(); ?>";
}
- return "".
+ return "" .
"";
},
@@ -82,15 +82,15 @@
$expression = Util::parse($expression);
if (! empty($expression->get(3)) && ! is_string($expression->get(2))) {
- return "get(0)}, {$expression->get(3)})[{$expression->get(1)}] === {$expression->get(2)}) : ?>";
+ return "get(0)}, {$expression->get(3)})[{$expression->get(1)}] === {$expression->get(2)}) : ?>"; // phpcs:ignore
}
if (! empty($expression->get(2)) && ! is_string($expression->get(2))) {
- return "get(0)}, {$expression->get(2)}) === {$expression->get(1)}) : ?>";
+ return "get(0)}, {$expression->get(2)}) === {$expression->get(1)}) : ?>"; // phpcs:ignore
}
if (! empty($expression->get(2)) && is_string($expression->get(2))) {
- return "get(0)})[{$expression->get(2)}] === {$expression->get(1)}) : ?>";
+ return "get(0)})[{$expression->get(2)}] === {$expression->get(1)}) : ?>"; // phpcs:ignore
}
return "get(0)}) === {$expression->get(1)}) : ?>";
@@ -126,7 +126,7 @@
$expression = Util::parse($expression);
if (! empty($expression->get(2))) {
- return "get(0)})[{$expression->get(1)}][{$expression->get(2)}]) : ?>";
+ return "get(0)})[{$expression->get(1)}][{$expression->get(2)}]) : ?>"; // phpcs:ignore
}
return "get(0)})[{$expression->get(1)}]) : ?>";
@@ -140,7 +140,7 @@
$expression = Util::parse($expression);
if (! empty($expression->get(2))) {
- return "get(0)})[{$expression->get(1)}] === {$expression->get(2)}) : ?>";
+ return "get(0)})[{$expression->get(1)}] === {$expression->get(2)}) : ?>"; // phpcs:ignore
}
return "get(0)}) === {$expression->get(1)}) : ?>";
@@ -161,11 +161,11 @@
if (str_contains($expression, ',')) {
$expression = Util::parse($expression);
- return "get(0)}, {$expression->get(1)})) : ?>".
+ return "get(0)}, {$expression->get(1)})) : ?>" .
"get(0)}, {$expression->get(1)})) : the_row(); ?>";
}
- return "".
+ return "" .
"";
},
@@ -197,11 +197,11 @@
if (str_contains($expression, ',')) {
$expression = Util::parse($expression);
- return "get(0)}, {$expression->get(1)})) : ?>".
+ return "get(0)}, {$expression->get(1)})) : ?>" .
"get(0)}, {$expression->get(1)})) : the_row(); ?>";
}
- return "".
+ return "" .
"";
},
@@ -216,7 +216,7 @@
*/
'options' => function ($expression) {
- return "".
+ return "" .
"";
},
@@ -255,7 +255,7 @@
$expression = Util::parse($expression);
if (! empty($expression->get(2))) {
- return "get(0)}, 'option')[{$expression->get(1)}] === {$expression->get(2)}) : ?>";
+ return "get(0)}, 'option')[{$expression->get(1)}] === {$expression->get(2)}) : ?>"; // phpcs:ignore
}
return "get(0)}, 'option') === {$expression->get(1)}) : ?>";
diff --git a/src/Directives/Helpers.php b/src/Directives/Helpers.php
index 38fd351..a4fc8ab 100644
--- a/src/Directives/Helpers.php
+++ b/src/Directives/Helpers.php
@@ -23,8 +23,8 @@
if (str_contains($expression, ',')) {
$expression = Util::parse($expression);
- return "get(0)}) && (bool) {$expression->get(0)} === true) : ?>".
- "get(1)}; ?>".
+ return "get(0)}) && (bool) {$expression->get(0)} === true) : ?>" .
+ "get(1)}; ?>" .
"";
}
@@ -39,8 +39,8 @@
if (str_contains($expression, ',')) {
$expression = Util::parse($expression);
- return "get(0)}) && (bool) {$expression->get(0)} === false) : ?>".
- "get(1)}; ?>".
+ return "get(0)}) && (bool) {$expression->get(0)} === false) : ?>" .
+ "get(1)}; ?>" .
"";
}
@@ -178,7 +178,7 @@
*/
'repeat' => function ($expression) {
- return "".
+ return "" .
" \$iteration,
'iteration' => \$iteration + 1,
@@ -201,7 +201,7 @@
'style' => function ($expression) {
if (! empty($expression)) {
- return '';
+ return '';
}
return '';
+ return "';
}
if (ends_with($expression, ".js'")) {
- return "';
+ return "';
}
},
@@ -276,31 +276,31 @@
'fa' => function ($expression) {
$expression = Util::parse($expression);
- return '';
+ return ''; // phpcs:ignore
},
'fas' => function ($expression) {
$expression = Util::parse($expression);
- return '';
+ return ''; // phpcs:ignore
},
'far' => function ($expression) {
$expression = Util::parse($expression);
- return '';
+ return ''; // phpcs:ignore
},
'fal' => function ($expression) {
$expression = Util::parse($expression);
- return '';
+ return ''; // phpcs:ignore
},
'fab' => function ($expression) {
$expression = Util::parse($expression);
- return '';
+ return ''; // phpcs:ignore
},
];
diff --git a/src/Directives/WordPress.php b/src/Directives/WordPress.php
index e2a95a7..6f3e944 100644
--- a/src/Directives/WordPress.php
+++ b/src/Directives/WordPress.php
@@ -20,19 +20,19 @@
*/
'query' => function ($expression) {
- return "".
+ return "" .
"";
},
'posts' => function ($expression) {
if (! empty($expression)) {
- return "".
+ return "" .
- "".
- "put('p', is_a({$expression}, 'WP_Post') ? ({$expression})->ID : {$expression}); ?>".
- "".
+ "" .
+ "put('p', is_a({$expression}, 'WP_Post') ? ({$expression})->ID : {$expression}); ?>" .
+ "" .
- "".
+ "" .
"put('ignore_sticky_posts', true)
->put('posts_per_page', -1)
@@ -41,19 +41,19 @@
return is_a(\$post, 'WP_Post') ? \$post->ID : \$post;
})->all())
->put('orderby', 'post__in');
- ?>".
- "".
+ ?>" .
+ "" .
"isNotEmpty() ? new WP_Query(\$posts->all()) : {$expression}; ?>" .
"have_posts()) : while (\$query->have_posts()) : \$query->the_post(); ?>";
}
- return "".
- "".
- "".
- "".
+ return "" .
+ "" .
+ "" .
+ "" .
- "have_posts()) : ?>".
+ "have_posts()) : ?>" .
"have_posts()) : \$query->the_post(); ?>";
},
@@ -93,10 +93,10 @@
if (! empty($expression->get(2))) {
if ($expression->get(2) === 'false') {
- return "= get_the_post_thumbnail_url({$expression->get(0)}, is_numeric({$expression->get(1)}) ? [{$expression->get(1)}, {$expression->get(1)}] : {$expression->get(1)}); ?>";
+ return "= get_the_post_thumbnail_url({$expression->get(0)}, is_numeric({$expression->get(1)}) ? [{$expression->get(1)}, {$expression->get(1)}] : {$expression->get(1)}); ?>"; // phpcs:ignore
}
- return "= get_the_post_thumbnail({$expression->get(0)}, is_numeric({$expression->get(1)}) ? [{$expression->get(1)}, {$expression->get(1)}] : {$expression->get(1)}); ?>";
+ return "= get_the_post_thumbnail({$expression->get(0)}, is_numeric({$expression->get(1)}) ? [{$expression->get(1)}, {$expression->get(1)}] : {$expression->get(1)}); ?>"; // phpcs:ignore
}
if (! empty($expression->get(1))) {
@@ -104,7 +104,7 @@
return "= get_the_post_thumbnail_url({$expression->get(0)}, 'thumbnail'); ?>";
}
- return "= get_the_post_thumbnail({$expression->get(0)}, is_numeric({$expression->get(1)}) ? [{$expression->get(1)}, {$expression->get(1)}] : {$expression->get(1)}); ?>";
+ return "= get_the_post_thumbnail({$expression->get(0)}, is_numeric({$expression->get(1)}) ? [{$expression->get(1)}, {$expression->get(1)}] : {$expression->get(1)}); ?>"; // phpcs:ignore
}
if (! empty($expression->get(0))) {
@@ -147,10 +147,10 @@
'published' => function ($expression) {
if (! empty($expression)) {
- return "".
- "= get_the_date('', {$expression}); ?>".
- "".
- "= get_the_date({$expression}); ?>".
+ return "" .
+ "= get_the_date('', {$expression}); ?>" .
+ "" .
+ "= get_the_date({$expression}); ?>" .
"";
}
@@ -159,10 +159,10 @@
'modified' => function ($expression) {
if (! empty($expression)) {
- return "".
- "= get_the_modified_date('', {$expression}); ?>".
- "".
- "= get_the_modified_date({$expression}); ?>".
+ return "" .
+ "= get_the_modified_date('', {$expression}); ?>" .
+ "" .
+ "= get_the_modified_date({$expression}); ?>" .
"";
}
@@ -179,29 +179,29 @@
$expression = Util::parse($expression);
if ($expression->get(1) === 'true') {
- return "get(0)}))->isNotEmpty()) : ?>".
- "get(0)}))->shift()->cat_ID); ?>\">".
- "= collect(get_the_category({$expression->get(0)}))->shift()->name; ?>".
- "".
+ return "get(0)}))->isNotEmpty()) : ?>" .
+ "get(0)}))->shift()->cat_ID); ?>\">" . // phpcs:ignore
+ "= collect(get_the_category({$expression->get(0)}))->shift()->name; ?>" .
+ "" .
"";
}
if (! empty($expression->get(0))) {
if ($expression->get(0) === 'true') {
- return "isNotEmpty()) : ?>".
- "shift()->cat_ID); ?>\">".
- "= collect(get_the_category())->shift()->name; ?>".
- "".
+ return "isNotEmpty()) : ?>" .
+ "shift()->cat_ID); ?>\">" .
+ "= collect(get_the_category())->shift()->name; ?>" .
+ "" .
"";
}
- return "get(0)}))->isNotEmpty()) : ?>".
- "= collect(get_the_category({$expression->get(0)}))->shift()->name; ?>".
+ return "get(0)}))->isNotEmpty()) : ?>" .
+ "= collect(get_the_category({$expression->get(0)}))->shift()->name; ?>" .
"";
}
- return "isNotEmpty()) : ?>".
- "= collect(get_the_category())->shift()->name; ?>".
+ return "isNotEmpty()) : ?>" .
+ "= collect(get_the_category())->shift()->name; ?>" .
"";
},
@@ -228,30 +228,30 @@
$expression = Util::parse($expression);
if (! empty($expression->get(2))) {
- return "get(1)}, {$expression->get(0)}))->isNotEmpty()) : ?>".
- "get(1)}, {$expression->get(0)}))->shift()->term_ID); ?>\">".
- "= collect(get_the_terms({$expression->get(1)}, {$expression->get(0)}))->shift()->name(); ?>".
- "".
+ return "get(1)}, {$expression->get(0)}))->isNotEmpty()) : ?>" . // phpcs:ignore
+ "get(1)}, {$expression->get(0)}))->shift()->term_ID); ?>\">" . // phpcs:ignore
+ "= collect(get_the_terms({$expression->get(1)}, {$expression->get(0)}))->shift()->name(); ?>" .
+ "" .
"";
}
if (! empty($expression->get(1))) {
if ($expression->get(1) === 'true') {
- return "get(0)}))->isNotEmpty()) : ?>".
- "get(0)}))->shift()->term_ID); ?>\">".
- "= collect(get_the_terms(get_the_ID(), {$expression->get(0)}))->shift()->name(); ?>".
- "".
+ return "get(0)}))->isNotEmpty()) : ?>" .
+ "get(0)}))->shift()->term_ID); ?>\">" . // phpcs:ignore
+ "= collect(get_the_terms(get_the_ID(), {$expression->get(0)}))->shift()->name(); ?>" .
+ "" .
"";
}
- return "get(1)}, {$expression->get(0)}))->isNotEmpty()) : ?>".
- "= collect(get_the_terms({$expression->get(1)}, {$expression->get(0)}))->shift()->name(); ?>".
+ return "get(1)}, {$expression->get(0)}))->isNotEmpty()) : ?>" . // phpcs:ignore
+ "= collect(get_the_terms({$expression->get(1)}, {$expression->get(0)}))->shift()->name(); ?>" .
"";
}
if (! empty($expression->get(0))) {
- return "get(0)}))->isNotEmpty()) : ?>".
- "= collect(get_the_terms(get_the_ID(), {$expression->get(0)}))->shift()->name; ?>".
+ return "get(0)}))->isNotEmpty()) : ?>" .
+ "= collect(get_the_terms(get_the_ID(), {$expression->get(0)}))->shift()->name; ?>" .
"";
}
},
@@ -285,7 +285,7 @@
'role' => function ($expression) {
$expression = Util::parse($expression);
- return "get(0)}), (array) wp_get_current_user()->roles)) : ?>";
+ return "get(0)}), (array) wp_get_current_user()->roles)) : ?>"; // phpcs:ignore
},
'endrole' => function () {
diff --git a/src/Utilities.php b/src/Utilities.php
index ac60e41..92639a6 100644
--- a/src/Utilities.php
+++ b/src/Utilities.php
@@ -13,7 +13,7 @@ class Util
public static function parse($expression)
{
return collect(explode(',', $expression))
- ->map(function($item) {
+ ->map(function ($item) {
return trim($item);
});
}