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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class NullDefinedInVariableFirst
public function getTitle()
{
$title = null;
return trim((string) $title);
return trim('');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

final class CaseInsensitiveFunctionName
{
public function run($var)
{
return strToLower($var);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

/**
* Crypt requires 2 args since php 5.6, when it only fill 1st arg, it will only change 1st arg
*
* Note: Filling 2nd arg will require different Rule to match the salt algorithm.
*/
final class CryptOneArg
{
public function run($subject)
{
crypt($subject);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

trait ExplicitMixedInTrait
{
public function setTitle(mixed $title)
{
$this->title = $title;
return trim($this->title);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

final class NamedArgument
{
public function run($subject)
{
preg_split(subject: $subject, pattern: '#a#');
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

final class NonStringParamType
{
public function run($subject)
{
preg_split('#a#', $subject);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

final class NonStringParamTypeInUseClosure
{
public function run($subject)
{
function () use ($subject) {
preg_split('#a#', $subject);
};
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

trait NormalVariableInTrait
{
public function getTitle($title)
{
return trim($title);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

final class TernaryWithInts
{
public function run($value)
{
explode(
',',
(string) $value ? 100 : 500
);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

final class WithExistingCastOnTernary
{
public function run()
{
return $relpath
. '/' . rawurlencode((string) $this->Get('account_code') ?: $this->Get('customer_id'));
}

public function run2()
{
return $relpath
. '/' . rawurlencode((string) $this->Get('account_code') ?: null);
}

public function Get($fieldname)
{
return $this->{$fieldname} ?? null;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

class WithNullableDocblock
{
/**
* @var string|null
*/
public $importedId;

/**
* @param string|null $importedId
*/
public function setImportedId($importedId) {
if (strlen($this->importedId) > 0) {
$this->importedId = $importedId;
}
}
}

?>
Loading
Loading