Project

General

Profile

Actions

Bug #77106

closed

Error in TYPO3\CMS\Extbase\Domain\Model\FileReference::setOriginalResource caused by incompatible Declaration

Added by Dirk Wenzel over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2016-07-15
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
On Location Sprint

Description

While running unit test for a model with file references I got the following error

./bin/phpunit -c typo3/sysext/core/Build/UnitTests.xml typo3conf/ext/t3events/Tests/Unit/
PHPUnit 4.8.13 by Sebastian Bergmann and contributors.
[...]

There was 1 error:

1) Webfox\T3events\Tests\Unit\Domain\Model\PersonTest::imageCanBeAdded
Declaration of TYPO3\CMS\Extbase\Domain\Model\FileReference::setOriginalResource(TYPO3\CMS\Core\Resource\FileReference $originalResource) 
should be compatible with TYPO3\CMS\Extbase\Domain\Model\AbstractFileFolder::setOriginalResource(TYPO3\CMS\Core\Resource\ResourceInterface $originalResource)

/home/vagrant/UnitTests/typo3/sysext/extbase/Classes/Domain/Model/FileReference.php:22
/home/vagrant/UnitTests/vendor/typo3/class-alias-loader/src/ClassAliasLoader.php:130
/home/vagrant/UnitTests/vendor/typo3/class-alias-loader/src/ClassAliasLoader.php:169
/home/vagrant/UnitTests/vendor/typo3/class-alias-loader/src/ClassAliasLoader.php:120
/home/vagrant/UnitTests/typo3conf/ext/t3events/Tests/Unit/Domain/Model/PersonTest.php:394
/home/vagrant/UnitTests/vendor/phpunit/phpunit/phpunit:47

Model (Extract):

<?php
namespace Webfox\T3events\Domain\Model;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;

class Person extends AbstractEntity {

    /**
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     * @lazy
     */
    protected $images;

    /**
     *
     */
    public function initializeObject() {
        $this->images = new ObjectStorage();
    }

    /**
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    public function getImages()
    {
        return $this->images;
    }

    /**
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $images
     */
    public function setImages($images)
    {
        $this->images = $images;
    }

    /**
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $fileReference
     */
    public function addImage(FileReference $fileReference) {
        $this->images->attach($fileReference);
    }

    /**
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $fileReference
     */
    public function removeImage(FileReference $fileReference) {
        $this->images->detach($fileReference);
    }
}

Actions

Also available in: Atom PDF