diff --git a/.gitignore b/.gitignore index 1fc34d88..5da1eec9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ # Composer composer.phar -composer.lock \ No newline at end of file +composer.lock +vendor/composer +vendor/autoload.php \ No newline at end of file diff --git a/composer.json b/composer.json index a0c25da5..ca50a56f 100644 --- a/composer.json +++ b/composer.json @@ -4,13 +4,22 @@ "homepage": "http://wordpress.org/plugins/posts-to-posts", "license": "GPL-2.0+", "minimum-stability": "dev", + "scripts": { + "zip": "git archive --format zip --output \"../../posts-to-posts.zip\" master" + }, "require": { - "composer/installers": "~1.0" + "composer/installers": "~1.0", + "scribu/lib-posts-to-posts": "dev-master", + "mustache/mustache": "~2.6" }, "repositories": [ { "type": "vcs", - "url": "https://github.com/scribu/wp-lib-posts-to-posts" + "url": "https://github.com/jeffreyvr/wp-lib-posts-to-posts" + }, + { + "type": "vcs", + "url": "https://github.com/jeffreyvr/wp-scb-framework" } ] -} +} \ No newline at end of file diff --git a/posts-to-posts.php b/posts-to-posts.php index 5030d6fc..2b0915d9 100644 --- a/posts-to-posts.php +++ b/posts-to-posts.php @@ -2,7 +2,7 @@ /* Plugin Name: Posts 2 Posts Description: Create many-to-many relationships between all types of posts. -Version: 1.6.6 +Version: 1.6.7 Author: scribu Author URI: http://scribu.net/ Plugin URI: http://scribu.net/wordpress/posts-to-posts @@ -10,7 +10,7 @@ Domain Path: /lang */ -define( 'P2P_PLUGIN_VERSION', '1.6.6' ); +define( 'P2P_PLUGIN_VERSION', '1.6.7' ); define( 'P2P_TEXTDOMAIN', 'posts-to-posts' ); diff --git a/readme.txt b/readme.txt index 6df3bc05..22fc9a8d 100644 --- a/readme.txt +++ b/readme.txt @@ -1,14 +1,14 @@ === Posts 2 Posts === Contributors: scribu, ciobi, ayecode, stiofansisland -Tags: connections, custom post types, relationships, many-to-many, users -Requires at least: 3.9 +Tags: connections, custom post types, relationships, many-to-many, users +Requires at least: 3.9 Requires PHP: 5.6 Tested up to: 5.4 -Stable tag: 1.6.6 +Stable tag: 1.6.7 -License: GPLv2 or later -License URI: http://www.gnu.org/licenses/gpl-2.0.html +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html Efficient many-to-many connections between posts, pages, custom post types, users. @@ -42,7 +42,7 @@ Links: [**Documentation**](https://github.com/scribu/wp-posts-to-posts/wiki) | [P See [Installing Plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins). After activating it, refer to the [Basic usage](https://github.com/scribu/wp-posts-to-posts/wiki/Basic-usage) tutorial. - + Additional info can be found on the [wiki](https://github.com/scribu/wp-posts-to-posts/wiki). == Frequently Asked Questions == @@ -61,6 +61,9 @@ Additional info can be found on the [wiki](https://github.com/scribu/wp-posts-to- == Changelog == += 1.6.7 = +* Update Mustache package to support PHP 8. + = 1.6.6 = * AyeCode Ltd have committed to security and maintenance updates - INFO * Deprecated PHP notices showing with latest WordPress - FIXED diff --git a/vendor/mustache/mustache/.gitattributes b/vendor/mustache/mustache/.gitattributes new file mode 100644 index 00000000..95b7ab4c --- /dev/null +++ b/vendor/mustache/mustache/.gitattributes @@ -0,0 +1,8 @@ +/test export-ignore +/CONTRIBUTING.md export-ignore +/.php_cs export-ignore +/phpunit.xml.dist export-ignore +/.travis.yml export-ignore +/.styleci.yml export-ignore +/.gitmodules export-ignore +/.gitignore export-ignore diff --git a/vendor/mustache/mustache/.php_cs b/vendor/mustache/mustache/.php_cs deleted file mode 100644 index d924712b..00000000 --- a/vendor/mustache/mustache/.php_cs +++ /dev/null @@ -1,26 +0,0 @@ -level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) - ->fixers(array( - '-concat_without_spaces', - '-pre_increment', - '-unalign_double_arrow', - '-unalign_equals', - 'align_double_arrow', - 'concat_with_spaces', - 'ordered_use', - 'strict', - )) - ->setUsingLinter(false); - -$finder = $config->getFinder() - ->in('bin') - ->in('src') - ->in('test'); - -return $config; diff --git a/vendor/mustache/mustache/.styleci.yml b/vendor/mustache/mustache/.styleci.yml deleted file mode 100644 index 1aebcc37..00000000 --- a/vendor/mustache/mustache/.styleci.yml +++ /dev/null @@ -1,13 +0,0 @@ -preset: symfony - -enabled: - - align_double_arrow - - concat_with_spaces - - ordered_use - - strict - -disabled: - - concat_without_spaces - - pre_increment - - unalign_double_arrow - - unalign_equals diff --git a/vendor/mustache/mustache/.travis.yml b/vendor/mustache/mustache/.travis.yml deleted file mode 100644 index 7d3b7e5e..00000000 --- a/vendor/mustache/mustache/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: php - -install: - - curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer.phar - -script: - - phpunit - - if [[ `php -r "echo version_compare(PHP_VERSION, '5.3.6', '>=') && !defined('HHVM_VERSION');"` ]]; then php php-cs-fixer.phar --diff --dry-run -vv fix; fi - -php: - - 5.2 - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm - -sudo: false diff --git a/vendor/mustache/mustache/CONTRIBUTING.md b/vendor/mustache/mustache/CONTRIBUTING.md deleted file mode 100644 index c0b323de..00000000 --- a/vendor/mustache/mustache/CONTRIBUTING.md +++ /dev/null @@ -1,35 +0,0 @@ -# Contributions welcome! - - -### Here's a quick guide: - - 1. [Fork the repo on GitHub](https://github.com/bobthecow/mustache.php). - - 2. Update submodules: `git submodule update --init` - - 3. Run the test suite. We only take pull requests with passing tests, and it's great to know that you have a clean slate. Make sure you have PHPUnit 3.5+, then run `phpunit` from the project directory. - - 4. Add tests for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, add a test! - - 5. Make the tests pass. - - 6. Push your fork to GitHub and submit a pull request against the `dev` branch. - - -### You can do some things to increase the chance that your pull request is accepted the first time: - - * Submit one pull request per fix or feature. - * To help with that, do all your work in a feature branch (e.g. `feature/my-alsome-feature`). - * Follow the conventions you see used in the project. - * Use `phpcs --standard=PSR2` to check your changes against the coding standard. - * Write tests that fail without your code, and pass with it. - * Don't bump version numbers. Those will be updated — per [semver](http://semver.org) — once your change is merged into `master`. - * Update any documentation: docblocks, README, examples, etc. - * ... Don't update the wiki until your change is merged and released, but make a note in your pull request so we don't forget. - - -### Mustache.php follows the PSR-* coding standards: - - * [PSR-0: Class and file naming conventions](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) - * [PSR-1: Basic coding standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) - * [PSR-2: Coding style guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) diff --git a/vendor/mustache/mustache/README.md b/vendor/mustache/mustache/README.md index 6a309aee..1560192c 100644 --- a/vendor/mustache/mustache/README.md +++ b/vendor/mustache/mustache/README.md @@ -1,10 +1,11 @@ Mustache.php ============ -A [Mustache](http://mustache.github.com/) implementation in PHP. +A [Mustache](https://mustache.github.io/) implementation in PHP. [![Package version](http://img.shields.io/packagist/v/mustache/mustache.svg?style=flat-square)](https://packagist.org/packages/mustache/mustache) [![Build status](http://img.shields.io/travis/bobthecow/mustache.php/dev.svg?style=flat-square)](http://travis-ci.org/bobthecow/mustache.php) +[![StyleCI](https://styleci.io/repos/569670/shield)](https://styleci.io/repos/569670) [![Monthly downloads](http://img.shields.io/packagist/dm/mustache/mustache.svg?style=flat-square)](https://packagist.org/packages/mustache/mustache) @@ -15,7 +16,7 @@ A quick example: ```php ENT_QUOTES)); echo $m->render('Hello {{planet}}', array('planet' => 'World!')); // "Hello World!" ``` @@ -52,11 +53,12 @@ And render it: ```php ENT_QUOTES)); $chris = new Chris; echo $m->render($template, $chris); ``` +*Note:* we recommend using `ENT_QUOTES` as a default of [entity_flags](https://github.com/bobthecow/mustache.php/wiki#entity_flags) to decrease the chance of Cross-site scripting vulnerability. And That's Not All! ------------------- @@ -67,5 +69,5 @@ Read [the Mustache.php documentation](https://github.com/bobthecow/mustache.php/ See Also -------- + * [mustache(5)](http://mustache.github.io/mustache.5.html) man page. * [Readme for the Ruby Mustache implementation](https://github.com/defunkt/mustache/blob/master/README.md). - * [mustache(5)](http://mustache.github.com/mustache.5.html) man page. diff --git a/vendor/mustache/mustache/bin/build_bootstrap.php b/vendor/mustache/mustache/bin/build_bootstrap.php new file mode 100755 index 00000000..cc23b2bd --- /dev/null +++ b/vendor/mustache/mustache/bin/build_bootstrap.php @@ -0,0 +1,178 @@ +#!/usr/bin/env php + + */ +class SymfonyClassCollectionLoader +{ + private static $loaded; + + const HEADER = <<<'EOS' +\s*$/'), '', file_get_contents($r->getFileName())); + } + + $cache = $cacheDir . '/' . $name . $extension; + $header = sprintf(self::HEADER, strftime('%Y')); + self::writeCacheFile($cache, $header . substr(self::stripComments('=5.2.4" }, "require-dev": { - "phpunit/phpunit": "~3.7|~4.0", - "fabpot/php-cs-fixer": "~1.6" + "phpunit/phpunit": "~3.7|~4.0|~5.0", + "friendsofphp/php-cs-fixer": "~1.11" }, "autoload": { "psr-0": { "Mustache": "src/" } diff --git a/vendor/mustache/mustache/phpunit.xml.dist b/vendor/mustache/mustache/phpunit.xml.dist deleted file mode 100644 index 3c620b6f..00000000 --- a/vendor/mustache/mustache/phpunit.xml.dist +++ /dev/null @@ -1,17 +0,0 @@ - - - - ./test - ./test/Mustache/Test/FiveThree - - - - ./test/Mustache/Test/FiveThree - - - - - ./src/Mustache - - - \ No newline at end of file diff --git a/vendor/mustache/mustache/src/Mustache/Autoloader.php b/vendor/mustache/mustache/src/Mustache/Autoloader.php index b33bc24f..e8ea3f4a 100644 --- a/vendor/mustache/mustache/src/Mustache/Autoloader.php +++ b/vendor/mustache/mustache/src/Mustache/Autoloader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,6 +16,14 @@ class Mustache_Autoloader { private $baseDir; + /** + * An array where the key is the baseDir and the key is an instance of this + * class. + * + * @var array + */ + private static $instances; + /** * Autoloader constructor. * @@ -45,7 +53,13 @@ public function __construct($baseDir = null) */ public static function register($baseDir = null) { - $loader = new self($baseDir); + $key = $baseDir ? $baseDir : 0; + + if (!isset(self::$instances[$key])) { + self::$instances[$key] = new self($baseDir); + } + + $loader = self::$instances[$key]; spl_autoload_register(array($loader, 'autoload')); return $loader; diff --git a/vendor/mustache/mustache/src/Mustache/Cache.php b/vendor/mustache/mustache/src/Mustache/Cache.php index 5df8a23d..3292efac 100644 --- a/vendor/mustache/mustache/src/Mustache/Cache.php +++ b/vendor/mustache/mustache/src/Mustache/Cache.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -33,4 +33,11 @@ public function load($key); * @param string $value */ public function cache($key, $value); + + /** + * Set a logger instance. + * + * @param Mustache_Logger|Psr\Log\LoggerInterface $logger + */ + public function setLogger($logger = null); } diff --git a/vendor/mustache/mustache/src/Mustache/Cache/AbstractCache.php b/vendor/mustache/mustache/src/Mustache/Cache/AbstractCache.php index cf1c0416..281038fa 100644 --- a/vendor/mustache/mustache/src/Mustache/Cache/AbstractCache.php +++ b/vendor/mustache/mustache/src/Mustache/Cache/AbstractCache.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -47,7 +47,7 @@ public function setLogger($logger = null) /** * Add a log record if logging is enabled. * - * @param int $level The logging level + * @param string $level The logging level * @param string $message The log message * @param array $context The log context */ diff --git a/vendor/mustache/mustache/src/Mustache/Cache/FilesystemCache.php b/vendor/mustache/mustache/src/Mustache/Cache/FilesystemCache.php index 5b56222b..3e742b70 100644 --- a/vendor/mustache/mustache/src/Mustache/Cache/FilesystemCache.php +++ b/vendor/mustache/mustache/src/Mustache/Cache/FilesystemCache.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -27,8 +27,8 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache /** * Filesystem cache constructor. * - * @param string $baseDir Directory for compiled templates. - * @param int $fileMode Override default permissions for cache files. Defaults to using the system-defined umask. + * @param string $baseDir Directory for compiled templates + * @param int $fileMode Override default permissions for cache files. Defaults to using the system-defined umask */ public function __construct($baseDir, $fileMode = null) { @@ -108,9 +108,11 @@ private function buildDirectoryForFilename($fileName) ); @mkdir($dirName, 0777, true); + // @codeCoverageIgnoreStart if (!is_dir($dirName)) { throw new Mustache_Exception_RuntimeException(sprintf('Failed to create cache directory "%s".', $dirName)); } + // @codeCoverageIgnoreEnd } return $dirName; @@ -143,13 +145,17 @@ private function writeFile($fileName, $value) return; } + // @codeCoverageIgnoreStart $this->log( Mustache_Logger::ERROR, 'Unable to rename Mustache temp cache file: "{tempName}" -> "{fileName}"', array('tempName' => $tempFile, 'fileName' => $fileName) ); + // @codeCoverageIgnoreEnd } + // @codeCoverageIgnoreStart throw new Mustache_Exception_RuntimeException(sprintf('Failed to write cache file "%s".', $fileName)); + // @codeCoverageIgnoreEnd } } diff --git a/vendor/mustache/mustache/src/Mustache/Cache/NoopCache.php b/vendor/mustache/mustache/src/Mustache/Cache/NoopCache.php index 7a4b55b5..ed9eec9d 100644 --- a/vendor/mustache/mustache/src/Mustache/Cache/NoopCache.php +++ b/vendor/mustache/mustache/src/Mustache/Cache/NoopCache.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Compiler.php b/vendor/mustache/mustache/src/Mustache/Compiler.php index 7d5c96b5..93a295ae 100644 --- a/vendor/mustache/mustache/src/Mustache/Compiler.php +++ b/vendor/mustache/mustache/src/Mustache/Compiler.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -75,7 +75,7 @@ public function setPragmas(array $pragmas) /** * Helper function for walking the Mustache token parse tree. * - * @throws Mustache_Exception_SyntaxException upon encountering unknown token types. + * @throws Mustache_Exception_SyntaxException upon encountering unknown token types * * @param array $tree Parse tree of Mustache tokens * @param int $level (default: 0) @@ -191,7 +191,6 @@ public function renderInternal(Mustache_Context $context, $indent = \'\') { $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context); $buffer = \'\'; - $newContext = array(); %s return $buffer; @@ -207,7 +206,6 @@ class %s extends Mustache_Template public function renderInternal(Mustache_Context $context, $indent = \'\') { $buffer = \'\'; - $newContext = array(); %s return $buffer; @@ -240,10 +238,11 @@ private function writeCode($tree, $name) $blockFunction = $context->findInBlock(%s); if (is_callable($blockFunction)) { $buffer .= call_user_func($blockFunction, $context); - } else {%s - } + %s} '; + const BLOCK_VAR_ELSE = '} else {%s'; + /** * Generate Mustache Template inheritance block variable PHP source. * @@ -261,10 +260,15 @@ private function blockVar($nodes, $id, $start, $end, $otag, $ctag, $level) { $id = var_export($id, true); - return sprintf($this->prepare(self::BLOCK_VAR, $level), $id, $this->walk($nodes, $level)); + $else = $this->walk($nodes, $level); + if ($else !== '') { + $else = sprintf($this->prepare(self::BLOCK_VAR_ELSE, $level + 1, false, true), $else); + } + + return sprintf($this->prepare(self::BLOCK_VAR, $level), $id, $else); } - const BLOCK_ARG = '$newContext[%s] = array($this, \'block%s\');'; + const BLOCK_ARG = '%s => array($this, \'block%s\'),'; /** * Generate Mustache Template inheritance block argument PHP source. @@ -282,10 +286,9 @@ private function blockVar($nodes, $id, $start, $end, $otag, $ctag, $level) private function blockArg($nodes, $id, $start, $end, $otag, $ctag, $level) { $key = $this->block($nodes); - $keystr = var_export($key, true); $id = var_export($id, true); - return sprintf($this->prepare(self::BLOCK_ARG, 1), $id, $key); + return sprintf($this->prepare(self::BLOCK_ARG, $level), $id, $key); } const BLOCK_FUNCTION = ' @@ -317,7 +320,6 @@ private function block($nodes) } const SECTION_CALL = ' - // %s section $value = $context->%s(%s);%s $buffer .= $this->section%s($context, $indent, $value); '; @@ -326,14 +328,15 @@ private function block($nodes) private function section%s(Mustache_Context $context, $indent, $value) { $buffer = \'\'; + if (%s) { $source = %s; - $result = call_user_func($value, $source, $this->lambdaHelper); + $result = (string) call_user_func($value, $source, %s); if (strpos($result, \'{{\') === false) { $buffer .= $result; } else { $buffer .= $this->mustache - ->loadLambda((string) $result%s) + ->loadLambda($result%s) ->renderInternal($context); } } elseif (!empty($value)) { @@ -360,40 +363,37 @@ private function section%s(Mustache_Context $context, $indent, $value) * @param string $otag Current Mustache opening tag * @param string $ctag Current Mustache closing tag * @param int $level - * @param bool $arg (default: false) * * @return string Generated section PHP source code */ - private function section($nodes, $id, $filters, $start, $end, $otag, $ctag, $level, $arg = false) + private function section($nodes, $id, $filters, $start, $end, $otag, $ctag, $level) { $source = var_export(substr($this->source, $start, $end - $start), true); $callable = $this->getCallable(); if ($otag !== '{{' || $ctag !== '}}') { - $delims = ', ' . var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true); + $delimTag = var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true); + $helper = sprintf('$this->lambdaHelper->withDelimiters(%s)', $delimTag); + $delims = ', ' . $delimTag; } else { + $helper = '$this->lambdaHelper'; $delims = ''; } $key = ucfirst(md5($delims . "\n" . $source)); if (!isset($this->sections[$key])) { - $this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $delims, $this->walk($nodes, 2)); + $this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $helper, $delims, $this->walk($nodes, 2)); } - if ($arg === true) { - return $key; - } else { - $method = $this->getFindMethod($id); - $id = var_export($id, true); - $filters = $this->getFilters($filters, $level); + $method = $this->getFindMethod($id); + $id = var_export($id, true); + $filters = $this->getFilters($filters, $level); - return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $method, $id, $filters, $key); - } + return sprintf($this->prepare(self::SECTION_CALL, $level), $method, $id, $filters, $key); } const INVERTED_SECTION = ' - // %s inverted section $value = $context->%s(%s);%s if (empty($value)) { %s @@ -416,7 +416,7 @@ private function invertedSection($nodes, $id, $filters, $level) $id = var_export($id, true); $filters = $this->getFilters($filters, $level); - return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $filters, $this->walk($nodes, $level)); + return sprintf($this->prepare(self::INVERTED_SECTION, $level), $method, $id, $filters, $this->walk($nodes, $level)); } const PARTIAL_INDENT = ', $indent . %s'; @@ -451,15 +451,20 @@ private function partial($id, $indent, $level) } const PARENT = ' - %s - - if ($parent = $this->mustache->LoadPartial(%s)) { - $context->pushBlockContext($newContext); + if ($parent = $this->mustache->loadPartial(%s)) { + $context->pushBlockContext(array(%s + )); $buffer .= $parent->renderInternal($context, $indent); $context->popBlockContext(); } '; + const PARENT_NO_CONTEXT = ' + if ($parent = $this->mustache->loadPartial(%s)) { + $buffer .= $parent->renderInternal($context, $indent); + } + '; + /** * Generate Mustache Template inheritance parent call PHP source. * @@ -474,11 +479,14 @@ private function parent($id, $indent, array $children, $level) { $realChildren = array_filter($children, array(__CLASS__, 'onlyBlockArgs')); + if (empty($realChildren)) { + return sprintf($this->prepare(self::PARENT_NO_CONTEXT, $level), var_export($id, true)); + } + return sprintf( $this->prepare(self::PARENT, $level), - $this->walk($realChildren, $level), var_export($id, true), - var_export($indent, true) + $this->walk($realChildren, $level + 1) ); } @@ -487,7 +495,7 @@ private function parent($id, $indent, array $children, $level) * * @param array $node * - * @return bool True if $node is a block arg token. + * @return bool True if $node is a block arg token */ private static function onlyBlockArgs(array $node) { @@ -495,8 +503,8 @@ private static function onlyBlockArgs(array $node) } const VARIABLE = ' - $value = $this->resolveValue($context->%s(%s), $context, $indent);%s - $buffer .= %s%s; + $value = $this->resolveValue($context->%s(%s), $context);%s + $buffer .= %s($value === null ? \'\' : %s); '; /** @@ -615,7 +623,7 @@ private function getEscape($value = '$value') /** * Select the appropriate Context `find` method for a given $id. * - * The return value will be one of `find`, `findDot` or `last`. + * The return value will be one of `find`, `findDot`, `findAnchoredDot` or `last`. * * @see Mustache_Context::find * @see Mustache_Context::findDot diff --git a/vendor/mustache/mustache/src/Mustache/Context.php b/vendor/mustache/mustache/src/Mustache/Context.php index e660b543..69c02e01 100644 --- a/vendor/mustache/mustache/src/Mustache/Context.php +++ b/vendor/mustache/mustache/src/Mustache/Context.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -150,7 +150,7 @@ public function findDot($id) * * @see Mustache_Context::findDot * - * @throws Mustache_Exception_InvalidArgumentException if given an invalid anchored dot $id. + * @throws Mustache_Exception_InvalidArgumentException if given an invalid anchored dot $id * * @param string $id Dotted variable selector * @@ -182,7 +182,7 @@ public function findAnchoredDot($id) * * @param string $id * - * @return mixed Variable value, or '' if not found. + * @return mixed Variable value, or '' if not found */ public function findInBlock($id) { diff --git a/vendor/mustache/mustache/src/Mustache/Engine.php b/vendor/mustache/mustache/src/Mustache/Engine.php index 08bcc810..5e96e411 100644 --- a/vendor/mustache/mustache/src/Mustache/Engine.php +++ b/vendor/mustache/mustache/src/Mustache/Engine.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -23,8 +23,8 @@ */ class Mustache_Engine { - const VERSION = '2.9.0'; - const SPEC_VERSION = '1.1.2'; + const VERSION = '2.14.0'; + const SPEC_VERSION = '1.2.2'; const PRAGMA_FILTERS = 'FILTERS'; const PRAGMA_BLOCKS = 'BLOCKS'; @@ -54,6 +54,7 @@ class Mustache_Engine private $logger; private $strictCallables = false; private $pragmas = array(); + private $delimiters; // Services private $tokenizer; @@ -81,6 +82,14 @@ class Mustache_Engine * // sections are often too dynamic to benefit from caching. * 'cache_lambda_templates' => true, * + * // Customize the tag delimiters used by this engine instance. Note that overriding here changes the + * // delimiters used to parse all templates and partials loaded by this instance. To override just for a + * // single template, use an inline "change delimiters" tag at the start of the template file: + * // + * // {{=<% %>=}} + * // + * 'delimiters' => '<% %>', + * * // A Mustache template loader instance. Uses a StringLoader if not specified. * 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'), * @@ -126,13 +135,17 @@ class Mustache_Engine * 'pragmas' => [Mustache_Engine::PRAGMA_FILTERS], * ); * - * @throws Mustache_Exception_InvalidArgumentException If `escape` option is not callable. + * @throws Mustache_Exception_InvalidArgumentException If `escape` option is not callable * * @param array $options (default: array()) */ public function __construct(array $options = array()) { if (isset($options['template_class_prefix'])) { + if ((string) $options['template_class_prefix'] === '') { + throw new Mustache_Exception_InvalidArgumentException('Mustache Constructor "template_class_prefix" must not be empty'); + } + $this->templateClassPrefix = $options['template_class_prefix']; } @@ -191,6 +204,10 @@ public function __construct(array $options = array()) $this->strictCallables = $options['strict_callables']; } + if (isset($options['delimiters'])) { + $this->delimiters = $options['delimiters']; + } + if (isset($options['pragmas'])) { foreach ($options['pragmas'] as $pragma) { if (!isset(self::$knownPragmas[$pragma])) { @@ -429,7 +446,7 @@ public function removeHelper($name) /** * Set the Mustache Logger instance. * - * @throws Mustache_Exception_InvalidArgumentException If logger is not an instance of Mustache_Logger or Psr\Log\LoggerInterface. + * @throws Mustache_Exception_InvalidArgumentException If logger is not an instance of Mustache_Logger or Psr\Log\LoggerInterface * * @param Mustache_Logger|Psr\Log\LoggerInterface $logger */ @@ -589,22 +606,43 @@ protected function getLambdaCache() /** * Helper method to generate a Mustache template class. * - * @param string $source + * This method must be updated any time options are added which make it so + * the same template could be parsed and compiled multiple different ways. + * + * @param string|Mustache_Source $source * * @return string Mustache Template class name */ public function getTemplateClassName($source) { - return $this->templateClassPrefix . md5(sprintf( - 'version:%s,escape:%s,entity_flags:%i,charset:%s,strict_callables:%s,pragmas:%s,source:%s', - self::VERSION, - isset($this->escape) ? 'custom' : 'default', - $this->entityFlags, - $this->charset, - $this->strictCallables ? 'true' : 'false', - implode(' ', $this->getPragmas()), - $source - )); + // For the most part, adding a new option here should do the trick. + // + // Pick a value here which is unique for each possible way the template + // could be compiled... but not necessarily unique per option value. See + // escape below, which only needs to differentiate between 'custom' and + // 'default' escapes. + // + // Keep this list in alphabetical order :) + $chunks = array( + 'charset' => $this->charset, + 'delimiters' => $this->delimiters ? $this->delimiters : '{{ }}', + 'entityFlags' => $this->entityFlags, + 'escape' => isset($this->escape) ? 'custom' : 'default', + 'key' => ($source instanceof Mustache_Source) ? $source->getKey() : 'source', + 'pragmas' => $this->getPragmas(), + 'strictCallables' => $this->strictCallables, + 'version' => self::VERSION, + ); + + $key = json_encode($chunks); + + // Template Source instances have already provided their own source key. For strings, just include the whole + // source string in the md5 hash. + if (!$source instanceof Mustache_Source) { + $key .= "\n" . $source; + } + + return $this->templateClassPrefix . md5($key); } /** @@ -681,8 +719,8 @@ public function loadLambda($source, $delims = null) * @see Mustache_Engine::loadPartial * @see Mustache_Engine::loadLambda * - * @param string $source - * @param Mustache_Cache $cache (default: null) + * @param string|Mustache_Source $source + * @param Mustache_Cache $cache (default: null) * * @return Mustache_Template */ @@ -725,7 +763,7 @@ private function loadSource($source, Mustache_Cache $cache = null) */ private function tokenize($source) { - return $this->getTokenizer()->scan($source); + return $this->getTokenizer()->scan($source, $this->delimiters); } /** @@ -750,13 +788,12 @@ private function parse($source) * * @see Mustache_Compiler::compile * - * @param string $source + * @param string|Mustache_Source $source * * @return string generated Mustache template class code */ private function compile($source) { - $tree = $this->parse($source); $name = $this->getTemplateClassName($source); $this->log( @@ -765,6 +802,11 @@ private function compile($source) array('className' => $name) ); + if ($source instanceof Mustache_Source) { + $source = $source->getSource(); + } + $tree = $this->parse($source); + $compiler = $this->getCompiler(); $compiler->setPragmas($this->getPragmas()); diff --git a/vendor/mustache/mustache/src/Mustache/Exception.php b/vendor/mustache/mustache/src/Mustache/Exception.php index 7c047926..d4001a9b 100644 --- a/vendor/mustache/mustache/src/Mustache/Exception.php +++ b/vendor/mustache/mustache/src/Mustache/Exception.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Exception/InvalidArgumentException.php b/vendor/mustache/mustache/src/Mustache/Exception/InvalidArgumentException.php index c6084b8e..becf2ed1 100644 --- a/vendor/mustache/mustache/src/Mustache/Exception/InvalidArgumentException.php +++ b/vendor/mustache/mustache/src/Mustache/Exception/InvalidArgumentException.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Exception/LogicException.php b/vendor/mustache/mustache/src/Mustache/Exception/LogicException.php index 4bfda5f4..b2424d67 100644 --- a/vendor/mustache/mustache/src/Mustache/Exception/LogicException.php +++ b/vendor/mustache/mustache/src/Mustache/Exception/LogicException.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Exception/RuntimeException.php b/vendor/mustache/mustache/src/Mustache/Exception/RuntimeException.php index 5eb90ddd..b6369f4b 100644 --- a/vendor/mustache/mustache/src/Mustache/Exception/RuntimeException.php +++ b/vendor/mustache/mustache/src/Mustache/Exception/RuntimeException.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Exception/SyntaxException.php b/vendor/mustache/mustache/src/Mustache/Exception/SyntaxException.php index ab4d6aa8..b1879a3d 100644 --- a/vendor/mustache/mustache/src/Mustache/Exception/SyntaxException.php +++ b/vendor/mustache/mustache/src/Mustache/Exception/SyntaxException.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,13 +17,18 @@ class Mustache_Exception_SyntaxException extends LogicException implements Musta protected $token; /** - * @param string $msg - * @param array $token + * @param string $msg + * @param array $token + * @param Exception $previous */ - public function __construct($msg, array $token) + public function __construct($msg, array $token, Exception $previous = null) { $this->token = $token; - parent::__construct($msg); + if (version_compare(PHP_VERSION, '5.3.0', '>=')) { + parent::__construct($msg, 0, $previous); + } else { + parent::__construct($msg); // @codeCoverageIgnore + } } /** diff --git a/vendor/mustache/mustache/src/Mustache/Exception/UnknownFilterException.php b/vendor/mustache/mustache/src/Mustache/Exception/UnknownFilterException.php index 43d2c06d..0651c173 100644 --- a/vendor/mustache/mustache/src/Mustache/Exception/UnknownFilterException.php +++ b/vendor/mustache/mustache/src/Mustache/Exception/UnknownFilterException.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,12 +17,18 @@ class Mustache_Exception_UnknownFilterException extends UnexpectedValueException protected $filterName; /** - * @param string $filterName + * @param string $filterName + * @param Exception $previous */ - public function __construct($filterName) + public function __construct($filterName, Exception $previous = null) { $this->filterName = $filterName; - parent::__construct(sprintf('Unknown filter: %s', $filterName)); + $message = sprintf('Unknown filter: %s', $filterName); + if (version_compare(PHP_VERSION, '5.3.0', '>=')) { + parent::__construct($message, 0, $previous); + } else { + parent::__construct($message); // @codeCoverageIgnore + } } public function getFilterName() diff --git a/vendor/mustache/mustache/src/Mustache/Exception/UnknownHelperException.php b/vendor/mustache/mustache/src/Mustache/Exception/UnknownHelperException.php index 7fe4a71e..193be782 100644 --- a/vendor/mustache/mustache/src/Mustache/Exception/UnknownHelperException.php +++ b/vendor/mustache/mustache/src/Mustache/Exception/UnknownHelperException.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,12 +17,18 @@ class Mustache_Exception_UnknownHelperException extends InvalidArgumentException protected $helperName; /** - * @param string $helperName + * @param string $helperName + * @param Exception $previous */ - public function __construct($helperName) + public function __construct($helperName, Exception $previous = null) { $this->helperName = $helperName; - parent::__construct(sprintf('Unknown helper: %s', $helperName)); + $message = sprintf('Unknown helper: %s', $helperName); + if (version_compare(PHP_VERSION, '5.3.0', '>=')) { + parent::__construct($message, 0, $previous); + } else { + parent::__construct($message); // @codeCoverageIgnore + } } public function getHelperName() diff --git a/vendor/mustache/mustache/src/Mustache/Exception/UnknownTemplateException.php b/vendor/mustache/mustache/src/Mustache/Exception/UnknownTemplateException.php index f1f69bf3..32a778a5 100644 --- a/vendor/mustache/mustache/src/Mustache/Exception/UnknownTemplateException.php +++ b/vendor/mustache/mustache/src/Mustache/Exception/UnknownTemplateException.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,12 +17,18 @@ class Mustache_Exception_UnknownTemplateException extends InvalidArgumentExcepti protected $templateName; /** - * @param string $templateName + * @param string $templateName + * @param Exception $previous */ - public function __construct($templateName) + public function __construct($templateName, Exception $previous = null) { $this->templateName = $templateName; - parent::__construct(sprintf('Unknown template: %s', $templateName)); + $message = sprintf('Unknown template: %s', $templateName); + if (version_compare(PHP_VERSION, '5.3.0', '>=')) { + parent::__construct($message, 0, $previous); + } else { + parent::__construct($message); // @codeCoverageIgnore + } } public function getTemplateName() diff --git a/vendor/mustache/mustache/src/Mustache/HelperCollection.php b/vendor/mustache/mustache/src/Mustache/HelperCollection.php index 0a92428e..5d8f73c1 100644 --- a/vendor/mustache/mustache/src/Mustache/HelperCollection.php +++ b/vendor/mustache/mustache/src/Mustache/HelperCollection.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -81,7 +81,7 @@ public function __get($name) /** * Get a helper by name. * - * @throws Mustache_Exception_UnknownHelperException If helper does not exist. + * @throws Mustache_Exception_UnknownHelperException If helper does not exist * * @param string $name * @@ -137,7 +137,7 @@ public function __unset($name) /** * Check whether a given helper is present in the collection. * - * @throws Mustache_Exception_UnknownHelperException if the requested helper is not present. + * @throws Mustache_Exception_UnknownHelperException if the requested helper is not present * * @param string $name */ diff --git a/vendor/mustache/mustache/src/Mustache/LambdaHelper.php b/vendor/mustache/mustache/src/Mustache/LambdaHelper.php index de48fd63..e93dbfa3 100644 --- a/vendor/mustache/mustache/src/Mustache/LambdaHelper.php +++ b/vendor/mustache/mustache/src/Mustache/LambdaHelper.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -20,17 +20,20 @@ class Mustache_LambdaHelper { private $mustache; private $context; + private $delims; /** * Mustache Lambda Helper constructor. * - * @param Mustache_Engine $mustache Mustache engine instance. - * @param Mustache_Context $context Rendering context. + * @param Mustache_Engine $mustache Mustache engine instance + * @param Mustache_Context $context Rendering context + * @param string $delims Optional custom delimiters, in the format `{{= <% %> =}}`. (default: null) */ - public function __construct(Mustache_Engine $mustache, Mustache_Context $context) + public function __construct(Mustache_Engine $mustache, Mustache_Context $context, $delims = null) { $this->mustache = $mustache; $this->context = $context; + $this->delims = $delims; } /** @@ -38,12 +41,36 @@ public function __construct(Mustache_Engine $mustache, Mustache_Context $context * * @param string $string * - * @return string Rendered template. + * @return string Rendered template */ public function render($string) { return $this->mustache - ->loadLambda((string) $string) + ->loadLambda((string) $string, $this->delims) ->renderInternal($this->context); } + + /** + * Render a string as a Mustache template with the current rendering context. + * + * @param string $string + * + * @return string Rendered template + */ + public function __invoke($string) + { + return $this->render($string); + } + + /** + * Get a Lambda Helper with custom delimiters. + * + * @param string $delims Custom delimiters, in the format `{{= <% %> =}}` + * + * @return Mustache_LambdaHelper + */ + public function withDelimiters($delims) + { + return new self($this->mustache, $this->context, $delims); + } } diff --git a/vendor/mustache/mustache/src/Mustache/Loader.php b/vendor/mustache/mustache/src/Mustache/Loader.php index 1b075d05..23adba1a 100644 --- a/vendor/mustache/mustache/src/Mustache/Loader.php +++ b/vendor/mustache/mustache/src/Mustache/Loader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,11 +17,11 @@ interface Mustache_Loader /** * Load a Template by name. * - * @throws Mustache_Exception_UnknownTemplateException If a template file is not found. + * @throws Mustache_Exception_UnknownTemplateException If a template file is not found * * @param string $name * - * @return string Mustache Template source + * @return string|Mustache_Source Mustache Template source */ public function load($name); } diff --git a/vendor/mustache/mustache/src/Mustache/Loader/ArrayLoader.php b/vendor/mustache/mustache/src/Mustache/Loader/ArrayLoader.php index 90cecca5..4276493a 100644 --- a/vendor/mustache/mustache/src/Mustache/Loader/ArrayLoader.php +++ b/vendor/mustache/mustache/src/Mustache/Loader/ArrayLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -41,7 +41,7 @@ public function __construct(array $templates = array()) /** * Load a Template. * - * @throws Mustache_Exception_UnknownTemplateException If a template file is not found. + * @throws Mustache_Exception_UnknownTemplateException If a template file is not found * * @param string $name * diff --git a/vendor/mustache/mustache/src/Mustache/Loader/CascadingLoader.php b/vendor/mustache/mustache/src/Mustache/Loader/CascadingLoader.php index 09a376cd..3fb6353c 100644 --- a/vendor/mustache/mustache/src/Mustache/Loader/CascadingLoader.php +++ b/vendor/mustache/mustache/src/Mustache/Loader/CascadingLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -48,7 +48,7 @@ public function addLoader(Mustache_Loader $loader) /** * Load a Template by name. * - * @throws Mustache_Exception_UnknownTemplateException If a template file is not found. + * @throws Mustache_Exception_UnknownTemplateException If a template file is not found * * @param string $name * diff --git a/vendor/mustache/mustache/src/Mustache/Loader/FilesystemLoader.php b/vendor/mustache/mustache/src/Mustache/Loader/FilesystemLoader.php index e2aab781..e366df70 100644 --- a/vendor/mustache/mustache/src/Mustache/Loader/FilesystemLoader.php +++ b/vendor/mustache/mustache/src/Mustache/Loader/FilesystemLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -40,9 +40,9 @@ class Mustache_Loader_FilesystemLoader implements Mustache_Loader * 'extension' => '.ms', * ); * - * @throws Mustache_Exception_RuntimeException if $baseDir does not exist. + * @throws Mustache_Exception_RuntimeException if $baseDir does not exist * - * @param string $baseDir Base directory containing Mustache template files. + * @param string $baseDir Base directory containing Mustache template files * @param array $options Array of Loader options (default: array()) */ public function __construct($baseDir, array $options = array()) @@ -53,7 +53,7 @@ public function __construct($baseDir, array $options = array()) $this->baseDir = realpath($this->baseDir); } - if (!is_dir($this->baseDir)) { + if ($this->shouldCheckPath() && !is_dir($this->baseDir)) { throw new Mustache_Exception_RuntimeException(sprintf('FilesystemLoader baseDir must be a directory: %s', $baseDir)); } @@ -88,7 +88,7 @@ public function load($name) /** * Helper function for loading a Mustache file by name. * - * @throws Mustache_Exception_UnknownTemplateException If a template file is not found. + * @throws Mustache_Exception_UnknownTemplateException If a template file is not found * * @param string $name * @@ -98,7 +98,7 @@ protected function loadFile($name) { $fileName = $this->getFileName($name); - if (!file_exists($fileName)) { + if ($this->shouldCheckPath() && !file_exists($fileName)) { throw new Mustache_Exception_UnknownTemplateException($name); } @@ -121,4 +121,15 @@ protected function getFileName($name) return $fileName; } + + /** + * Only check if baseDir is a directory and requested templates are files if + * baseDir is using the filesystem stream wrapper. + * + * @return bool Whether to check `is_dir` and `file_exists` + */ + protected function shouldCheckPath() + { + return strpos($this->baseDir, '://') === false || strpos($this->baseDir, 'file://') === 0; + } } diff --git a/vendor/mustache/mustache/src/Mustache/Loader/InlineLoader.php b/vendor/mustache/mustache/src/Mustache/Loader/InlineLoader.php index 29709377..ae297fec 100644 --- a/vendor/mustache/mustache/src/Mustache/Loader/InlineLoader.php +++ b/vendor/mustache/mustache/src/Mustache/Loader/InlineLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -68,7 +68,7 @@ class Mustache_Loader_InlineLoader implements Mustache_Loader * @param string $fileName The file to parse for inline templates * @param int $offset A string offset for the start of the templates. * This usually coincides with the `__halt_compiler` - * call, and the `__COMPILER_HALT_OFFSET__`. + * call, and the `__COMPILER_HALT_OFFSET__` */ public function __construct($fileName, $offset) { @@ -87,7 +87,7 @@ public function __construct($fileName, $offset) /** * Load a Template by name. * - * @throws Mustache_Exception_UnknownTemplateException If a template file is not found. + * @throws Mustache_Exception_UnknownTemplateException If a template file is not found * * @param string $name * diff --git a/vendor/mustache/mustache/src/Mustache/Loader/MutableLoader.php b/vendor/mustache/mustache/src/Mustache/Loader/MutableLoader.php index 4855c165..57fe5be3 100644 --- a/vendor/mustache/mustache/src/Mustache/Loader/MutableLoader.php +++ b/vendor/mustache/mustache/src/Mustache/Loader/MutableLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Loader/ProductionFilesystemLoader.php b/vendor/mustache/mustache/src/Mustache/Loader/ProductionFilesystemLoader.php new file mode 100644 index 00000000..e7353327 --- /dev/null +++ b/vendor/mustache/mustache/src/Mustache/Loader/ProductionFilesystemLoader.php @@ -0,0 +1,86 @@ + '.ms', + * 'stat_props' => array('size', 'mtime'), + * ); + * + * Specifying 'stat_props' overrides the stat properties used to invalidate the template cache. By default, this + * uses 'mtime' and 'size', but this can be set to any of the properties supported by stat(): + * + * http://php.net/manual/en/function.stat.php + * + * You can also disable filesystem stat entirely: + * + * $options = array('stat_props' => null); + * + * But with great power comes great responsibility. Namely, if you disable stat-based cache invalidation, + * YOU MUST CLEAR THE TEMPLATE CACHE YOURSELF when your templates change. Make it part of your build or deploy + * process so you don't forget! + * + * @throws Mustache_Exception_RuntimeException if $baseDir does not exist. + * + * @param string $baseDir Base directory containing Mustache template files. + * @param array $options Array of Loader options (default: array()) + */ + public function __construct($baseDir, array $options = array()) + { + parent::__construct($baseDir, $options); + + if (array_key_exists('stat_props', $options)) { + if (empty($options['stat_props'])) { + $this->statProps = array(); + } else { + $this->statProps = $options['stat_props']; + } + } else { + $this->statProps = array('size', 'mtime'); + } + } + + /** + * Helper function for loading a Mustache file by name. + * + * @throws Mustache_Exception_UnknownTemplateException If a template file is not found. + * + * @param string $name + * + * @return Mustache_Source Mustache Template source + */ + protected function loadFile($name) + { + $fileName = $this->getFileName($name); + + if (!file_exists($fileName)) { + throw new Mustache_Exception_UnknownTemplateException($name); + } + + return new Mustache_Source_FilesystemSource($fileName, $this->statProps); + } +} diff --git a/vendor/mustache/mustache/src/Mustache/Loader/StringLoader.php b/vendor/mustache/mustache/src/Mustache/Loader/StringLoader.php index 99fb38e4..7012c03b 100644 --- a/vendor/mustache/mustache/src/Mustache/Loader/StringLoader.php +++ b/vendor/mustache/mustache/src/Mustache/Loader/StringLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Logger.php b/vendor/mustache/mustache/src/Mustache/Logger.php index 93c27f6b..cb4037a2 100644 --- a/vendor/mustache/mustache/src/Mustache/Logger.php +++ b/vendor/mustache/mustache/src/Mustache/Logger.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Logger/AbstractLogger.php b/vendor/mustache/mustache/src/Mustache/Logger/AbstractLogger.php index 1c27db9c..a169f9c6 100644 --- a/vendor/mustache/mustache/src/Mustache/Logger/AbstractLogger.php +++ b/vendor/mustache/mustache/src/Mustache/Logger/AbstractLogger.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/vendor/mustache/mustache/src/Mustache/Logger/StreamLogger.php b/vendor/mustache/mustache/src/Mustache/Logger/StreamLogger.php index 88f30000..402a148e 100644 --- a/vendor/mustache/mustache/src/Mustache/Logger/StreamLogger.php +++ b/vendor/mustache/mustache/src/Mustache/Logger/StreamLogger.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -36,7 +36,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger protected $url = null; /** - * @throws InvalidArgumentException if the logging level is unknown. + * @throws InvalidArgumentException if the logging level is unknown * * @param resource|string $stream Resource instance or URL * @param int $level The minimum logging level at which this handler will be triggered @@ -65,7 +65,7 @@ public function __destruct() /** * Set the minimum logging level. * - * @throws Mustache_Exception_InvalidArgumentException if the logging level is unknown. + * @throws Mustache_Exception_InvalidArgumentException if the logging level is unknown * * @param int $level The minimum logging level which will be written */ @@ -91,7 +91,7 @@ public function getLevel() /** * Logs with an arbitrary level. * - * @throws Mustache_Exception_InvalidArgumentException if the logging level is unknown. + * @throws Mustache_Exception_InvalidArgumentException if the logging level is unknown * * @param mixed $level * @param string $message @@ -111,8 +111,8 @@ public function log($level, $message, array $context = array()) /** * Write a record to the log. * - * @throws Mustache_Exception_LogicException If neither a stream resource nor url is present. - * @throws Mustache_Exception_RuntimeException If the stream url cannot be opened. + * @throws Mustache_Exception_LogicException If neither a stream resource nor url is present + * @throws Mustache_Exception_RuntimeException If the stream url cannot be opened * * @param int $level The logging level * @param string $message The log message @@ -139,7 +139,7 @@ protected function writeLog($level, $message, array $context = array()) /** * Gets the name of the logging level. * - * @throws InvalidArgumentException if the logging level is unknown. + * @throws InvalidArgumentException if the logging level is unknown * * @param int $level * diff --git a/vendor/mustache/mustache/src/Mustache/Parser.php b/vendor/mustache/mustache/src/Mustache/Parser.php index 7d3559b7..0ec41922 100644 --- a/vendor/mustache/mustache/src/Mustache/Parser.php +++ b/vendor/mustache/mustache/src/Mustache/Parser.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -63,7 +63,7 @@ public function setPragmas(array $pragmas) /** * Helper method for recursively building a parse tree. * - * @throws Mustache_Exception_SyntaxException when nesting errors or mismatched section tags are encountered. + * @throws Mustache_Exception_SyntaxException when nesting errors or mismatched section tags are encountered * * @param array &$tokens Set of Mustache tokens * @param array $parent Parent token (default: null) @@ -149,7 +149,7 @@ private function buildTree(array &$tokens, array $parent = null) case Mustache_Tokenizer::T_BLOCK_VAR: if ($this->pragmaBlocks) { // BLOCKS pragma is enabled, let's do this! - if ($parent[Mustache_Tokenizer::TYPE] === Mustache_Tokenizer::T_PARENT) { + if (isset($parent) && $parent[Mustache_Tokenizer::TYPE] === Mustache_Tokenizer::T_PARENT) { $token[Mustache_Tokenizer::TYPE] = Mustache_Tokenizer::T_BLOCK_ARG; } $this->clearStandaloneLines($nodes, $tokens); @@ -195,10 +195,10 @@ private function buildTree(array &$tokens, array $parent = null) * * Returns a whitespace token for indenting partials, if applicable. * - * @param array $nodes Parsed nodes. - * @param array $tokens Tokens to be parsed. + * @param array $nodes Parsed nodes + * @param array $tokens Tokens to be parsed * - * @return array|null Resulting indent token, if any. + * @return array|null Resulting indent token, if any */ private function clearStandaloneLines(array &$nodes, array &$tokens) { @@ -268,14 +268,14 @@ private function tokenIsWhitespace(array $token) /** * Check whether a token is allowed inside a parent tag. * - * @throws Mustache_Exception_SyntaxException if an invalid token is found inside a parent tag. + * @throws Mustache_Exception_SyntaxException if an invalid token is found inside a parent tag * * @param array|null $parent * @param array $token */ private function checkIfTokenIsAllowedInParent($parent, array $token) { - if ($parent[Mustache_Tokenizer::TYPE] === Mustache_Tokenizer::T_PARENT) { + if (isset($parent) && $parent[Mustache_Tokenizer::TYPE] === Mustache_Tokenizer::T_PARENT) { throw new Mustache_Exception_SyntaxException('Illegal content in < parent tag', $token); } } diff --git a/vendor/mustache/mustache/src/Mustache/Source.php b/vendor/mustache/mustache/src/Mustache/Source.php new file mode 100644 index 00000000..278c2cb3 --- /dev/null +++ b/vendor/mustache/mustache/src/Mustache/Source.php @@ -0,0 +1,40 @@ +fileName = $fileName; + $this->statProps = $statProps; + } + + /** + * Get the Source key (used to generate the compiled class name). + * + * @throws Mustache_Exception_RuntimeException when a source file cannot be read + * + * @return string + */ + public function getKey() + { + $chunks = array( + 'fileName' => $this->fileName, + ); + + if (!empty($this->statProps)) { + if (!isset($this->stat)) { + $this->stat = @stat($this->fileName); + } + + if ($this->stat === false) { + throw new Mustache_Exception_RuntimeException(sprintf('Failed to read source file "%s".', $this->fileName)); + } + + foreach ($this->statProps as $prop) { + $chunks[$prop] = $this->stat[$prop]; + } + } + + return json_encode($chunks); + } + + /** + * Get the template Source. + * + * @return string + */ + public function getSource() + { + return file_get_contents($this->fileName); + } +} diff --git a/vendor/mustache/mustache/src/Mustache/Template.php b/vendor/mustache/mustache/src/Mustache/Template.php index 91074c44..4de82393 100644 --- a/vendor/mustache/mustache/src/Mustache/Template.php +++ b/vendor/mustache/mustache/src/Mustache/Template.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -164,16 +164,15 @@ protected function prepareContextStack($context = null) * * @param mixed $value * @param Mustache_Context $context - * @param string $indent * * @return string */ - protected function resolveValue($value, Mustache_Context $context, $indent = '') + protected function resolveValue($value, Mustache_Context $context) { if (($this->strictCallables ? is_object($value) : !is_string($value)) && is_callable($value)) { return $this->mustache ->loadLambda((string) call_user_func($value)) - ->renderInternal($context, $indent); + ->renderInternal($context); } return $value; diff --git a/vendor/mustache/mustache/src/Mustache/Tokenizer.php b/vendor/mustache/mustache/src/Mustache/Tokenizer.php index a71df2ce..2a172c34 100644 --- a/vendor/mustache/mustache/src/Mustache/Tokenizer.php +++ b/vendor/mustache/mustache/src/Mustache/Tokenizer.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2010-2015 Justin Hileman + * (c) 2010-2017 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -72,34 +72,47 @@ class Mustache_Tokenizer private $tokens; private $seenTag; private $line; + private $otag; - private $ctag; + private $otagChar; private $otagLen; + + private $ctag; + private $ctagChar; private $ctagLen; /** * Scan and tokenize template source. * - * @throws Mustache_Exception_SyntaxException when mismatched section tags are encountered. + * @throws Mustache_Exception_SyntaxException when mismatched section tags are encountered + * @throws Mustache_Exception_InvalidArgumentException when $delimiters string is invalid * * @param string $text Mustache template source to tokenize - * @param string $delimiters Optionally, pass initial opening and closing delimiters (default: null) + * @param string $delimiters Optionally, pass initial opening and closing delimiters (default: empty string) * * @return array Set of Mustache tokens */ - public function scan($text, $delimiters = null) + public function scan($text, $delimiters = '') { // Setting mbstring.func_overload makes things *really* slow. // Let's do everyone a favor and scan this string as ASCII instead. + // + // The INI directive was removed in PHP 8.0 so we don't need to check there (and can drop it + // when we remove support for older versions of PHP). + // + // @codeCoverageIgnoreStart $encoding = null; - if (function_exists('mb_internal_encoding') && ini_get('mbstring.func_overload') & 2) { - $encoding = mb_internal_encoding(); - mb_internal_encoding('ASCII'); + if (version_compare(PHP_VERSION, '8.0.0', '<')) { + if (function_exists('mb_internal_encoding') && ini_get('mbstring.func_overload') & 2) { + $encoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } } + // @codeCoverageIgnoreEnd $this->reset(); - if ($delimiters = trim($delimiters)) { + if (is_string($delimiters) && $delimiters = trim($delimiters)) { $this->setDelimiters($delimiters); } @@ -107,12 +120,13 @@ public function scan($text, $delimiters = null) for ($i = 0; $i < $len; $i++) { switch ($this->state) { case self::IN_TEXT: - if ($this->tagChange($this->otag, $this->otagLen, $text, $i)) { + $char = $text[$i]; + // Test whether it's time to change tags. + if ($char === $this->otagChar && substr($text, $i, $this->otagLen) === $this->otag) { $i--; $this->flushBuffer(); $this->state = self::IN_TAG_TYPE; } else { - $char = $text[$i]; $this->buffer .= $char; if ($char === "\n") { $this->flushBuffer(); @@ -148,7 +162,9 @@ public function scan($text, $delimiters = null) break; default: - if ($this->tagChange($this->ctag, $this->ctagLen, $text, $i)) { + $char = $text[$i]; + // Test whether it's time to change tags. + if ($char === $this->ctagChar && substr($text, $i, $this->ctagLen) === $this->ctag) { $token = array( self::TYPE => $this->tagType, self::NAME => trim($this->buffer), @@ -193,7 +209,7 @@ public function scan($text, $delimiters = null) $this->state = self::IN_TEXT; $this->tokens[] = $token; } else { - $this->buffer .= $text[$i]; + $this->buffer .= $char; } break; } @@ -202,9 +218,11 @@ public function scan($text, $delimiters = null) $this->flushBuffer(); // Restore the user's encoding... + // @codeCoverageIgnoreStart if ($encoding) { mb_internal_encoding($encoding); } + // @codeCoverageIgnoreEnd return $this->tokens; } @@ -214,16 +232,20 @@ public function scan($text, $delimiters = null) */ private function reset() { - $this->state = self::IN_TEXT; - $this->tagType = null; - $this->buffer = ''; - $this->tokens = array(); - $this->seenTag = false; - $this->line = 0; - $this->otag = '{{'; - $this->ctag = '}}'; - $this->otagLen = 2; - $this->ctagLen = 2; + $this->state = self::IN_TEXT; + $this->tagType = null; + $this->buffer = ''; + $this->tokens = array(); + $this->seenTag = false; + $this->line = 0; + + $this->otag = '{{'; + $this->otagChar = '{'; + $this->otagLen = 2; + + $this->ctag = '}}'; + $this->ctagChar = '}'; + $this->ctagLen = 2; } /** @@ -244,6 +266,8 @@ private function flushBuffer() /** * Change the current Mustache delimiters. Set new `otag` and `ctag` values. * + * @throws Mustache_Exception_SyntaxException when delimiter string is invalid + * * @param string $text Mustache template source * @param int $index Current tokenizer index * @@ -255,28 +279,44 @@ private function changeDelimiters($text, $index) $close = '=' . $this->ctag; $closeIndex = strpos($text, $close, $index); - $this->setDelimiters(trim(substr($text, $startIndex, $closeIndex - $startIndex))); - - $this->tokens[] = array( + $token = array( self::TYPE => self::T_DELIM_CHANGE, self::LINE => $this->line, ); + try { + $this->setDelimiters(trim(substr($text, $startIndex, $closeIndex - $startIndex))); + } catch (Mustache_Exception_InvalidArgumentException $e) { + throw new Mustache_Exception_SyntaxException($e->getMessage(), $token); + } + + $this->tokens[] = $token; + return $closeIndex + strlen($close) - 1; } /** * Set the current Mustache `otag` and `ctag` delimiters. * + * @throws Mustache_Exception_InvalidArgumentException when delimiter string is invalid + * * @param string $delimiters */ private function setDelimiters($delimiters) { - list($otag, $ctag) = explode(' ', $delimiters); - $this->otag = $otag; - $this->ctag = $ctag; - $this->otagLen = strlen($otag); - $this->ctagLen = strlen($ctag); + if (!preg_match('/^\s*(\S+)\s+(\S+)\s*$/', $delimiters, $matches)) { + throw new Mustache_Exception_InvalidArgumentException(sprintf('Invalid delimiters: %s', $delimiters)); + } + + list($_, $otag, $ctag) = $matches; + + $this->otag = $otag; + $this->otagChar = $otag[0]; + $this->otagLen = strlen($otag); + + $this->ctag = $ctag; + $this->ctagChar = $ctag[0]; + $this->ctagLen = strlen($ctag); } /** @@ -304,19 +344,4 @@ private function addPragma($text, $index) return $end + $this->ctagLen - 1; } - - /** - * Test whether it's time to change tags. - * - * @param string $tag Current tag name - * @param int $tagLen Current tag name length - * @param string $text Mustache template source - * @param int $index Current tokenizer index - * - * @return bool True if this is a closing section tag - */ - private function tagChange($tag, $tagLen, $text, $index) - { - return substr($text, $index, $tagLen) === $tag; - } } diff --git a/vendor/scribu/lib-posts-to-posts/.gitignore b/vendor/scribu/lib-posts-to-posts/.gitignore new file mode 100644 index 00000000..d1502b08 --- /dev/null +++ b/vendor/scribu/lib-posts-to-posts/.gitignore @@ -0,0 +1,2 @@ +vendor/ +composer.lock diff --git a/vendor/scribu/lib-posts-to-posts/composer.json b/vendor/scribu/lib-posts-to-posts/composer.json index 233db869..1f32bb9f 100644 --- a/vendor/scribu/lib-posts-to-posts/composer.json +++ b/vendor/scribu/lib-posts-to-posts/composer.json @@ -9,5 +9,11 @@ }, "autoload": { "files": ["autoload.php"] - } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/jeffreyvr/wp-scb-framework/" + } + ] } diff --git a/vendor/scribu/lib-posts-to-posts/side-post.php b/vendor/scribu/lib-posts-to-posts/side-post.php index c84a3f97..4b26d1ff 100644 --- a/vendor/scribu/lib-posts-to-posts/side-post.php +++ b/vendor/scribu/lib-posts-to-posts/side-post.php @@ -22,7 +22,7 @@ private function get_ptype() { $ptype_object = get_post_type_object( $ptype ); if ( !$ptype_object ) { - throw new P2P_Exception( "Can't find $ptype." ); + throw new P2P_Exception( "Can't find post type $ptype." ); } return $ptype_object; diff --git a/vendor/scribu/scb-framework/.gitignore b/vendor/scribu/scb-framework/.gitignore new file mode 100644 index 00000000..90ec22be --- /dev/null +++ b/vendor/scribu/scb-framework/.gitignore @@ -0,0 +1 @@ +.svn diff --git a/vendor/scribu/scb-framework/AdminPage.php b/vendor/scribu/scb-framework/AdminPage.php index 5539cc66..b73add5e 100644 --- a/vendor/scribu/scb-framework/AdminPage.php +++ b/vendor/scribu/scb-framework/AdminPage.php @@ -136,6 +136,9 @@ public function __construct( $file = false, $options = null ) { add_action( 'admin_menu', array( $this, 'page_init' ), $this->args['admin_action_priority'] ); + // Commented out due to deprecated notice. + // add_filter( 'contextual_help', array( $this, '_contextual_help' ), 10, 2 ); + if ( $file ) { $this->file = $file; $this->plugin_url = plugin_dir_url( $file ); @@ -508,7 +511,6 @@ private function check_args() { 'toplevel' => '', 'position' => null, 'icon_url' => '', - 'screen_icon' => '', 'parent' => 'options-general.php', 'capability' => 'manage_options', 'menu_title' => $this->args['page_title'], @@ -538,7 +540,6 @@ private function check_args() { * @param string|object $screen * * @return string - * @deprecated 1.6.6 Not used */ public function _contextual_help( $help, $screen ) { if ( is_object( $screen ) ) { @@ -580,4 +581,3 @@ public function _action_link( $links ) { return $links; } } - diff --git a/vendor/scribu/scb-framework/Forms.php b/vendor/scribu/scb-framework/Forms.php index 241c4857..43c4cd1a 100644 --- a/vendor/scribu/scb-framework/Forms.php +++ b/vendor/scribu/scb-framework/Forms.php @@ -606,6 +606,10 @@ protected static function _input_gen( $args ) { * @return string */ protected static function add_label( $input, $desc, $desc_pos ) { + if ( empty( $desc ) ) { + return $input; + } + return html( 'label', self::add_desc( $input, $desc, $desc_pos ) ) . "\n"; } diff --git a/vendor/scribu/scb-framework/load.php b/vendor/scribu/scb-framework/load.php index df20f542..56c5e643 100644 --- a/vendor/scribu/scb-framework/load.php +++ b/vendor/scribu/scb-framework/load.php @@ -1,6 +1,6 @@