Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 1d2a759

Browse files
committed
Merge branch 'hotfix/156'
Close #156
2 parents e4c8d1a + 42f9205 commit 1d2a759

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/Generator/ClassGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use function ltrim;
2929
use function sprintf;
3030
use function str_replace;
31+
use function strpos;
3132
use function strrpos;
3233
use function strstr;
3334
use function strtolower;
@@ -288,7 +289,7 @@ public function __construct(
288289
*/
289290
public function setName($name)
290291
{
291-
if (strstr($name, '\\')) {
292+
if (false !== strpos($name, '\\')) {
292293
$namespace = substr($name, 0, strrpos($name, '\\'));
293294
$name = substr($name, strrpos($name, '\\') + 1);
294295
$this->setNamespaceName($namespace);

src/Generator/DocBlock/TagManager.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use function method_exists;
1717
use function substr;
18+
use function strpos;
1819
use function ucfirst;
1920

2021
/**
@@ -57,12 +58,12 @@ public function createTagFromReflection(ReflectionTagInterface $reflectionTag)
5758
// transport any properties via accessors and mutators from reflection to codegen object
5859
$reflectionClass = new \ReflectionClass($reflectionTag);
5960
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
60-
if (substr($method->getName(), 0, 3) == 'get') {
61+
if (0 === strpos($method->getName(), 'get')) {
6162
$propertyName = substr($method->getName(), 3);
6263
if (method_exists($newTag, 'set' . $propertyName)) {
6364
$newTag->{'set' . $propertyName}($reflectionTag->{'get' . $propertyName}());
6465
}
65-
} elseif (substr($method->getName(), 0, 2) == 'is') {
66+
} elseif (0 === strpos($method->getName(), 'is')) {
6667
$propertyName = ucfirst($method->getName());
6768
if (method_exists($newTag, 'set' . $propertyName)) {
6869
$newTag->{'set' . $propertyName}($reflectionTag->{$method->getName()}());

src/Scanner/ConstantScanner.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use function reset;
2020
use function strtolower;
2121
use function substr;
22+
use function strpos;
2223
use function var_export;
2324

2425
class ConstantScanner implements ScannerInterface
@@ -217,7 +218,7 @@ protected function scan()
217218
case T_LNUMBER:
218219
$string = is_string($token) ? $token : $tokenContent;
219220

220-
if (substr($string, 0, 1) === '"' || substr($string, 0, 1) === "'") {
221+
if (0 === strpos($string, '"') || 0 === strpos($string, "'")) {
221222
$this->value = substr($string, 1, -1); // Remove quotes
222223
} else {
223224
$this->value = $string;

src/Scanner/PropertyScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ protected function scan()
316316
$this->valueType = self::T_INTEGER;
317317
} elseif (0 === strpos($value, 'array') || 0 === strpos($value, '[')) {
318318
$this->valueType = self::T_ARRAY;
319-
} elseif (substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'") {
319+
} elseif (0 === strpos($value, '"') || 0 === strpos($value, "'")) {
320320
$value = substr($value, 1, -1); // Remove quotes
321321
$this->valueType = self::T_STRING;
322322
}

0 commit comments

Comments
 (0)