Skip to content
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

Access to undefined property #60

Open
pattisahusiwa opened this issue Oct 9, 2020 · 9 comments
Open

Access to undefined property #60

pattisahusiwa opened this issue Oct 9, 2020 · 9 comments

Comments

@pattisahusiwa
Copy link
Contributor

$verbosity is not defined.

$this->set('verbosity', ($this->verbosity ?? 0) + 1);

@adhocore
Copy link
Owner

adhocore commented Oct 9, 2020

should not happen, because of null coalesce

@pattisahusiwa
Copy link
Contributor Author

Unit test failed when adding $verbosity to Command class

@adhocore
Copy link
Owner

adhocore commented Oct 9, 2020

hmm verbosity, help, version etc are reserved members, best to use something else

@pattisahusiwa
Copy link
Contributor Author

These errors are reported by phpstan with error level 3. You can check the changes in my fork.

 ------ -----------------------------------------------------------------------------------------------------------
  Line   src/Application.php
 ------ -----------------------------------------------------------------------------------------------------------
  260    Method Ahc\Cli\Application::parse() should return Ahc\Cli\Input\Command but returns Ahc\Cli\Input\Parser.
 ------ -----------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------
  Line   src/Helper/Shell.php
 ------ -------------------------------------------------------------------------------
  181    Property Ahc\Cli\Helper\Shell::$processStartTime (int) does not accept float.
 ------ -------------------------------------------------------------------------------

 ------ --------------------------------------------------------------------
  Line   src/Input/Command.php
 ------ --------------------------------------------------------------------
  92     Access to an undefined property Ahc\Cli\Input\Command::$verbosity.
 ------ --------------------------------------------------------------------

 ------ --------------------------------------------------------------------------------
  Line   src/Input/Parser.php
 ------ --------------------------------------------------------------------------------
  248    Array (array<Ahc\Cli\Input\Argument>) does not accept Ahc\Cli\Input\Parameter.
 ------ --------------------------------------------------------------------------------

 ------ -------------------------------------------------------------
  Line   tests/Output/ColorTest.php
 ------ -------------------------------------------------------------
  34     Call to an undefined method Ahc\Cli\Output\Color::alert().
  66     Call to an undefined method Ahc\Cli\Output\Color::bold().
  71     Call to an undefined method Ahc\Cli\Output\Color::bgRed().
  76     Call to an undefined method Ahc\Cli\Output\Color::purple().
  84     Call to an undefined method Ahc\Cli\Output\Color::random().
 ------ -------------------------------------------------------------

 ------ ----------------------------------------------------------------
  Line   tests/Output/WriterTest.php
 ------ ----------------------------------------------------------------
  30     Access to an undefined property Ahc\Cli\Output\Writer::$error.
  46     Access to an undefined property Ahc\Cli\Output\Writer::$bold.
  56     Call to an undefined method Ahc\Cli\Output\Writer::clear().
 ------ ----------------------------------------------------------------

 [ERROR] Found 12 errors

@pattisahusiwa
Copy link
Contributor Author

When adding $verbosity property to Command or Parser class, this test fails because $p->verbosity = 0. To continue working on phpstan, this issue needs to be addressed.

public function test_verbosity()
{
$p = $this->newCommand()->parse(['php', '-vv', '-vvv']);
$this->assertSame(5, $p->verbosity);
}

@adhocore
Copy link
Owner

hmm some of that is happening because we have code without declare strict_types.

@adhocore
Copy link
Owner

i'm on a vacation for few more days, will take time to look into it

@pattisahusiwa
Copy link
Contributor Author

What's new?

@adhocore
Copy link
Owner

nothing new :)

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

No branches or pull requests

2 participants