coenjacobs / mozart

Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace, in order to prevent conflicts with other plugins loading the same dependencies in different versions.
https://coenjacobs.me/projects/mozart/
MIT License
424 stars 52 forks source link

Brain-WP/Cortex incompatibility: PHP Fatal error: Uncaught Error: Call to undefined function Brain\did_action() #14

Open wujekbogdan opened 5 years ago

wujekbogdan commented 5 years ago

After running "vendor/bin/mozart" compose I'm getting the following error:

PHP Fatal error:  Uncaught Error: Call to undefined function Brain\did_action() in /Users/my_user_name/htdocs/wordpress/wp-content/themes/my-tmene-name/vendor/brain/cortex/src/Cortex.php:55

My package.json

{
  // ...
  "require": {
    "composer/installers": "~1.0",
    "timber/timber": "^1.5",
    "abraham/twitteroauth": "^0.7.4",
    "defuse/php-encryption": "^2.1",
    "guzzlehttp/guzzle": "^6.3",
    "brain/cortex": "~1.0.0@dev",
    "symfony/var-dumper": "^4.2.0",
    "monolog/monolog": "^1.24.0",
    "google/cloud-firestore": "^1.0.0"
  },
  "autoload": {
    "psr-4": {
      "Sw\\": "lib/Sw/",
      "Vendor\\": "build/"
    },
    "files": [
     // some files
    ]
  },
  "require-dev": {
    "coenjacobs/mozart": "^0.3.0"
  },
  "extra": {
    "mozart": {
      "dep_namespace": "Vendor\\",
      "dep_directory": "/build/",
      "classmap_directory": "/classes/dependencies/",
      "classmap_prefix": "SW_",
      "packages": [
        "timber/timber"
      ]
    }
  },
  "scripts": {
    "post-install-cmd": [
      "\"vendor/bin/mozart\" compose",
      "composer dump-autoload"
    ],
    "post-update-cmd": [
      "\"vendor/bin/mozart\" compose",
      "composer dump-autoload"
    ]
  }
}
coenjacobs commented 5 years ago

Based on just this error, the error is within the package brain/cortex that you're requiring. It seems that you are trying to call a function within a namespace, while in reality you probably need the global did_action() function. Please share the lines of code that the error is referring to, but I'm afraid that's the case and therefore not a Mozart issue.

wujekbogdan commented 5 years ago

@coenjacobs I'm not calling the did_action() function, the library calls this function internally: see Cortex/Cortex.php#L55

ChristophWurst commented 4 years ago

Hi,

I'm currently fighting with rubix/ml and Mozart. I think I've run into the same issue, therefore I created a composer project from scratch to demonstrate the issue in isolation.

The function is imported at https://github.com/ChristophWurst/rubix-ml-mozart/blob/1344bfba014c8f2c9b7d4edca5c7cc1fddcf989b/lib/Vendor/Rubix/ML/Datasets/Dataset.php#L17. As you can see here, there the original function got namespaced for the import.

The definition, however, has the original namespace: https://github.com/ChristophWurst/rubix-ml-mozart/blob/1344bfba014c8f2c9b7d4edca5c7cc1fddcf989b/lib/Vendor/Rubix/ML/functions.php#L44.

Hope this makes it easier to debug :v: