diff --git a/composer.json b/composer.json index 2df01fb..e22b83a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "webwizo/laravel-shortcodes", "type": "library", - "description": "Wordpress like shortcodes for Laravel 5, 6, 7, and 8", + "description": "Wordpress like shortcodes for Laravel 5, 6, 7, 8, and 9", "keywords": [ "laravel", "wordpress", @@ -18,16 +18,16 @@ } ], "require": { - "illuminate/view": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0", - "illuminate/support": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0", - "illuminate/contracts": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0", + "illuminate/view": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/support": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/contracts": "5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0|^9.0|^10.0", "php": "^7.2|^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.5|^8.0", - "orchestra/testbench": "~3.8.0", + "phpunit/phpunit": "^8.0|^9.0", + "orchestra/testbench": "~3.9.0|^4.0|^5.0|^6.0|^7.0|^8.0", "scrutinizer/ocular": "^1.5", - "squizlabs/php_codesniffer": "~2.3" + "squizlabs/php_codesniffer": "~2.3|^3.7" }, "autoload": { "classmap": [ @@ -55,4 +55,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/Compilers/Shortcode.php b/src/Compilers/Shortcode.php index 6bd11c7..a18d121 100644 --- a/src/Compilers/Shortcode.php +++ b/src/Compilers/Shortcode.php @@ -29,14 +29,14 @@ class Shortcode implements Arrayable * Constructor * * @param string $name - * @param array $attributes * @param string $content + * @param array $attributes */ - public function __construct($name, $attributes = [], $content) + public function __construct($name, $content, $attributes = []) { $this->name = $name; - $this->attributes = $attributes; $this->content = $content; + $this->attributes = $attributes; } /** diff --git a/src/Compilers/ShortcodeCompiler.php b/src/Compilers/ShortcodeCompiler.php index 9d30fd9..ea49eec 100644 --- a/src/Compilers/ShortcodeCompiler.php +++ b/src/Compilers/ShortcodeCompiler.php @@ -37,7 +37,7 @@ class ShortcodeCompiler * @var array */ protected $data = []; - + protected $_viewData; /** @@ -141,11 +141,11 @@ protected function renderShortcodes($value) return preg_replace_callback("/{$pattern}/s", [$this, 'render'], $value); } - + // get view data public function viewData( $viewData ) { - $this->_viewData = $viewData; + $this->_viewData = array_merge($this->_viewData ?? [], $viewData); return $this; } @@ -190,8 +190,8 @@ protected function compileShortcode($matches) // return shortcode instance return new Shortcode( $this->getName(), - $attributes, - $this->getContent() + $this->getContent(), + $attributes ); } @@ -373,7 +373,7 @@ protected function stripTag($m) return $m[1] . $m[6]; } - + /** * Get registered shortcodes *