Skip to content

Commit

Permalink
PHPOffice#634 : Rules for PHPCSFixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jun 18, 2021
1 parent 75e303e commit 2caa24e
Show file tree
Hide file tree
Showing 235 changed files with 4,693 additions and 5,129 deletions.
33 changes: 33 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@

$config
->setUsingCache(true)
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'array_indentation' => true,
'cast_spaces' => [
'space' => 'single',
],
'combine_consecutive_issets' => true,
'concat_space' => [
'spacing' => 'one',
],
'error_suppression' => [
'mute_deprecation_error' => false,
'noise_remaining_usages' => false,
'noise_remaining_usages_exclude' => [],
],
'function_to_constant' => false,
'method_chaining_indentation' => true,
'no_alias_functions' => false,
'no_superfluous_phpdoc_tags' => false,
'non_printable_character' => [
'use_escape_sequences_in_strings' => true,
],
'phpdoc_align' => [
'align' => 'left',
],
'phpdoc_summary' => false,
'protected_to_private' => false,
'self_accessor' => false,
'yoda_style' => false,
'single_line_throw' => false,
'no_alias_language_construct_call' => false,
])
->getFinder()
->in(__DIR__)
->exclude('vendor');
Expand Down
125 changes: 61 additions & 64 deletions samples/Sample_01_Complex.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
$colorBlack = new Color('FF000000');

// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object'.EOL;
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();

// Set properties
echo date('H:i:s') . ' Set properties'.EOL;
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')
->setLastModifiedBy('PHPPresentation Team')
->setTitle('Sample 02 Title')
->setSubject('Sample 02 Subject')
->setDescription('Sample 02 Description')
->setKeywords('office 2007 openxml libreoffice odt php')
->setCategory('Sample Category');
->setLastModifiedBy('PHPPresentation Team')
->setTitle('Sample 02 Title')
->setSubject('Sample 02 Subject')
->setDescription('Sample 02 Description')
->setKeywords('office 2007 openxml libreoffice odt php')
->setCategory('Sample Category');

// Remove first slide
echo date('H:i:s') . ' Remove first slide'.EOL;
echo date('H:i:s') . ' Remove first slide' . EOL;
$objPHPPresentation->removeSlideByIndex(0);

// Create templated slide
echo date('H:i:s') . ' Create templated slide'.EOL;
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation); // local function

// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(200);
$shape->setWidth(600);
Expand All @@ -52,135 +52,132 @@
$textRun->getFont()->setSize(60);
$textRun->getFont()->setColor($colorBlack);


// Create templated slide
echo date('H:i:s') . ' Create templated slide'.EOL;
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation); // local function

// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(50);
->setWidth(930)
->setOffsetX(10)
->setOffsetY(50);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);

$textRun = $shape->createTextRun('What is PHPPresentation?');
$textRun->getFont()->setBold(true)
->setSize(48)
->setColor($colorBlack);
->setSize(48)
->setColor($colorBlack);

// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape()
->setHeight(600)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(130);
->setHeight(600)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(130);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT)
->setMarginLeft(25)
->setIndent(-25);
->setMarginLeft(25)
->setIndent(-25);
$shape->getActiveParagraph()->getFont()->setSize(36)
->setColor($colorBlack);
->setColor($colorBlack);
$shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);

$shape->createTextRun('A class library');
$shape->createParagraph()->createTextRun('Written in PHP');
$shape->createParagraph()->createTextRun('Representing a presentation');
$shape->createParagraph()->createTextRun('Supports writing to different file formats');


// Create templated slide
echo date('H:i:s') . ' Create templated slide'.EOL;
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation); // local function

// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape()
->setHeight(100)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(50);
->setHeight(100)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(50);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);

$textRun = $shape->createTextRun('What\'s the point?');
$textRun->getFont()->setBold(true)
->setSize(48)
->setColor($colorBlack);
->setSize(48)
->setColor($colorBlack);

// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(600)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(130);
->setWidth(930)
->setOffsetX(10)
->setOffsetY(130);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT)
->setMarginLeft(25)
->setIndent(-25);
->setMarginLeft(25)
->setIndent(-25);
$shape->getActiveParagraph()->getFont()->setSize(36)
->setColor($colorBlack);
->setColor($colorBlack);
$shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);

$shape->createTextRun('Generate slide decks');
$shape->createParagraph()->getAlignment()->setLevel(1)
->setMarginLeft(75)
->setIndent(-25);
->setMarginLeft(75)
->setIndent(-25);
$shape->createTextRun('Represent business data');
$shape->createParagraph()->createTextRun('Show a family slide show');
$shape->createParagraph()->createTextRun('...');

$shape->createParagraph()->getAlignment()->setLevel(0)
->setMarginLeft(25)
->setIndent(-25);
->setMarginLeft(25)
->setIndent(-25);
$shape->createTextRun('Export these to different formats');
$shape->createParagraph()->getAlignment()->setLevel(1)
->setMarginLeft(75)
->setIndent(-25);
->setMarginLeft(75)
->setIndent(-25);
$shape->createTextRun('PHPPresentation 2007');
$shape->createParagraph()->createTextRun('Serialized');
$shape->createParagraph()->createTextRun('... (more to come) ...');


