I am trying to fix all these errors but no matter what i do it doesnt work.
[25-Apr-2018 13:57:20 UTC] PHP Warning: Declaration of FPDF::SetDrawColor() should be compatible with tFPDF::SetDrawColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 10
[25-Apr-2018 13:57:20 UTC] PHP Warning: Declaration of FPDF::SetFillColor() should be compatible with tFPDF::SetFillColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 10
[25-Apr-2018 13:57:20 UTC] PHP Warning: Declaration of FPDF::SetTextColor() should be compatible with tFPDF::SetTextColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 10 25-Apr-2018 13:57:20 UTC] PHP Warning: Declaration of FPDF::SetDrawColor() should be compatible with tFPDF::SetDrawColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 10
class FPDF extends tFPDF {}
{ private $_encoding = 'UTF-8';
var $angle=0;
public function Rotate($angle, $x=-1, $y=-1)
{
if($x==-1)
$x=$this->x;
if($y==-1)
$y=$this->y;
if($this->angle!=0)
$this->_out('Q');
$this->angle=$angle;
if($angle!=0)
{
$angle*=M_PI/180;
$c=cos($angle);
$s=sin($angle);
$cx=$x*$this->k;
$cy=($this->h-$y)*$this->k;
$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm', $c, $s, -$s, $c, $cx, $cy, -$cx, -$cy));
}
}
[25-Apr-2018 13:57:20 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; fpdi_pdf_parser has a deprecated constructor in /Applications/MAMP/htdocs/squid/lib/FPDI-1.4/fpdi_pdf_parser.php on line 22
class fpdi_pdf_parser extends pdf_parser {
/**
* Pages
* Index beginns at 0
*
* @var array
*/
var $pages;
/**
* Page count
* @var integer
*/
var $page_count;
/**
* actual page number
* @var integer
*/
var $pageno;
/**
* PDF Version of imported Document
* @var string
*/
var $pdfVersion;
/**
* FPDI Reference
* @var object
*/
var $fpdi;
/**
* Available BoxTypes
*
* @var array
*/
var $availableBoxes = array('/MediaBox', '/CropBox', '/BleedBox', '/TrimBox', '/ArtBox');
/**
* Constructor
*
* @param string $filename Source-Filename
* @param object $fpdi Object of type fpdi
*/
function fpdi_pdf_parser($filename, &$fpdi) {
$this->fpdi =& $fpdi;
parent::pdf_parser($filename);
// resolve Pages-Dictonary
$pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']);
// Read pages
$this->read_pages($this->c, $pages, $this->pages);
// count pages;
$this->page_count = count($this->pages);
}
[25-Apr-2018 13:57:20 UTC] PHP Warning: Declaration of FPDF::SetDrawColor() should be compatible with tFPDF::SetDrawColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 10
Methods have to have consistant declerations especially in PHP7 where they made it more strict as I found. So your FPDF::SetDrawColor()
has to be defined exactly like this
class FPDF{
public function SetDrawColor($r, $g = NULL, $b = NULL){}
}
You can add arguments on (I believe, but I would suggest not doing so), but you cannot change the type hints, or default values. Public methods are your classes API or interface, and as such should be consistent across any children that inherent that class or implement an interface where they are defined in. So if you have something like this
public function SetDrawColor($r, $g = '', $b = NULL){}
It will give you this warning, or if you have something like this:
public function SetDrawColor($r){}
Or many other variation on that idea, PHP will warn you that it's not consistent.
[25-Apr-2018 13:57:20 UTC] PHP Warning: Declaration of FPDF::SetFillColor() should be compatible with tFPDF::SetFillColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 10
See above
[25-Apr-2018 13:57:20 UTC] PHP Warning: Declaration of FPDF::SetTextColor() should be compatible with tFPDF::SetTextColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 10 25-Apr-2018 13:57:20 UTC] PHP Warning: Declaration of FPDF::SetDrawColor() should be compatible with tFPDF::SetDrawColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 10
See above
[25-Apr-2018 13:57:20 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; fpdi_pdf_parser has a deprecated constructor in /Applications/MAMP/htdocs/squid/lib/FPDI-1.4/fpdi_pdf_parser.php on line 22
In PHP 4.x, the __construct
method had not yet been introduced. In those days of old, the constructor was named the same as the class was, so you must have a method like this:
class fpdi_pdf_parser{
public function fpdi_pdf_parser($foo){ echo $foo; }
}
Which PHP sees as an "old school" constructor. I spent a lot of time when I first started working with PHP ( back in 2008 ), updating old constructors to be compatible with PHP 5, It was fun, I made a lot of money doing it too... lol. The only real solution to this is to rename the method to something else. I don't see turning off Deprecated
warnings as a viable solution, but it's an "option" of course.
The easiest way to fix this (if it's a constructor) is to just rename it:
class fpdi_pdf_parser{
public function __construct($foo){ echo $foo; }
}
If it's not a constructor, you'll have to come up with some logical name for the method.
This probably will require some amount of refactoring, if this is a 3rd party piece of software, I would look for an updated version of it, or something that does it's equivalent that is current. If it's not code you wrote it's not worth putting the time in to refactor it unless there are not viable substitutes.
Hope that helps.
PHP Strict Standards: Declaration of FPDF::SetDrawColor() should be compatible with tFPDF::SetDrawColor($r, $g = NULL, $b = NULL) in /Applications/MAMP/htdocs/squid/lib/card_pdf.php on line 11
<?php
$cwd = getcwd();
chdir( dirname(__FILE__) );
require 'tfpdf/tfpdf.php';
class FPDF extends tFPDF
{
private $_encoding = 'UTF-8';
var $angle=0;
public function Rotate($angle, $x=-1, $y=-1)
{
if($x==-1)
$x=$this->x;
if($y==-1)
$y=$this->y;
if($this->angle!=0)
$this->_out('Q');
$this->angle=$angle;
if($angle!=0)
{
$angle*=M_PI/180;
$c=cos($angle);
$s=sin($angle);
$cx=$x*$this->k;
$cy=($this->h-$y)*$this->k;
$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm', $c, $s, -$s, $c, $cx, $cy, -$cx, -$cy));
}
}