Skip to content

Commit

Permalink
Ensuring compatibility with future PHP versions
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Jul 21, 2024
1 parent 0323bd0 commit bbef96d
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 17 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 9.1.6 <small>(2024-07-21)</small>

#### Compatibility

* Ensuring compatibility with future PHP versions.

--------------------------------------------------------

### 9.1.5 <small>(2023-11-24)</small>

#### Bugfixes
Expand Down
4 changes: 2 additions & 2 deletions src/mako/Mako.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Mako
*
* @var string
*/
public const VERSION = '9.1.5';
public const VERSION = '9.1.6';

/**
* Mako major version.
Expand All @@ -38,5 +38,5 @@ class Mako
*
* @var int
*/
public const VERSION_PATCH = 5;
public const VERSION_PATCH = 6;
}
1 change: 0 additions & 1 deletion src/mako/error/handlers/cli/DevelopmentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ protected function determineExceptionType(Throwable $exception): string
E_PARSE => 'Parse Error',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_STRICT => 'Strict Mode Error',
E_NOTICE => 'Notice',
E_WARNING => 'Warning',
E_RECOVERABLE_ERROR => 'Recoverable Error',
Expand Down
3 changes: 1 addition & 2 deletions src/mako/http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use function stripos;
use function strlen;
use function strpos;
use function strtok;
use function strtoupper;

/**
Expand Down Expand Up @@ -342,7 +341,7 @@ public function getContentType(): string
{
if($this->contentType === null)
{
$this->contentType = rtrim(strtok((string) $this->headers->get('content-type'), ';'));
$this->contentType = rtrim(explode(';', (string) $this->headers->get('content-type'))[0]);
}

return $this->contentType;
Expand Down
7 changes: 3 additions & 4 deletions src/mako/utility/UUID.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
use function chr;
use function dechex;
use function explode;
use function hash;
use function hex2bin;
use function hexdec;
use function md5;
use function microtime;
use function ord;
use function preg_match;
use function random_bytes;
use function sha1;
use function sprintf;
use function str_replace;
use function str_split;
Expand Down Expand Up @@ -131,7 +130,7 @@ public static function toHexadecimal(string $bytes): string
*/
public static function v3(string $namespace, string $name): string
{
$hash = md5(static::toBinary($namespace) . $name);
$hash = hash('md5', static::toBinary($namespace) . $name);

return sprintf
(
Expand Down Expand Up @@ -169,7 +168,7 @@ public static function v4(): string
*/
public static function v5(string $namespace, string $name): string
{
$hash = sha1(static::toBinary($namespace) . $name);
$hash = hash('sha1', static::toBinary($namespace) . $name);

return sprintf
(
Expand Down
4 changes: 2 additions & 2 deletions src/mako/view/compilers/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

use mako\file\FileSystem;

use function hash;
use function ltrim;
use function md5;
use function preg_match;
use function preg_replace;
use function preg_replace_callback;
Expand Down Expand Up @@ -302,6 +302,6 @@ public function compile(): void

// Store compiled template

$this->fileSystem->put($this->cachePath . '/' . md5($this->template) . '.php', trim($contents));
$this->fileSystem->put($this->cachePath . '/' . hash('md5', $this->template) . '.php', trim($contents));
}
}
4 changes: 2 additions & 2 deletions src/mako/view/renderers/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use function array_merge;
use function array_pop;
use function current;
use function md5;
use function hash;
use function ob_get_clean;
use function ob_start;
use function str_replace;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function __construct(
*/
protected function getCompiledPath(string $view): string
{
return "{$this->cachePath}/" . md5($view) . '.php';
return "{$this->cachePath}/" . hash('md5', $view) . '.php';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL);

date_default_timezone_set('UTC');

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/syringe/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function testHasInstanceOf(): void

$container->registerSingleton([Bar::class, 'bar'], function ()
{
return new Bar(uniqid(), uniqid());
return new Bar(bin2hex(random_bytes(16)), bin2hex(random_bytes(16)));
});

$this->assertFalse($container->hasInstanceOf(Bar::class));
Expand All @@ -401,7 +401,7 @@ public function testRegisterSingleton(): void

$container->registerSingleton([Bar::class, 'bar'], function ()
{
return new Bar(uniqid(), uniqid());
return new Bar(bin2hex(random_bytes(16)), bin2hex(random_bytes(16)));
});

$this->assertEquals($container->get('bar'), $container->get('bar'));
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/view/compilers/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getFileSystem($template, $compiled)

$fileSystem->shouldReceive('get')->with($this->templateName)->once()->andReturn($template);

$fileSystem->shouldReceive('put')->with($this->cachePath . '/' . md5($this->templateName) . '.php', $compiled);
$fileSystem->shouldReceive('put')->with($this->cachePath . '/' . hash('md5', $this->templateName) . '.php', $compiled);

return $fileSystem;
}
Expand Down

0 comments on commit bbef96d

Please sign in to comment.