// Create templated slide
echo date('H:i:s') . ' Create templated slide'.EOL;
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation); // local function

// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(50);
->setWidth(930)
->setOffsetX(10)
->setOffsetY(50);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);

$textRun = $shape->createTextRun('Need more info?');
$textRun->getFont()->setBold(true)
->setSize(48)
->setColor($colorBlack);
->setSize(48)
->setColor($colorBlack);

// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(600)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(130);
->setWidth(930)
->setOffsetX(10)
->setOffsetY(130);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);

$textRun = $shape->createTextRun('Check the project site on GitHub:');
$textRun->getFont()->setSize(36)
->setColor($colorBlack);
->setColor($colorBlack);

$shape->createBreak();

$textRun = $shape->createTextRun('https://github.com/PHPOffice/PHPPresentation/');
$textRun->getFont()->setSize(32)
->setColor($colorBlack);
->setColor($colorBlack);
$textRun->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPresentation/')
->setTooltip('PHPPresentation');
->setTooltip('PHPPresentation');

// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
Expand Down
52 changes: 26 additions & 26 deletions samples/Sample_02_Serialized.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,64 @@

include_once 'Sample_Header.php';

use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\IOFactory;

// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object'.EOL;
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();

// Set properties
echo date('H:i:s') . ' Set properties'.EOL;
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')
->setLastModifiedBy('PHPPresentation Team')
->setLastModifiedBy('PHPPresentation Team')
->setTitle('Sample 02 Title')
->setSubject('Sample 02 Subject')
->setDescription('Sample 02 Description')
->setKeywords('office 2007 openxml libreoffice odt php')
->setCategory('Sample Category');
->setKeywords('office 2007 openxml libreoffice odt php')
->setCategory('Sample Category');

// Create slide
echo date('H:i:s') . ' Create slide'.EOL;
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();

// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)'.EOL;
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
$shape->getShadow()->setVisible(true)
->setDirection(45)
->setDistance(10);
->setDirection(45)
->setDistance(10);

// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)'.EOL;
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape()
->setHeight(300)
->setWidth(600)
->setOffsetX(170)
->setOffsetY(180);
->setHeight(300)
->setWidth(600)
->setOffsetX(170)
->setOffsetY(180);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$textRun = $shape->createTextRun('Thank you for using PHPPresentation!');
$textRun->getFont()->setBold(true)
->setSize(60)
->setColor(new Color('FFE06B20'));
->setSize(60)
->setColor(new Color('FFE06B20'));

// Save serialized file
$basename = basename(__FILE__, '.php');
echo date('H:i:s') . ' Write to serialized format'.EOL;
echo date('H:i:s') . ' Write to serialized format' . EOL;
$objWriter = IOFactory::createWriter($objPHPPresentation, 'Serialized');
$objWriter->save('results/'.basename(__FILE__, '.php').'.phppt');
$objWriter->save('results/' . basename(__FILE__, '.php') . '.phppt');

// Read from serialized file
echo date('H:i:s') . ' Read from serialized format'.EOL;
$objPHPPresentationLoaded = IOFactory::load('results/'.basename(__FILE__, '.php').'.phppt');
echo date('H:i:s') . ' Read from serialized format' . EOL;
$objPHPPresentationLoaded = IOFactory::load('results/' . basename(__FILE__, '.php') . '.phppt');

// Save file
echo write($objPHPPresentationLoaded, basename(__FILE__, '.php'), $writers);
Expand Down
22 changes: 11 additions & 11 deletions samples/Sample_03_Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
use PhpOffice\PhpPresentation\Style\Fill;

// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object'.EOL;
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();

// Create slide
echo date('H:i:s') . ' Create slide'.EOL;
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();

// Generate an image
echo date('H:i:s') . ' Generate an image'.EOL;
$gdImage = @imagecreatetruecolor(140, 20) or die('Cannot Initialize new GD image stream');
echo date('H:i:s') . ' Generate an image' . EOL;
$gdImage = @imagecreatetruecolor(140, 20) or exit('Cannot Initialize new GD image stream');
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PHPPresentation', $textColor);

// Add a generated drawing to the slide
echo date('H:i:s') . ' Add a drawing to the slide'.EOL;
echo date('H:i:s') . ' Add a drawing to the slide' . EOL;
$shape = new Drawing\Gd();
$shape->setName('Sample image')
->setDescription('Sample image')
->setImageResource($gdImage)
->setMimeType(Drawing\Gd::MIMETYPE_DEFAULT)
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
->setDescription('Sample image')
->setImageResource($gdImage)
->setMimeType(Drawing\Gd::MIMETYPE_DEFAULT)
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
$currentSlide->addShape($shape);

// Add a file drawing (GIF) to the slide
Expand Down
Loading

0 comments on commit 2caa24e

Please sign in to comment.