Skip to content

Commit e2cc151

Browse files
authoredMar 19, 2022
Merge pull request #56 from begleweyer/master
Add Laravel 9 compatibility, return types: offsetExists, offsetGet, offsetSet, offsetUnset
2 parents 4978fc9 + 7ec2039 commit e2cc151

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed
 

‎composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=5.3.0"
18+
"php": ">=7.1"
1919
},
2020
"autoload": {
2121
"psr-0": {

‎src/Flynsarmy/DbBladeCompiler/DbView.php

+23-23
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DbView extends \Illuminate\View\View implements ArrayAccess, Renderable
1717
/**
1818
* DbView constructor.
1919
*
20-
* @param Repository $config
20+
* @param Repository $config
2121
* @param DbBladeCompilerEngine $engine
2222
*/
2323
public function __construct(Repository $config, DbBladeCompilerEngine $engine)
@@ -29,10 +29,10 @@ public function __construct(Repository $config, DbBladeCompilerEngine $engine)
2929
/**
3030
* Get a evaluated view contents for the given view.
3131
*
32-
* @param Model $model
33-
* @param array $data
34-
* @param array $mergeData
35-
* @param string $content_field
32+
* @param Model $model
33+
* @param array $data
34+
* @param array $mergeData
35+
* @param string $content_field
3636
* @return DbView
3737
*/
3838
public function make(Model $model, $data = array(), $mergeData = array(), $content_field = null)
@@ -49,7 +49,7 @@ public function make(Model $model, $data = array(), $mergeData = array(), $conte
4949
}
5050

5151
/**
52-
* @param string $content_field
52+
* @param string $content_field
5353
* @return DbView
5454
*/
5555
public function field($content_field)
@@ -62,7 +62,7 @@ public function field($content_field)
6262
/**
6363
* Get the string contents of the view.
6464
*
65-
* @param callable $callback
65+
* @param callable $callback
6666
* @return string
6767
*/
6868
public function render(callable $callback = null)
@@ -75,9 +75,9 @@ public function render(callable $callback = null)
7575
// done rendering all views so that there is nothing left hanging over when
7676
// anothoer view is rendered in the future by the application developers.
7777
// Before flushing, check Laravel version for correct method use
78-
if ( version_compare(app()->version(), '5.4.0') >= 0 )
78+
if (version_compare(app()->version(), '5.4.0') >= 0)
7979
View::flushStateIfDoneRendering();
80-
else
80+
else
8181
View::flushSectionsIfDoneRendering();
8282

8383
return $response ?: $contents;
@@ -107,7 +107,7 @@ protected function renderContents()
107107

108108
protected function getContents()
109109
{
110-
$field = $this->config->get('db-blade-compiler.model_property');
110+
$field = $this->config->get('db-blade-compiler.model_property');
111111
$this->path->{$field} = $this->content_field;
112112

113113
return parent::getContents();
@@ -116,7 +116,7 @@ protected function getContents()
116116
/**
117117
* Parse the given data into a raw array.
118118
*
119-
* @param mixed $data
119+
* @param mixed $data
120120
* @return array
121121
*/
122122
protected function parseData($data)
@@ -145,9 +145,9 @@ public function gatherData()
145145
/**
146146
* Add a view instance to the view data.
147147
*
148-
* @param string $key
149-
* @param string $view
150-
* @param array $data
148+
* @param string $key
149+
* @param string $view
150+
* @param array $data
151151
* @return \Illuminate\View\View
152152
*/
153153
public function nest($key, $view, array $data = array())
@@ -158,44 +158,44 @@ public function nest($key, $view, array $data = array())
158158
/**
159159
* Determine if a piece of data is bound.
160160
*
161-
* @param string $key
161+
* @param string $key
162162
* @return bool
163163
*/
164-
public function offsetExists($key)
164+
public function offsetExists($key): bool
165165
{
166166
return array_key_exists($key, $this->data);
167167
}
168168

169169
/**
170170
* Get a piece of bound data to the view.
171171
*
172-
* @param string $key
172+
* @param string $key
173173
* @return mixed
174174
*/
175-
public function offsetGet($key)
175+
public function offsetGet($key): mixed
176176
{
177177
return $this->data[$key];
178178
}
179179

180180
/**
181181
* Set a piece of data on the view.
182182
*
183-
* @param string $key
184-
* @param mixed $value
183+
* @param string $key
184+
* @param mixed $value
185185
* @return void
186186
*/
187-
public function offsetSet($key, $value)
187+
public function offsetSet($key, $value): void
188188
{
189189
$this->with($key, $value);
190190
}
191191

192192
/**
193193
* Unset a piece of data from the view.
194194
*
195-
* @param string $key
195+
* @param string $key
196196
* @return void
197197
*/
198-
public function offsetUnset($key)
198+
public function offsetUnset($key): void
199199
{
200200
unset($this->data[$key]);
201201
}

0 commit comments

Comments
 (0)
Please sign in to comment.