You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If I include/require a class that is namespaced while in drush php-cli, and subsequently call that class, the call fails with this error output:
The undefined key (265 above) varies depending on the input, for example if I invoke the class with a prepended backslash (absolute namespace) then the key cited is 263.
To Reproduce
Download drush-8.4.12
Create test file Foo.php in D7 document root containing namespaced class declaration (see below)
Execute drush.phar -l <my-site-url> php
In php-cli execute: include getcwd().'/Foo.php';
Execute: echo Bar\Foo::BAR;
Test file contents:
<?php
namespace Bar;
class Foo {
const BAR = 'baz';
}
Expected behavior
String baz printed on commandline
Actual behavior
Error output as above
Workaround
The equivalent expression(s) do not cause an error when the classname is given indirectly using a string:
>>> echo ('Bar\Foo')::BAR;
baz
System Configuration
Q
A
Drush version?
8.4.12
Drupal version?
7.x
PHP version
8.1
OS?
Linux
Additional information
I have extracted drush.phar and located the files/lines cited in the errors but this does not make the cause of the issue any clearer to me personally. In general terms, it appears that the command-line parser does not expect to find a backslash in this (perfectly valid in PHP) lexical position.
Calling class_exists('Bar\Foo') does not cause any error, nor does new ReflectionClass('Bar\Foo').
The text was updated successfully, but these errors were encountered:
Describe the bug
If I
include
/require
a class that is namespaced while indrush php-cli
, and subsequently call that class, the call fails with this error output:The undefined key (265 above) varies depending on the input, for example if I invoke the class with a prepended backslash (absolute namespace) then the key cited is 263.
To Reproduce
Foo.php
in D7 document root containing namespaced class declaration (see below)drush.phar -l <my-site-url> php
include getcwd().'/Foo.php';
echo Bar\Foo::BAR;
Test file contents:
Expected behavior
String
baz
printed on commandlineActual behavior
Error output as above
Workaround
The equivalent expression(s) do not cause an error when the classname is given indirectly using a string:
System Configuration
Additional information
I have extracted drush.phar and located the files/lines cited in the errors but this does not make the cause of the issue any clearer to me personally. In general terms, it appears that the command-line parser does not expect to find a backslash in this (perfectly valid in PHP) lexical position.
Calling
class_exists('Bar\Foo')
does not cause any error, nor doesnew ReflectionClass('Bar\Foo')
.The text was updated successfully, but these errors were encountered: