Skip to content

Commit

Permalink
Merge pull request #24081 from seamuslee001/php81_trait
Browse files Browse the repository at this point in the history
[NFC][PHP8.1] Ensure that Trait function is only accessed by classes …
  • Loading branch information
demeritcowboy authored Jul 30, 2022
2 parents 5c84a37 + 04e4f41 commit e2f0cab
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/phpunit/CRM/Core/Resources/CollectionTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@
*/
trait CRM_Core_Resources_CollectionTestTrait {

use CRM_Core_Resources_CollectionAdderTrait;

/**
* Add an item to the collection.
*
* @param array $snippet
* @return array
* The full/computed snippet (with defaults applied).
* @see CRM_Core_Resources_CollectionInterface::add()
* @see CRM_Core_Resources_CollectionTrait::add()
*/
public function add($snippet) {
return $snippet;
}

/**
* Locate the 'settings' snippet.
*
* @param array $options
* @return array
* @see CRM_Core_Resources_CollectionTrait::findCreateSettingSnippet()
*/
public function &findCreateSettingSnippet($options = []): array {
return $options;
}

/**
* @return \CRM_Core_Resources_CollectionInterface
*/
Expand Down Expand Up @@ -329,7 +355,7 @@ public function testAddBundle() {
*/
public function testStandardSplatParser() {
$parse = function(...$options) {
return CRM_Core_Resources_CollectionAdderTrait::mergeStandardOptions($options, []);
return self::mergeStandardOptions($options, []);
};
$this->assertEquals([], $parse());
$this->assertEquals(['weight' => '100'], $parse('100'));
Expand All @@ -346,7 +372,7 @@ public function testStandardSplatParser() {
*/
public function testSettingsSplatParser() {
$parse = function(...$options) {
return CRM_Core_Resources_CollectionAdderTrait::mergeSettingOptions($options, []);
return self::mergeSettingOptions($options, []);
};
$this->assertEquals([], $parse());
$this->assertEquals(['region' => 'oakaneigh'], $parse('oakaneigh'));
Expand Down

0 comments on commit e2f0cab

Please sign in to comment.