Skip to content

Commit 7377329

Browse files
committed
fixes for php 8.4 deprecations
1 parent bbd9ec9 commit 7377329

File tree

12 files changed

+13
-49
lines changed

12 files changed

+13
-49
lines changed

php/hamle/Exception/ParseError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ParseError extends Hamle\Exception
3434
function __construct(
3535
string $message = '',
3636
int $code = 0,
37-
Throwable $previous = null
37+
?Throwable $previous = null
3838
) {
3939
///@todo Include Line number & file name within parse error exceptions
4040
$message .= ', on line ' . Hamle\Hamle::getLineNo() . ' in file ?.hamle';

php/hamle/Hamle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function initSnipFiles(): void
121121
* @throws Exception\NotFound If tempalte file cannot be found
122122
* @return Hamle Returns instance for chaining commands
123123
*/
124-
function load($hamleFile, \Closure $parseFunc = null)
124+
function load($hamleFile, ?\Closure $parseFunc = null)
125125
{
126126
$template = $this->setup->templatePath($hamleFile);
127127
if (!file_exists($template)) {
@@ -152,7 +152,7 @@ function load($hamleFile, \Closure $parseFunc = null)
152152
* @param string $hamleCode Hamle Template as string
153153
* @throws Exception\ParseError if unable to write to the cache file
154154
*/
155-
function parse($hamleCode, \Closure $parseFunc = null): void
155+
function parse($hamleCode, ?\Closure $parseFunc = null): void
156156
{
157157
if (!$this->cacheFile) {
158158
$this->cacheFile = $this->setup->cachePath('string.hamle.php');

php/hamle/Scope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Scope
2020
/** @var null|Callable */
2121
static $scopeHook;
2222

23-
static function add(Model $model, string $name = null): void
23+
static function add(Model $model, ?string $name = null): void
2424
{
2525
if (!$model instanceof Model) {
2626
throw new Unsupported(

php/hamle/Tag/Control.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Control extends H\Tag
4747
* @param \Seufert\Hamle\Tag $parentTag
4848
* @throws ParseError
4949
*/
50-
function __construct(string $tag, H\Tag $parentTag = null)
50+
function __construct(string $tag, ?H\Tag $parentTag = null)
5151
{
5252
parent::__construct();
5353
$this->o = "\$o" . self::$instCount++;

php/hamle/Text/Complex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function toPHPVar(): string
8686
}
8787
}
8888

89-
function getOrCreateModel(Model $parent = null): Model
89+
function getOrCreateModel(?Model $parent = null): Model
9090
{
9191
if ($this->func instanceof Text\Scope) {
9292
return $this->func->getOrCreateModel($parent);

php/hamle/Text/Func.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function toPHP(): string
172172
* @param Model|null $parent
173173
* @return Model
174174
*/
175-
public function getOrCreateModel(Model $parent = null): Model
175+
public function getOrCreateModel(?Model $parent = null): Model
176176
{
177177
if ($this->scope instanceof Scope) {
178178
$parent = $this->scope->getOrCreateModel();

php/hamle/Text/FuncSub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function toPHP(): string
8686
",$limit)$sub";
8787
}
8888

89-
public function getOrCreateModel(Model $parent = null): Model
89+
public function getOrCreateModel(?Model $parent = null): Model
9090
{
9191
if (!$parent) {
9292
throw new \RuntimeException('Unable to create when no model is passed');

php/hamle/Text/Scope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function setValue(mixed $value): WriteModel
6666
throw new \Exception('Unsupported');
6767
}
6868

69-
function getOrCreateModel(Model $parent = null): Model
69+
function getOrCreateModel(?Model $parent = null): Model
7070
{
7171
if (is_int($this->scope)) {
7272
return \Seufert\Hamle\Scope::get($this->scope);

php/hamle/Text/SimpleVar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function toPHPVar(): string
6363
return 'Hamle\\Scope::get()->hamleGet(' . Text::varToCode($this->var) . ')';
6464
}
6565

66-
function getOrCreateModel(Model $parent = null): Model
66+
function getOrCreateModel(?Model $parent = null): Model
6767
{
6868
return \Seufert\Hamle\Scope::get()->current();
6969
}

php/hamle/TextNode/FilterFunc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FilterFunc implements Chainable
1616

1717
public function __construct(
1818
string $func,
19-
Chainable $chain = null,
19+
?Chainable $chain = null,
2020
array $args = []
2121
) {
2222
$this->chain = $chain;

0 commit comments

Comments
 (0)