Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 src/PHPSemVerChecker/Analyzer/ClassAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function analyze(Registry $registryBefore, Registry $registryAfter)
if ($classBefore != $classAfter) {
// Check for case change of class name.
// If we entered this section then the normalized names (lowercase) were equal.
if ($classBefore->name !== $classAfter->name) {
if ($classBefore->name->toString() !== $classAfter->name->toString()) {
$report->add(
$this->context,
new ClassCaseChanged(
Expand Down
26 changes: 26 additions & 0 deletions src/PHPSemVerChecker/Analyzer/ClassMethodAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PHPSemVerChecker\Operation\ClassMethodParameterTypingAdded;
use PHPSemVerChecker\Operation\ClassMethodParameterTypingRemoved;
use PHPSemVerChecker\Operation\ClassMethodRemoved;
use PHPSemVerChecker\Operation\ClassMethodReturnTypeAdded;
use PHPSemVerChecker\Operation\ClassMethodReturnTypeChanged;
use PHPSemVerChecker\Operation\ClassMethodReturnTypeRemoved;
use PHPSemVerChecker\Report\Report;

class ClassMethodAnalyzer
Expand Down Expand Up @@ -109,6 +112,29 @@ public function analyze(Stmt $contextBefore, Stmt $contextAfter)
);
}

if ($methodBefore->returnType !== $methodAfter->returnType) {
$class = ClassMethodCaseChanged::class;
if ($methodBefore->returnType === null) {
$class = ClassMethodReturnTypeAdded::class;
} elseif ($methodAfter->returnType === null) {
$class = ClassMethodReturnTypeRemoved::class;
} elseif ($methodAfter->returnType->name !== $methodBefore->returnType->name) {
$class = ClassMethodReturnTypeChanged::class;
}
$report->add(
$this->context,
new $class(
$this->context,
$this->fileBefore,
$contextAfter,
$methodBefore,
$this->fileAfter,
$contextAfter,
$methodAfter
)
);
}

$signatureResult = Signature::analyze($methodBefore->getParams(), $methodAfter->getParams());

$changes = [
Expand Down
2 changes: 1 addition & 1 deletion src/PHPSemVerChecker/Analyzer/InterfaceAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function analyze(Registry $registryBefore, Registry $registryAfter)
if ($interfaceBefore != $interfaceAfter) {
// Check if the name of the interface has changed case.
// If we entered this section then the normalized names (lowercase) were equal.
if ($interfaceBefore->name !== $interfaceAfter->name) {
if ($interfaceBefore->name->toString() !== $interfaceAfter->name->toString()) {
$report->add(
'interface',
new InterfaceCaseChanged(
Expand Down
2 changes: 1 addition & 1 deletion src/PHPSemVerChecker/Analyzer/TraitAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function analyze(Registry $registryBefore, Registry $registryAfter)
if ($traitBefore != $traitAfter) {
// Check for name case change.
// If we entered this section then the normalized names (lowercase) were equal.
if ($traitBefore->name !== $traitAfter->name) {
if ($traitBefore->name->toString() !== $traitAfter->name->toString()) {
$report->add(
$this->context,
new TraitCaseChanged(
Expand Down
6 changes: 6 additions & 0 deletions src/PHPSemVerChecker/Configuration/LevelMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ class LevelMapping
'V158' => Level::PATCH,
'V159' => Level::PATCH,
'V160' => Level::PATCH,
'V161' => Level::PATCH,
'V162' => Level::PATCH,
'V163' => Level::PATCH,
'V164' => Level::PATCH,
'V165' => Level::PATCH,
'V166' => Level::PATCH,
];

/**
Expand Down
19 changes: 19 additions & 0 deletions src/PHPSemVerChecker/Operation/ClassMethodReturnTypeAdded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace PHPSemVerChecker\Operation;

class ClassMethodReturnTypeAdded extends ClassMethodOperationDelta
{
/**
* @var array
*/
protected $code = [
'class' => ['V161'],
'interface' => ['V162'],
'trait' => ['V163'],
];
/**
* @var string
*/
protected $reason = 'Method return type added.';
}
19 changes: 19 additions & 0 deletions src/PHPSemVerChecker/Operation/ClassMethodReturnTypeChanged.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace PHPSemVerChecker\Operation;

class ClassMethodReturnTypeChanged extends ClassMethodOperationDelta
{
/**
* @var array
*/
protected $code = [
'class' => ['V164'],
'interface' => ['V165'],
'trait' => ['V166'],
];
/**
* @var string
*/
protected $reason = 'Method return type changed.';
}
19 changes: 19 additions & 0 deletions src/PHPSemVerChecker/Operation/ClassMethodReturnTypeRemoved.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace PHPSemVerChecker\Operation;

class ClassMethodReturnTypeRemoved extends ClassMethodOperationDelta
{
/**
* @var array
*/
protected $code = [
'class' => ['V164'],
'interface' => ['V165'],
'trait' => ['V166'],
];
/**
* @var string
*/
protected $reason = 'Method return type removed.';
}