Skip to content
Closed
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.

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

namespace Rector\Tests\Php80\Rector\Identical\StrEndsWithRector\Fixture;

class SkipLooseNumericString
{
public function run($haystack)
{
// '+1' == '01' is true
$isMatch = substr($haystack, -2) == '01';
}
}

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

namespace Rector\Tests\Php80\Rector\Identical\StrEndsWithRector\Fixture;

class SkipLooseSubstr
{
public function run()
{
$isMatch = substr($haystack, -strlen($needle)) == $needle;

$isMatch = $needle == substr($haystack, -strlen($needle));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert this? While technically it's correct removal, in legacy projects where this change would be valid most people use ==.

}

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

namespace Rector\Tests\Php80\Rector\Identical\StrEndsWithRector\Fixture;

class SkipLooseSubstrNotPrefix
{
public function run()
{
$isNotMatch = substr($haystack, -strlen($needle)) != $needle;

$isNotMatch = $needle != substr($haystack, -strlen($needle));
}
}

?>

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
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\Fixture;

class SkipLooseNotEqualSubstr
{
public function run()
{
$isNotMatch = substr($haystack, 0, strlen($needle)) != $needle;
}
}

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

namespace Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\Fixture;

class SkipLooseNumericString
{
public function run($haystack)
{
// '+1' == '01' is true
$isMatch = substr($haystack, 0, 2) == '01';
}
}

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

namespace Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\Fixture;

class SkipLooseStrpos
{
public function run()
{
$isMatch = strpos($haystack, $needle) == 0;
}
}

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

namespace Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\Fixture;

class SkipLooseStrposHardcoded
{
public function run()
{
$isMatch = strpos($haystack, 'hardcoded') == 0;
}
}

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

namespace Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\Fixture;

class SkipLooseStrposNotPrefix
{
public function run()
{
$notMatch = strpos($haystack, $needle) != 0;
}
}

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

namespace Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\Fixture;

class SkipLooseStrposOtherSide
{
public function run()
{
$isMatch = 0 == strpos($haystack, $needle);
}
}

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

namespace Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\Fixture;

class SkipLooseSubstr
{
public function run()
{
$isMatch = substr($haystack, 0, strlen($needle)) == $needle;
}
}

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

namespace Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\Fixture;

class SkipLooseSubstrOtherSide
{
public function run()
{
$isMatch = $needle == substr($haystack, 0, strlen($needle));

$isNotMatch = $needle != substr($haystack, 0, strlen($needle));
}
}

?>

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading