Task #57992

Make package HHVM compatible - failing getPackageReturnsTheSpecifiedPackage test

Added by Tymoteusz Motylewski over 5 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2014-04-16
Due date:
% Done:

100%


Description

the PackageManagerTest::getPackageReturnsTheSpecifiedPackage is failing on hhvm, because it HHVM doesn't support calling key() on objects.
So it is failing now with "Fatal error: Cannot access empty property in..."
Responsible code is in Package->getNamespace()

$namespaces = $manifest->autoload->{'psr-0'};
if (count($namespaces) === 1) {
    $namespace = key($namespaces);
}

it can be solved by first cast object to an array

$namespaces = (array)$manifest->autoload->{'psr-0'};
if (count($namespaces) === 1) {
    $namespace = key($namespaces);
}

quote from
https://github.com/facebook/hhvm/blob/master/hphp/doc/inconsistencies#L90-95
about this inconsistency:

(5) Object internal cursors

Under Zend PHP, objects have an internal cursor (similar to the array internal
cursor) that can be used to iterate over the object's properties. Under HipHop
VM, objects do not have internal cursors, and the next(), prev(), current(),
key(), reset(), end(), and each() builtin functions do not support objects.


Related issues

Related to TYPO3 Core - Task #57993: Make package HHVM compatible - failing getPackageReturnsTheSpecifiedPackage test Closed 2014-04-16

Associated revisions

Revision ae4b77ca (diff)
Added by Tymoteusz Motylewski over 5 years ago

[TASK] Make Flow Package/Package HHVM compatible

HHVM doesn't support calling array functions like key()
on objects, we need to cast object to array first.

Resolves: #57992
Releases: master
Change-Id: I20777f78f63f512a104c4e144aa29cbedafe0f23

Revision 85dea6c8 (diff)
Added by Bastian Waidelich over 5 years ago

[BUGFIX] Fix basic support for packages with multiple PSR-0/4 mappings

Some (3rd party) package define multiple autoload mappings for
different PHP namespaces in their composer manifest, for example::

"autoload": {
"psr-0": {
"SomeNamespace": "lib/",
"SomeNamespace\\Test": "test/lib/"
}
}

Flow does not yet support multiple autoload mappings but it always
just ignored everything but the first mapping.
With I20777f78f63f512a104c4e144aa29cbedafe0f23 this is no longer the
case and an exception is thrown for packages with more than one
mapping per autoloader type.

This change reintroduces the previous behavior and fixes some minor
bugs along the way.

Background:
Because ``Package::getComposerManifest()`` returns a ``stdClass`` the
code ``count($namespaces) === 1`` always evaluated TRUE.
By casting the manifest to an array (for better HVVM support) this is
no longer the case and the exception is thrown.

In the long run we should replace the stdClass by an associative array
or DTO and introduce real support for multiple autoload mappings.

This change also fixes some minor issues and adds some unit tests.

Change-Id: Ic737cfd2e48c9547c865772d1a6cdd4153ea63bb
Related: #57992
Releases: master

History

#1 Updated by Gerrit Code Review over 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/29509

#2 Updated by Stefan Neufeind over 5 years ago

Merged in Flow-package for TYPO3 CMS. https://review.typo3.org/#/c/29508/
Imho it would be great if you could please consider this adjustment as well.

#3 Updated by Tymoteusz Motylewski over 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
  • translation missing: en.field_remaining_hours set to 0.0

Also available in: Atom PDF