Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
# lowest and highest supported PHP only, to keep CI cheap
php: ['7.4', '8.3']
php: ['7.4', '8.5']
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion KeyLighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function registeredFormatters()
return $this->_formatters;
}

public function highlight($source, Language $language, FormatterInterface $formatter = null)
public function highlight($source, Language $language, ?FormatterInterface $formatter = null)
{
$formatter = $formatter ?: $this->getDefaultFormatter();
return $formatter->format($language->parse($source));
Expand Down
2 changes: 1 addition & 1 deletion Matcher/CommentMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CommentMatcher implements MatcherInterface
* @param array $singleLine
* @param array $multiLine
*/
public function __construct(array $singleLine = null, array $multiLine = null)
public function __construct(?array $singleLine = null, ?array $multiLine = null)
{
$this->singleLine = $singleLine ?: [];
$this->multiLine = $multiLine ?: [];
Expand Down
4 changes: 2 additions & 2 deletions Parser/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Context
public $stack = [];
public $language;

public function __construct(Language $language = null) {
public function __construct(?Language $language = null) {
$this->language = $language;
}

Expand Down Expand Up @@ -52,7 +52,7 @@ public function has($name) {
return in_array($name, $this->stack, true);
}

public static function fromArray(array $array, Language $language = null) {
public static function fromArray(array $array, ?Language $language = null) {
$context = new Context($language);
$context->stack = $array;
return $context;
Expand Down
2 changes: 1 addition & 1 deletion Parser/DelegateTokenFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DelegateTokenFactory implements TokenFactoryInterface
* @param callable (TokenFactoryInterface $factory, array $params) $function
* @param TokenFactoryInterface|null $factory
*/
public function __construct(callable $function, TokenFactoryInterface $factory = null) {
public function __construct(callable $function, ?TokenFactoryInterface $factory = null) {
$this->_factory = $factory ?: new TokenFactory(Token::class);
$this->_callable = $function;
}
Expand Down
2 changes: 1 addition & 1 deletion Parser/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Result extends \ArrayObject implements Tokens
private $_source;
private $_start;

public function __construct($source, Token $start = null)
public function __construct($source, ?Token $start = null)
{
$this->_source = $source;
$this->_start = $start;
Expand Down
2 changes: 1 addition & 1 deletion Parser/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Rule
* @param MatcherInterface|null $matcher
* @param array $options
*/
public function __construct(MatcherInterface $matcher = null, array $options = [])
public function __construct(?MatcherInterface $matcher = null, array $options = [])
{
$this->_matcher = $matcher;

Expand Down
2 changes: 1 addition & 1 deletion Parser/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getLanguage()
/**
* @param Language $language
*/
public function setLanguage(Language $language = null)
public function setLanguage(?Language $language = null)
{
$this->_language = $language;
}
Expand Down
7 changes: 7 additions & 0 deletions Parser/Token/LanguageToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@
*/
class LanguageToken extends Token
{
/**
* Declared to avoid dynamic property creation (deprecated in PHP 8.2). Unset when no
* injection is given so the value is resolved from the rule through Token::__get().
*/
public $inject;

public function __construct($name, $options = []) {
parent::__construct($name, $options);
unset($this->inject);
if(isset($options['inject'])) {
$this->inject = $options['inject'];
}
Expand Down
2 changes: 1 addition & 1 deletion Parser/TokenFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private function link($name, $params) {
private function getName($name)
{
if (!isset($this->_cache[$name])) {
$this->_cache[$name] = str_replace('$', $this->_base, $name);
$this->_cache[$name] = str_replace('$', (string) $this->_base, $name);
}

return $this->_cache[$name];
Expand Down
2 changes: 1 addition & 1 deletion Tests/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testEnable() {
$rule = new Rule(new WholeMatcher(), ['enabled' => false]);

$rule->enable();
$this->assertNotEmpty($rule->match('source'));
$this->assertNotEmpty(iterator_to_array($rule->match('source')));
}

public function testMatcherReturning() {
Expand Down
2 changes: 1 addition & 1 deletion bin/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct()
$this->setDefaultCommand('highlight');
}

public function run(InputInterface $input = null, OutputInterface $output = null)
public function run(?InputInterface $input = null, ?OutputInterface $output = null)
{
$output = $output ?: new ConsoleOutput();

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"require-dev": {
"symfony/console": "^2.8|^3.0",
"phpunit/phpunit": "^8.0"
"phpunit/phpunit": "^8.0 | ^9.6"
},
"suggest": {
"symfony/console": "Allows usage of keylighters CLI utility."
Expand Down
Loading
Loading