-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1959 from sabbelasichon/issue-1955
[TASK] Enhance OptionalConstructorToHardRequirementRector
- Loading branch information
Showing
7 changed files
with
173 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TYPO3\CMS\Core\Database; | ||
|
||
if (class_exists(Connection::class)) { | ||
return; | ||
} | ||
|
||
final class Connection | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace TYPO3\CMS\Core\Log; | ||
|
||
if(class_exists(LogManager::class)) { | ||
return null; | ||
} | ||
|
||
final class LogManager | ||
{ | ||
public function getLogger(string $class): Logger | ||
{ | ||
return new Logger(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
|
||
namespace TYPO3\CMS\Core\Log; | ||
|
||
if(class_exists(Logger::class)) { | ||
return null; | ||
} | ||
|
||
final class Logger | ||
{ | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
...s/Rector/Experimental/OptionalConstructorToHardRequirement/Fixture/fixture_logger.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\v10\v1\OptionalConstructorToHardRequirement\Fixture; | ||
|
||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; | ||
use TYPO3\CMS\Core\Database\Connection; | ||
use TYPO3\CMS\Core\Database\ConnectionPool; | ||
use TYPO3\CMS\Core\Log\Logger; | ||
use TYPO3\CMS\Core\Log\LogManager; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class MyClassWithLogManager | ||
{ | ||
/** | ||
* @var Logger | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* @var Connection | ||
*/ | ||
private $connection; | ||
|
||
/** | ||
* @var mixed|BackendUserAuthentication|null | ||
*/ | ||
private $backendUser; | ||
|
||
public function __construct(LogManager $logManager = null, ConnectionPool $connectionPool = null, BackendUserAuthentication $backendUser = null) | ||
{ | ||
$this->backendUser = $backendUser ?? $GLOBALS['BE_USER'] ?? null; | ||
$connectionPool = $connectionPool ?? GeneralUtility::makeInstance(ConnectionPool::class); | ||
$this->connection = $connectionPool->getConnectionForTable('sys_language'); | ||
$logManager = $logManager ?? GeneralUtility::makeInstance(LogManager::class); | ||
$this->logger = $logManager->getLogger(__CLASS__); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\v10\v1\OptionalConstructorToHardRequirement\Fixture; | ||
|
||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; | ||
use TYPO3\CMS\Core\Database\Connection; | ||
use TYPO3\CMS\Core\Database\ConnectionPool; | ||
use TYPO3\CMS\Core\Log\Logger; | ||
use TYPO3\CMS\Core\Log\LogManager; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class MyClassWithLogManager | ||
{ | ||
/** | ||
* @var Logger | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* @var Connection | ||
*/ | ||
private $connection; | ||
|
||
/** | ||
* @var mixed|BackendUserAuthentication|null | ||
*/ | ||
private $backendUser; | ||
|
||
public function __construct(LogManager $logManager, ConnectionPool $connectionPool, BackendUserAuthentication $backendUser = null) | ||
{ | ||
$this->backendUser = $backendUser ?? $GLOBALS['BE_USER'] ?? null; | ||
$this->connection = $connectionPool->getConnectionForTable('sys_language'); | ||
$this->logger = $logManager->getLogger(__CLASS__); | ||
} | ||
} | ||
|
||
?> |