-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8401 from michalsn/fix/highlightFile
fix: `highlightFile()` in `BaseExceptionHandler` for PHP 8.3
- Loading branch information
Showing
7 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CodeIgniter\Test; | ||
|
||
trait IniTestTrait | ||
{ | ||
private array $iniSettings = []; | ||
|
||
private function backupIniValues(array $keys): void | ||
{ | ||
foreach ($keys as $key) { | ||
$this->iniSettings[$key] = ini_get($key); | ||
} | ||
} | ||
|
||
private function restoreIniValues(): void | ||
{ | ||
foreach ($this->iniSettings as $key => $value) { | ||
ini_set($key, $value); | ||
} | ||
|
||
$this->iniSettings = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<pre><code><span class="line"><span class="number"> 9</span> * the LICENSE file that was distributed with this source code. | ||
<span class="line"><span class="number">10</span> */ | ||
<span class="line"><span class="number">11</span> | ||
<span class="line"><span class="number">12</span> </span><span style="color: #f1ce61;">namespace </span><span style="color: #c7c7c7">Tests\Support\Controllers</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">13</span> | ||
<span class="line"><span class="number">14</span> use </span><span style="color: #c7c7c7">CodeIgniter\Controller</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">15</span> | ||
<span class='line highlight'><span class='number'>16</span> class Hello extends Controller | ||
</span></span><span style="color: #c7c7c7"></span><span style="color: #f1ce61;"></span><span style="color: #c7c7c7"><span class="line"><span class="number">17</span> </span><span style="color: #f1ce61;">{ | ||
<span class="line"><span class="number">18</span> public function </span><span style="color: #c7c7c7">index</span><span style="color: #f1ce61;">() | ||
<span class="line"><span class="number">19</span> { | ||
<span class="line"><span class="number">20</span> return </span><span style="color: #869d6a">'Hello'</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">21</span> } | ||
<span class="line"><span class="number">22</span> } | ||
<span class="line"><span class="number">23</span> </span> | ||
</span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<pre><code><span class="line"><span class="number"> 9</span> * the LICENSE file that was distributed with this source code. | ||
<span class="line"><span class="number">10</span> */ | ||
<span class="line"><span class="number">11</span> | ||
<span class="line"><span class="number">12</span> </span><span style="color: #f1ce61;">namespace </span><span style="color: #c7c7c7">Tests</span><span style="color: #f1ce61;">\</span><span style="color: #c7c7c7">Support</span><span style="color: #f1ce61;">\</span><span style="color: #c7c7c7">Controllers</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">13</span> | ||
<span class="line"><span class="number">14</span> use </span><span style="color: #c7c7c7">CodeIgniter</span><span style="color: #f1ce61;">\</span><span style="color: #c7c7c7">Controller</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">15</span> | ||
<span class='line highlight'><span class='number'>16</span> class Hello extends Controller | ||
</span></span><span style="color: #c7c7c7"></span><span style="color: #f1ce61;"></span><span style="color: #c7c7c7"><span class="line"><span class="number">17</span> </span><span style="color: #f1ce61;">{ | ||
<span class="line"><span class="number">18</span> public function </span><span style="color: #c7c7c7">index</span><span style="color: #f1ce61;">() | ||
<span class="line"><span class="number">19</span> { | ||
<span class="line"><span class="number">20</span> return </span><span style="color: #869d6a">'Hello'</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">21</span> } | ||
<span class="line"><span class="number">22</span> } | ||
<span class="line"><span class="number">23</span> </span> | ||
</span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<pre><code><span class="line"><span class="number"> 9</span> * the LICENSE file that was distributed with this source code. | ||
<span class="line"><span class="number">10</span> */ | ||
<span class="line"><span class="number">11</span> | ||
<span class="line"><span class="number">12</span> </span><span style="color: #f1ce61;">namespace </span><span style="color: #c7c7c7">Tests\Support\Controllers</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">13</span> | ||
<span class="line"><span class="number">14</span> use </span><span style="color: #c7c7c7">CodeIgniter\Controller</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">15</span> | ||
<span class='line highlight'><span class='number'>16</span> class Hello extends Controller | ||
</span></span><span style="color: #c7c7c7"></span><span style="color: #f1ce61;"></span><span style="color: #c7c7c7"><span class="line"><span class="number">17</span> </span><span style="color: #f1ce61;">{ | ||
<span class="line"><span class="number">18</span> public function </span><span style="color: #c7c7c7">index</span><span style="color: #f1ce61;">() | ||
<span class="line"><span class="number">19</span> { | ||
<span class="line"><span class="number">20</span> return </span><span style="color: #869d6a">'Hello'</span><span style="color: #f1ce61;">; | ||
<span class="line"><span class="number">21</span> } | ||
<span class="line"><span class="number">22</span> } | ||
<span class="line"><span class="number">23</span> </span> | ||
</span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CodeIgniter\Test; | ||
|
||
use ReflectionException; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @group Others | ||
*/ | ||
final class IniTestTraitTest extends CIUnitTestCase | ||
{ | ||
use IniTestTrait; | ||
|
||
/** | ||
* @throws ReflectionException | ||
*/ | ||
public function testBackupAndRestoreIniValues(): void | ||
{ | ||
$this->backupIniValues(['highlight.default']); | ||
$backup = $this->getPrivateProperty($this, 'iniSettings'); | ||
$this->assertSame('#0000BB', $backup['highlight.default']); | ||
|
||
ini_set('highlight.default', '#FFFFFF'); | ||
$this->assertSame('#FFFFFF', ini_get('highlight.default')); | ||
|
||
$this->restoreIniValues(); | ||
$this->assertSame('#0000BB', ini_get('highlight.default')); | ||
|
||
$backup = $this->getPrivateProperty($this, 'iniSettings'); | ||
$this->assertSame([], $backup); | ||
} | ||
} |