Completed
Pull Request — 2.0.x (#6)
by Andrew
02:11
created
config/dependencies.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -1,44 +1,44 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * KohanaView dependency container configuration for use with https://github.com/zeelot/kohana-dependencies
4
- *
5
- * @author     Andrew Coulton <[email protected]>
6
- * @copyright  2015 inGenerator Ltd
7
- * @license    http://kohanaframework.org/license
8
- */
3
+	 * KohanaView dependency container configuration for use with https://github.com/zeelot/kohana-dependencies
4
+	 *
5
+	 * @author     Andrew Coulton <[email protected]>
6
+	 * @copyright  2015 inGenerator Ltd
7
+	 * @license    http://kohanaframework.org/license
8
+	 */
9 9
 return [
10
-    'kohanaview' => [
11
-        'renderer' => [
12
-            'html' => [
13
-                '_settings' => [
14
-                    'class'     => '\Ingenerator\KohanaView\Renderer\HTMLRenderer',
15
-                    'arguments' => ['%kohanaview.template.selector%', '%kohanaview.template.manager%'],
16
-                    'shared'    => TRUE,
17
-                ],
18
-            ],
19
-        ],
20
-        'template' => [
21
-            'compiler' => [
22
-                '_settings' => [
23
-                    'class'     => '\Ingenerator\KohanaView\TemplateCompiler',
24
-                    'arguments' => [],
25
-                    'shared'    => TRUE,
26
-                ],
27
-            ],
28
-            'manager'  => [
29
-                '_settings' => [
30
-                    'class'     => '\Ingenerator\KohanaView\TemplateManager\CFSTemplateManager',
31
-                    'arguments' => ['%kohanaview.template.compiler%', '@kohanaview.template_manager@'],
32
-                    'shared'    => TRUE,
33
-                ],
34
-            ],
35
-            'selector' => [
36
-                '_settings' => [
37
-                    'class'     => '\Ingenerator\KohanaView\ViewTemplateSelector',
38
-                    'arguments' => [],
39
-                    'shared'    => TRUE,
40
-                ],
41
-            ],
42
-        ],
43
-    ],
10
+	'kohanaview' => [
11
+		'renderer' => [
12
+			'html' => [
13
+				'_settings' => [
14
+					'class'     => '\Ingenerator\KohanaView\Renderer\HTMLRenderer',
15
+					'arguments' => ['%kohanaview.template.selector%', '%kohanaview.template.manager%'],
16
+					'shared'    => TRUE,
17
+				],
18
+			],
19
+		],
20
+		'template' => [
21
+			'compiler' => [
22
+				'_settings' => [
23
+					'class'     => '\Ingenerator\KohanaView\TemplateCompiler',
24
+					'arguments' => [],
25
+					'shared'    => TRUE,
26
+				],
27
+			],
28
+			'manager'  => [
29
+				'_settings' => [
30
+					'class'     => '\Ingenerator\KohanaView\TemplateManager\CFSTemplateManager',
31
+					'arguments' => ['%kohanaview.template.compiler%', '@kohanaview.template_manager@'],
32
+					'shared'    => TRUE,
33
+				],
34
+			],
35
+			'selector' => [
36
+				'_settings' => [
37
+					'class'     => '\Ingenerator\KohanaView\ViewTemplateSelector',
38
+					'arguments' => [],
39
+					'shared'    => TRUE,
40
+				],
41
+			],
42
+		],
43
+	],
44 44
 ];
Please login to merge, or discard this patch.
classes/Ingenerator/KohanaView/TemplateCompiler.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author     Andrew Coulton <[email protected]>
4
- * @copyright  2015 inGenerator Ltd
5
- * @license    http://kohanaframework.org/license
6
- */
3
+	 * @author     Andrew Coulton <[email protected]>
4
+	 * @copyright  2015 inGenerator Ltd
5
+	 * @license    http://kohanaframework.org/license
6
+	 */
7 7
 
8 8
 namespace Ingenerator\KohanaView;
9 9
 
@@ -33,83 +33,83 @@  discard block
 block discarded – undo
33 33
 class TemplateCompiler
34 34
 {
35 35
 
36
-    /**
37
-     * @var array
38
-     */
39
-    protected $options = [
40
-        'raw_output_prefix' => '!',
41
-        'escape_method'     => 'HTML::chars',
42
-    ];
36
+	/**
37
+	 * @var array
38
+	 */
39
+	protected $options = [
40
+		'raw_output_prefix' => '!',
41
+		'escape_method'     => 'HTML::chars',
42
+	];
43 43
 
44
-    /**
45
-     * @param array $options
46
-     */
47
-    public function __construct(array $options = [])
48
-    {
49
-        $this->options = array_merge($this->options, $options);
50
-    }
44
+	/**
45
+	 * @param array $options
46
+	 */
47
+	public function __construct(array $options = [])
48
+	{
49
+		$this->options = array_merge($this->options, $options);
50
+	}
51 51
 
52
-    /**
53
-     * Compile a string containing a PHP template, automatically escaping variables that are echoed in PHP short tags,
54
-     * and return the compiled PHP string.
55
-     *
56
-     * @param string $source
57
-     *
58
-     * @return string
59
-     * @throws \InvalidArgumentException if the template is empty or invalid
60
-     */
61
-    public function compile($source)
62
-    {
63
-        if ( ! $source) {
64
-            throw InvalidTemplateContentException::forEmptyTemplate();
65
-        }
52
+	/**
53
+	 * Compile a string containing a PHP template, automatically escaping variables that are echoed in PHP short tags,
54
+	 * and return the compiled PHP string.
55
+	 *
56
+	 * @param string $source
57
+	 *
58
+	 * @return string
59
+	 * @throws \InvalidArgumentException if the template is empty or invalid
60
+	 */
61
+	public function compile($source)
62
+	{
63
+		if ( ! $source) {
64
+			throw InvalidTemplateContentException::forEmptyTemplate();
65
+		}
66 66
 
67
-        return preg_replace_callback('/<\?=(.+?)(;|\?>)/s', [$this, 'compilePhpShortTag'], $source);
68
-    }
67
+		return preg_replace_callback('/<\?=(.+?)(;|\?>)/s', [$this, 'compilePhpShortTag'], $source);
68
+	}
69 69
 
70
-    /**
71
-     * @param string[] $matches
72
-     *
73
-     * @return string
74
-     */
75
-    protected function compilePhpShortTag($matches)
76
-    {
77
-        $var               = trim($matches[1]);
78
-        $terminator        = $matches[2];
79
-        $escape_method     = $this->options['escape_method'];
80
-        $raw_output_prefix = $this->options['raw_output_prefix'];
70
+	/**
71
+	 * @param string[] $matches
72
+	 *
73
+	 * @return string
74
+	 */
75
+	protected function compilePhpShortTag($matches)
76
+	{
77
+		$var               = trim($matches[1]);
78
+		$terminator        = $matches[2];
79
+		$escape_method     = $this->options['escape_method'];
80
+		$raw_output_prefix = $this->options['raw_output_prefix'];
81 81
 
82
-        if ($this->startsWith($var, $raw_output_prefix)) {
83
-            // Remove prefix and echo unescaped
84
-            $compiled = '<?='.trim(substr($var, strlen($raw_output_prefix))).';';
85
-        } elseif ($this->startsWith($var, '//')) {
86
-            // Echo an empty string to prevent the comment causing a parse error
87
-            $compiled = "<?='';$var;";
82
+		if ($this->startsWith($var, $raw_output_prefix)) {
83
+			// Remove prefix and echo unescaped
84
+			$compiled = '<?='.trim(substr($var, strlen($raw_output_prefix))).';';
85
+		} elseif ($this->startsWith($var, '//')) {
86
+			// Echo an empty string to prevent the comment causing a parse error
87
+			$compiled = "<?='';$var;";
88 88
 
89
-        } elseif ($this->startsWith($var, $escape_method)) {
90
-            throw InvalidTemplateContentException::containsImplicitDoubleEscape($escape_method, $matches[0]);
89
+		} elseif ($this->startsWith($var, $escape_method)) {
90
+			throw InvalidTemplateContentException::containsImplicitDoubleEscape($escape_method, $matches[0]);
91 91
 
92
-        } else {
93
-            // Escape the value before echoing
94
-            $compiled = "<?={$escape_method}($var);";
95
-        }
92
+		} else {
93
+			// Escape the value before echoing
94
+			$compiled = "<?={$escape_method}($var);";
95
+		}
96 96
 
97
-        if ($terminator === '?>') {
98
-            $compiled .= '?>';
99
-        }
97
+		if ($terminator === '?>') {
98
+			$compiled .= '?>';
99
+		}
100 100
 
101
-        return $compiled;
102
-    }
101
+		return $compiled;
102
+	}
103 103
 
104
-    /**
105
-     * @param string $string
106
-     * @param string $prefix
107
-     *
108
-     * @return bool
109
-     */
110
-    protected function startsWith($string, $prefix)
111
-    {
112
-        return (strncmp($string, $prefix, strlen($prefix)) === 0);
113
-    }
104
+	/**
105
+	 * @param string $string
106
+	 * @param string $prefix
107
+	 *
108
+	 * @return bool
109
+	 */
110
+	protected function startsWith($string, $prefix)
111
+	{
112
+		return (strncmp($string, $prefix, strlen($prefix)) === 0);
113
+	}
114 114
 
115 115
 }
Please login to merge, or discard this patch.
classes/Ingenerator/KohanaView/ViewModel.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
17 17
 interface ViewModel
18 18
 {
19 19
 
20
-    /**
21
-     * @param  array $variables
22
-     *
23
-     * @return void
24
-     */
25
-    public function display(array $variables);
20
+	/**
21
+	 * @param  array $variables
22
+	 *
23
+	 * @return void
24
+	 */
25
+	public function display(array $variables);
26 26
 
27 27
 }
Please login to merge, or discard this patch.
classes/Ingenerator/KohanaView/Exception/UndefinedViewVarException.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author     Andrew Coulton <[email protected]>
4
- * @copyright  2015 inGenerator Ltd
5
- * @license    http://kohanaframework.org/license
6
- */
3
+	 * @author     Andrew Coulton <[email protected]>
4
+	 * @copyright  2015 inGenerator Ltd
5
+	 * @license    http://kohanaframework.org/license
6
+	 */
7 7
 
8 8
 namespace Ingenerator\KohanaView\Exception;
9 9
 
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
 class UndefinedViewVarException extends \BadMethodCallException
16 16
 {
17 17
 
18
-    /**
19
-     * @param string $view_class
20
-     * @param string $var_name
21
-     *
22
-     * @return static
23
-     */
24
-    public static function forClassAndVar($view_class, $var_name)
25
-    {
26
-        return new static(
27
-            "$view_class does not define a '$var_name' field"
28
-        );
29
-    }
18
+	/**
19
+	 * @param string $view_class
20
+	 * @param string $var_name
21
+	 *
22
+	 * @return static
23
+	 */
24
+	public static function forClassAndVar($view_class, $var_name)
25
+	{
26
+		return new static(
27
+			"$view_class does not define a '$var_name' field"
28
+		);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
Ingenerator/KohanaView/Exception/InvalidTemplateContentException.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@
 block discarded – undo
15 15
  */
16 16
 class InvalidTemplateContentException extends \InvalidArgumentException
17 17
 {
18
-    /**
19
-     * @param string $escape_method
20
-     * @param string $source_fragment
21
-     *
22
-     * @return static
23
-     */
24
-    public static function containsImplicitDoubleEscape($escape_method, $source_fragment)
25
-    {
26
-        return new static(
27
-            "Invalid implicit double-escape in template - remove $escape_method from `$source_fragment` or mark as raw"
28
-        );
29
-    }
18
+	/**
19
+	 * @param string $escape_method
20
+	 * @param string $source_fragment
21
+	 *
22
+	 * @return static
23
+	 */
24
+	public static function containsImplicitDoubleEscape($escape_method, $source_fragment)
25
+	{
26
+		return new static(
27
+			"Invalid implicit double-escape in template - remove $escape_method from `$source_fragment` or mark as raw"
28
+		);
29
+	}
30 30
 
31
-    public static function forEmptyTemplate()
32
-    {
33
-        return new static('Cannot compile empty template');
34
-    }
31
+	public static function forEmptyTemplate()
32
+	{
33
+		return new static('Cannot compile empty template');
34
+	}
35 35
 
36 36
 }
Please login to merge, or discard this patch.
classes/Ingenerator/KohanaView/TemplateManager/CFSTemplateManager.php 1 patch
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author     Andrew Coulton <[email protected]>
4
- * @copyright  2015 inGenerator Ltd
5
- * @license    http://kohanaframework.org/license
6
- */
3
+	 * @author     Andrew Coulton <[email protected]>
4
+	 * @copyright  2015 inGenerator Ltd
5
+	 * @license    http://kohanaframework.org/license
6
+	 */
7 7
 
8 8
 namespace Ingenerator\KohanaView\TemplateManager;
9 9
 
@@ -24,117 +24,117 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class CFSTemplateManager implements TemplateManager
26 26
 {
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $cache_dir;
31
-
32
-    /**
33
-     * @var CFSWrapper
34
-     */
35
-    protected $cascading_files;
36
-
37
-    /**
38
-     * @var array
39
-     */
40
-    protected $compiled_paths = [];
41
-
42
-    /**
43
-     * @var TemplateCompiler
44
-     */
45
-    protected $compiler;
46
-
47
-    /**
48
-     * @var boolean
49
-     */
50
-    protected $recompile_always;
51
-
52
-    /**
53
-     * Valid options:
54
-     * * cache_dir => the path where compiled templates will be cached
55
-     * * recompile_always => whether to recompile each template on every execution,
56
-     *
57
-     * @param TemplateCompiler $compiler
58
-     * @param array            $options
59
-     * @param CFSWrapper       $cascading_files
60
-     */
61
-    public function __construct(TemplateCompiler $compiler, array $options, CFSWrapper $cascading_files = NULL)
62
-    {
63
-        $this->cascading_files  = $cascading_files ?: new CFSWrapper;
64
-        $this->compiler         = $compiler;
65
-        $this->cache_dir        = rtrim($options['cache_dir'], '/');
66
-        $this->recompile_always = \Arr::get($options, 'recompile_always', FALSE);
67
-    }
68
-
69
-    /**
70
-     * {@inheritdoc}
71
-     */
72
-    public function getPath($template_name)
73
-    {
74
-        $compiled_path = $this->cache_dir.'/'.$template_name.'.php';
75
-
76
-        if ($this->isCompileRequired($compiled_path)) {
77
-            $source   = $this->requireSourceFileContent($template_name);
78
-            $compiled = $this->compiler->compile($source);
79
-            $this->writeFile($compiled_path, $compiled);
80
-            $this->compiled_paths[$compiled_path] = TRUE;
81
-        }
82
-
83
-        return $compiled_path;
84
-    }
85
-
86
-    /**
87
-     * @param string $compiled_path
88
-     *
89
-     * @return bool
90
-     */
91
-    protected function isCompileRequired($compiled_path)
92
-    {
93
-        if ($this->recompile_always AND ! isset($this->compiled_paths[$compiled_path])) {
94
-            return TRUE;
95
-        }
96
-
97
-        return ! file_exists($compiled_path);
98
-    }
99
-
100
-    /**
101
-     * @param string $template_name
102
-     *
103
-     * @return string
104
-     */
105
-    protected function requireSourceFileContent($template_name)
106
-    {
107
-        if ( ! $source_file = $this->cascading_files->find_file('views', $template_name)) {
108
-            throw TemplateNotFoundException::forSourcePath('views/'.$template_name);
109
-        }
110
-
111
-        return file_get_contents($source_file);
112
-    }
113
-
114
-    /**
115
-     * @param string $compiled_path
116
-     * @param string $compiled
117
-     */
118
-    protected function writeFile($compiled_path, $compiled)
119
-    {
120
-        $this->ensureWriteableDirectory(dirname($compiled_path));
121
-        file_put_contents($compiled_path, $compiled);
122
-    }
123
-
124
-    /**
125
-     * @param string $path
126
-     */
127
-    protected function ensureWriteableDirectory($path)
128
-    {
129
-        if (is_dir($path)) {
130
-            if ( ! is_writeable($path)) {
131
-                throw TemplateCacheException::pathNotWriteable($path);
132
-            }
133
-        } else {
134
-            if ( ! mkdir($path, 0777, TRUE)) {
135
-                throw TemplateCacheException::cannotCreateDirectory($path);
136
-            }
137
-        }
138
-    }
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $cache_dir;
31
+
32
+	/**
33
+	 * @var CFSWrapper
34
+	 */
35
+	protected $cascading_files;
36
+
37
+	/**
38
+	 * @var array
39
+	 */
40
+	protected $compiled_paths = [];
41
+
42
+	/**
43
+	 * @var TemplateCompiler
44
+	 */
45
+	protected $compiler;
46
+
47
+	/**
48
+	 * @var boolean
49
+	 */
50
+	protected $recompile_always;
51
+
52
+	/**
53
+	 * Valid options:
54
+	 * * cache_dir => the path where compiled templates will be cached
55
+	 * * recompile_always => whether to recompile each template on every execution,
56
+	 *
57
+	 * @param TemplateCompiler $compiler
58
+	 * @param array            $options
59
+	 * @param CFSWrapper       $cascading_files
60
+	 */
61
+	public function __construct(TemplateCompiler $compiler, array $options, CFSWrapper $cascading_files = NULL)
62
+	{
63
+		$this->cascading_files  = $cascading_files ?: new CFSWrapper;
64
+		$this->compiler         = $compiler;
65
+		$this->cache_dir        = rtrim($options['cache_dir'], '/');
66
+		$this->recompile_always = \Arr::get($options, 'recompile_always', FALSE);
67
+	}
68
+
69
+	/**
70
+	 * {@inheritdoc}
71
+	 */
72
+	public function getPath($template_name)
73
+	{
74
+		$compiled_path = $this->cache_dir.'/'.$template_name.'.php';
75
+
76
+		if ($this->isCompileRequired($compiled_path)) {
77
+			$source   = $this->requireSourceFileContent($template_name);
78
+			$compiled = $this->compiler->compile($source);
79
+			$this->writeFile($compiled_path, $compiled);
80
+			$this->compiled_paths[$compiled_path] = TRUE;
81
+		}
82
+
83
+		return $compiled_path;
84
+	}
85
+
86
+	/**
87
+	 * @param string $compiled_path
88
+	 *
89
+	 * @return bool
90
+	 */
91
+	protected function isCompileRequired($compiled_path)
92
+	{
93
+		if ($this->recompile_always AND ! isset($this->compiled_paths[$compiled_path])) {
94
+			return TRUE;
95
+		}
96
+
97
+		return ! file_exists($compiled_path);
98
+	}
99
+
100
+	/**
101
+	 * @param string $template_name
102
+	 *
103
+	 * @return string
104
+	 */
105
+	protected function requireSourceFileContent($template_name)
106
+	{
107
+		if ( ! $source_file = $this->cascading_files->find_file('views', $template_name)) {
108
+			throw TemplateNotFoundException::forSourcePath('views/'.$template_name);
109
+		}
110
+
111
+		return file_get_contents($source_file);
112
+	}
113
+
114
+	/**
115
+	 * @param string $compiled_path
116
+	 * @param string $compiled
117
+	 */
118
+	protected function writeFile($compiled_path, $compiled)
119
+	{
120
+		$this->ensureWriteableDirectory(dirname($compiled_path));
121
+		file_put_contents($compiled_path, $compiled);
122
+	}
123
+
124
+	/**
125
+	 * @param string $path
126
+	 */
127
+	protected function ensureWriteableDirectory($path)
128
+	{
129
+		if (is_dir($path)) {
130
+			if ( ! is_writeable($path)) {
131
+				throw TemplateCacheException::pathNotWriteable($path);
132
+			}
133
+		} else {
134
+			if ( ! mkdir($path, 0777, TRUE)) {
135
+				throw TemplateCacheException::cannotCreateDirectory($path);
136
+			}
137
+		}
138
+	}
139 139
 
140 140
 }
Please login to merge, or discard this patch.
classes/Ingenerator/KohanaView/ViewModel/AbstractViewModel.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author     Andrew Coulton <[email protected]>
4
- * @copyright  2015 inGenerator Ltd
5
- * @license    http://kohanaframework.org/license
6
- */
3
+	 * @author     Andrew Coulton <[email protected]>
4
+	 * @copyright  2015 inGenerator Ltd
5
+	 * @license    http://kohanaframework.org/license
6
+	 */
7 7
 namespace Ingenerator\KohanaView\ViewModel;
8 8
 
9 9
 use Ingenerator\KohanaView\Exception\InvalidDisplayVariablesException;
@@ -40,89 +40,89 @@  discard block
 block discarded – undo
40 40
  */
41 41
 abstract class AbstractViewModel implements ViewModel
42 42
 {
43
-    /**
44
-     * @var array The actual view data
45
-     */
46
-    protected $variables = [];
43
+	/**
44
+	 * @var array The actual view data
45
+	 */
46
+	protected $variables = [];
47 47
 
48
-    /**
49
-     * @var string[] The names of the valid set of fields that must be passed to the display() method
50
-     */
51
-    protected $expect_var_names = [];
48
+	/**
49
+	 * @var string[] The names of the valid set of fields that must be passed to the display() method
50
+	 */
51
+	protected $expect_var_names = [];
52 52
 
53
-    public function __construct()
54
-    {
55
-        // Assign the expect_var_names to ensure that we don't accidentally start requiring compiled fields
56
-        $this->expect_var_names = array_keys($this->variables);
57
-    }
53
+	public function __construct()
54
+	{
55
+		// Assign the expect_var_names to ensure that we don't accidentally start requiring compiled fields
56
+		$this->expect_var_names = array_keys($this->variables);
57
+	}
58 58
 
59
-    /**
60
-     * Get field values
61
-     *
62
-     * @param string $name
63
-     *
64
-     * @return mixed
65
-     */
66
-    public function __get($name)
67
-    {
68
-        if (array_key_exists($name, $this->variables)) {
69
-            return $this->variables[$name];
70
-        } elseif (method_exists($this, 'var_'.$name)) {
71
-            $method = 'var_'.$name;
59
+	/**
60
+	 * Get field values
61
+	 *
62
+	 * @param string $name
63
+	 *
64
+	 * @return mixed
65
+	 */
66
+	public function __get($name)
67
+	{
68
+		if (array_key_exists($name, $this->variables)) {
69
+			return $this->variables[$name];
70
+		} elseif (method_exists($this, 'var_'.$name)) {
71
+			$method = 'var_'.$name;
72 72
 
73
-            return $this->$method();
74
-        } else {
75
-            throw UndefinedViewVarException::forClassAndVar(static::class, $name);
76
-        }
77
-    }
73
+			return $this->$method();
74
+		} else {
75
+			throw UndefinedViewVarException::forClassAndVar(static::class, $name);
76
+		}
77
+	}
78 78
 
79
-    /**
80
-     * @param string $name
81
-     * @param mixed  $value
82
-     *
83
-     * @throws \BadMethodCallException values cannot be assigned except with the display method
84
-     */
85
-    public function __set($name, $value)
86
-    {
87
-        throw InvalidViewVarAssignmentException::forReadOnlyVar(static::class, $name);
88
-    }
79
+	/**
80
+	 * @param string $name
81
+	 * @param mixed  $value
82
+	 *
83
+	 * @throws \BadMethodCallException values cannot be assigned except with the display method
84
+	 */
85
+	public function __set($name, $value)
86
+	{
87
+		throw InvalidViewVarAssignmentException::forReadOnlyVar(static::class, $name);
88
+	}
89 89
 
90
-    /**
91
-     * Set the data to be rendered in the view - note this does not actually render the view.
92
-     *
93
-     * @param array $variables
94
-     */
95
-    public function display(array $variables)
96
-    {
97
-        if ($errors = $this->validateDisplayVariables($variables)) {
98
-            throw InvalidDisplayVariablesException::passedToDisplay(static::class, $errors);
99
-        }
90
+	/**
91
+	 * Set the data to be rendered in the view - note this does not actually render the view.
92
+	 *
93
+	 * @param array $variables
94
+	 */
95
+	public function display(array $variables)
96
+	{
97
+		if ($errors = $this->validateDisplayVariables($variables)) {
98
+			throw InvalidDisplayVariablesException::passedToDisplay(static::class, $errors);
99
+		}
100 100
 
101
-        $this->variables = $variables;
102
-    }
101
+		$this->variables = $variables;
102
+	}
103 103
 
104
-    /**
105
-     * @param array $variables
106
-     *
107
-     * @return string[] of errors
108
-     */
109
-    protected function validateDisplayVariables(array $variables)
110
-    {
111
-        $errors             = [];
112
-        $provided_variables = array_keys($variables);
113
-        foreach (array_diff($provided_variables, $this->expect_var_names) as $unexpected_var) {
114
-            if (method_exists($this, 'var_'.$unexpected_var)) {
115
-                $errors[] = "'$unexpected_var' conflicts with ::var_$unexpected_var()";
116
-            } else {
117
-                $errors[] = "'$unexpected_var' is not expected";
118
-            }
119
-        }
104
+	/**
105
+	 * @param array $variables
106
+	 *
107
+	 * @return string[] of errors
108
+	 */
109
+	protected function validateDisplayVariables(array $variables)
110
+	{
111
+		$errors             = [];
112
+		$provided_variables = array_keys($variables);
113
+		foreach (array_diff($provided_variables, $this->expect_var_names) as $unexpected_var) {
114
+			if (method_exists($this, 'var_'.$unexpected_var)) {
115
+				$errors[] = "'$unexpected_var' conflicts with ::var_$unexpected_var()";
116
+			} else {
117
+				$errors[] = "'$unexpected_var' is not expected";
118
+			}
119
+		}
120 120
 
121
-        foreach (array_diff($this->expect_var_names, $provided_variables) as $missing_var) {
122
-            $errors[] = "'$missing_var' is missing";
123
-        }
121
+		foreach (array_diff($this->expect_var_names, $provided_variables) as $missing_var) {
122
+			$errors[] = "'$missing_var' is missing";
123
+		}
124 124
 
125
-        return $errors;
126
-    }
125
+		return $errors;
126
+	}
127 127
 
128 128
 }
Please login to merge, or discard this patch.