Skip to content

Commit

Permalink
Changed method names
Browse files Browse the repository at this point in the history
  • Loading branch information
sspat committed Jan 24, 2020
1 parent 0328648 commit b765703
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ $isReserved = $reservedWords->isReserved($word);
/**
* Checks that the word cannot be used as a constant name in your current php version.
*/
$cannotUseAsConstantName = $reservedWords->cannotUseAsConstantName($word);
$cannotUseAsConstantName = $reservedWords->isReservedConstantName($word);
/**
* Checks that the word cannot be used as a namespace part or class/interface/trait name in your current php version.
*/
$cannotUseAsNamespaceName = $reservedWords->cannotUseAsNamespaceName($word);
$cannotUseAsNamespaceName = $reservedWords->isReservedNamespaceName($word);
/**
* Checks that the word cannot be used as a function name in your current php version.
*/
$cannotUseAsFunctionName = $reservedWords->cannotUseAsFunctionName($word);
$cannotUseAsFunctionName = $reservedWords->isReservedFunctionName($word);
/**
* Checks that the word cannot be used as a method name in your current php version.
*/
$cannotUseAsMethodName = $reservedWords->cannotUseAsMethodName($word);
$cannotUseAsMethodName = $reservedWords->isReservedMethodName($word);

/**
* The following methods also accept a second parameter, to check against a PHP version different than your current runtime
*/
$cannotUseAsConstantName = $reservedWords->cannotUseAsConstantName($word, '5.6');
$cannotUseAsNamespaceName = $reservedWords->cannotUseAsNamespaceName($word, '5.6.1');
$cannotUseAsFunctionName = $reservedWords->cannotUseAsFunctionName($word, '7.0');
$cannotUseAsMethodName = $reservedWords->cannotUseAsMethodName($word, '7.4.2');
$cannotUseAsConstantName = $reservedWords->isReservedConstantName($word, '5.6');
$cannotUseAsNamespaceName = $reservedWords->isReservedNamespaceName($word, '5.6.1');
$cannotUseAsFunctionName = $reservedWords->isReservedFunctionName($word, '7.0');
$cannotUseAsMethodName = $reservedWords->isReservedMethodName($word, '7.4.2');
```
8 changes: 4 additions & 4 deletions src/ReservedWords.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,31 @@ public function isReserved(string $string) : bool
/**
* Checks that the word cannot be used as a constant name
*/
public function cannotUseAsConstantName(string $string, ?string $phpVersion = null) : bool
public function isReservedConstantName(string $string, ?string $phpVersion = null) : bool
{
return $this->isReservedAs($string, 'constant', $phpVersion);
}

/**
* Checks that the word cannot be used as a namespace part or class/interface/trait name
*/
public function cannotUseAsNamespaceName(string $string, ?string $phpVersion = null) : bool
public function isReservedNamespaceName(string $string, ?string $phpVersion = null) : bool
{
return $this->isReservedAs($string, 'namespace', $phpVersion);
}

/**
* Checks that the word cannot be used as a function name
*/
public function cannotUseAsFunctionName(string $string, ?string $phpVersion = null) : bool
public function isReservedFunctionName(string $string, ?string $phpVersion = null) : bool
{
return $this->isReservedAs($string, 'function', $phpVersion);
}

/**
* Checks that the word cannot be used as a method name
*/
public function cannotUseAsMethodName(string $string, ?string $phpVersion = null) : bool
public function isReservedMethodName(string $string, ?string $phpVersion = null) : bool
{
return $this->isReservedAs($string, 'method', $phpVersion);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/ReservedWordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testConstantName(
) : void {
$reservedWords = new ReservedWords([$reservedWord => $reservedWordParameters]);

$this->assertEquals($isReserved, $reservedWords->cannotUseAsConstantName($reservedWord, $phpVersion));
$this->assertEquals($isReserved, $reservedWords->isReservedConstantName($reservedWord, $phpVersion));
}

/**
Expand All @@ -65,7 +65,7 @@ public function testNamespaceName(
) : void {
$reservedWords = new ReservedWords([$reservedWord => $reservedWordParameters]);

$this->assertEquals($isReserved, $reservedWords->cannotUseAsNamespaceName($reservedWord, $phpVersion));
$this->assertEquals($isReserved, $reservedWords->isReservedNamespaceName($reservedWord, $phpVersion));
}

/**
Expand All @@ -81,7 +81,7 @@ public function testFunctionName(
) : void {
$reservedWords = new ReservedWords([$reservedWord => $reservedWordParameters]);

$this->assertEquals($isReserved, $reservedWords->cannotUseAsFunctionName($reservedWord, $phpVersion));
$this->assertEquals($isReserved, $reservedWords->isReservedFunctionName($reservedWord, $phpVersion));
}

/**
Expand All @@ -97,7 +97,7 @@ public function testMethodName(
) : void {
$reservedWords = new ReservedWords([$reservedWord => $reservedWordParameters]);

$this->assertEquals($isReserved, $reservedWords->cannotUseAsMethodName($reservedWord, $phpVersion));
$this->assertEquals($isReserved, $reservedWords->isReservedMethodName($reservedWord, $phpVersion));
}

/**
Expand Down

0 comments on commit b765703

Please sign in to comment.