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

Error: Call to a member function #55

Closed
bivilbi opened this issue Dec 5, 2019 · 2 comments
Closed

Error: Call to a member function #55

bivilbi opened this issue Dec 5, 2019 · 2 comments

Comments

@bivilbi
Copy link

bivilbi commented Dec 5, 2019

Good afternoon.
Put through composer require mjaschen/phpgeo (php 7.2).
I try to use an example from the description

`<?php
use Location\Bearing\BearingEllipsoidal;
use Location\Bearing\BearingSpherical;
use Location\Coordinate;
use Location\Formatter\Coordinate\DecimalDegrees;

$berlin = new Coordinate(52.5, 13.5);

$bearingSpherical = new BearingSpherical();
$bearingEllipsoidal = new BearingEllipsoidal();

$destination1 = $BearingSpherical->calculateDestination($berlin, 153, 56100);
$destination2 = $bearingEllipsoidal->calculateDestination($berlin, 153, 56100);

echo "Spherical: " . $destination1->format(new DecimalDegrees()) . PHP_EOL;
echo "Ellipsoidal: " . $destination2->format(new DecimalDegrees()) . PHP_EOL;
`

I receive an error.
Uncaught Error: Call to a member function calculateDestination() on null in ...

But all other functions work.
What could be wrong?
Thanks.

@mjaschen
Copy link
Owner

mjaschen commented Dec 5, 2019

Hi,

$bearingSpherical = new BearingSpherical();
$bearingEllipsoidal = new BearingEllipsoidal();

$destination1 = $BearingSpherical->calculateDestination($berlin, 153, 56100);
$destination2 = $bearingEllipsoidal->calculateDestination($berlin, 153, 56100);

In the line

$bearingSpherical = new BearingSpherical();

an instance named $bearingSpherical is created (name begins with b), while in

$destination1 = $BearingSpherical->calculateDestination($berlin, 153, 56100);

the instance name begins with a captial letter B.

Probably the problem vanishes after fixing the name.

@bivilbi
Copy link
Author

bivilbi commented Dec 5, 2019

That's right! Thanks!

@mjaschen mjaschen closed this as completed Dec 5, 2019
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