-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use object of type stdClass as array in ComposerJson.php #1
Comments
I was able to get it working (only by) using the following, however it required the external library being inside the module file, which I don't want: function phpword_xautoload($adapter) {
$adapter->addPsr4('PHPOffice\PHPWord\\', 'phpword/src/PhpWord');
$adapter->addClassmapSources(array('src'));
} Furthermore, another big issue I've found so far is that if I try and use
Libraries is the latest version too. Curiouser and curiouser... Cheers, Matt Update: Seems that using a string as a reference to the function like in this fixes the closure issue! |
Hi! Also interesting: |
I will have more time for this on the weekend or beginning of next week. |
There was more stuff broken in ComposerJson and ComposerJsonTargetDir. |
I thought this is fixed since 7.x-5.0-beta2. |
7.x-5.0-beta3 released. |
Hi Andreas, Thanks so much for the speedy reply. I bumped the version up, played about a bit and finally actually got it to work from libraries, so I'm pretty pleased now! Final version required the following: 'xautoload' => function($adapter) {
$adapter->addPsr4('PHPOffice\PHPWord\\', 'src/PhpWord');
$adapter->ComposerJson('composer.json');
} I think partially I was confused that I would have to register it as PSR-4, as that's mentioned in the Many thanks once again! |
If the addPsr4() is necessary then there is something wrong. |
It is indeed the correct file- but yeah, it didn't work without the addPsr4()... |
I am playing around with this myself now. On Mon, Jun 30, 2014 at 3:23 PM, Matt Fletcher [email protected]
|
It works for me without addPsr4(), but you might have to clear a cache. |
Strange. I commented out the addPsr4 line, drush cc all'ed, ran my test script and as before it couldn't find the classes any more, so I've not been able to reproduce it without that line unfortunately 😩 |
Can you share the module? And the place where you use the library classes? |
I can, but as it's currently part of a big, closed-source system I'll have to migrate it out to an open repo. Bear with me! |
Okay, here it is so far https://github.com/MaffooBristol/drupal-phpword (very early stages). Libraries/xautoload hooks are in the module file, class usage is in the inc file. Library's been added in as sites/all/libraries/phpword/etc/etc too Thanks (PHPWord version 0.11.1 btw) |
Ok, what is the class that is not found, and what is the stack trace? |
Here: https://github.com/MaffooBristol/drupal-phpword/blob/master/phpword.inc#L63 (The first instance of trying to call a class that is in a file that's not defined within |
Got it. It's a spelling thing - uppercase/lowercase. It must be "PhpOffice\PhpWord..", not "PHPOffice\PHPWord.." And btw you don't need the \PHPOffice\PhpWord\Autoloader::register(), if you have xautoload doing the job. |
Oh god... you're right. Haha. I've seen and written it so far as phpword, phpWord, PhpWord, PHPWord, PHPword... at least we sorted out it was my fault in the end ;) Thanks for the tip too! |
Hey, I'm getting the error listed below whilst trying to use xautoload.
Brief overview: I'm currently making a wrapper module for the PHPWord library, which uses the namespace
\PHPOffice\PHPWord
. I'm adding the 3rd party API using the libraries module, and I've tried using xautoload as a closure withinhook_libraries_info()
and as a separate hook. Code snippet is as follows:The error is here:
When I tried to investigate the cause of the error, I saw that the
$data
variable is indeed a class not an array, and that there is no 'target-dir' property available, which is peculiar as I was to believe that I'd followed the same instructions as in the documentation.Any ideas? Thanks :)
( ! ) Fatal error: Cannot use object of type stdClass as array in sites/all/modules/contrib/xautoload/lib/Discovery/ComposerJson.php on line 47
The text was updated successfully, but these errors were encountered: