Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

PHP7 Declaration Warning #16

Open
kersten opened this issue Jan 8, 2016 · 4 comments
Open

PHP7 Declaration Warning #16

kersten opened this issue Jan 8, 2016 · 4 comments

Comments

@kersten
Copy link

kersten commented Jan 8, 2016

Hi,

since update to PHP7 pt_extbase does not work anymore:

PHP Warning: Declaration of Tx_PtExtbase_Registry_Registry::addItem($object, $label, $overwrite = false) should be compatible with Tx_PtExtbase_Collection_Collection::addItem($itemObj, $id = 0) in /var/www/webroot/typo3conf/ext/pt_extbase/Classes/Registry/Registry.php line 33

Could you please check this?

@kersten
Copy link
Author

kersten commented Jan 8, 2016

Collection.php

public function addItem($itemObj, $id = 0, $overwrite = false) {
        // add item if item type is validated
        if ($this->checkItemType($itemObj) == true) {
            if ($id === 0) {
                $this->itemsArr[] = $itemObj;
            } else {
                $this->itemsArr[$id] = $itemObj;
            }
        } else {
            // throw exception if item type is not validated
            throw new Tx_PtExtbase_Exception_Internal('Item to add to collection is of wrong type (' . get_class($itemObj) . '). 1316764449' );
        }
    }

Registry.php

public function addItem($itemObj, $id = 0, $overwrite = false ) {
        Tx_PtExtbase_Assertions_Assert::isNotEmpty($id, array('message' => 'Registry keys cannot be empty!'));

        if (!$this->hasItem($id) || $overwrite == true) {

            // add object to the collection
            parent::addItem($itemObj, $id);
        } else {
            throw new Exception('There is already an element stored with the label "'.$id.'" (and overwriting not permitted)!');
        }
    }

Helps, but I don't know if this is all

@hannesbochmann
Copy link

It would be great if this bug could be fixed.

@ghost
Copy link

ghost commented Jul 13, 2017

Came across this issue today too. Running PHP 7.0.21.

@hannesbochmann
Copy link

For the time being I attached a patch which can be used through composer.
PtExtBase-16.txt

I use the package cweagans/composer-patches to apply the patches automatically during composer updates/installs. composer.json should look like this:
{ "name": "mycompany/myproject", "type" : "project", "license": "proprietary", "version" : "0.0.1", "require" : { ... "punktde/pt_extbase" : "2.3.0", ... "cweagans/composer-patches": "~1.0" }, "extra" : { "patches": { "punktde/pt_extbase": { "patch for https://github.com/punktDe/pt_extbase/issues/16": "PtExtBase-16.txt" } } }, "minimum-stability":"dev", "_prefer-stable" : "true" }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants